


150 common commands you must know in Linux operation and maintenance
Linux commands are the core of Linux system management, similar to DOS commands. There are two types of commands in Linux systems: built-in Shell commands and Linux commands. These commands manage the CPU, memory, disk drives, etc., and are necessary for the normal operation of the system.
Order | Function Description |
Online query and help commands (2) | |
man | View command help, command dictionary, more complex ones include info, but they are not commonly used. |
help | View help for Linux built-in commands, such as the cd command. |
File and directory operation commands (18) | |
ls | Quan spell list, the function is to list the contents of the directory and its content attribute information. |
cd | Quanpin change directory, the function is to switch from the current working directory to the specified working directory. |
cp | Quan spelling copy, its function is to copy files or directories. |
find | Search means, used to find directories and files under directories. |
mkdir | Quanpin make directories, its function is to create directories. |
mv | Quan spell move, its function is to move or rename files. |
pwd | Quanpin print working directory, its function is to display the absolute path of the current working directory. |
rename | is used to rename files. |
rm | Quanpin remove, its function is to delete one or more files or directories. |
rmdir | Quanpin remove empty directories, the function is to delete empty directories. |
touch | Create a new empty file and change the timestamp attribute of the existing file. |
tree | The function is to display the contents of the directory in a tree structure. |
basename | Display file name or directory name. |
dirname | Display file or directory path. |
chattr | Change the extended attributes of the file. |
lsattr | View file extension attributes. |
file | Display the type of file. |
md5sum | Calculate and verify the MD5 value of the file. |
View file and content processing commands (21) | |
cat | Quanpin concatenate, the function is to connect multiple files and print to the screen output or redirect to the specified file. |
tac | tac is the reverse spelling of cat, so the function of the command is to display the file contents in reverse. |
more | Display file contents in pages. |
less | Display the file contents in pages, the opposite usage of the more command. |
head | Display the header of the file content. |
tail | Display the end of the file content. |
cut | Split each line of the file according to the specified delimiter and output it. |
split | Split the file into different small fragments. |
paste | Merge file contents line by line. |
sort | Sort the text content of the file. |
uniq | Remove duplicate rows. oldboy |
wc | Count the number of lines, words or bytes of the file. |
iconv | Convert the encoding format of the file. |
dos2unix | Convert DOS format files to UNIX format. |
diff | Quan spelling difference, compares the differences of files, often used for text files. |
vimdiff | Command line visual file comparison tool, often used for text files. |
rev | Reverse output file content. |
grep/egrep | Filter string, the third of the Three Musketeers. |
join | Merge by the same fields in the two files. |
tr | Replace or delete characters. |
vi/vim | Command line text editor. |
File compression and decompression commands (4) | |
tar | Package and compress. oldboy |
unzip | unzip files. |
gzip | gzip compression tool. |
zip | Compression tool. |
Information display commands (11) | |
uname | Command to display operating system related information. |
hostname | Display or set the host name of the current system. |
dmesg | Displays boot information and is used to diagnose system faults. |
uptime | Display system running time and load. |
stat | Display the status of a file or file system. |
du | Calculate disk space usage. |
df | Report file system disk space usage. |
top | Real-time display of system resource usage. |
free | View system memory. |
date | Display and set system time. |
cal | View calendar and other time information. |
Search file commands (4) | |
which | Search for binary commands and search according to the path of the environment variable PATH. |
find | Traverse the disk to find files or directories. |
whereis | Search for binary commands and search according to the path of the environment variable PATH. |
locate | Find the command from the database (/var/lib/mlocate/mlocate.db) and use updatedb to update the library. |
User management commands (10) | |
useradd | Add user. |
usermod | Modify user attributes that already exist in the system. |
userdel | delete users. |
groupadd | Add user group. |
passwd | Change user password. |
chage | Modify the user password validity period. |
id | View the user's uid, gid and user group. |
su | Switch user identity. |
visudo | Exclusive command to edit /etc/sudoers file. |
sudo | Execute commands previously allowed in the sudoers file as another user (default root user). |
Basic network operation commands (11) | |
telnet | Use TELNET protocol to log in remotely. |
ssh | Use SSH encryption protocol to log in remotely. |
scp | Quanpin secure copy, used to copy files between different hosts. |
wget | Command line download file. |
ping | Test the network connectivity between hosts. |
route | Display and set the routing table of the linux system. |
ifconfig | Commands to view, configure, enable or disable network interfaces. |
ifup | Start the network card. |
ifdown | Close the network card. |
netstat | Check network status. |
ss | Check network status. |
In-depth network operation commands (9) | |
nmap | Network scan command. |
lsof | Full name list open files, which is to list the files that have been opened in the system. |
Send and receive emails. | |
mutt | Mail management commands. |
nslookup | Command to interactively query Internet DNS servers. |
dig | Find the DNS resolution process. |
host | Query DNS command. |
traceroute | Track data transmission routing status. |
tcpdump | Command line packet capture tool. |
Commands related to disk and file system (16) | |
mount | Mount the file system. |
umount | Unmount the file system. |
fsck | Check and repair Linux file system. |
dd | Convert or copy files. |
dumpe2fs | Export ext2/ext3/ext4 file system information. |
dump | ext2/3/4 file system backup tool. |
fdisk | Disk partition command, applicable to disk partitions below 2TB. |
parted | Disk partition command has no disk size limit and is commonly used for disk partitions below 2TB. |
mkfs | Format to create a Linux file system. |
partprobe | Update the kernel’s hard disk partition table information. |
e2fsck | Check ext2/ext3/ext4 type file system. |
mkswap | Create Linux swap partition. |
swapon | Enable swap partition. |
swapoff | Close the swap partition. |
sync | Write the data in the memory buffer to disk. |
resize2fs | Adjust the size of the ext2/ext3/ext4 file system. |
System permissions and user authorization related commands (4) | |
chmod | Change file or directory permissions. |
chown | Change the owner and group of a file or directory. |
chgrp | Change the file user group. |
umask | Display or set permission mask. |
Commands to view system user login information (7) | |
whoami | Display the currently valid user name, which is equivalent to executing the id -un command. |
who | Display the user information currently logged into the system. |
w | Display the list of users who have logged in to the system and display the instructions that the user is executing. |
last | Display users logged into the system. |
lastlog | Display the latest login information of all users in the system. |
users | Display the user list of all users currently logged in to the system. |
finger | Find and display user information. |
Built-in commands and others (19) | |
echo | Print variables, or directly output the specified string |
printf | Format the results and output them to standard output. |
rpm | Commands to manage rpm packages. |
yum | Automate and simplify the management of rpm package commands. |
watch | Periodically execute the given command and display the output of the command in full screen mode. |
alias | Set system alias. |
unalias | Cancel system alias. |
date | View or set the system time. |
clear | Clear the screen, referred to as clear screen. |
history | View the history of command execution. |
eject | Eject the optical drive. |
time | Calculate command execution time. |
nc | Powerful network tool. |
xargs | Convert standard input into command line parameters. |
exec | The command to call and execute the instruction. |
export | Set or display environment variables. |
unset | Delete variables or functions. |
type | Used to determine whether another command is a built-in command. |
bc | Command line scientific calculator |
System management and performance monitoring commands (9) | |
chkconfig | Manage Linux system startup items. |
vmstat | Virtual memory statistics. |
mpstat | Display status statistics of each available CPU. |
iostat | Statistics system IO. |
sar | Comprehensively obtain the system's CPU, run queue, disk I/O, paging (swap area), memory, CPU interrupt and network performance data. |
ipcs | Used to report the status of inter-process communication facilities in Linux. The information displayed includes message list, shared memory and semaphore information. |
ipcrm | Used to delete one or more message queues, semaphore sets or shared memory identifiers. |
strace | Used to diagnose and debug Linux user space tracker. We use it to monitor the interaction between user space processes and the kernel, such as system calls, signal transmission, process state changes, etc. |
ltrace | Thecommand will track the library function calls of the process, and it will show which library function is called. |
Commands to shut down/restart/log off and view system information (6) | |
shutdown | Shut down. |
halt | Shut down. |
poweroff | Turn off the power. |
logout | Quit the currently logged in Shell. |
exit | Quit the currently logged in Shell. |
Ctrl d | Shortcut key to exit the currently logged in Shell. |
Process management related commands (15) | |
bg | Convert a command that is paused in the background to continue execution (execute in the background). |
fg | Move the command in the background to the foreground to continue running. |
jobs | Check how many commands are currently running in the background. |
kill | Terminate the process. |
killall | Terminate the process by process name. |
pkill | Terminate the process by process name. |
crontab | Scheduled task command. |
ps | Display a snapshot of the process. |
pstree | Tree display process. |
nice/renice | Adjust the priority of program running. |
nohup | Ignore the pending signal and run the specified command. |
pgrep | Find processes matching the conditions. |
runlevel | View the current running level of the system. |
init | Switch run level. |
service | Start, stop, restart and shut down system services, and also display the current status of all system services. |
The above is the detailed content of 150 common commands you must know in Linux operation and maintenance. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



