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

JavaScript code to achieve a simple calendar effect

This article shares the specific code for JavaScr...

The use of mysql unique key in query and related issues

1. Create table statement: CREATE TABLE `employee...

Detailed tutorial on installing nvidia driver + CUDA + cuDNN in Ubuntu 16.04

Preparation 1. Check whether the GPU supports CUD...

Vue3 (III) Website Homepage Layout Development

Table of contents 1. Introduction 2. Actual Cases...

In-depth explanation of the style feature in Vue3 single-file components

Table of contents style scoped style module State...

Complete the search function in the html page

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

Solution to the problem of repeated triggering of functions in Vue project watch

Table of contents Problem description: Solution 1...

WeChat Mini Programs Implement Star Rating

This article shares the specific code for WeChat ...

React tsx generates random verification code

React tsx generates a random verification code fo...

Detailed explanation of MySQL batch SQL insert performance optimization

For some systems with large amounts of data, the ...

Improvement experience and sharing of 163 mailbox login box interactive design

I saw in the LOFTER competition that it was mentio...

Answers to several high-frequency MySQL interview questions

Preface: In interviews for various technical posi...

Detailed explanation of the use of Join in Mysql

In the previous chapters, we have learned how to ...