Linux System (3) System Foundation Literacy Complete

Keywords: Linux network ssh shell

Preface

If everyone likes to play hard, they usually prefer to install the minimal liunx system, then your system does not have graphical desktop functions. So for a beginner who wants to install B, Liunx is black and sloppy, endless black screen, black screen. How to quickly have a more comprehensive understanding of the liunx system? Answer: Read on, haha.

The purpose of this article is to give you a comprehensive basic understanding of linux system.

Main contents: network, system, cpu, memory, hard disk, process and other commonly used basic information viewing and basic function settings.

Linux System Time Dependence

View the current time of the system

[root@zlhpc ~]# date
2017 Thursday, 09, 02, 2003:20:45 CST

Modification time

[root@zlhpc sysconfig]# date -s "2016-02-09 15:15:00"
2016 Tuesday, 09, 2002:15:00 CST
[root@zlhpc sysconfig]# date
2016 Tuesday, 09, 2002:15:05 CST

Synchronized network time

[root@zlhpc sysconfig]# ntpdate -u ntp.api.bz
 9 Feb 15:56:21 ntpdate[4132]: step time server 17.253.68.253 offset 31624839.558211 sec
[root@zlhpc sysconfig]# date
2017 Thursday, 09, 2002 15:56:27 CST

note1:ntp is a network time protocol, which is mainly used to synchronize computer time with server time. Common NTP servers are 210.72.145.44 (National Time Service Center Server Address), ntp.api.bz (Shanghai), time.nist.gov (USA), ntp.fudan.edu.cn (Fudan), s1b.time.edu.cn (Tsinghua University), etc.

note2:date command setup time is only available to super users, ordinary users can only view, and after modification and play, remember to execute clock-w command, write system time into CMOS.

Linux System Host Name and Operating System Related Information

Display System Host Name

[root@zlhpc sysconfig]# hostname
zlhpc

To modify the host name, it is necessary to modify / etc/hosts and / etc/sysconfig/network at the same time. After the modification, it is necessary to restart the machine and save it permanently. Using the host name command, only temporary modification can not be permanently valid.

[root@zlhpc sysconfig]# vim /etc/hostname
- v: Detailed information mode;
- a: Display host alias; 
- d: Display DNS domain name; 
- f: Display FQDN name; 
- i: display the ip address of the host; 
- s: Short host name is displayed and truncated at the first point. 
- y: Display the NIS domain name.

uname Views Operating System Related Information

[root@zlhpc /]# uname -a   
Linux zlhpc 3.10.0-327.el7.x86_64 #1 SMP Thu Nov 19 22:10:57 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

Data in turn are: kernel name, host name, kernel version number, kernel version, hardware name, processor type, hardware platform type, operating system name.

The parameters are as follows

  • - m or machine displays the hardware (CPU) name of the host
  • - n or - nodename displays the name or host name of the host on the network node
  • - r or release displays the linux operating system kernel version number
  • - s or sysname displays the linux kernel name
  • - v Display Operating System is the first version.
  • - p Displays processor type or unknown
  • - i Display hardware platform type or unknown
  • - o Displays the name of the operating system
  • - Help to get help information
  • Version displays uname version information

Several other ways to go out and see Linux version information

[root@zlhpc /]# cat /proc/version
Linux version 3.10.0-327.el7.x86_64 (builder@kbuilder.dev.centos.org) (gcc version 4.8.3 20140911 (Red Hat 4.8.3-9) (GCC) ) #1 SMP Thu Nov 19 22:10:57 UTC 2015
[root@zlhpc /]# cat /etc/issue
\S
Kernel \r on an \m

[root@zlhpc /]# lsb_release -a
LSB Version:    :core-4.1-amd64:core-4.1-noarch:cxx-4.1-amd64:cxx-4.1-noarch:desktop-4.1-amd64:desktop-4.1-noarch:languages-4.1-amd64:languages-4.1-noarch:printing-4.1-amd64:printing-4.1-noarch
Distributor ID:    CentOS
Description:    CentOS Linux release 7.2.1511 (Core) 
Release:    7.2.1511
Codename:    Core

Viewing cpu information on Linux system

[root@zlhpc /]# grep "model name" /proc/cpuinfo  #View cpu Information
model name    : Intel(R) Core(TM) i7-4790 CPU @ 3.60GHz
[root@zlhpc /]# more /proc/cpuinfo    #View cpu Information
processor    : 0
vendor_id    : GenuineIntel
cpu family    : 6
model        : 60
model name    : Intel(R) Core(TM) i7-4790 CPU @ 3.60GHz
stepping    : 3
microcode    : 0x1e
cpu MHz        : 3591.678
cache size    : 8192 KB
physical id    : 0
siblings    : 1
core id        : 0
cpu cores    : 1
apicid        : 0
initial apicid    : 0
fpu        : yes
fpu_exception    : yes
cpuid level    : 13
[root@zlhpc /]# getconf LONG_BIT   #View cpu digits
64

Linux System Users and User Groups

Users and groups can be classified according to the location of the account or group: local account | group, remote (domain) account | group, LDAP,NIS.

According to the functional classification of account | group, it can be divided into: super user (root) uid: 0, ordinary user. Ordinary users can be divided into: system accounts (uid range: 1-499, 1-99: system accounts created by distributions, 100-499: uid accounts can be used if users have the need for system accounts) and logged-in accounts (uid range: 500+).

Relevant configuration files for system users and groups are placed in the following files of the system:

User account information: / etc/passwd user password information: / etc/shadow

User group information: / etc/group password information: / etc/gshadow

So let's open these files one by one to see what content they have stored, what the format is, and how we interpret it.

