Linux series of commonly used operation and maintenance commands (summary)

Linux series of commonly used operation and maintenance commands (summary)

This blog records the Linux operation and maintenance commands needed for work. I started to use Linux in college and knew some basic operations, but I didn't organize them. In addition, I was doing development, not operation and maintenance, so I forgot some commands. So now I organize them into a blog. Of course, I won't introduce vi and file operations. I will slowly accumulate some other extended commands. The blog will be updated from time to time.

1. System monitoring

1. free command

The free command can display the physical free and used memory in the system, as well as the swap memory, and also the buffers and caches used by the kernel.

語法:free [param]

param can be:

  • -b: Display memory usage in bytes;
  • -k: Display memory usage in KB;
  • -m: Display memory usage in MB;
  • -o: Do ​​not display the buffer adjustment column;
  • -s<interval in seconds>: continuously monitor memory usage;
  • -t: Display the total memory column;
  • -V: Display version information.

Mem: indicates physical memory statistics

  • total: indicates the total amount of physical memory (total=used+free)
  • Used: Indicates the amount of cache allocated by the system (the cache here includes buffer and cache)
  • Free: indicates the total amount of unallocated physical memory
  • shared: indicates shared memory
  • buffers: The number of buffers allocated by the system but not used.
  • cached: The number of caches allocated by the system but not used.

-/+ buffers/cache: indicates the cache statistics of physical memory

  • (-buffers/cache) Memory: (refers to the used – buffers – cached in the first part of the Mem line)
  • (+buffers/cache) Memory: (refers to the first part of the Mem line, free + buffers + cached)

(-buffers/cache) indicates the amount of memory actually used, and (+buffers/cache) indicates the amount of memory actually not used.

Swap: Indicates the usage of the swap partition on the hard disk

2. ulimit command

ulimit is used to display information about system resource limits

語法:ulimit [param]

The param parameter can be:

  • -a Displays the current resource limit settings.
  • -c <core file upper limit> Set the maximum value of the core file in blocks.
  • -d <data section size> The maximum value of the program data section, in KB.
  • -f <file size> The largest file that the shell can create, in blocks.
  • -H sets a hard limit on the resource, that is, the limit set by the administrator.
  • -m <memory size> specifies the upper limit of available memory in KB.
  • -n <number of files> specifies the maximum number of files that can be opened at the same time.
  • -p <buffer size> specifies the size of the pipe buffer in units of 512 bytes.
  • -s <stack size> Specifies the upper limit of the stack in KB.
  • -S Set elastic limits for resources.
  • -t <CPU time> specifies the upper limit of CPU usage time in seconds.
  • -u <number of programs> The maximum number of programs a user can open.
  • -v <virtual memory size> specifies the upper limit of available virtual memory in KB

3. top command

The top command can dynamically view the overall operation of the system in real time. It is a practical tool that integrates multiple information to monitor system performance and operation information.

語法:top [param]

param is:

  • -b: operate in batch mode;
  • -c: Display the complete management command;
  • -d: screen refresh interval;
  • -I: Ignore the invalidation process;
  • -s: confidentiality mode;
  • -S: cumulative mode;
  • -u [user name]: specify the user name;
  • -p [process number]: specify the process;
  • -n [number of times]: The number of times to loop display.

4. df command

  • df -h to view disk usage
  • df -i View inode usage

5. ps command

The ps command is used to view process statistics

Common parameters:

  • a: Display all process information under the current terminal, including processes of other users.
  • u: Output process information in user-centric format.
  • x: Display the processes of the current user in all terminals.
  • -e: Display all process information in the system.
  • -l: Display process information in long format.
  • -f: Display process information using full format.

You can use it with the grep command or use it alone.

# When the ps command is used alone ps -elf tomcat
#Combining pipeline operation and grep command to filter and query the information of a certain process ps -elf | grep tomcat

2. File Operation

1. tail command