The key differences between CentOS and Ubuntu are: origin (CentOS originates from Red Hat, for enterprises; Ubuntu originates from Debian, for individuals), package management (CentOS uses yum, focusing on stability; Ubuntu uses apt, for high update frequency), support cycle (CentOS provides 10 years of support, Ubuntu provides 5 years of LTS support), community support (CentOS focuses on stability, Ubuntu provides a wide range of tutorials and documents), uses (CentOS is biased towards servers, Ubuntu is suitable for servers and desktops), other differences include installation simplicity (CentOS is thin)

How to use Docker Desktop? Docker Desktop is a tool for running Docker containers on local machines. The steps to use include: 1. Install Docker Desktop; 2. Start Docker Desktop; 3. Create Docker image (using Dockerfile); 4. Build Docker image (using docker build); 5. Run Docker container (using docker run).

CentOS installation steps: Download the ISO image and burn bootable media; boot and select the installation source; select the language and keyboard layout; configure the network; partition the hard disk; set the system clock; create the root user; select the software package; start the installation; restart and boot from the hard disk after the installation is completed.

CentOS has been discontinued, alternatives include: 1. Rocky Linux (best compatibility); 2. AlmaLinux (compatible with CentOS); 3. Ubuntu Server (configuration required); 4. Red Hat Enterprise Linux (commercial version, paid license); 5. Oracle Linux (compatible with CentOS and RHEL). When migrating, considerations are: compatibility, availability, support, cost, and community support.