[root@zlhpc home]# cat /etc/passwd
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
operator:x:11:0:operator:/root:/sbin/nologin
games:x:12:100:games:/usr/games:/sbin/nologin
ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
nobody:x:99:99:Nobody:/:/sbin/nologin
avahi-autoipd:x:170:170:Avahi IPv4LL Stack:/var/lib/avahi-autoipd:/sbin/nologin
systemd-bus-proxy:x:999:997:systemd Bus Proxy:/:/sbin/nologin
systemd-network:x:998:996:systemd Network Management:/:/sbin/nologin
dbus:x:81:81:System message bus:/:/sbin/nologin
polkitd:x:997:995:User for polkitd:/:/sbin/nologin
tss:x:59:59:Account used by the trousers package to sandbox the tcsd daemon:/dev/null:/sbin/nologin
postfix:x:89:89::/var/spool/postfix:/sbin/nologin
sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
rpc:x:32:32:Rpcbind Daemon:/var/lib/rpcbind:/sbin/nologin
abrt:x:173:173::/etc/abrt:/sbin/nologin
libstoragemgmt:x:996:994:daemon account for libstoragemgmt:/var/run/lsm:/sbin/nologin
chrony:x:995:993::/var/lib/chrony:/sbin/nologin
ntp:x:38:38::/etc/ntp:/sbin/nologin
tcpdump:x:72:72::/:/sbin/nologin
rabbitmq:x:994:992:RabbitMQ messaging server:/var/lib/rabbitmq:/bin/bash
nginx:x:993:991:Nginx web server:/var/lib/nginx:/sbin/nologin

Each line represents a user, and the colon (:) in each line represents a separator. Let's read the first line as follows:

root:x:0:0:root:/root:/bin/bash

  1. root: User name
  2. x: Password placeholder
  3. UID
  4. GID
  5. User description
  6. User Home Folder
  7. The shell./sbin/nologin used after login prevents the user from login.

View which shell s are supported in the system:

[root@zlhpc home]# cat /etc/shells
/bin/sh
/bin/bash
/sbin/nologin
/usr/bin/sh
/usr/bin/bash
/usr/sbin/nologin
/bin/tcsh
/bin/csh

Next, let's look at the user's password configuration file:

[root@zlhpc home]# cat /etc/shadow
root:$6$zVDR2oO1Yg7alTbs$.70PPMYxg70k9BvLtjHdm94CDA1YWDRDI5NFzSfcmZF5WMESgIbLUdnqRjuVycg481Ny9rl//YzAFnXhurQi//::0:99999:7:::
bin:*:16659:0:99999:7:::
daemon:*:16659:0:99999:7:::
adm:*:16659:0:99999:7:::
lp:*:16659:0:99999:7:::
sync:*:16659:0:99999:7:::
shutdown:*:16659:0:99999:7:::
halt:*:16659:0:99999:7:::
mail:*:16659:0:99999:7:::
operator:*:16659:0:99999:7:::
games:*:16659:0:99999:7:::
ftp:*:16659:0:99999:7:::
nobody:*:16659:0:99999:7:::
avahi-autoipd:!!:17203::::::
systemd-bus-proxy:!!:17203::::::
systemd-network:!!:17203::::::
dbus:!!:17203::::::
polkitd:!!:17203::::::
tss:!!:17203::::::
postfix:!!:17203::::::
sshd:!!:17203::::::
rpc:!!:17204:0:99999:7:::
abrt:!!:17204::::::
libstoragemgmt:!!:17204::::::
chrony:!!:17204::::::
ntp:!!:17204::::::
tcpdump:!!:17204::::::
rabbitmq:!!:17204::::::
nginx:!!:17204::::::

Still take the first line to read:

root:$6$zVDR2oO1Yg7alTbs$.70PPMYxg70k9BvLtjHdm94CDA1YWDRDI5NFzSfcmZF5WMESgIbLUdnqRjuVycg481Ny9rl//YzAFnXhurQi//::0:99999:7:::

  1. root: User name
  2. $6 zVDR2oO1Yg7alTbs$.70PPMYxg70k9BvLtjHdm94CDA1YWDRDI5NFzSfcmZF5WMESgIbLUdnqRjuVycg481Ny9rl//YzAFnXhurQi/:root User's User Password Encrypted with sha512
  3. The date of the latest password change was calculated from 19700101 to the cumulative number of days on which the password was changed.
  4. 0: The number of days the password cannot be changed. It will not be changed again until several years after the latest change. 0 means that the password can be changed at any time.
  5. 99999: Password expiration time, how many days after the password must be changed.
  6. 7: The system needs to issue a warning that the password is about to expire 7 days before the password expires.
  7. Grace days, passwords can be changed after a few days.
  8. Account expiration time
  9. Reserved fields are not currently used.

See the configuration file for groups as follows:

[root@zlhpc home]# head -n 4 /etc/group
root:x:0:
bin:x:1:
daemon:x:2:
sys:x:3:

root:x:0:

  1. root: User group name
  2. x: Placeholder for user group password
  3. 0: GID for user groups
  4. The name of the account supported by this user group.

Next, let's take a look at account management and check the operation of adding, deleting and modifying accounts.

1. Adding Users

[root@zlhpc home]# useradd zhanglonghao
[root@zlhpc home]# useradd zhanglonghao1

useradd (options) (parameters)

  • - C < Note >: Add notes. Note text will be saved in the comment field of passwd.
  • - d < Login Directory >: The Start Directory when the specified user logs in;
  • - D: Change the default value;
  • - e < validity period >: the validity period of the designated account number;
  • - f < Buffer Days >: Specifies how many days after the password expires to close the account;
  • - G < Groups >: Specify the group to which the user belongs;
  • - G < Groups >: Specify additional groups to which users belong;
  • - m: Automatically establish the user's login directory;
  • - M: Do not automatically create a user's login directory;
  • - n: Cancel the establishment of a group named after the user name;
  • - r: Establish system account number;
  • - s: specify the shell used by the user after login;
  • - u: Specify user id.

Modify user information, parameter options and add consistency.

[root@zlhpc home]# usermod zhanglonghao -u 1005
[root@zlhpc home]# id zhanglonghao
uid=1005(zhanglonghao) gid=1000(zhanglonghao) group=1000(zhanglonghao)

delete user

[root@zlhpc home]# userdel zhanglonghao2 -rf

userdel, the parameters are as follows: if the following parameters are not added to delete directly, then the user deletes, and the user's directory and file remain.

  • - f: Force deletion of users even if they are currently logged in;
  • - r: While deleting users, delete all files related to users.

Add a user to which group: The example adds user zhanglonghao to the group zhanglonghao 1 and it is not deleted in the original group. This means that - a must be added, which means additional, as follows:

[root@zlhpc home]# usermod zhanglonghao -a -G zhanglonghao1
[root@zlhpc home]# groups zhanglonghao
zhanglonghao : zhanglonghao zhanglonghao1

