linux 备忘
常用命令
| 命令 | 功能 | |
|---|---|---|
| ctrl+shift+ + | 放大命令行字体 | |
| ctrl+ - | 缩小命令行字体 | |
| history (!200 执行200行的命令) | 查看历史命令 | |
| ls 2* | 以2开头的文件 | |
| ls 2? | 以2开头的文件(占一位) | |
| ls 1[1-5]3.txt | 正则匹配 | |
| ls > xxx.txt | ls结果保存到xxx.txt | |
| ls >> xxx.txt | ls结果追加到xxx.txt | |
| more xxx.txt | 滚屏查看文件 | |
| ls -alh /bin \ | more | 管道 |
| cd …/… | 上上层 | |
| cd - | 回到上一次目录 | |
| cd ~ | 回到加速目录 | |
| tree | 目录树 | |
| mkdir A/B/C/D -p | ||
| rmdir | 删除文件夹 | |
| rm C -r | 递归删除 | |
| mv 111.txt A/222.txt | 剪切粘贴 | |
| mv 1.txt 2.txt | 重命名 | |
| cp 111.txt A/222.txt | 复制粘贴 | |
| cp A B -r | 复制粘贴文件夹 | |
| ln -s 1.txt 1-softlink.txt | 软连接 | |
| ln 1.txt 1.txt 1-hardlink.txt | 硬链接 | |
| cat 1.txt 2.txt >> xxx.txt | ||
| grep -n “ntfs” xxx.txt | 显示包含ntfs的内容 | |
| grep -v “ntfs” xxx.txt | 不包含ntfs的内容 | |
| grep “^ntfs” xxx.txt | 以ntfs开头 | |
| grep “ntfs$” xxx.txt | 以ntfs结尾 | |
| find / -name “name” | 按名字查找 |
zsh
use oh my vsh on ubuntu
- 安装zsh
sudo apt-get install zsh
- 设置zsh为默认shell
chsh -s /bin/zsh
-
重启
-
安装oh-my-zsh https://github.com/robbyrussell/oh-my-zsh
-
安装主题
vim ~/.zshrc
如果出现中间图片的显示异常

- 安装powerline https://github.com/powerline/fonts
如果还是显示异常
terminal>Preference>Profiles>myprofile(默认unamed)>General>custom font
选择 ubuntu mono derivative Powerline Regular 当然你也可以在powerline的github页面上 Powerline Font Family 列下选择自己喜欢的字体
当然即使这样设置 也只是字体改变了 主题还没有改变
参考这个
装一个主题
git clone git://github.com/sigurdga/gnome-terminal-colors-solarized.git ~/.solarized
建议新建一个自己的profile因为palette改为solarized之后就改不了其他的了(不管是terminal还是terminator 有可能是个bug 当然你可以用命令恢复)
terminal恢复
dconf reset -f /org/gnome/terminal/legacy/profiles:/
terminator 就不用改了 自己加一个profile吧

然后修改 ~/.config/terminator/config 中的[layout]参数为你自己设置的profile
zsh小tips
- zsh 下 popd 就可以跳转到上次的目录 如果是bash的话上次需要 pushd 当然也可以用 cd - 回到上次的目录 我比较喜欢的是以下的操作方式
cd - //按tab
---------------------
☁ blog [dev] cd -
1 -- /cygdrive/d/vscode-workspace/blog
2 -- /cygdrive/d/vscode-workspace
// 用ctrl+p 和ctrl+n 就可以上下选择
- 多层目录时按 d 就可以显示出当前的tree 然后按数字就可以跳转到想去的目录
☁ blog [dev] ⚡ d
0 /cygdrive/d/vscode-workspace/blog/blog
1 /cygdrive/d/vscode-workspace/blog
2 /cygdrive/d/vscode-workspace
%
☁ blog [dev] ⚡ 1
/cygdrive/d/vscode-workspace/blog
- 替换上次指令中的错误
☁ Blog cd bllog
cd: no such file or directory: bllog
%
☁ Blog r bllog=blog
cd blog
- 任意级目
☁ blog [dev] ⚡ ls **/*.xml
node_modules/hexo-generator-sitemap/sitemap.xml node_modules/json-schema/draft-zyp-json-schema-03.xml node_modules/stylus/node_modules/sax/examples/shopping.xml public/sitemap.xml
node_modules/htmlparser2/test/Documents/Atom_Example.xml node_modules/json-schema/draft-zyp-json-schema-04.xml node_modules/stylus/node_modules/sax/examples/test.xml
node_modules/htmlparser2/test/Documents/RDF_Example.xml node_modules/stylus/node_modules/sax/examples/big-not-pretty.xml public/baidusitemap.xml
node_modules/htmlparser2/test/Documents/RSS_Example.xml node_modules/stylus/node_modules/sax/examples/not-pretty.xml public/search.xml
- 快速搜索
ack xxx
- alias
- zsh lovers
oh my zsh
在~/.oh-my-zsh/plugins/下已有很多预设文件
cheatssheet
git
| shortcuts | operation |
|---|---|
| gaa | git add -all |
| gst | git status |
| gb | git branch |
| gcmsg | git commit -m |
| gd | git diff |
| gcb | git checkout -b |
| gco | git checkout |
| grhh | git reset HEAD --hard |
| ggp | git push origin $(current_branch) |
| ggl | git pull $(current_branch) |
| gco | git checkout |
| gm | git merge |
plugins
zsh-syntax-highlighting
高亮命令
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
修改 ~/.zshrc
plugins=( [plugins...] zsh-syntax-highlighting)
最后
source ~/.zshrc
