Ubuntu common commands [3] - netstat, systemctl, echo, chown

*netstat

Netstat is used to display statistical data related to IP, TCP, UDP or ICMP protocols and to check the network connection status of each port of the machine.

60e843cb0ca345d5818181d47e3ba234.png

 netstat <options>, such as sudo netstat -tulpn in the above figure, displays data related to tcp and udp transport layer protocols (-tu), displays the binding port and IP information of the process that is listening or has established a connection (- ln), display the process pid and process name (-p). For example, mysqld transmits data through port 8888. It can also be written as sudo netstat -npltu.

Direct netstat --help, you can view <options> detailed information, such as -a shows all sockets included in the listening

              -n directly displays the network connection with the network ip address and port.

              -t Display the tcp protocol.

              -l shows connections in the listening state.

             -u Display udp protocol.

             -p displays the process PID and process name to which the socket belongs.

 sudo netstat -nplt will only display the tcp protocol and other information.

sudo netstat -nltp, display the tcp protocol, the binding port and IP information of the process being monitored , and display the pid and process name of the process. sudo netstat -natp, display the tcp protocol, the binding port and IP information of the process that is listening or has established a connection , and display the pid and process name of the process.

(Socket means socket, which is the abstraction of the endpoints for two-way communication between application processes of different hosts in the network. For example, a socket is one end of network process communication.)

*systemctl

systemctl is the system service manager command:

(1) A certain service runs automatically after booting

eg. systemctl enable apache.service

(2) Cancel the automatic operation of a certain service

eg. systemctl disable apache.service

(3) Check whether a service runs automatically after booting

eg. systemctl is-enabled apache.service

(4) Start a service

eg. systemctl start apache.service

(5) Restart a service

eg. systemctl restart apache.service

(6) Stop a service

eg. systemctl stop apache.service

(7) Query the running status of a service

eg. systemctl status apache.service

(8) Re-download the configuration file of a service

eg. systemctl reload apache.service

(9) Prohibit a service from starting automatically or manually

eg. systemctl mask apache.service

(10) Cancel the prohibition of automatic or manual startup of a service

eg. systemctl unmask apache.service

(11) Check whether a service is activated

eg. systemctl is-active apache.service

(12) List all activated services

eg. systemctl list-units --type|-t  service

(13) View all services

eg. systemctl list-units --type service --all

(14) List all failed services

eg. systemctl --failed --type=service

*echo

This command is used to output a string: echo string

You can also direct the output to a file, echo string > myfile or echo string >> myfile

*chown

The chown command can change the owner of the specified file to the specified user or group.

eg. chown root /usr/local/etc/opensips/opensips.cfg

 

 

Guess you like

Origin blog.csdn.net/m0_51292856/article/details/128310720