weiren1998 / weiren1998.github.io

This is my blog.
1 stars 0 forks source link

Linux基本命令 | J球星的博客 #8

Open weiren1998 opened 2 years ago

weiren1998 commented 2 years ago

https://weiren1998.github.io/archives/4b6ea061.html

在实验室得服务器上运行跑代码时,总是会用到一些Linux的基础命令,在此做一些积累,方便之后不用百度再去查。

weiren1998 commented 2 years ago

补充:查看文件个数

ls -l | grep "^-" | wc -l # 查看当前目录下文件个数(不包含子目录)
ls -lR | grep "^-" | wc -l # 查看当前目录下文件个数(包括子目录)
ls -l | grep "^d" | wc -l # 查看当前目录下文件夹个数(不包含子目录)
ls -lR | grep "^d" | wc -l # 查看当前目录下文件夹个数(包含子目录)

查看txt文件行数

cat ./test.txt | wc -l # 查看txt文件行数
weiren1998 commented 2 years ago
ctrl+z # 挂起进程
jobs # 显示当前暂停的进程([作业号]   运行状态   作业名称)
bg %N # 将一个在后台暂停的命令,变成继续执行
fg %N # 将后任务的程序放到前台

sudo chmod 777 ./SynthText # 修改文件夹为others, group, user都有读写权限

sudo df -h # 查看磁盘空间

cd ~/ # 进入根目录
pwd # 查看当前路径

conda env list # 查看虚拟环境
source activate __env_name__ # 进入相应python环境

watch -n 1 nvidia-smi # 查看GPU使用情况,每隔1s刷新一次
top # 查看cpu情况

import moxing as mox
mox.file.copy('s3://bucket-6526/tyh/code/AS_MLP/apex-master/apex/__init__.py','./a.py') # 从桶里复制文件到jupyter里
mox.file.copy_parallel('s3://bucket-6526/hankai/data/imagenet/','./imagenet/') # 从桶里复制文件夹(所有文件)到jupyter里

# 在运行中查看各个参数维度等信息,这两条语句应放到Model的forward函数中
import pdb 
pdb.set_trace()
# kill the program use 'q' or 'quit'
weiren1998 commented 2 years ago

查看文件大小

du -BM image_feature_resnet50.npy # MB
du -BG image_feature_resnet50.npy # GB
weiren1998 commented 1 year ago

shell中的export命令

参考:https://www.cnblogs.com/guojun-junguo/p/9855356.html

weiren1998 commented 1 year ago

shell中的${aa:-4}变量

参考:https://www.cnblogs.com/hkui/p/6423918.html

weiren1998 commented 1 year ago

git 使用技巧

https://www.cnblogs.com/springclout/p/16203197.html

weiren1998 commented 1 year ago

tmux 教程

https://blog.csdn.net/qq_43912191/article/details/123214679