The tail command can be used to view the contents of a file. The syntax is

tail [param] [filename]

Where param can be:

  • -f :Loop reading
  • -q : Do not display processing information
  • -v : Display detailed processing information
  • -c [number]: Number of bytes to display
  • -n [number of lines]: Display the last n lines of the file
  • –pid=PID: Used with -f, it means to end after the process ID, PID dies.
  • -q, --quiet, --silent : Never output the header of the given file name
  • -s, --sleep-interval=S : Used with -f, it means sleeping for S seconds between each repetition

2.ll-ah

ll -ah command can be used to view file status

ll-ah

3. Network Communication

1. netstat

The netstat command is a command-line tool used to monitor packets entering and leaving the network and network interface statistics.

語法:netstat [param]

The param parameter can be:

  • -h : View help
  • -r : Display routing table
  • -i : View network interfaces

2. Restart the network

After setting up the Linux network, you need to restart the network. You can use the command:

service network restart

3. SELinux

SELinux stands for Security-Enhanced Linux, which was contributed by the National Security Agency (NSA) of the United States. It introduces a robust Mandatory Access Control architecture for the Linux kernel subsystem. For more details, please refer to SELinux Introduction, SELINUX Working Principle

In fact, the function of SELinux is similar to that of a firewall, but it is relatively safer. OK, so this blog introduces the usage commands of SELinux.

Check selinux status

getenforce

Temporarily disable SELINUX (only for learning Linux, it is not recommended to disable SELINUX for production)

setenforce

Permanently disable SELINUX (only for learning Linux can be disabled, it is not recommended to disable SELINUX for production)

 # Change SELINUX=enforce to SELINUX=disabled
 vi /etc/selinux/config

4. Firewall

Query the Linux system firewall opening status

firewall-cmd --state

Temporarily disable the firewall (this can only be disabled for learning Linux, it is not recommended to disable SELINUX for production)

systemctl stop firewalld.service

Permanently disable the firewall (this can only be disabled for learning Linux, and it is not recommended to disable SELINUX for production)

systemctl disable firewalld.service

4. System Management

1. uname

The uname command is used to view the kernel version

2. ip addr

View the ip address of Linux: You can use the command

 ip addr

appendix:

Linux Commands (Manual)

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • Linux Operation and Maintenance Basic System Disk Management Tutorial
  • Linux operation and maintenance basic process management real-time monitoring and control
  • Linux operation and maintenance basic process management and environment composition analysis
  • Linux operation and maintenance basic swap partition and lvm management tutorial

<<:  Detailed steps to upgrade mysql8.0.11 to mysql8.0.17 under win2008

>>:  Mini Program to Implement the Complete Shopping Cart

Recommend

MySQL InnoDB transaction lock source code analysis

Table of contents 1. Lock and Latch 2. Repeatable...

Installation and use of Ubuntu 18.04 Server version (picture and text)

1 System Installation Steps OS Version:1804 Image...

VUE introduces the implementation of using G2 charts

Table of contents About G2 Chart use Complete cod...

Complete the search function in the html page

Recently I've been working on a framework tha...

Linux loading vmlinux debugging

Loading kernel symbols using gdb arm-eabi-gdb out...

How to display percentage and the first few percent in MySQL

Table of contents Require Implementation Code dat...

Detailed explanation of props and context parameters of SetUp function in Vue3

1. The first parameter props of the setUp functio...

Linux CentOS MySQL database installation and configuration tutorial

Notes on installing MySQL database, share with ev...

Vue implements partial refresh of the page (router-view page refresh)

Using provide+inject combination in Vue First you...

A few steps to easily build a Windows SSH server

The SSH mentioned here is called Security Shell. ...

How to invert the implementation of a Bezier curve in CSS

First, let’s take a look at a CSS carousel animat...

Use of docker system command set

Table of contents docker system df docker system ...

Example method of viewing IP in Linux

Knowing the IP address of a device is important w...