id view user id information

[root@zlhpc home]# id zhanglonghao
uid=1005(zhanglonghao) gid=1000(zhanglonghao) group=1000(zhanglonghao),1001(zhanglonghao1)

View user information for the current login system

[root@zlhpc home]# who
root     pts/0        2017-02-12 15:01 (172.18.8.196)
[root@zlhpc home]# users
root
[root@zlhpc home]# id -un
root
[root@zlhpc home]# whoami
root
[root@zlhpc home]# who
root     pts/0        2017-02-12 15:01 (172.18.8.196)
[root@zlhpc home]# w
 16:51:15 up  1:50,  1 user,  load average: 0.00, 0.01, 0.05
USER     TTY      FROM             LOGIN@   IDLE   JCPU   PCPU WHAT
root     pts/0    172.18.8.196     15:01    3.00s  0.44s  0.01s w

Let's explain the w command.

  1. user: Username
  2. tty: User's machine name or tty number
  3. from: address of remote host
  4. login @: The time when a user logs in to the system
  5. Idle: idle time
  6. Jcpu: The time taken by the process attached to tty (terminal) (JCPU time)
  7. Pcpu: Time spent by the current process (PCPU time)
  8. what: Commands the user is currently using

The parameters are - h: ignoring header file information, - u: loading time of displaying results, - s: not displaying JCPU,PCPU, landing time.

Basic Operation of Liunx Network

Open the page: curl

[root@zlhpc ~]# curl www.baidu.com
<!DOCTYPE html>
<!--STATUS OK--><html> <head><meta http-equiv=content-type content=text/html;charset=utf-8><meta http-equiv=X-UA-Compatible content=IE=Edge><meta content=always name=referrer><link rel=stylesheet type=text/css href=http://Bdstatic 1.bdstatic.s1.bs1.bdstatic.s1.bdstatic.s1.bdstatic.s1.bdstatic.s1.bdstatic.s1.bdstatic.s1.bdstatic.s1.bdstatic.s1.bdstatic.s1.bdstatic.s1.bdstatic.com/r/www/cache/bdorz/baidu.min.css><title><title><title><title><title><title><title><title><title><title><title><title><title><title><title><title><title><<\\> <div class= "head_wrapper"<head = "head_wrapper=" class_wrapper="class_wrapper=" class_wrapper="Wrappeapper ="class_wrapper="wrappeappeapper_wrdiv_form> <div_id= <divid= <divid= <divid id = ldiv> <hide = <div_id= <divid ID ID ID ID ID ID ID ID id= <ldiv> <hide = <hide = <hide = <hide = <hthththththththththththththththththththththththththththththththththththththththththththththththththththththththththththththththththththththththththththththththththththththththththththththththththththththththththththththththt Hthththththt hthtg/bd_bd_loglogloglogo1.pd_logo1.pwidth=270 hidden name = dorz_come = 1 > < input type = name = hidden type = bz_value = 1 > < in Put value = hidden value = name = hidden = value = 8 > < InP > UT type = hidden name = hidden = name = hidden = name = f = 8 > input type = hidden value = RSV = hidden value = 1 > in Put value = hidden value = 1< Input type = hidden name = rsv_idx = hidden name = rsv_idx = 1 = > input type = hidden name = TN = n = Baidu > > span = spas_wr t_baibaibaibaibaibaibaibait_baibait_baibait_baibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibai Baibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibai Baibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibai Baibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaiclass= "mnav" >video</a> <a href=http://tieba.baidu.com name=tj_trtieba class="mnav">BBS</a> <noscript> <a href=http://www.baidu.com/bdorz/logi n.gif?login&tpl=mn&u=http%3A%2F%2Fwww.baidu.com%2f%3fbdorz_come%3 d1 name=tj_login class="lb">Login</a> </noscript> <script>docu Write ('<a href ('<a write ('<a href= "http:////www.baidu.com/bdorz/login.gif? Login& tpl=mn&u='+ + encodeURURIComponent (window.location.href+ (window.location.location.search======="??????????????"""+++"""bdorz_come=1"+ ++++++'''''''''''''''''" tj_login class= "login class=" LB LB a> >logilogin <<< <script script script> <href =/////////////tj_briicon class= "bri" style= "display: block;">more products </a> </div> </div> </di v>  <div id=ftCon> <div id=ftConw> <p id=lh> <a href=http://home.baidu.com>About Baidu</a> <a href=http://ir.baidu.com>About Baidu</a> </p>  <p id=cp> 2017 Baidu <a href=http://www.baidu.com/duty/> Read b Efore using Baidu </a> <a href=http://jianyi.baidu.com/class= "cp-feedback"> Feedback </a> Beijing ICP Certificate 030173 <img s Rc=//www.baidu.com / img/gs.f> </p> </div> </div>.</body></html>

Download file: wget

[root@zlhpc ~]# wget http://download.redis.io/releases/redis-3.0.6.tar.gz

Text browser under linux: w3m and links

[root@zlhpc ~]# w3m www.baidu.com
[root@zlhpc ~]# links www.baidu.com

Check if your network interacts with another machine:ping

[root@zlhpc ~]# ping www.baidu.com

Making routing diagrams provides us with an analysis of where a failure occurs or whether there is a network congestion: mtr

