Merge pull request #10207 from MZqk/master

20180828 15 command-line aliases to save you time.md
This commit is contained in:
Xingyu.Wang 2018-09-15 21:25:19 +08:00 committed by GitHub
commit 38d83fa74a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,102 +1,98 @@
15 command-line aliases to save you time
15 个可以节省你时间的命令别名
======
![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/computer_keyboard_laptop_development_blue.png?itok=IfckxN48)
Linux command-line aliases are great for helping you work more efficiently. Better still, some are included by default in your installed Linux distro.
Linux 命令行别名非常适合帮助你提高工作效率。更好的是,有些 Linux 发行版中就默认包含一些别名。
This is an example of a command-line alias in Fedora 27:
这是 Fedora 27 中的命令别名的示例:
![](https://opensource.com/sites/default/files/uploads/default.png)
The command `alias` shows the list of existing aliases. Setting an alias is as simple as typing:
这个 `alias` 命令列出了已有的别名。设置别名也十分简单:
`alias new_name="command"`
Here are 15 command-line aliases that will save you time:
这里有 15 个命令行别名,可以节省你的时间:
1. To install any utility/application:
1. 安装任何应用实用 / 应用程序:
`alias install="sudo yum install -y"`
Here, `sudo` and `-y` are optional as per users preferences:
在这里, `sudo``-y` 是可选的,因为每个用户的偏好:
![install alias.png][2]
2. To update the system:
2. 更新系统:
`alias update="sudo yum update -y"`
3. To upgrade the system:
3. 升级系统:
`alias upgrade="sudo yum upgrade -y"`
4. To change to the root user:
4. 切换 root 用户:
`alias root="sudo su -"`
5. To change to "user," where "user" is set as your username:
5. 要更改"用户", 其中"user"设置为你的用户名:
`alias user="su user"`
6. To display the list of all available ports, their status, and IP:
6. 显示列出所有可用端口,状态还有 IP
`alias myip="ip -br -c a"`
7. To `ssh` to the server `myserver`:
7. `ssh`你的服务器`myserver`
`alias myserver="ssh user@my_server_ip”`
8. To list all processes in the system:
8. 列出系统中所有进程:
`alias process="ps -aux"`
9. To check the status of any system service:
9. 检查系统的服务状态:
`alias sstatus="sudo systemctl status"`
10. To restart any system service:
10. 重启系统服务在:
`alias srestart="sudo systemctl restart"`
11. To kill any process by its name:
11. 按名称杀死进程:
`alias kill="sudo pkill"`
![kill process alias.png][4]
12. To display the total used and free memory of the system:
12. 显示系统系统总使用内存和空闲内存
`alias mem="free -h"`
13. To display the CPU architecture, number of CPUs, threads, etc. of the system:
13. 显示系统 CPU 框架结构CPU 数量,线程数等:
`alias cpu="lscpu"`
14. To display the total disk size of the system:
14. 显示系统总磁盘大小:
`alias disk="df -h"`
15. To display the current system Linux distro (for CentOS, Fedora, and Red Hat):
15. 显示当前系统 Linux 发行版本(适用于 CentOS,Fedora 和 Red Hat)
`alias os="cat /etc/redhat-release"`
![system_details alias.png][6]
--------------------------------------------------------------------------------
via: https://opensource.com/article/18/8/time-saving-command-line-aliases
作者:[Aarchit Modi][a]
选题:[lujun9972](https://github.com/lujun9972)
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
译者:[MZqk](https://github.com/)
校对:[校对者 ID](https://github.com/ 校对者 ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux 中国](https://linux.cn/) 荣誉推出
[a]:https://opensource.com/users/architmodi
[2]:https://opensource.com/sites/default/files/uploads/install.png (install alias.png)