原本这些命令都写在便条贴上贴在我的工位上,觉得太明显了降低逼格,于是悄摸摸整理到这里。
split -l 5000 filename # 切分大文件,每个文件小于5000行
split -b 600k filename # 切分大文件,每个文件不吵过600kb
cat dir/* > total_file # 把多个文件合并成为1个文件
chmod 777 *.log # 文件权限修改
du -hs ./* | sort -hr # 文件夹大小,并按大小排序显示
wget -r -nH --cut-dirs=7 # 获取文件夹,并删掉几个文件夹前缀
sed -i 's/str1/str2/g' file # 把file文件里的str1字符串替换称str2
grep -rn "string" file # 在file文件里查找字符串string
find /dir -name "filename" # 查找文件
iconv -f gbk -t utf-8 -c file # 把文件编码从gbk转成utf-8
ls -l /proc/95271 # 查找进程95271启动路径
free -mh # 查看系统内存
vmstat # 查看系统内存
netstat -nlp | grep "keyword" # 找端口占用
$(date +%Y%m%d-%H:%M:%S) # 获取系统时间并按格式输出
${var##*str} #从左向右截取最后一个str后的字符串
${var#*str} #从左向右截取第一个str后的字符串
${var%str*} #从右向左截取最后一个str前的字符串
${var%%str*} #从右向左截取第一个str前的字符串
-eq # 等于
-ne # 不等于
-gt # 大于
-ge # 大于等于
-lt # 小于
-le # 小于等于
> < ≥ ≤ # 需要双括号
$0 # 当前脚本文件名
$n # 传给脚本的第n个参数
$# # 传给脚本的参数个数
$* # 传给脚本的所有参数
$@ # 所有参数用空格隔开
$? # 上个命令的退出状态
$$ # 当前shell的PID
${#string} # 字符串长度
vimdiff # 对比文件
diff -qr dir1 dir2 # 对比文件夹
diff -urNa dir1 dir2 # 对比文件夹
pip freeze | grep -v '^-e' | xargs pip uninstall -y # 卸载所有pip包
uname -a
uname -m
lsb_release -a
cat /etc/*-release # 系统信息
uptime
last reboot # 重启信息
awk
awk -F ':' '{print $1,$3}' # 分隔符:当前行$0
$NF # 最后一列
$(NF-1) # 倒数第二列
NR # 第几行
awk -F ':' '{print toupper($1)}' # 函数
awk '{if ($1>"m") print $1; else print "-"}' # 条件
pstree username # 查看用户username下开启的进程,树状图展示
ps -aux | grep python
history | grep python
pbcopy < ~/.ssh/id_rsa.pub # 复制到剪切板
git clone --depth=1 xxx.git -b master # 只克隆最小最新可用的代码仓库,大大降低下载量
git pull / add / commit
git push origin lkj
git push origin master
#发生冲突时,放弃本地修改
git diff -w + 文件名 # 查看合并情况
# 解决方法1
git stash
git pull
git stash pop
# 解决方法2
git reset --hard
git pull
htop # 查看CPU运行情况,可用pip安装
gpustat # 查看GPU运行情况,可用pip安装
nvidia-smi # 查看 GPU 运行情况和相应进程
watch -n 0.1 nvidia-smi # 以0.1秒的频率刷新结果
watch --color -n 0.1 gpustat -cpu # 显示颜色
tensorboard --logdir=./ --host=172.18.202.25 --port=8005
export CUDA_VISIBLE_DEVICES='6'
export FLAGS_fraction_of_gpu_memory_to_use=0.3
conda deactivate
cat /usr/local/cuda/version.txt #查看cuda版本
git
github上fork了别人的项目后,再同步更新别人的提交
git remote -v # 1.查看远程信息
git remote add upstream git@github.com:xxx/xxx.git # 2.添加远程仓库
git fetch upstream # 3.从别人的源仓库更新同步代码
git merge upstream/master # 4.合并到本地代码,分支为master
git push # 5.向自己的远程仓库推送刚刚同步源仓库后的代码
使用git clone --depth=1 ***
下载最新代码后,想要拉取其他分支
git remote set-branches origin 'remote_branch_name'
git fetch --depth 1 origin remote_branch_name
git checkout remote_branch_name
使用git checkout -b branchname
创建新分支并切换到新分支
git的撤销操作
- step1:运行
git reflog
命令查看你的历史变更记录,如下: - step2:然后用git reset --hard HEAD@{n},(n是你要回退到的引用位置)回退。
比如上图可运行git reset --hard bfef3a5
git切换到某一commit
git log
git checkout commitId
网友评论