Docker process viewing method: 1. Docker CLI command: docker ps; 2. Systemd CLI command: systemctl status docker; 3. Docker Compose CLI command: docker-compose ps; 4. Process Explorer (Windows); 5. /proc directory (Linux).

Docker uses Linux kernel features to provide an efficient and isolated application running environment. Its working principle is as follows: 1. The mirror is used as a read-only template, which contains everything you need to run the application; 2. The Union File System (UnionFS) stacks multiple file systems, only storing the differences, saving space and speeding up; 3. The daemon manages the mirrors and containers, and the client uses them for interaction; 4. Namespaces and cgroups implement container isolation and resource limitations; 5. Multiple network modes support container interconnection. Only by understanding these core concepts can you better utilize Docker.

Troubleshooting steps for failed Docker image build: Check Dockerfile syntax and dependency version. Check if the build context contains the required source code and dependencies. View the build log for error details. Use the --target option to build a hierarchical phase to identify failure points. Make sure to use the latest version of Docker engine. Build the image with --t [image-name]:debug mode to debug the problem. Check disk space and make sure it is sufficient. Disable SELinux to prevent interference with the build process. Ask community platforms for help, provide Dockerfiles and build log descriptions for more specific suggestions.

VS Code system requirements: Operating system: Windows 10 and above, macOS 10.12 and above, Linux distribution processor: minimum 1.6 GHz, recommended 2.0 GHz and above memory: minimum 512 MB, recommended 4 GB and above storage space: minimum 250 MB, recommended 1 GB and above other requirements: stable network connection, Xorg/Wayland (Linux)