[root@zlhpc ~]# mtr
[root@zlhpc ~]# mtr -r -c 30 www.baidu.com   #The number of packets sent per second is 30. mtr -r -c 30 -s 1024 www.baidu.com #The size of ping package is 1024 bytes
Start: Sun Feb 12 18:01:09 2017
HOST: zlhpc                       Loss%   Snt   Last   Avg  Best  Wrst StDev
  1.|-- ???                       100.0    30    0.0   0.0   0.0   0.0   0.0
  2.|-- 116.236.169.77             0.0%    30  4179. 9116. 4179. 11973 2051.2
  3.|-- 124.74.124.165             0.0%    30    1.9   3.6   1.7   5.4   1.0
  4.|-- 124.74.210.101             0.0%    30    4.1   4.5   2.4   6.1   1.0
  5.|-- 59.43.77.141               0.0%    30   20.1  18.1   7.4  54.5   8.2
  6.|-- 59.43.80.94                0.0%    30    4.3   6.0   2.7  24.3   3.6
  7.|-- 202.97.26.2               86.7%    30    5.1   5.2   5.0   5.4   0.0
  8.|-- 220.191.200.30             0.0%    30    5.9   5.5   5.1   7.0   0.3
  9.|-- ???                       100.0    30    0.0   0.0   0.0   0.0   0.0
 10.|-- 115.239.209.2              0.0%    30    6.8   7.1   6.6   8.0   0.0
 11.|-- ???                       100.0    30    0.0   0.0   0.0   0.0   0.0
 12.|-- 115.239.210.27             0.0%    30    6.1   6.5   5.6  11.7   1.4
  • The first column shows the IP address and the local domain name, which is very similar to tracert.
  • The second column, Loss%: shows the packet loss rate for each corresponding IP.
  • The third column, snt: snt, is equal to 10. Set the number of packets sent per second. The default value is 10, which can be specified by parameter - c.
  • Column Four Last: Shows the latest return delay.
  • Column 5: Avg: Average, which should be the average delay for sending ping packets.
  • Column 6 Best: Better or shortest delay.
  • Seventh column Wrst: The worst or the longest delay.
  • Column 8 StDev: Standard deviation.

The mtr parameters are as follows:

  1. - h Provide Help Command
  2. - v Displays version information of mtr
  3. - r Reported Mode Display
  4. - c. Set the number of packets sent per second
  5. - s is used to specify the size of ping packets
  6. - n no-dns does not do domain name resolution for IP addresses
  7. - A to set the IP address for sending packets. This is useful for a host with multiple IP addresses.
  8. - i use this parameter to set the requirement between ICMP returns by default of 1 second
  9. -4 IPv4
  10. -6 IPv6

DNS query, if the parameter is the domain name output associated ip, if the parameter is the IP output associated domain name:

[root@zlhpc ~]# host www.baidu.com
www.baidu.com is an alias for www.a.shifen.com.
www.a.shifen.com has address 115.239.211.112
www.a.shifen.com has address 115.239.210.27

Options for network interface configuration, tuning and debug: ifconfig

