wget:
下载
wget url/a.txt
file/folder
创建文件: touch a.txt
创建文件夹: mkdir NewFolder
mkdir -p dir1/dir2/a.txt
如果 dir1/dir2 不存在,会进行创建
删除文件: rm a.txt
删除文件夹: rmdir NewFolder
删除带有文件的文件夹: rm -r NewFolde
强行删除:
rm -f -r 文件名
mv
更改文件名称:
a.txt -> b.txt
mv a.txt b.txt
移动文件
mv 源文件 目标文件
cp
复制文件
cp 源文件 目标文件
将a.txt从A复制到B,并改名为b.txt
cp /A/a.txt /B/b.txt
pwd
查询当前路径:
pwd
grep
查询包含关键字的行
grep -r keyword /user/src
递归查找当前目录下所有文件
grep -rn keyword
输出包含关键字的行数
grep -c keyword xxx.txt
chmod
man chmod
身份:
u g o a
A combination of the letters ugoa controls which users’ access to the file will be changed: the user who owns it (u), other users in the file’s group (g), other users not in the file’s group (o), or all users (a). If none of these are given, the effect is as if (a) were given, but bits that are set in the umask are not affected.
权限:
- r 读 4
- w 写 2
- x 执行 1
- s 特殊
示例:
执行权限
chmod +x filename
scp
服务器本地文件互传
选择一批相同前缀的文件
scp 'path.*' path
内存使用情况
top
free
cat /proc/meminfo
硬盘使用情况
df -h
当前所有文件夹大小
du -sh .
显卡使用情况
nvidia-smi
定时查看
watch -n 5 nvidia-smi
(5s一次)
重定向
tee 命令
tee [选项] [文件]
将数据重定向到文件和屏幕
常用选项:
-a 追加文件
ls | tee -a res.txt
make | tee res.txt
”>“ (”>>“ 表示追加)
将 make 信息重定向到文件
make > res.txt
make > res.txt 2>&1
make &> res.txt
tree
显示目录结构
tree ./my_dir -L 2
在 ./my_dir 显示两层的树状目录
ps
ps a
/ps -A
显示所有进程
ps aux
显示所有正在运行的进程
ps -l
显示与本次登录相关进程
ps -ef | grep main
查找相关进程
tar
tar -cvf xxx.tar file
打包但是不压缩
-zcvf
打包压缩成gzip
-jcvf
打包压缩成bzip2
一般用法是
cd dir/
tar -cvf xxx.tar *
linux 查看 CUDA
cd /usr/local
目录下有多个 CUDA 版本
查看当前使用的版本:
vi /usr/local/cuda/version.txt
pkg-config
查看 opencv 版本
pkg-config --modversion opencv
module
使用 module 库来管理
module avail 查看可用的库
Module list 查看当前加载的库
module load XXX/xxx 加载
module unload XXX/xxx 卸载
使用 Python 的 opencv 时,切换 opencv 版本后,需要更新对应的python库
pip install opencv-python --user
sed
替换文件中所有包含 source 为 target :
sed -i 's/source/target/g' file.txt
删除文件中包含 source 的行:
sed -i '/source/d' file.txt