Linux 实用命令:
1.查看系统中运行的服务程序
service --status-all
2.``
运行``中的命令,其输出作为下一条命令的参数。如: find `pwd` cuda
3.查看cpu信息
lscpu
4.查看gpu信息
/usr/local stat cuda
5.find
find . -name raw_data #查找当前目录
find . -name "*.zip" #递归查找子目录
-prune #排除目录
-[a|c|m]time -- [最后访问|最后状态修改|最后内容修改]time
find . -name node_modules -prune -type f -o -print | grep Annotatio
-path node_modules -prune # -prune 必须紧邻-path之后
find . -name "*.zip" -exec unzip -o {} \; #{}左右两边必须有空格
-o 覆盖已有文件 {} 参数传递
wget 高速下载,wget可以递归,支持断点
curl 精简的命令行网页浏览器,可以模拟提交web数据,支持URL中加入变量,因此可以批量下载
curl "url" -o "path/filename" -k(不使用ssl证书)
wget url -P <aimPath> -O fileName
curl -L url -o <filePath>
7. 进程挂起
nohup “command” &
在正常退出终端时(exit),继续执行命令。异常退出时,停止执行。输出保存在当前文件夹下的nohup.out文件中
tail -f nohup.out 动态查看输出
8.netstat -tunlp
显示tcp,udp的端口和进程等相关情况
9. ldd 、ll 、locate
ldd命令用于打印程序或者库文件所依赖的共享库列表。
ldconfig -p|grep uuid
apt-cache search uuid
例:ldd /home/zwx/.../lib.so | grep uuid
解决caffe编译时//usr/lib/x86_64-linux-gnu/libSM.so.6: undefined reference to `uuid_unparse_lower@UUID_1.0
10. ps -aux | grep xrdp
当netstat不显pid和进程名时,查看端口占用服务的pid
11 启动tensorboard 服务
tensorboard --logdir=" " --host --port
12. 查看pip安装的路径
python -m site
13. 文件内容搜索
find / -name "*.log" | xargs grep "vl"
14. ldconfig
ldconfig是一个动态链接库管理命令,为了让动态链接库为系统所共享,还需运行动态链接库的管理命令--ldconfig。 ldconfig 命令的用途,主要是在默认搜寻目录(/lib和/usr/lib)以及动态库配置文件/etc/ld.so.conf内所列的目录下,搜索出可共享的动态链接库(格式如前介绍,lib*.so*),进而创建出动态装入程序(ld.so)所需的连接和缓存文件,缓存文件默认为 /etc/ld.so.cache,此文件保存已排好序的动态链接库名字列表
https://www.cnblogs.com/lyongde/p/4190588.html
15. du
统计文件夹总大小
du -sh VOCdevkit200711 | grep G
详细查看当前目录,子目录下的,所有文件和目录
du -ah
du -h --max-depth=1
16 统计目录下的文件个数
ls -l | grep "^-"| wc -l #统计当前目录下的文件个数
ls -lR | grep "^d"| wc -l #递归统计目录下的所有文件夹个数
wc -I/w/m #文件夹中的行数、字数、字符数
17. 查看显卡信息
nvidia-smi : 显示系统cuda版本
nvcc --version :显示runtime library 版本
cuda多版本切换:
ln -s /usr/local/cuda-9.0 /usr/local/cuda #ln -s 源 目标 ,源目录必须为绝对路径
vi ~/.bashrc
export export PATH="/usr/local/cuda/bin:$PATH"
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/cuda/lib64"
export CUDA_HOME=/usr/local/cuda
同理:可以修改.bashrc文件为为每个用户指定不同的cuda版本。
export export PATH="/usr/local/cuda-9.0/bin:$PATH"
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/cuda-9.0/lib64"
export CUDA_HOME=/usr/local/cuda-9.0
注意:
每个版本都需要安装对应的cudnn(深度神经网络的GPU加速库),两个文件夹(cuda/include/、cuda/lib64/)共5个文件
18 . 标注输出重定向到文件
1. python -u train.py > log.txt 2>&1 & # -u 强制刷新缓存
2. sys.stdout = f # f 以追加方式打开,如:with open('log.txt', 'a+') as f:
3. loging 类
https://www.cnblogs.com/nancyzhu/p/8551506.html
19. 多线程压缩
apt install pigz
tar cvf - derain | pigz -1 -p 32 -krK > smog.zip
-1 压缩率(0~9 最快)| -p 线程数 | -k 保留源文件 | -r 压缩子文件 |-K 压缩为zip
https://blog.csdn.net/xfg0218/article/details/100744063
20 中文文件夹转码(UTF-8 -> GBK)
apt install convmv
convmv -f gbk -t utf-8 -r --notest /home/wwwroot
21.设置系统语言
dpkg-reconfigure locales
.勾选[ ]zh_CN.GBK_GBK
和[ ] zh-CN.UTF-8.UTF-8
reboot
22. 设置系统启动模式
#开机默认进入图像化界面
systemctl set-default graphical.target
#开机默认进入命令行界面
systemctl set-default multi-user.target
23 ps -aux
Here are the different values that the s, stat and state output specifiers (header "STAT" or "S") will display to describe the state of a process:
D uninterruptible sleep (usually IO)
R running or runnable (on run queue)
S interruptible sleep (waiting for an event to complete)
T stopped by job control signal
t stopped by debugger during the tracing
W paging (not valid since the 2.6.xx kernel)
X dead (should never be seen)
Z defunct ("zombie") process, terminated but not reaped by its parent
For BSD formats and when the stat keyword is used, additional characters may be displayed:
< high-priority (not nice to other users)
N low-priority (nice to other users)
L has pages locked into memory (for real-time and custom IO)
s is a session leader
l is multi-threaded (using CLONE_THREAD, like NPTL pthreads do)
+ is in the foreground process group
./bin:
bin为binary的简写主要放置一些系统的必备执行档例如:cat、cp、chmod df、dmesg、gzip、kill、ls、mkdir、more、mount、rm、su、tar等。
/usr/bin:
主要放置一些应用软体工具的必备执行档例如c++、g++、gcc、chdrv、diff、dig、du、eject、elm、free、gnome*、 gzip、htpasswd、kfm、ktop、last、less、locale、m4、make、man、mcopy、ncftp、 newaliases、nslookup passwd、quota、smb*、wget等。
/sbin:
主要放置一些系统管理的必备程式例如:cfdisk、dhcpcd、dump、e2fsck、fdisk、halt、ifconfig、ifup、 ifdown、init、insmod、lilo、lsmod、mke2fs、modprobe、quotacheck、reboot、rmmod、 runlevel、shutdown等。
/usr/sbin:
放置一些网路管理的必备程式例如:dhcpd、httpd、imap、in.*d、inetd、lpd、named、netconfig、nmbd、samba、sendmail、squid、swap、tcpd、tcpdump等
CUDA_Installation_Guide_Linux.pdf in /usr/local/cuda-10.1/doc/pdf for detailed information on setting up CUDA.