
Linux
[TOC]
Base
bash
查看当前shell echo $SHELL
列出所有shell cat /etc/shells
切换shell bash 直接输入shell名
安装 bash-it
修改bash ~/.inputrc
1 | set show-all-if-ambiguous on # 一次tab键显示补全列表 |
删除上一条命令多余输入 ^1 替换 ^1^2,替换或删除 找到的第一个
1 | cat file1, ^1, cat file |
全局替换
1 | ansible nginx -a 'which nginx' |
家目录 ~
root用户 /root
普通用户 /home
How
| $ | …… |
|---|---|
| whatis command | 简要说明 |
| man command | 说明文档 |
| which command | binary 文件路径 |
| whereis command | 搜索路径 |
DIRECTORIES
| $ | …… |
|---|---|
| pwd | Display path of current working directory |
| cd directory | Change directory to directory |
| ls -lh | List directory contents |
| mkdir directory | Create new directory named directory |
| ls -lh | List directory contents |
| tree -h | List the contents of the directory in a tree view |
OUTPUT
| $ | …… |
|---|---|
| cat file> | Output the contents of file |
| less file | Output the contents of file using the less command |
| head file | Output the first 10 lines of file |
| cmd > file | Direct the output of cmd into file |
| cmd >> file | Append the output of cmd to file |
| clear | Clear the command line window |
FILES
| $ | …… |
|---|---|
| rm file | Delete file |
| rm -r directory | Delete directory |
| rm -f file | Force-delete file (add -r to force-delete a directory) |
| mv file-old file-new | Rename file-old to file-new |
| mv file directory | Move file todirectory (overwriting an existing file) |
| cp file directory | Copy file todirectory (overwriting an existing file) |
| touch file | Update file access & modification time (and create file if it doesn’t exist) |
PERMISSIONS
| $ | …… |
|---|---|
| chmod 755 file | Change permissions of file to 755 |
| chmod -R 600 directory | Change permissions of directory (and its contents) to 600 |
| chown user:group file | Change ownership of file to user and group (add -R to include a directory’s contents) |
SEARCH
| $ | …… |
|---|---|
| find dir -name “ file“ | Find all files named file inside dir |
| grep “ text“ file | Output all occurrences of text inside file (add -i for case-insensitivity) |
| grep -rl “text“ dir | Search for all files containing text inside dir |
CTRL
| $ | …… |
|---|---|
| CTRL+A | move the caret to the beginning |
| CTRL+E | move the caret to the end of the line |
| CTRL+K | delete all characters after the caret |
| CTRL+U | delete all characters in front of the caret |
| CTRL+L | clear command |
| CTRL+C | abort a running command |
Note
alias
永久命名别名,查看 ~/.bashrc 文件,发现这样一段代码
1 | if [ -f ~/.bash_aliases ]; then |
新建文件 .bash_alases , 写入 alias ll='ll -lh' , 保存后执行 source ~/.bashrc
替换 man 为中文
apt-get install manpages-zh
vi /etc/manpath.config
:1,$s#/usr/share/man#/usr/share/man/zh_CN#g
1.在用 vi 命令编辑文件,使用命令前先按:键,然后输入命令 1,$s#/usr/share/man#/usr/share/man/zh_CN#g,回车即可 2.替换第 1 行开始到最后一行中所有的 /usr/share/man 为 /usr/share/man/zh_CN
开启远程ssh登录
- 安装openssh-server: sudo apt-get install openssh-server
- 开机自动启动ssh命令: sudo systemctl enable ssh
- 关闭ssh开机自动启动命令: sudo systemctl disable ssh
- 单次开启ssh: sudo systemctl start ssh
- 单次关闭ssh: sudo systemctl stop ssh
- 设置好后重启系统 reboot
- 查看ssh是否启动,看到Active: active (running)即表示成功 sudo systemctl status ssh
ssh生成密钥:ssh-keygen
复制本地公钥到服务器:ssh-copy-id user@remoteip
复制器配置别名 code ~/.ssh/config 可通过ssh deepin 登录服务器
1 | Host deeping |
byobu
1 | F2 - Create a new win |
micro
下载 curl https://getmic.ro | bash
设置全局使用 mv ~/micro /usr/bin/micro
tldr
下载tldr替代 ls man
https://mp.weixin.qq.com/s/qPhUxmIF2ar2pQbJe6Buyg
bat 替代 cat
使用 batcat,建议 修改 alias cat=’batcat’