[root@zlhpc ~]# ifconfig
eno16777736: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.18.8.190  netmask 255.255.255.0  broadcast 172.18.8.255
        inet6 fe80::20c:29ff:feb5:d2d8  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:b5:d2:d8  txqueuelen 1000  (Ethernet)
        RX packets 10916  bytes 7044121 (6.7 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 7267  bytes 774719 (756.5 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 0  (Local Loopback)
        RX packets 318  bytes 32844 (32.0 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 318  bytes 32844 (32.0 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

Commands on ip

[root@zlhpc ~]# ip link show  #View all network interface property information
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eno16777736: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT qlen 1000
    link/ether 00:0c:29:b5:d2:d8 brd ff:ff:ff:ff:ff:ff
[root@zlhpc ~]# ip -s link show   #View all statistics
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    RX: bytes  packets  errors  dropped overrun mcast   
    32844      318      0       0       0       0       
    TX: bytes  packets  errors  dropped carrier collsns 
    32844      318      0       0       0       0       
2: eno16777736: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT qlen 1000
    link/ether 00:0c:29:b5:d2:d8 brd ff:ff:ff:ff:ff:ff
    RX: bytes  packets  errors  dropped overrun mcast   
    7050452    10988    0       0       0       0       
    TX: bytes  packets  errors  dropped carrier collsns 
    780097     7309     0       0       0       0       
[root@zlhpc ~]# ip addr show  #View network information
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eno16777736: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:0c:29:b5:d2:d8 brd ff:ff:ff:ff:ff:ff
    inet 172.18.8.190/24 brd 172.18.8.255 scope global dynamic eno16777736
       valid_lft 83120sec preferred_lft 83120sec
    inet6 fe80::20c:29ff:feb5:d2d8/64 scope link 
       valid_lft forever preferred_lft forever

Here is a brief introduction, there will be in-depth introduction in the future.

ifdown and ifup are respectively disabled and enabled to touch a network interface

[root@zlhpc ~]# ifdown eno16777736
[root@zlhpc ~]# ifup eno16777736

netstat command to view network information

The netstat command is a very useful tool for monitoring TCP/IP networks. It can display routing tables, actual network connections and each network interface device. The function of the netstat command is to display network connections, routing tables and network interface information, so that users can know which network connections are in operation at present.

netstat [option]

  • - a Displays all socket s, including those being monitored.
  • - c is redisplayed every 1 second until the user interrupts it.
  • - i displays all network interface information in the same format as "ifconfig-e".
  • - n Replaces the name with the network IP address, showing the network connection situation
  • - r displays the core routing table in the same format as route-e.
  • - t shows the connection of TCP protocol.
  • - u shows the connection of UDP protocol.
  • - v shows ongoing work.
  • - p. Display the name of the program that establishes the relevant link

List all connections

[root@zlhpc ~]# netstat -a  --List all connections
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State      
tcp        0      0 0.0.0.0:sunrpc          0.0.0.0:*               LISTEN     
tcp        0      0 0.0.0.0:ssh             0.0.0.0:*               LISTEN     
tcp        0      0 localhost:smtp          0.0.0.0:*               LISTEN  

List only connections for tcp or udp protocols

[root@zlhpc ~]# netstat -at
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State      
tcp        0      0 0.0.0.0:sunrpc          0.0.0.0:*               LISTEN     
tcp        0      0 0.0.0.0:ssh             0.0.0.0:*               LISTEN     
tcp        0      0 localhost:smtp          0.0.0.0:*               LISTEN   
[root@zlhpc ~]# netstat -au
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State      
udp        0      0 0.0.0.0:18604           0.0.0.0:*                          
udp        0      0 localhost:323           0.0.0.0:*                          
udp        0      0 0.0.0.0:bootpc          0.0.0.0:*                          
udp6       0      0 localhost:323           [::]:*                             
udp6       0      0 [::]:53744              [::]:*   

Disable reverse domain name resolution to speed up queries

[root@zlhpc ~]# netstat -ant
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State      
tcp        0      0 0.0.0.0:111             0.0.0.0:*               LISTEN     
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN     
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN     
tcp        0     52 172.18.8.190:22         172.18.8.196:51171      ESTABLISHED
tcp        0      0 172.18.8.190:22         172.18.8.196:49639      ESTABLISHED

List only connections in listening

[root@zlhpc ~]# netstat -tnl
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State      
tcp        0      0 0.0.0.0:111             0.0.0.0:*               LISTEN     
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN     
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN     
tcp6       0      0 :::111                  :::*                    LISTEN     
tcp6       0      0 :::22                   :::*                    LISTEN     
tcp6       0      0 ::1:25                  :::*                    LISTEN    

Get the process name, process number, and user id

[root@zlhpc ~]# netstat -nlpt
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.0:111             0.0.0.0:*               LISTEN      1/systemd           
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1538/sshd           
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      2094/master         
tcp6       0      0 :::111                  :::*                    LISTEN      1/systemd           
tcp6       0      0 :::22                   :::*                    LISTEN      1538/sshd           
tcp6       0      0 ::1:25                  :::*                    LISTEN      2094/master      
[root@zlhpc ~]# netstat -ltpe
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       User       Inode      PID/Program name    
tcp        0      0 0.0.0.0:sunrpc          0.0.0.0:*               LISTEN      root       16299      1/systemd           
tcp        0      0 0.0.0.0:ssh             0.0.0.0:*               LISTEN      root       21179      1538/sshd           
tcp        0      0 localhost:smtp          0.0.0.0:*               LISTEN      root       22083      2094/master         
tcp6       0      0 [::]:sunrpc             [::]:*                  LISTEN      root       16298      1/systemd           
tcp6       0      0 [::]:ssh                [::]:*                  LISTEN      root       21189      1538/sshd           
tcp6       0      0 localhost:smtp          [::]:*                  LISTEN      root       22084      2094/master         

Statistical Information of Network Newspaper

[root@zlhpc ~]# netstat -s
Ip:
    7872 total packets received
    0 forwarded
    0 incoming packets discarded
    6932 incoming packets delivered
    7284 requests sent out
    60 dropped because of missing route
Icmp:
    260 ICMP messages received
    1 input ICMP message failed.
    ICMP input histogram:
        destination unreachable: 1
        timeout in transit: 214
        echo requests: 1
        echo replies: 44
    409 ICMP messages sent
    0 ICMP messages failed
    ICMP output histogram:
        destination unreachable: 33
        echo request: 12
        echo replies: 
... OUTPUT TRUNCATED ...

Continuous Output-c Continuous Output of tcp Protocol Information

[root@zlhpc ~]# netstat -ct
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State      
tcp        0     52 zlhpc:ssh               localhost:51171         ESTABLISHED
tcp        0      0 zlhpc:ssh               localhost:49639         ESTABLISHED

iftop tool real-time monitoring network traffic information of linux system

Finally, the last simple real-time traffic monitoring tool: iftop, which can be used to monitor real-time traffic, reverse parse ip, display port and so on. If you want to use it, you need to install iftop, official address: http://www.ex-parrot.com/~pdw/iftop/

But there are many other similar software, which we will discuss later.  

[root@zlhpc ~]# iftop
interface: eno16777736
IP address is: 172.18.8.190
MAC address is: 00:0c:29:b5:d2:d8

Common parameter commands:

  • - I Set up the monitoring network card, such as: iftop-i eth1
  • - B Displays traffic in bytes (default is bits), such as: # iftop-B
  • - n makes host information display IP directly by default, such as: iftop-n
  • - N makes port information display port number directly by default, such as: iftop-N
  • - F shows the incoming and outgoing traffic of a particular network segment, such as # iftop-F 10.10.1.0/24 or # iftop-F 10.10.1.0/255.255.0.
  • - h (display this message), help, display parameter information
  • - After using this parameter, the list in the middle shows the local host information, and IP information outside the local host appears.
  • - b Make the flow graph bar display by default;
  • - f This is not very useful for the time being, filtering and computing packages;
  • - P makes host information and port information display by default.
  • - M Sets the maximum value of the scale at the top of the interface, and the scale is displayed in five large sections, for example: iftop-m 100M

Illustration:

  • Interface Head: Flow Scale, corresponding to each line below the white bar.
  • In the middle of the interface: server on the left; IP on the outside, left arrow flowing in and right arrow flowing out; 2s 10s 40s traffic on the right.
  • The lower part of the interface: TX: sending traffic, RX: receiving traffic, TOTAL: total traffic, Cumm: total traffic from running iftop to the current time, peak: peak: traffic peak, rates: representing the average traffic of the past 2s 10s 40s, respectively.

Interface commands:

  • Press h to switch whether to display help or not.
  • Press n to switch to display the IP or host name of the machine.
  • Press s s s to switch whether the host information of the machine is displayed or not.
  • Switch by d to display host information of remote target host.
  • Switch the display format by t to 2/1 rows/only displaying the sending traffic/only displaying the receiving traffic;
  • Display port number or port service name by N switch.
  • Press S to switch whether the port information of the local machine is displayed or not.
  • Switch by D to display port information of remote target host.
  • Press p to switch whether to display port information or not.
  • Press P to switch pause/continue display;
  • Switch to show the average flow graph bar according to b.
  • Calculate the average flow in 2 seconds or 10 seconds or 40 seconds according to B switch.
  • Whether to display the total traffic of each connection by T switch or not;
  • Press l to open the screen filtering function, enter the characters to be filtered, such as ip, press Enter, the screen will only display the IP-related traffic information;
  • Switch the scale above the display screen according to L. The flow graph bar will change with different scale.
  • Press j or k to scroll up or down the connection record displayed on the screen.
  • Sort by 1 or 2 or 3 according to the three columns of traffic data displayed on the right.
  • Sort by < local name or IP on the left;
  • Sort by > Host name or IP of remote target host.
  • Press o to switch whether fixed or not only shows the current connection;
  • Press f to edit the filter code. This is translated. I haven't used this yet!
  • Press! You can use the shell command, this is not used! I don't understand what commands are useful here! ____________
  • Quit monitoring by q.

Hard Disk Storage and tree Tools in Linux System

Storage of the whole system

[root@zlhpc ~]# df -h
//File system capacity used Available% mount point
/dev/mapper/centos-root   18G  2.1G   16G   12% /
devtmpfs                 479M     0  479M    0% /dev
tmpfs                    489M     0  489M    0% /dev/shm
tmpfs                    489M  6.7M  483M    2% /run
tmpfs                    489M     0  489M    0% /sys/fs/cgroup
/dev/sda1                497M  124M  374M   25% /boot
tmpfs                     98M     0   98M    0% /run/user/0

Size of a file or folder

[root@zlhpc usr]# du --max-depth=1 -h
108M    ./bin
46M    ./sbin
390M    ./lib
417M    ./lib64
517M    ./share
0    ./etc
0    ./games
35M    ./include
78M    ./libexec
51M    ./local
55M    ./src
1.7G    .

The parameters of du are as follows:

  • - a Displays all file and directory sizes, recursively
  • - apparent-size shows the size of the file and directory display, not the amount of disk occupancy.
  • - B,--block-size='SIZE'shows the number of blocks, and the size in quotation marks represents the size of the block in the system.
  • - b Displays the size of the viewing object in byte, equivalent to -- apparent-size --block-size=1
  • - c Total and total surface total
  • - D calculation does not contain link files
  • - H is similar to -- si calculates the disk occupancy of files and directories in 1000 units
  • - h Human Readable Patterns (K,M,G)
  • - si substitutes 1000 for 1024 conversion units
  • - K is similar to -- block-size=1k, which specifies a block size of 1K and calculates the file directory size.
  • - l,--count-links computes multiple times if it contains hard links
  • - m is similar to -- block-size=1M, which specifies a block size of 1M and calculates the file directory size.
  • - L, --dereference and - D parameters are different, ignoring all linked objects (files, directories)
  • - P,--no-dereference default parameter, no
  • - 0 replaces line breaks with 0 bytes
  • - S,--separate-dirs does not contain the size of subdirectories
  • - s,--summar shows only the total size of each object at the current directory level
  • - x, --one-file-system skips directories on different file systems.
  • - X FILE, --exclude-from=FILE does not contain matching objects, where FILE is a user-specified file object
  • --exclude=PATTERN
  • - max-depth = shows directory-level depth -- max-depth=0 corresponds to -- summarize
  • - time shows the last change time of a file or subdirectory in a directory
  • - time=WORD displays time with the keyword WORD, including: atime,access,use,ctime,status
  • - time-style=STYLE adjusts the display time format, including full-iso, long-iso, iso, +FORMAT (the format comes from the date command)
  • - help
  • --version version version information

Use the tree tool to view the tree directory structure. First install the tree tool

[root@zlhpc usr]# tree -L 3 src   #List all files with src levels less than 3
src
├── debug
└── kernels
    └── 3.10.0-514.6.1.el7.x86_64
        ├── arch
        ├── block
        ├── crypto
        ├── drivers
        ├── firmware

tree common parameters:

- d: Display directories only

- a: Display all

- f: Display the full path

- L n: n is a number, which means several layers of reality.

Real-time occupancy of process resources, task manager in Linux:top

top is refreshed by default in 3 seconds, refreshed immediately by spaces, q: quit, M: sort by memory, P: sort by cpu, <>: turn the page.

top - 21:32:45 up  6:31,  2 users,  load average: 0.01, 0.02, 0.05
Tasks: 348 total,   2 running, 346 sleeping,   0 stopped,   0 zombie
%Cpu(s):  0.3 us,  0.3 sy,  0.0 ni, 99.3 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem :  1001332 total,   321616 free,   166176 used,   513540 buff/cache
KiB Swap:  2097148 total,  2097148 free,        0 used.   596688 avail Mem 

   PID USER      PR  NI    VIRT    RES    SHR S %CPU %MEM     TIME+ COMMAND             
  3865 root      20   0  146296   2272   1452 R  0.7  0.2   0:00.62 top                 
     1 root      20   0  126416   7184   2608 S  0.0  0.7   0:02.43 systemd             
     2 root      20   0       0      0      0 S  0.0  0.0   0:00.06 kthreadd            
     3 root      20   0       0      0      0 S  0.0  0.0   0:00.37 ksoftirqd/0         
     6 root      20   0       0      0      0 S  0.0  0.0   0:00.98 kworker/u256:0      
     7 root      rt   0       0      0      0 S  0.0  0.0   0:00.00 migration/0         
     8 root      20   0       0      0      0 S  0.0  0.0   0:00.00 rcu_bh              
     9 root      20   0       0      0      0 S  0.0  0.0   0:00.00 rcuob/0             
    10 root      20   0       0      0      0 S  0.0  0.0   0:00.00 rcuob/1             
    11 root      20   0       0      0      0 S  0.0  0.0   0:00.00 rcuob/2             
    12 root      20   0       0      0      0 S  0.0  0.0   0:00.00 rcuob/3             
    13 root      20   0       0      0      0 S  0.0  0.0   0:00.00 rcuob/4  

Statistical explanation:

The first line of statistics is consistent with the command uptime command execution results, followed by:

  • 21:32:45:current time
  • 6:31: System Runtime
  • 2 users: Number of currently logged-in users
  • load average: 0.01, 0.02, 0.05: System load, that is, the average length of the task queue: 1 minute, 5 minutes, 15 minutes ago to the present average. Generally speaking, if the current active process of each cpu kernel is no more than 3, the system will perform well. Of course, what I'm talking about here is every cpu kernel, that is, if your host is 8 cores, then the last string of characters output by uptime should be less than 8*3=24, which means that the system load is not very heavy.

The second and third behavioral processes and the information of the cpu may exceed two lines when there are multiple CPUs, as follows:

  • Tasks: 348 total: total number of processes
  • 2 run: Number of running processes
  • 346 sleeping: the number of sleep processes
  • 0 stopped: number of processes stopped
  • 0 zombie: number of zombie processes
  • % Cpu(s) 0.3 us: Percentage of cpu used by system user processes, excluding processes with higher priority. cpu% is calculated by the sum of the cpu occupancy rate of each core. If it is 4 cores, the utilization rate of core 1 is 100%, and the utilization rate of core 2 is 100%, then the phenomenon that the cpu occupancy rate is higher than 100% will occur, and eventually it will be 200%.
  • 0.3 sy: Percentage of cpu occupied by kernel space
  • 0.0 ni: Percentage of cpu occupied by processes that have changed priority in user process space
  • 99.3 id: Percentage of idle cpu
  • 0.0 wa: Percentage of cpu time waiting for input and output
  • 0.0 hi: hardware cpu interrupt percentage
  • 0.0 si: Soft interrupt percentage
  • 0.0 st: Percentage of virtual machine occupancy

Fourth and Fifth Behavior Memory Information

  • KiB Mem: 1001332 total: total physical memory
  • 321616 free: total free memory
  • 166176 used: Total amount of physical memory used
  • 513540 buff/cache: The amount of memory used as the kernel cache, meaning the free-k command
  • KiB Swap: 2097 148 total: total exchange area
  • 2097148 free: Total Free Exchange Area
  • 0 used: Total switching area used
  • 596688 avail Mem: The total number of buffered swaps, the contents of memory are swapped out to the swap area, and then into the memory, but the used swap area has not been overwritten. This value is the size of the swap area where these contents already exist in memory. When the corresponding memory is swapped out again, it is not necessary to write to the swap area.

Column 6 Heading Details

  • PID: Process id
  • PPID: parent process id
  • RUSER : Real user name
  • UID: User id of process owner
  • USER: User name of process owner
  • GROUP: Group name of process owner
  • TTY: The terminal name of the start process. The process that is not started from the terminal is displayed as follows?
  • PR: Priority
  • NI: nice value. Negative values denote high priority and positive values denote low priority.
  • P: The last CPU used makes sense only in multi-CPU environments
  • % CPU: Percentage of CPU time taken up since last update
  • TIME: Total CPU time used by a process, per second
  • TIME+: Total CPU time used by processes in 1/100 seconds
  • % MEM: Percentage of physical memory used by processes
  • VIRT: The total amount of virtual memory used by a process, per kb. VIRT=SWAP+RES
  • SWAP: In the virtual memory used by the process, the size of the swap is in kb.
  • RES: The size of physical memory used by a process that has not been swapped out, in kb. RES=CODE+DATA
  • CODE: Physical memory occupied by executable code, in kb
  • DATA: Physical memory occupied by parts other than executable code (data segment + stack), unit kb
  • SHR: Shared memory size, unit kb
  • nFLT: Number of page errors
  • nDRT: The number of pages that have been modified since the last time they were written.
  • S: Process state (D = Uninterruptible sleep, R = running, S = sleep, T = tracking / stopping, Z = zombie process)
  • COMMAND: Command name / command line
  • WCHAN: If the process is asleep, the name of the system function in sleep is displayed.
  • Flags: Task logo, refer to sched.h

top command parameters

  • d Specifies the time interval between two screen information refreshes. Of course, users can use the s interactive command to change it.
  • p only monitors the status of a process by specifying the monitoring process ID.
  • q This option will cause top to refresh without any delay. If the calling program has superuser privileges, top will run at the highest priority possible.
  • S specified cumulative mode
  • s makes the top command run in safe mode. This removes the potential dangers of interactive commands.
  • i make top not show any idle or dead processes.
  • c Displays the entire command line, not just the command name

Frequently used commands

top   //Explicit resource usage of all processes every five seconds
top -d 2  //Explicit resource usage of all processes every 2 seconds
top -c  //Explicit process resource usage every 5 seconds and display process command line parameters (default only process name)
top -p 12345 -p 6789//pid is shown every 5 seconds as 12345 and pid is 6789.
top -d 2 -c -p 123456 //Display the resource usage of the process whose pid is 12345 every 2 seconds, and explicit the command line parameters that the process starts

Linux System free Command Views System Memory

[root@zlhpc ~]# free -h
              total        used        free      shared  buff/cache   available
Mem:           977M        138M        693M        6.6M        145M        690M
Swap:          2.0G          0B        2.0G
  • Mem: System physical memory
  • Swap: It's equivalent to virtual memory in windows, which is called swap area. When the physical memory of the system is not enough, the system will use the disk space as virtual memory. In the case of insufficient memory, the operating system first stores the data temporarily unused in memory into the swap space of the hard disk to free up memory for other programs to run.
  • Buff: Buff: Buff: I'll explain briefly here. Compared with cache, it centralizes decentralized write operations to reduce disk I/O and improve system performance. The file is buffed before the write operation.
  • Cache: When you do the read operation, put the data into the cache. When you visit the data next time, you don't need to read the disk, just read the cache directly.
  • Total: The total amount of memory remaining after the removal of memory reserved for hardware and operating systems. Many people wonder that their computers have a total of 8G of memory installed, but it shows that there is only a total of 7.0G. Now there should be no doubt about it. No matter Linux or Windows, there will be some memory reserved for hardware and operating system.
  • used: allocated memory
  • free: Unallocated memory
  • Shared: shared memory
  • Available: total amount of memory available

Linux System Views Memory Information

[root@zlhpc /]# more /proc/meminfo   #View memory information
MemTotal:        1001332 kB 
MemFree:          322740 kB
MemAvailable:     597536 kB
Buffers:            1004 kB
Cached:           261816 kB
SwapCached:            0 kB
Active:           169740 kB
Inactive:         167476 kB
Active(anon):      74780 kB
Inactive(anon):     6452 kB
Active(file):      94960 kB
Inactive(file):   161024 kB
Unevictable:           0 kB
Mlocked:               0 kB
SwapTotal:       2097148 kB
SwapFree:        2097148 kB
Dirty:                 0 kB
Writeback:             0 kB
[root@zlhpc /]# grep MemTotal /proc/meminfo   #View memory information
MemTotal:        1001332 kB

Linux system process-related

pstree: tree structure displays system process information

- p Displays process number

[root@zlhpc ~]# pstree -p
systemd(1)─┬─NetworkManager(978)─┬─dhclient(1320)
           │                     ├─{NetworkManager}(1051)
           │                     └─{NetworkManager}(1054)
           ├─abrt-watch-log(886)
           ├─abrtd(885)
           ├─agetty(906)
           ├─atd(900)
           ├─auditd(852)───{auditd}(871)

ps: Used to show the process status of the current system. You can interrupt and delete unnecessary programs with kill instructions at any time. ps command is the most basic and powerful process view command. It can be used to determine which processes are running and running, whether the process ends, whether the process is dead, which processes occupy too much resources and so on. In a word, most of the information can be obtained by executing the command.

[root@zlhpc ~]# ps -aux
USER        PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root          1  0.0  0.7 126420  7172 ?        Ss   09:12   0:01 /usr/lib/systemd/system
root          2  0.0  0.0      0     0 ?        S    09:12   0:00 [kthreadd]
root          3  0.0  0.0      0     0 ?        S    09:12   0:00 [ksoftirqd/0]
root          6  0.0  0.0      0     0 ?        S    09:12   0:00 [kworker/u256:0]
root          7  0.0  0.0      0     0 ?        S    09:12   0:00 [migration/0]
root          8  0.0  0.0      0     0 ?        S    09:12   0:00 [rcu_bh]
root          9  0.0  0.0      0     0 ?        S    09:12   0:00 [rcuob/0]
  • user: Username for running the secondary process
  • pid: the process number of the process
  • % cpu: Percentage of cpu resources used by the process
  • % MEM: Percentage of physical memory occupied by the process
  • VSZ: The amount of virtual memory used by the process (Kbytes)
  • RSS: The amount of fixed memory (Kbytes) used by the process
  • TTY: Which terminal does the process operate on? If it has nothing to do with the terminal, it will be displayed? In addition, tty-tty6 is the login program on the machine. If it is pts/0 and so on, it is the program connected to the host by the network.
  • STAT: The current state of the program, Linux process has six basic states: R: running or running queue waiting, S: interruptible sleep state, can be waked up by some signal. T: pause state or tracking state, D: uninterruptible sleep state, Z: exit state, process becomes a zombie process, X: exit state, process is about to be destroyed. Six seed states are <: high priority, N: low priority, L: memory paging but locking, s: containing sub-processes, l: mu lt ithreading, +: front-end programs (commands are opening programs, such as vim)
  • START: The time when the process was triggered
  • Time: How long the process actually uses the cpu to run
  • Command: Actual instructions for the program

The parameters of terror are as follows:

  • - a: Show all the programs executed under the terminal except the phase operation leader.
  • a: Display all programs under the current terminal, including those of other users.
  • - A: Display all programs.
  • - c: Display the CLS and PI fields.
  • c: When listing programs, display the real instruction name of each program, without the path, option or resident service label.
  • - C < Instruction Name >: Specifies the name of the instruction to be executed and lists the status of the program that executes the instruction.
  • - d: Display all procedures, but exclude those of the phase leader.
  • - e: This option works the same as the specified "A" option.
  • e: When listing programs, display the environment variables used by each program.
  • - f: Display UID,PPIP,C and STIME fields.
  • f: Use ASCII characters to display tree structure and express the relationship between programs.
  • - G < Group Name >: The effect of this option is the same as that of specifying the "-G" option. It can also be specified using the name of the phase job leader.
  • g: Display all programs under the current terminal, including those of group leaders.
  • - G < Group Identification Code >: Lists the status of programs belonging to the group, or can be specified by the group name.
  • h: No title column is displayed.
  • - H: Shows the tree structure, indicating the relationship between programs.
  • - J or j: Display program status in a work-controlled format.
  • - L or l: Use a detailed format to display the status of the program.
  • L: List the relevant information of the field.
  • - m or m: Displays all threads.
  • n: Numbers for USER and WCHAN fields.
  • - N: Displays all programs except those under the ps instruction terminal.
  • - P < Program Identification Code >: Specify the Program Identification Code and list the status of the Program.
  • P < Program Identification Code >: The effect of this option is the same as that of the specified "-p" option, only slightly different in the list format.
  • r: List only the programs currently being executed by the terminal.
  • - s < Stage Job >: The program identification code for the specified stage job and the status of the program subordinate to the stage job.
  • s: The program status is displayed in the format of program signal.
  • S: When listing programs, include interrupted subroutine data.
  • - T < Terminal Number >: Specify the terminal number and list the status of the program belonging to the terminal.
  • T < Terminal Number >: The effect of this option is the same as that of the specified "-t" option, only slightly different in the list format.
  • - T: Display all programs under the current terminal.
  • - U < User Identification Code >: This option works the same as the specified "-U" option.
  • u: Display the status of the program in a user-oriented format.
  • - U < User Identification Code >: List the status of the program belonging to that user, or you can use the user name to specify it.
  • U < User Name >: Lists the status of programs belonging to that user.
  • v: Display program status in virtual memory format.
  • - V or V: Display version information. - W or w: Use a wide format to display program status.  
  • x: Display all programs, not distinguished by terminals.
  • X: Use the old Linux i386 login format to display program status.
  • - y: When the option "-l" is used, the F(flag) field is not displayed, and RSS field is used instead of ADDR field.
  • - Program Identification Code >: This option works the same as the specified "p" option.
  • - cols < Number of Characters per Column >: Set the maximum number of characters per column.
  • Columns < Number of Characters per Column >: This option works the same as the specified "- cols" option.
  • --cumulative: This option works the same as specifying the "S" option.
  • - deselect: This option works the same as specifying the "-N" option.
  • forest: This option works the same as specifying the "f" option.
  • --headers: Repeated display of header columns.
  • - help: Online help.
  • info: Display error-clearing information.
  • Lines < Number of Display Columns >: Set the number of columns on the display screen.
  • no-headers: This option works the same as the specified "h" option, only slightly different in list format.
  • Group < Group Name >: This option works the same as the specified "-G" option.
  • Group < Group Identification Code >: This option works the same as the specified "-G" option.
  • Pid < Program Identification Code >: This option works the same as the specified "-p" option.
  • - rows < Number of Display Columns >: This option works the same as the specified "- lines" option.
  • - Sid < Phase Job >: This option works the same as the specified "-s" option.
  • - TTY < Terminal Number >: This option works the same as the specified "-t" option.
  • User < User Name >: This option works the same as the specified "-U" option.
  • User < User ID >: This option works the same as the specified "-U" option.
  • --version: This option works the same as specifying the "-V" option.
  • Widty < Number of Characters per Column >: This option works the same as the specified "- cols" option.
[root@zlhpc ~]# ps -ef    --Standard format display process
[root@zlhpc ~]# ps -aux --BSD Format display process

summary

Following is your favorite summary. There are three contents, as follows:

I hope to pay attention to my other articles.

2. Is there a clear explanation in the blog, or if you have a better way, then welcome to join the top left two communication groups, we will study and discuss together.

3. You can forget to praise and pay attention, but don't forget to sweep code and reward.

Posted by ermarkar on Tue, 02 Apr 2019 09:30:30 -0700