服務(wù)器停電后尔艇,重啟順序
1、將外置移動(dòng)硬盤或者機(jī)械硬盤拔出么鹤;
2终娃、進(jìn)入系統(tǒng),選擇內(nèi)核版本139的系統(tǒng)蒸甜;
3棠耕、重新插入拔出的硬盤余佛;
4、檢查顯卡情況窍荧;
watch -n 1 nvidia-smi
5辉巡、啟動(dòng)VNCserver;
vncserver
每運(yùn)行一次蕊退,多開(kāi)一個(gè)端口
6郊楣、查看其他保存情況。
ubuntu 新建用戶
- 切換至root
sudo su
- 添加新用戶
sudo useradd -r -m -s /bin/bash lhz
創(chuàng)建用戶瓤荔,自動(dòng)在/home/目錄下創(chuàng)建相應(yīng)的文件夾
sudo adduser lhz
- 配置新用戶密碼
sudo passwd lhz
- 給新添加的用戶增加ROOT權(quán)限
sudo vi /etc/sudoers
然后添加:
用戶名 ALL=(ALL:ALL) ALL
linux中用adduser和useradd命令創(chuàng)建用戶
- 刪除用戶
一開(kāi)始報(bào)錯(cuò)净蚤,后來(lái)關(guān)閉進(jìn)程后刪掉用戶
(base) lhzouc@s-desktop:~$ sudo userdel -r public
userdel: user public is currently used by process 18219
(base) lhzouc@s-desktop:~$ sudo su
root@s-desktop:/home/lhzouc# userdel public
userdel: user public is currently used by process 18219
root@s-desktop:/home/lhzouc# kill -9 18219
root@s-desktop:/home/lhzouc# userdel public
userdel: user public is currently used by process 18250
root@s-desktop:/home/lhzouc# kill -9 18250
root@s-desktop:/home/lhzouc# userdel public
root@s-desktop:/home/lhzouc# exit
(base) lhzouc@s-desktop:~$ su public
No passwd entry for user 'public'
(base) lhzouc@s-desktop:~$ sudo public
sudo: public: command not found
- 查看所有用戶信息
sudo vim /etc/passwd
7.切換用戶/root
su lhz
8.查看當(dāng)前用戶所在的用戶組
id -Gn
groups
- 將用戶加入到某個(gè)用戶組/sudo組
sudo adduser lhz scw4750
sudo adduser lhz sudo
或者
su scw4750
groups lhz
sudo usermod -G sudo lhz
groups lhz
- 修改文件夾所有者
chown -R scw4750:lhz liuhz/
- 刪除用戶
sudo deluser lhz --remove-home
Linux 清除內(nèi)存的 Cache、Buffer 和交換空間
1输硝、在 Linux 中清除緩存(Cache)
清除頁(yè)面緩存(PageCache)
sync; echo 1 > /proc/sys/vm/drop_caches今瀑、
清除目錄項(xiàng)和inode
sync; echo 2 > /proc/sys/vm/drop_caches
清除頁(yè)面緩存,目錄項(xiàng)和inode
sync; echo 3 > /proc/sys/vm/drop_caches
這里使用了 "echo 3"点把,但是不推薦使用在產(chǎn)品環(huán)境中橘荠,應(yīng)該使用 "echo 1"
echo "echo 3 > /proc/sys/vm/drop_caches
2、清除Linux的交換空間
swapoff -a && swapon -a
3郎逃、將上面兩種命令結(jié)合成一個(gè)命令哥童,寫成正確的腳本來(lái)同時(shí)清除RAM緩存和交換空間
echo 3 > /proc/sys/vm/drop_caches && swapoff -a && swapon -a && printf '\n%s\n' 'Ram-cache and Swap Cleared'
或者
su -c 'echo 3 > /proc/sys/vm/drop_caches' && swapoff -a && swapon -a && printf '\n%s\n' 'Ram-cache and Swap Cleared'
顯卡丟失問(wèn)題解決
NVIDIA-SMI has failed because it couldn't communicate with the NVIDIA driver. Make sure that the latest NVIDIA driver is installed and running.
sudo apt-get update
sudo apt-get install --no-install-recommends nvidia-384 libcuda1-384 nvidia-opencl-icd-384
sudo reboot
由于我們服務(wù)器驅(qū)動(dòng)為390.87,因此按照如下指令
sudo apt-get update
sudo apt-get install --no-install-recommends nvidia-390 libcuda1-390 nvidia-opencl-icd-390
sudo reboot
如果重啟后光標(biāo)閃爍衣厘,不進(jìn)入系統(tǒng)如蚜,則切換內(nèi)核版本
NVIDIA顯卡報(bào)錯(cuò)并重裝
NVIDIA-SMI has failed because it couldn’t communicate with the NVIDIA driver.
Make sure that the latest NVIDIA driver is installed and running.
- 卸載原驅(qū)動(dòng)
sudo apt-get --purge remove nvidia*
- 更新源
sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt update
- 查看當(dāng)前系統(tǒng)推薦你安裝的驅(qū)動(dòng)版本
ubuntu-drivers devices
4.安裝
sudo apt-get install nvidia-384
5.查看是否成功
nvidia-smi
Anaconda 虛擬環(huán)境
1、環(huán)境配置
下載anaconda.sh文件并運(yùn)行腳本
sudo sh Anaconda3-5.3.0-Linux-x86_64.sh
... # 多次按空格讀完license影暴。
Do you accept the license terms? [yes|no]
[no] >>> yes # 輸入yes
[/home/andrew/anaconda3] >>> /usr/local/anaconda3 # 輸入自定義目錄
Do you wish the installer to initialize Anaconda3
in your /home/andrew/.bashrc ? [yes|no]
[no] >>> # 選擇yes
進(jìn)入bashrc文件中
ouc@ouc:~/Desktop$ gedit ~/.bashrc
添加需要補(bǔ)充的Anaconda環(huán)境
# added by Miniconda3 installer
export PATH="/home/ouc/miniconda3/bin:$PATH"
#export PATH ="/home/ouc/anaconda2/bin:$PATH"
#export PATH="/usr/bin/python2.7:$PATH"
最后修改完成后執(zhí)行語(yǔ)句
ouc@ouc:~/Desktop$ source ~/.bashrc
2错邦、查看當(dāng)前用戶安裝的虛擬環(huán)境
conda create -n envname python=3.7
lhz@s-desktop:/media/disk/liuhongzhi/EncripGAN/EncripGAN0215$ conda info -e
WARNING: The conda.compat module is deprecated and will be removed in a future release.
# conda environments:
#
py36tf14 /home/lhz/.conda/envs/py36tf14
py36tf18 /home/lhz/.conda/envs/py36tf18
py36torch04 /home/lhz/.conda/envs/py36torch04
sphere /home/lhz/.conda/envs/sphere
base * /media/disk/liuhongzhi/anaconda3
con1 /media/disk/liuhongzhi/anaconda3/envs/con1
encrip /media/disk/liuhongzhi/anaconda3/envs/encrip
lhz@s-desktop:/media/disk/liuhongzhi/EncripGAN/EncripGAN0215$ conda activate encrip
(encrip) lhz@s-desktop:/media/disk/liuhongzhi/EncripGAN/EncripGAN0215$
(encrip) lhz@s-desktop:/media/disk/liuhongzhi/EncripGAN/EncripGAN0215$ conda deactivate
3、添加清華鏡像源型宙,修改~/.condarc
首先在終端中運(yùn)行
conda config --set show_channel_urls yes
channels:
- defaults
show_channel_urls: true
default_channels:
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
custom_channels:
conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
msys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
bioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
menpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
tuna添加清華鏡像源
lhz@scw4750:~$ conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
lhz@scw4750:~$ conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
4撬呢、conda: command not found 問(wèn)題
lhz@scw4750:~$ vi ~/.bashrc
最后一行加上
export PATH=$PATH:/media/scw4750/liuhz/anaconda3/bin
保存更改運(yùn)行
source ~/.bashrc
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
# don't put duplicate lines or lines starting with space in the history.
# See bash(1) for more options
HISTCONTROL=ignoreboth
# append to the history file, don't overwrite it
shopt -s histappend
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=1000
HISTFILESIZE=2000
# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize
# If set, the pattern "**" used in a pathname expansion context will
# match all files and zero or more directories and subdirectories.
#shopt -s globstar
# make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
debian_chroot=$(cat /etc/debian_chroot)
fi
# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
xterm-color|*-256color) color_prompt=yes;;
esac
# uncomment for a colored prompt, if the terminal has the capability; turned
# off by default to not distract the user: the focus in a terminal window
# should be on the output of commands, not on the prompt
#force_color_prompt=yes
if [ -n "$force_color_prompt" ]; then
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
# We have color support; assume it's compliant with Ecma-48
# (ISO/IEC-6429). (Lack of such support is extremely rare, and such
# a case would tend to support setf rather than setaf.)
color_prompt=yes
else
color_prompt=
fi
fi
if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
unset color_prompt force_color_prompt
# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
;;
*)
;;
esac
# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
alias ls='ls --color=auto'
#alias dir='dir --color=auto'
#alias vdir='vdir --color=auto'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
fi
# colored GCC warnings and errors
#export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
# some more ls aliases
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'
# Add an "alert" alias for long running commands. Use like so:
# sleep 10; alert
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if ! shopt -oq posix; then
if [ -f /usr/share/bash-completion/bash_completion ]; then
. /usr/share/bash-completion/bash_completion
elif [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
fi
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/media/scw4750/liuhz/anaconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
if [ -f "/media/scw4750/liuhz/anaconda3/etc/profile.d/conda.sh" ]; then
. "/media/scw4750/liuhz/anaconda3/etc/profile.d/conda.sh"
else
export PATH="/media/scw4750/liuhz/anaconda3/bin:$PATH"
fi
fi
unset __conda_setup
# <<< conda initialize <<<
export PATH=$PATH:/media/scw4750/liuhz/anaconda3/bin
5.顯示conda信息
lhz@scw4750:~$ conda info
active environment : None
shell level : 0
user config file : /home/lhz/.condarc
populated config files : /home/lhz/.condarc
conda version : 4.7.12
conda-build version : 3.18.9
python version : 3.7.4.final.0
virtual packages : __cuda=10.1
base environment : /media/scw4750/liuhz/anaconda3 (read only)
channel URLs : https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/linux-64
https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/noarch
https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/linux-64
https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/noarch
https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r/linux-64
https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r/noarch
package cache : /media/scw4750/liuhz/anaconda3/pkgs
/home/lhz/.conda/pkgs
envs directories : /media/scw4750/liuhz/anaconda3/envs
/home/lhz/.conda/envs
platform : linux-64
user-agent : conda/4.7.12 requests/2.22.0 CPython/3.7.4 Linux/4.15.0-72-generic ubuntu/16.04.6 glibc/2.23
UID:GID : 1002:1002
netrc file : None
offline mode : False
如果保存環(huán)境到/home/lhz/.conda/envs路徑時(shí),需要修改~/.condarc中的pkgs_dirs和envs_dirs
修改conda環(huán)境和緩存默認(rèn)路徑
lhz@scw4750:~$ vi ~/.condarc
auto_activate_base: false
channels:
- defaults
show_channel_urls: true
default_channels:
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
custom_channels:
conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
msys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
bioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
menpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
pkgs_dirs:
- /media/scw4750/liuhz/anaconda3/pkgs
- /home/lhz/.conda/pkgs
envs_dirs:
- /media/scw4750/liuhz/anaconda3/envs
- /home/lhz/.conda/envs
- 讓Anaconda不再自動(dòng)進(jìn)入虛擬環(huán)境base
conda config --set auto_activate_base false
- 卸載Anaconda環(huán)境
# 卸載包
# 刪除指定環(huán)境中的指定包
conda remove --name snowflakes biopython
# 卸載環(huán)境
# --all參數(shù)表示移除環(huán)境中的所有軟件包妆兑,即刪除整個(gè)環(huán)境
conda remove --name envname --all
Ubuntu 命令行方式安裝魂拦、啟動(dòng)、設(shè)置和鏈接 teamviewer
1搁嗓、下載軟件
wget http://download.teamviewer.com/download/teamviewer_i386.deb
2芯勘、更新依賴及安裝指令
sudo apt-get update
出現(xiàn)錯(cuò)誤:sudo apt-get update -f
sudo dpkg -i teamviewer_i386.deb
3、停止teamviewer
sudo teamviewer –daemon stop
4腺逛、修改配置文件
打開(kāi)文件:vim /opt/teamviewer/config/global.conf
增加內(nèi)容:
EulaAccepted = 1
EulaAcceptedRevision = 6
5荷愕、啟動(dòng)teamviewer
sudo teamviewer –daemon start
6、設(shè)置登錄密碼
sudo teamviewer –passwd 123456
7、獲取TeamviewerID
teamviewer –info print id
或
teamviewer –info
8安疗、teamviewer啟動(dòng)失敗
s@s-desktop:/home/lhz/.vnc$ teamviewer –daemon start
Init...
CheckCPU: SSE2 support: yes
XRandRWait: No value set. Using default.
XRandRWait: Started by user.
Checking setup...
Launching TeamViewer ...
Launching TeamViewer GUI ...
解決辦法:
s@s-desktop:/home/lhz/.vnc$ htop
s@s-desktop:/home/lhz/.vnc$ sudo kill -9 1480
s@s-desktop:/home/lhz/.vnc$ teamviewer –daemon start
Init...
CheckCPU: SSE2 support: yes
XRandRWait: No value set. Using default.
XRandRWait: Started by user.
Checking setup...
Launching TeamViewer ...
Launching TeamViewer GUI ...
s@s-desktop:/home/lhz/.vnc$ teamviewer &
[1] 22653
s@s-desktop:/home/lhz/.vnc$
Init...
CheckCPU: SSE2 support: yes
XRandRWait: No value set. Using default.
XRandRWait: Started by user.
Checking setup...
Launching TeamViewer ...
Launching TeamViewer GUI ...
Ubuntu 常用軟件包安裝
- Ristretto image viewer
# Install Howto
# Update the package index:
sudo apt-get update
# Install ristretto deb package:
sudo apt-get install ristretto
參考鏈接 ristretto_0.8.0-1_amd64.deb
VNC常見(jiàn)問(wèn)題
- 打開(kāi)VNC抛杨,查看端口可用
vncserver -list
查看vncserver已用端口的命令
(base) lhz@s-desktop:~$ ps -ef | grep vnc
- 刪除端口
vncserver -kill :3
- VNC 黑屏和accept clipboard from viewer
連接上VNC后桌面黑屏什么都沒(méi)有,又比如連接上后桌面左上角有3個(gè)選擇框關(guān)不掉荐类,選擇內(nèi)容為 Accept clipboard from viewer Send clipboard to viewer Send premary seletion to viewer
解決方法:
(1). 編輯vnc的配置文件怖现,文件位置為: /root/.vnc/xstartup
vi /root/.vnc/xstartup
(2).修改部分內(nèi)容
#!/bin/sh
# Uncomment the following two lines for normal desktop:
#unset SESSION_MANAGER
#exec /etc/X11/xinit/xinitrc
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
#xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
#twm &
改為
#!/bin/sh
# Uncomment the following two lines for normal desktop:
unset SESSION_MANAGER
exec /etc/X11/xinit/xinitrc
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
#xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
#twm &
gnome-session &
4.修改分辨率
查看vnc進(jìn)程:
ps -ef | grep vnc
該命令可以列出當(dāng)前系統(tǒng)上所有用戶vnc界面的端口號(hào),分辨率等信息玉罐。
我們要用到的只是端口號(hào)屈嗤。
殺掉vnc端口對(duì)應(yīng)的進(jìn)程
vncserver -kill :5
我的端口號(hào)是5
啟動(dòng)vnc服務(wù)器
vncserver :5
啟動(dòng)后發(fā)現(xiàn),與自己的電腦桌面相比界面比較小厌小,點(diǎn)擊全屏后恢共,原來(lái)多余的部分都變成黑色的了。
通過(guò)上面說(shuō)的查看vnc進(jìn)程命令后發(fā)現(xiàn)有個(gè)信息-geometry 1024x768璧亚,這說(shuō)明vnc的默認(rèn)分辨率是1024x768讨韭,而我的筆記本分辨率是1366x768。所以要全屏癣蟋,只需要修改分辨率即可透硝。
修改vnc分辨率
修改分辨率的命令為:
vncserver -geometry 1920x1080 :5
在這里要注意一點(diǎn),在vnc server運(yùn)行期間疯搅,使用該命令是會(huì)報(bào)錯(cuò)的:‘A VNC server is already running as :5’
所以濒生,在修改vnc分辨率之前,我們需要先將vnc server關(guān)閉幔欧。用上面說(shuō)過(guò)的-kill命令殺掉vnc端口對(duì)應(yīng)的進(jìn)程即可罪治。
或者可以采用以下方法:
lhz@s-desktop:~$ sudo vi /usr/bin/vncserver
#
# Global variables. You may want to configure some of these for your site.
#
$geometry = "1920x1080"; #可以修改分辨率
$depth = 16;
然后再運(yùn)行命令修改分辨率即可。之后登錄vnc界面就可以看到界面的大小已經(jīng)改變了礁蔗。
參考鏈接 修改VNC的分辨率
- 登錄VNC桌面時(shí)觉义,發(fā)現(xiàn)在終端中使用tab補(bǔ)全相關(guān)命令時(shí),會(huì)不起作用
方法是在遠(yuǎn)程桌面中進(jìn)行設(shè)置浴井,路徑是:打開(kāi)菜單—設(shè)置—窗口管理器晒骇,Settings-Window manager-Keyboard-Switch window-clear,由此可以在終端進(jìn)行指令補(bǔ)全
參考鏈接 學(xué)習(xí)ubuntu遠(yuǎn)程桌面(一):配置遠(yuǎn)程桌面
阿里云服務(wù)器反向端口轉(zhuǎn)發(fā)
外網(wǎng)服務(wù)器 IP: remote-host
外網(wǎng)用戶名: ouc03
指令含義
-f 后臺(tái)執(zhí)行ssh指令
-C 允許壓縮數(shù)據(jù)
-N 不執(zhí)行遠(yuǎn)程指令
-R 將遠(yuǎn)程主機(jī)(服務(wù)器)的某個(gè)端口轉(zhuǎn)發(fā)到本地端指定機(jī)器的指定端口
-L 將本地機(jī)(客戶機(jī))的某個(gè)端口轉(zhuǎn)發(fā)到遠(yuǎn)端指定機(jī)器的指定端口
-p 指定遠(yuǎn)程主機(jī)的端口
- 在內(nèi)網(wǎng)服務(wù)器上操作磺浙,建立內(nèi)網(wǎng)到外網(wǎng)的反向代理洪囤,并檢驗(yàn)是否已經(jīng)啟動(dòng)
7275 為阿里云服務(wù)器綁定端口號(hào)(需要在阿里云工作臺(tái)配置安全組規(guī)則開(kāi)啟)
22為 SSH 連接固定端口號(hào)(本地實(shí)驗(yàn)室服務(wù)器端口)
lhz@scw4750:~$ ssh -fCNR 7275:localhost:22 ouc03@remote-host
lhz@scw4750:~$ ps aux | grep ssh
root 1268 0.0 0.0 65512 6304 ? Ss 1月03 0:00 /usr/sbin/sshd -D
root 1440 0.0 0.0 94928 6988 ? Ss 08:55 0:00 sshd: videoudsd [priv]
videoud+ 1544 0.0 0.0 94928 4456 ? S 08:55 0:01 sshd: videoudsd@pts/5
root 6961 0.0 0.0 94928 6896 ? Ss 1月16 0:00 sshd: lhz [priv]
lhz 7071 0.0 0.0 94928 3456 ? S 1月16 0:10 sshd: lhz@pts/1
root 8629 0.0 0.0 94928 6840 ? Ss 1月16 0:00 sshd: lhz [priv]
lhz 8666 0.0 0.0 94928 3424 ? S 1月16 0:05 sshd: lhz@pts/2
root 16107 0.0 0.0 94928 6916 ? Ss 13:16 0:00 sshd: lhz [priv]
lhz 16216 0.0 0.0 94928 3220 ? S 13:16 0:00 sshd: lhz@pts/9
root 17142 0.0 0.0 95008 7124 ? Ss 10:20 0:00 sshd: lhz [priv]
lhz 17201 0.0 0.0 95296 4304 ? S 10:20 0:00 sshd: lhz@notty
lhz 20787 0.0 0.0 45212 2864 ? Ss 13:41 0:00 ssh -fCNR 7275:localhost:22 ouc03@47.102.120.134
root 21230 0.0 0.0 94928 6960 ? Ss 13:44 0:00 sshd: lhz [priv]
lhz 21289 0.0 0.0 94928 3592 ? S 13:44 0:00 sshd: lhz@pts/8
root 23343 0.0 0.0 94928 7020 ? Ss 13:54 0:00 sshd: lhz [priv]
lhz 23389 0.0 0.0 94928 3096 ? S 13:54 0:00 sshd: lhz@pts/10
lhz 24981 0.0 0.0 45212 780 ? Ss 14:03 0:00 ssh -fCNR 7275:localhost:22 ouc03@47.102.120.134
lhz 25019 0.0 0.0 21292 972 pts/9 S+ 14:03 0:00 grep --color=auto ssh
(base) [intern2@172-10-60-160 ssh]$ ssh -o serveraliveinterval=60 -fCNR 7257:localhost:22 airia160@remote-host
- 在外網(wǎng)服務(wù)器上建立正向代理,用來(lái)做轉(zhuǎn)發(fā)撕氧。
7274端口為本地轉(zhuǎn)發(fā)端口瘤缩,負(fù)責(zé)和外網(wǎng)進(jìn)行通信,并將數(shù)據(jù)轉(zhuǎn)發(fā)的7275這個(gè)端口伦泥,實(shí)現(xiàn)了可以從其他機(jī)器訪問(wèn)的功能款咖,并從7274端口登錄
ouc03@iZuf6bd4deudifh44e6p12Z:~$ ssh -fCNL *:7274:localhost:7275 localhost
ouc03@iZuf6bd4deudifh44e6p12Z:~$ ps aux | grep ssh
root 19700 0.0 0.2 59420 5920 ? Ss 13:22 0:00 /usr/sbin/sshd -D
root 20035 0.0 0.3 93460 7016 ? Ss 13:28 0:00 sshd: ouc03 [priv]
ouc03 20065 0.0 0.1 93460 3300 ? S 13:28 0:00 sshd: ouc03@pts/0
root 20082 0.0 0.3 93428 6892 ? Ss 13:34 0:00 sshd: ouc02 [priv]
ouc02 20113 0.0 0.2 93836 5068 ? S 13:34 0:00 sshd: ouc02
root 20114 0.0 0.3 93428 7112 ? Ss 13:34 0:00 sshd: ouc02 [priv]
ouc02 20137 0.0 0.1 93428 3492 ? S 13:34 0:00 sshd: ouc02@pts/1
root 20164 0.0 0.3 93460 6736 ? Ss 13:35 0:00 sshd: ouc02 [priv]
ouc02 20166 0.0 0.0 37380 740 ? Ss 13:35 0:00 ssh -fCNL *:7279:localhost:7278 localhost
ouc02 20188 0.0 0.2 93636 4952 ? S 13:35 0:00 sshd: ouc02
ouc02 20225 0.0 0.2 36680 5276 pts/1 S+ 13:36 0:00 ssh -p7278 gds@47.102.120.134
root 20226 0.0 0.3 93540 7132 ? Ss 13:38 0:00 sshd: ouc02 [priv]
ouc02 20249 0.0 0.1 93540 3464 ? S 13:38 0:00 sshd: ouc02@pts/2
ouc02 20269 0.0 0.2 36684 4452 pts/2 S+ 13:39 0:00 ssh -p7278 gds@47.102.120.134
root 20338 0.0 0.3 93432 6856 ? Ss 13:42 0:00 sshd: ouc02 [priv]
ouc02 20361 0.0 0.2 93704 4656 ? S 13:42 0:00 sshd: ouc02
root 20362 0.0 0.3 93432 7064 ? Ss 13:43 0:00 sshd: ouc02 [priv]
ouc02 20386 0.0 0.1 93432 3232 ? S 13:43 0:00 sshd: ouc02@pts/3
root 20402 0.0 0.3 93460 6708 ? Ss 13:43 0:00 sshd: ouc03 [priv]
ouc03 20404 0.0 0.1 37380 2444 ? Ss 13:43 0:00 ssh -fCNL *:7274:localhost:7275 localhost
ouc03 20426 0.0 0.2 93636 4924 ? S 13:43 0:00 sshd: ouc03
ouc02 20429 0.0 0.2 36684 4412 pts/3 S+ 13:43 0:00 ssh -p7278 gds@47.102.120.134
ouc03 20430 0.0 0.2 36676 5484 pts/0 S+ 13:44 0:00 ssh -p7275 lhz@47.102.120.134
root 20506 0.0 0.3 93460 6932 ? Ss 13:51 0:00 sshd: ouc03 [priv]
ouc03 20529 0.0 0.1 93460 3288 ? S 13:51 0:00 sshd: ouc03@pts/5
root 20618 0.0 0.3 93432 6856 ? Ss 13:52 0:00 sshd: ouc02 [priv]
ouc02 20641 0.0 0.2 93704 4644 ? S 13:52 0:00 sshd: ouc02
root 20777 0.0 0.3 93432 7064 ? Ss 14:03 0:00 sshd: ouc02 [priv]
ouc02 20800 0.0 0.2 93704 4900 ? S 14:03 0:00 sshd: ouc02
root 20801 0.0 0.3 93428 6896 ? Ss 14:03 0:00 sshd: ouc03 [priv]
ouc03 20824 0.0 0.2 93704 4680 ? S 14:03 0:00 sshd: ouc03
root 20828 0.0 0.3 93460 7028 ? Ss 14:05 0:00 sshd: ouc03 [priv]
ouc03 20851 0.0 0.1 93460 3300 ? S 14:05 0:00 sshd: ouc03@pts/4
root 20867 0.0 0.3 93460 6600 ? Ss 14:05 0:00 sshd: ouc03 [priv]
ouc03 20869 0.0 0.0 37380 732 ? Ss 14:05 0:00 ssh -fCNL *:7274:localhost:7275 localhost
ouc03 20891 0.0 0.2 93636 4744 ? S 14:05 0:00 sshd: ouc03
ouc03 20893 0.0 0.0 14220 928 pts/4 S+ 14:06 0:00 grep --color=auto ssh
- 用SSH連接
ouc03@iZuf6bd4deudifh44e6p12Z:~$ ssh -p7274 lhz@remote-host
lhz@remote-host's password:
Welcome to Ubuntu 16.04.6 LTS (GNU/Linux 4.15.0-72-generic x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
95 packages can be updated.
0 updates are security updates.
New release '18.04.3 LTS' available.
Run 'do-release-upgrade' to upgrade to it.
*** System restart required ***
Last login: Fri Jan 17 14:09:34 2020 from 127.0.0.1
- 建立穩(wěn)定隧道
lhz@scw4750:~$ autossh -M 7273 -fCNR 7275:localhost:22 -o ServerAliveInterval=60 -o TCPKeepAlive=yes ouc03@remote-host
利用ssh反向代理以及autossh實(shí)現(xiàn)從外網(wǎng)連接內(nèi)網(wǎng)服務(wù)器
autossh的參數(shù)與ssh的參數(shù)是一致的何暮,但是不同的是,在隧道斷開(kāi)的時(shí)候铐殃,autossh會(huì)自動(dòng)重新連接而ssh不會(huì)。另外不同的是需要指出的-M參數(shù)蜡歹,這個(gè)參數(shù)指定一個(gè)端口敞葛,這個(gè)端口是外網(wǎng)的B機(jī)器用來(lái)接收內(nèi)網(wǎng)A機(jī)器的信息琉朽,如果隧道不正常而返回給A機(jī)器讓他實(shí)現(xiàn)重新連接。
- 查看端口使用情況
ouc03@iZuf6bd4deudifh44e6p12Z:~$ netstat -tln
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:7273 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:7274 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:7278 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:7279 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
tcp6 0 0 :::7274 :::* LISTEN
tcp6 0 0 :::7279 :::* LISTEN
tcp6 0 0 :::80 :::* LISTEN
- 配置開(kāi)機(jī)自啟
Ubuntu14.04以下寫入 /etc/rc.local 的 exit 0 之前
su - lab-user -c autossh -M 7274 -fCNR 7275:localhost:22 -o ServerAliveInterval=60 -o TCPKeepAlive=yes ouc03@remote-host
在 Ubuntu16.04+ 中實(shí)現(xiàn)開(kāi)機(jī)自啟要復(fù)雜一點(diǎn)
sudo vim /lib/systemd/system/autossh.service
[Unit]
Description=Start autossh to aliyun at startup.
After=network.target
[Service]
User=lab-user
Group=lab-user
Environment="AUTOSSH_GATETIME=0"
ExecStart=/usr/bin/autossh -M 7281 -CNR 7280:localhost:22 -o ServerAliveInterval=60 -o TCPKeepAlive=yes remote-user@remote-host
[Install]
WantedBy=multi-user.target
注意:
a. 上面 autossh 命令沒(méi)有 -f 選項(xiàng)赘被,因?yàn)?systemd 不支持,"AUTOSSH_GATETIME=0" 已經(jīng)有這個(gè)作用了肖揣。
b. 上面的 User民假、Group 字段對(duì)應(yīng) lab-user 用戶的用戶名、用戶組龙优,意思是使用 lab-user 這個(gè)用戶執(zhí)行上面的 service羊异。如果不加 User、Group 字段彤断,上面的 service 在開(kāi)機(jī)時(shí)會(huì)由 root 用戶執(zhí)行野舶,所以 root 用戶應(yīng)該能夠免密碼登錄 remote-host 才行,否則會(huì)報(bào) Host key verification failed 的錯(cuò)誤宰衙。
[Unit]
Description=Start autossh to aliyun at startup.
After=network.target
[Service]
User=lhz
Group=lhz
Environment="AUTOSSH_GATETIME=0"
ExecStart=/usr/bin/autossh -M 7273 -CNR 7275:localhost:22 -o ServerAliveInterval=60 -o TCPKeepAlive=yes ouc03@remote-host
[Install]
WantedBy=multi-user.target
然后運(yùn)行:
sudo systemctl daemon-reload
sudo systemctl enable autossh.service
sudo systemctl start autossh.service
利用 sudo systemctl status autossh.service 檢查運(yùn)行狀態(tài)平道。
- 將服務(wù)器某些端口內(nèi)容轉(zhuǎn)發(fā)到本地端口
例如,服務(wù)器正在用 tensorboard 在 6006 端口可視化 loss供炼,然后將該端口轉(zhuǎn)發(fā)到阿里云服務(wù)器的 5000 端口:
# 在實(shí)驗(yàn)室服務(wù)器執(zhí)行
$ ssh -CNR *:5000:localhost:6006 remote-user@remote-host
在瀏覽器打開(kāi) remote-host:5000 即可訪問(wèn)一屋。
- 將本地文件傳到遠(yuǎn)程服務(wù)器
(1) 不需要連代理服務(wù)器
scp filename user@HostName:route
scp -r filedir user@HostName:route
(2)連接代理服務(wù)器
scp filename Host:route
scp -r filedir Host:route
- 將遠(yuǎn)程服務(wù)器文件傳到本地
(1) 不需要連代理服務(wù)器
scp user@HostName:route filename
scp -r user@HostName:route filedir
(2)連接代理服務(wù)器
scp Host:route filename
scp -r Host:route filedir
hzq@hzq:~/Medical$ scp -r -P 7256 intern2@remote-host:/data/jay/lhz/Methods/ScaledYOLOv4/ScaledYOLOv4/runs/exp3_yolov4-csp/*.jpg ./
- 注意事項(xiàng)
- ssh認(rèn)第一個(gè)輸入指令,autossh前清掉之前的ssh命令(直到連接不上)袋哼,否則連接會(huì)斷
- 可以運(yùn)行長(zhǎng)時(shí)間交互命令冀墨,比如ifstat等
- 目前可以連接27和38服務(wù)器
(base) lhzouc@s-desktop:~$ autossh -M 7260 -fCNR 7261:localhost:22 -o ServerAliveInterval=60 -o TCPKeepAlive=yes ouc03@remote-host
參考鏈接
利用ssh反向代理以及autossh實(shí)現(xiàn)從外網(wǎng)連接內(nèi)網(wǎng)服務(wù)器
利用阿里云服務(wù)器配置反向端口轉(zhuǎn)發(fā) <實(shí)驗(yàn)室內(nèi)部論壇>
VSCode 遠(yuǎn)程開(kāi)發(fā)含免密操作
- 在本地生成密鑰對(duì)
ssh-keygen -t rsa -C "your email"
# 或者
ssh-keygen -t rsa -b 4096
在遠(yuǎn)程服務(wù)器進(jìn)行相同的操作
ssh-keygen -t rsa
2.將本地公鑰保存到遠(yuǎn)程服務(wù)器上,讓遠(yuǎn)程機(jī)器的authorized_keys中包含公鑰內(nèi)容先嬉,用于免密操作
# 本地
scp ~/.ssh/id_rsa.pub ouc03@remote-host:/home/authorized_keys
# 遠(yuǎn)程服務(wù)器
cd ~/.ssh/
scp ouc03@remote-host:/home/authorized_keys ./
chmod 600 ~/.ssh/authorized_keys
# 可選操作
sudo service ssh restart
- VSCode 配置
選擇遠(yuǎn)程資源資源管理器(電腦帶箭頭)->配置(configure 齒輪形狀)
選擇橫條里選擇:/home/henry/.ssh/config
Host lab
HostName XX.XXX.XXX.XXX
User henry
Port 7251
Host 顯示在連接選項(xiàng)中的名字,
HostName 你的ssh服務(wù)器的地址
User 你登錄ssh時(shí)的用戶名
即可完成配置
參考鏈接:
vscode remote ssh 遠(yuǎn)程開(kāi)發(fā)免密登陸方法
VSCode 遠(yuǎn)程開(kāi)發(fā)(帶免密)
- 打開(kāi)服務(wù)器端的html文件
連接遠(yuǎn)程服務(wù)器后轧苫,按 shift+ctrl+x 安裝 HTML Preview 插件。
右鍵選擇 Open preview 或者 ctrl + shift + v即可打開(kāi)遠(yuǎn)程端的html文件疫蔓。
Ubuntu終端配置clash
1含懊、配置clash
創(chuàng)建 clash 文件夾
mkdir clash && cd clash
下載 Clash 文件,撰寫此教程時(shí)最新版本為v1.41衅胀,所以下載命令為 wget -N --no-check-certificate [https://github.com/Dreamacro/clash/releases/download/v1.4.1/clash-linux-amd64-v1.4.1.gz](https://github.com/Dreamacro/clash/releases/download/v1.4.1/clash-linux-amd64-v1.4.1.gz)
gunzip clash-linux-amd64-v1.4.1.gz
將解壓后的文件重命名為 clash
# 賦予 Clash 執(zhí)行權(quán)限
chmod +x clash
wget -O config.yaml 托管鏈接(ss)
./clash -d .
- 終端使用clash并使用wget下載
export http_proxy=http://proxyAddress:port
eg. 走的http的代理端口是7890
export http_proxy=http://127.0.0.1:7890
export https_proxy=http://127.0.0.1:7890
用命令$ curl cip.cc檢查終端是否處于代理狀態(tài)岔乔。
wget模擬瀏覽器下載
wget --user-agent="Mozilla/5.0" "https://storage.googleapis.com/kaggle-data-sets/654585/1157209/bundle/archive.zip?GoogleAccessId=web-data@kaggle-161607.iam.gserviceaccount.com&Expires=1626705399&Signature=sFUDxoYhLbApEA14GcV0Zz8%2FvyzegVb1B42hX6%2BC0ZOa437IsViKvyUnNXJJMkTqGXmRbrvX1FFkjrJJWaoUKdvdMIqOaC1etnkDJ3bmUNq77HgIfoi%2BtBcAs1SVd1SdbrcfZG53w3oxqhYH9V3KkOFxoM%2BWiM7WIVtept5bLov9mW01SMB1rNZ%2FyxmdKRAmMcVMWCqv8IVncmlEXPjr0MZ8cBHs%2BKsGluKAEfZjPU%2BrkN5ro5I6fIaQ%2FWDMz3SMX9Jwnsp8vcUsEiULj%2FFQALcqZbdza3G%2FhoSic7RlvevB2ay4Kz8qriwbzop6bVDOhJijKsofnQ0HINzp0aaAfw%3D%3D&response-content-disposition=attachment%3B+filename%3Drsna-intracranial-hemorrhage-detection.zip" -O rsna-intracranial-hemorrhage-detection.zip
查看當(dāng)前使用代理
env | grep -i proxy
去掉相關(guān)代理
gedit /etc/enviroment
如果還存在代理,運(yùn)行:
unset http_proxy
unset https_proxy
本地訪問(wèn)服務(wù)器端Ubuntu系統(tǒng)網(wǎng)頁(yè)
1滚躯、在本地的命令行終端
ssh -D 綁定的本機(jī)[端口號(hào)] 實(shí)驗(yàn)室遠(yuǎn)程username@實(shí)驗(yàn)室遠(yuǎn)程ip地址
ssh -D3060 username@remote-ip
2雏门、在本地下載firefox瀏覽器
本地下載一個(gè)firefox(以后專門用這個(gè)firefox來(lái)訪問(wèn)遠(yuǎn)程服務(wù)器的網(wǎng)頁(yè))
3嘿歌、修改firefox瀏覽器設(shè)置
將socks主機(jī)改成localhost 端口改為 綁定的本機(jī)端口號(hào)(此處設(shè)置為3060)
確定后再在本機(jī)的這個(gè)firefox訪問(wèn)校園網(wǎng)關(guān)就是以遠(yuǎn)程服務(wù)器身份打開(kāi)的了
常見(jiàn)系統(tǒng)問(wèn)題
1.Tab鍵無(wú)法補(bǔ)全命令
(1)修改bashrc
sudo vi /etc/bash.bashrc
將以下注釋的部分,取消注釋
1. #enable bash completion in interactive shells
2. #if ! shopt -oq posix; then
3. # if [-f /usr/share/bash-completion/bash_completion ]; then
4. # . /usr/share/bash-completion/bash_completion
5. # elif [ -f /etc/bash_completion]; then
6. # . /etc/bash_completion
7. # fi
8. #fi
改為
1. #enable bash completion in interactive shells
2. if ! shopt -oq posix; then
3. if [-f /usr/share/bash-completion/bash_completion ]; then
4. . /usr/share/bash-completion/bash_completion
5. elif [ -f /etc/bash_completion]; then
6. . /etc/bash_completion
7. fi
8. fi
最后 進(jìn)行一步source更新
sudo source /etc/bash.bashrc
參考 Ubuntu系統(tǒng)Tab鍵不能自動(dòng)補(bǔ)全問(wèn)題解決
(2)在遠(yuǎn)程桌面中設(shè)置茁影,打開(kāi)菜單->設(shè)置->窗口管理器宙帝,或者在終端中輸入xfwm4-settings打開(kāi)(xfwm4就是xfce4 window manger的縮寫)
選擇鍵盤,可以看到窗口快捷鍵中動(dòng)作一列有“切換同一應(yīng)用程序的窗口”選項(xiàng)募闲,將該選項(xiàng)的快捷鍵清除后關(guān)閉窗口即可步脓。
到此,Tab鍵自動(dòng)補(bǔ)全功能配置完成浩螺。
參考 windows遠(yuǎn)程桌面ubuntu中Tab鍵不能補(bǔ)全命令的解決辦法
- 在服務(wù)器上掛載U盤
(1) 查看磁盤情況
liangju@fuwuqi-Z370-HD3:~$ sudo fdisk -l
[sudo] password for liangju:
Disk /dev/sdb: 465.8 GiB, 500107862016 bytes, 976773168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x99d0c6d2
(2) 查看塊設(shè)備的文件系統(tǒng)靴患,LABEL和UUID
liangju@fuwuqi-Z370-HD3:/media/hd$ sudo blkid
[sudo] password for liangju:
/dev/sda4: UUID="02f0c150-9b43-4480-9b0c-d5e0e019de63" TYPE="ext4" PARTUUID="667f5f84-c211-4912-a737-194c65d8482a"
/dev/sda2: UUID="95300fdd-8a59-47c7-8ccf-41593ccd0751" TYPE="swap" PARTUUID="15774072-4714-4080-b85e-8791a10279e8"
/dev/loop0: TYPE="squashfs"
/dev/loop1: TYPE="squashfs"
/dev/loop2: TYPE="squashfs"
/dev/loop4: TYPE="squashfs"
/dev/loop5: TYPE="squashfs"
/dev/loop6: TYPE="squashfs"
/dev/loop7: TYPE="squashfs"
/dev/sda1: UUID="9cbe1c6c-1da2-4943-8396-41647fc1e8c3" TYPE="ext4" PARTUUID="aab40112-d765-45d1-be56-6455c9e5078d"
/dev/loop8: TYPE="squashfs"
/dev/loop9: TYPE="squashfs"
/dev/loop10: TYPE="squashfs"
/dev/loop11: TYPE="squashfs"
/dev/loop12: TYPE="squashfs"
/dev/loop13: TYPE="squashfs"
/dev/loop14: TYPE="squashfs"
/dev/loop15: TYPE="squashfs"
/dev/loop16: TYPE="squashfs"
/dev/sda3: PARTUUID="bcb440e8-a202-4529-8683-940e67c69a60"
/dev/sdb4: LABEL="Ubuntu 16.0" UUID="B4FE-5315" TYPE="vfat" PARTUUID="cad4ebea-04"
其中/dev/sdb4是我們需要掛載的U盤
(3) 新建掛載目錄 /media/hd
liangju@fuwuqi-Z370-HD3:~$ sudo mkdir /media/hd
(4) U盤掛載到指定路徑
liangju@fuwuqi-Z370-HD3:/media/hd$ sudo mount /dev/sdb4 /media/hd
(5) 查看U盤內(nèi)容
liangju@fuwuqi-Z370-HD3:/media/hd$ ls
boot 'FW150US 4.0' pics
casper install pool
compare isolinux preseed
config K40 res
dists movie 'RICOH SP 325SNw_windows???????.pdf'
EFI outpainting_1017_with_colorLoss 'System Volume Information'
FOUND.000 outpainting_car_slice16_Alpha uname
FOUND.001 PEN_3 XMPSetup_5.3.1.6065-VZqqpcmgr.exe
(6) 卸載U盤
liangju@fuwuqi-Z370-HD3:/media$ sudo umount /media/hd
(7) 設(shè)備繁忙
liangju@fuwuqi-Z370-HD3:/media/hd$ sudo umount /media/hd
umount: /media/hd: target is busy.
解決方式
liangju@fuwuqi-Z370-HD3:/media/hd$ sudo umount /media/hd
[sudo] password for liangju:
umount: /media/hd: target is busy.
liangju@fuwuqi-Z370-HD3:/media/hd$ cd ..
liangju@fuwuqi-Z370-HD3:/media$ fuser -km hd
liangju@fuwuqi-Z370-HD3:/media$ sudo umount /media/hd
liangju@fuwuqi-Z370-HD3:/media$