mirror of
https://github.com/LCTT/TranslateProject.git
synced 2024-12-23 21:20:42 +08:00
Translated tech/20160926 First 5 Commands When I Connect on a Linux Server.md
This commit is contained in:
parent
d6ec5148cd
commit
af0cd0a4cc
@ -1,16 +1,14 @@
|
||||
ictlyh translating
|
||||
|
||||
First 5 Commands When I Connect on a Linux Server
|
||||
当我连接到 Linux 服务器时运行的前 5 个命令
|
||||
============================================================
|
||||
|
||||
![First 5 shell commands I type when I connect to a linux server](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/first-5-commands_0.jpg?itok=sITDZBzw "First 5 shell commands I type when I connect to a linux server")
|
||||
[Creative Commons Attribution][1][Sylvain Kalache][2][First 5 shell commands I type when I connect to a linux server][3]
|
||||
![当我连接到 Linux 服务器时运行的前 5 个命令](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/first-5-commands_0.jpg?itok=sITDZBzw "当我连接到 Linux 服务器时运行的前 5 个命令")
|
||||
[Creative Commons Attribution][1][Sylvain Kalache][2][当我连接到 Linux 服务器时运行的前 5 个命令][3]
|
||||
|
||||
After half a decade working as a system administrator/SRE, I know where to start when I am connecting to a Linux server. There is a set of information that you must know about the server in order to properly, well most of the time, debug it.
|
||||
作为一个系统管理员/SRE 工作50年后,我知道当我连接到一台 Linux 服务器时我首先应该做什么。为了(在大部分时间里)更好的调试该服务器,这里有一系列关于服务器你必须了解的信息。
|
||||
|
||||
### First 60 seconds on a Linux server
|
||||
### 连上 Linux 服务器的第一分钟
|
||||
|
||||
These commands are well known for experienced software engineers but I realized that for a beginner who is getting started with Linux systems, such as my students at [Holberton School][5], it is not obvious. That’s why I decided to share the list of the first 5 commands I type when I connect on a Linux server.
|
||||
这些命令对于有经验的软件工程师来说都非常熟悉,但我意识到对于一个刚开始接触 Linux 系统的初学者来说,例如我在 [Holberton 学习][5]任教的学生,却并非如此。这也是我为什么决定分享当我连上 Linux 服务器首先要运行的5个命令的原因。
|
||||
|
||||
```
|
||||
w
|
||||
@ -20,7 +18,7 @@ df
|
||||
netstat
|
||||
```
|
||||
|
||||
These 5 commands are shipped with any Linux distribution so you can use them everywhere without extra installation needed.
|
||||
这5个命令在任何一个 Linux 发行版中都有,因此不需要额外的安装步骤你就可以直接使用它们。
|
||||
|
||||
### w:
|
||||
|
||||
@ -33,7 +31,7 @@ root pts/1 104-7-14-91.ligh 23:40 5.00s 0.01s 0.03s sshd: root [priv]
|
||||
[ubuntu@ip-172-31-48-251 ~]$
|
||||
```
|
||||
|
||||
A lot of great information in there. First, you can see the server [uptime][6] which is the time during which the server has been continuously running. You can then see what users are connected on the server, quite useful when you want to make sure that you are not impacting a colleague’s work. Finally the [load average][7] will give you a good sense of the server health.
|
||||
这里列出了很多有用的信息。首先,你可以看到服务器运行时间 [uptime][6],也就是服务器持续运行的时间。然后你可以看到有哪些用户连接到了服务器,当你要确认你没有影响你同事工作的时候这非常有用。最后 [load average][7] 能很好的向你展示服务器的健康状态。
|
||||
|
||||
### history:
|
||||
|
||||
@ -46,7 +44,7 @@ A lot of great information in there. First, you can see the server [uptime][6]
|
||||
5 cat ../../app/services/discourse_service.rb
|
||||
```
|
||||
|
||||
`History` will tell you what was previously run by the user you are currently connected to. You will learn a lot about what type work was previously performed on the machine, what could have gone wrong with it, and where you might want to start your debugging work.
|
||||
`history` 能告诉你当前连接的用户之前运行了什么命令。你可以看到很多关于这台机器之前在执行什么类型的任务、可能出现了什么错误、可以从哪里开始调试工作等信息。
|
||||
|
||||
### top:
|
||||
|
||||
@ -70,7 +68,7 @@ Swap: 0k total, 0k used, 0k free, 1052320k cached
|
||||
8 root 20 0 0 0 0 S 0.0 0.0 0:00.00 rcu_bh
|
||||
```
|
||||
|
||||
The next information you want to know: what is currently running on this server. With `top` you can see all running processes, then order them by CPU, memory utilization and catch the ones that are resource intensive.
|
||||
你想知道的下一个信息:服务器当前在执行什么工作。使用 `top` 命令你可以看到所有正在执行的进程,然后可以按照 CPU、内存使用进行排序,并找到资源敏感的进程。
|
||||
|
||||
### df:
|
||||
|
||||
@ -82,7 +80,7 @@ devtmpfs 1.9G 12K 1.9G 1% /dev
|
||||
tmpfs 1.9G 0 1.9G 0% /dev/shm
|
||||
```
|
||||
|
||||
The next important resource that your server needs to have to be working properly is disk space. Running out of it is a very classic issue.
|
||||
你服务器正常工作需要的下一个重要资源就是磁盘空间。磁盘空间消耗完是非常典型的问题。
|
||||
|
||||
### netstat:
|
||||
|
||||
@ -99,16 +97,16 @@ tcp 0 0 *:4242 *:* LIST
|
||||
tcp 0 0 *:ssh *:* LISTEN 1209/sshd
|
||||
```
|
||||
|
||||
Computers are a big part of our world now because they have the ability to communicate between each other via sockets. It is critical for you to know on what port and IP your server is listening on and what processes are using those.
|
||||
计算机已成为我们世界的重要一部分,因为它们有通过套接字进行相互交流的能力。知道你的服务器正在监听什么端口、IP地址是什么、以及哪些进程在使用它们,这对于你来说都非常重要。
|
||||
|
||||
Obviously this list might change depending on your goal and the amount of existing information you have. For example, when you want to debug specifically for performance, [Netflix came up with a customized list][8]. Do you have a useful command that is not in my top 5? Please share it in the comments section!
|
||||
显然这个列表会随着你的目的和你已有的信息而变化。例如,当你需要调试性能的时候,[Netflix就有一个自定义的列表][8]。你有任何不在我 Top 5中的有用命令吗?在评论部分和我们一起分享吧!
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.linux.com/blog/first-5-commands-when-i-connect-linux-server
|
||||
|
||||
作者:[SYLVAIN KALACHE ][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
译者:[ictlyh](https://github.com/ictlyh)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
Loading…
Reference in New Issue
Block a user