100 commonly used Linux commands
The linux command is a command for managing the Linux system. For the Linux system, whether it is the central processor, memory, disk drive, keyboard, mouse, or user, they are all files. The commands for Linux system management are the core of its normal operation, similar to the previous DOS commands. There are two types of Linux commands in the system: built-in Shell commands and Linux commands. In this article, we will list 100 commands that are frequently used when using Linux systems and give a brief explanation.
1, export //View all environment variables
2, wc -l //Count the number of lines, wc -w count words
3, lsattr file //View File attributes
4, cat /etc/passwd |awk -F: '{print $1}' //View all users in the system
5, cat /etc/group //View the system All groups in
6, echo '1+2'|bc -l //Mathematical operations
7, uname -a //View some information about the linux kernel, etc.
8. badblocks -s /dev/sda //Display progress during bad sector scanning
9. time command //View the running time of the command
10. nmap -sP 172.30.4.0 /24 //How many users are operating on my host in this network segment, a good security check tool
11, vgdisplay //View the available space in the system
12, lvextend -L+20G /dev/tank/part1 //Add 20G space to the part1 partition
13, lvresize -L-10G /dev/tank/part2 //Reduce 10G space to the part2 partition
14. pvdisplay //View disk information
15.mplayer -loop 10 /mnt/song/music/花儿开.mp3 //Loop 10 times
16, echo ~/ //Display the user's home directory
17, echo $[5*5] //Arithmetic operations
18, echo $((5*5)) / /Arithmetic operations
19, eval ls;ps aux|grep httpd //Both commands can be executed
20, free -m //Display memory in MB
21. uptime //Displays how long the system has been running. It displays the following information in sequence: current time, how long the system has been running, how many logged-in users are currently, and how long the system has been running in the past 1 minute, 5 minutes, and Average load within 15 minutes
22, addition operation
[root@phpac phpac]# let a=34+3;
[root@phpac phpac]# echo $a;
23, echo "aa" > test.txt and echo "bb" >> test.txt //> Clear the original file and write the content to the file, > ;>Put the content at the end of the file
24, echo $PATH //View a single variable
25, cmp file1 file2 //File content comparison
26 , clear //Clear the screen
27, echo 23423 |awk -re-interval '/[0-9]{3,}/' //If re-interval is not added, it will not be displayed
28, cal //Get a neat calendar format
29, chmod go+w -R /home/zhangy //Add write permissions to group users and other users
30. mirror /mysql //Download the mysql directory
31. Mirror -R /mysql //Upload the mysql directory
32. rmmod pcspkr //Turn off the tab prompt
33. modprobe pcspkr //Turn on the tab prompt sound
34.gpasswd -a zhangy wheel //Add the zhangy user to the wheel group
35.dd if=/dev/zero of=/virtual/ubuntu.virt.img bs=1M count=4096 //Create a 4G IMG image
36, lspic //Display pci device
37, lsusb //Display usb device
38, history | less //less root is a bit like more, it feels more comfortable to use less
39, ln -s //if you forget -s, it will become hard Linked
40, tar zxvf test.tar.gz -C /home/zhangy //Extract the content to the specified directory
41, umask 003 u permission is 7, g permission is 7 , other users are 4, that is, 774, 777-003=774
42, mkfs -t vfat /dev/hda6 //Format a partition in the mobile hard disk into vfat format
43. mount /dev/cdrom /media/cdrom //Mount cdrom
44. getent group 532 //Find group information through group ID
45.last //Login successful User record
46, lastb //Unsuccessful login user record
47, dump -S /dev/sda2 //Check the capacity required to back up /dev/sda2
48, dump -0j -f /dev/hda2/sda2_bak.dump.bz2 /dev/sda2 //Back up and compress sda2
49, restore -t -f /dev/hda2/sda2_bak .dump //View backup information
50, restore -r -f /dev/hda2/sda2_bak.dump //Restore backup
51, fc-list //View the files installed in the system Font
52, find ./ -type f -exec grep -q "root" {} \; -exec echo {} \; //Find the string contained in the file in the directory
53. vmstat 5 //Display the next system information, cpu, memory, i/o, etc. every 5 times
54. After top, use shift + P to sort the processes occupied
55 , top and then shift + M to sort the memory occupied
56, iptraf -g //View the traffic of each interface
57, ostat -d -x /dev/sda2 2 / /Use iostat to check the disk I/O status of disk /dev/sda2, refresh every two seconds
58, paste -sd '|||\n' test //Convert every 4 lines of the file to 1 Line, separated by |.
59, lsof -i :22 //Know what program is currently running on port 22
60, lsof -c abc //Display the files currently opened by the abc process
61 , lsof -p 12 //See which files are opened by the process with process number 12
62, rz -y //Upload files
63, route //View routing information
64, ifup //Open the network card
65, ifdown //Close the network card
66, route del -net 172.168.0.0 netmask 255.255.0.0 dev eth0 //Delete the network 172.168 part
67, route add -net 172.168.10.0 netmask 255.255.255.0 dev eth0 //Add a route
68, netstat -tunl //List the monitored network service ports
69 , netstat -tun //List connected network service ports
70, ls -lrt //Sort in reverse order of time
71, rsync -P //Display progress during synchronization
72.history -c //Clear history command
73, cd – //Return to the last directory
74, tree //Display directory tree
75, umount -n /mnt/hda2 //Force uninstall
76, pacman -S firefox -nd //nd remove dependencies
77, wget -c //Breakpoint download
78. chroot /mnt/ubuntu //Change the root directory to /mnt/ubuntu
79. ctrl+a //Under the command line, move the cursor to the beginning
80. ctrl+e // Under the command line, move the cursor to the end
81. cut -d: -f 1-4 test // Use: split the file and get the 1-4 columns after splitting
82, file /home/zhangy/test.php //Some basic information for viewing files
83, touch test.txt //Create an empty file text.txt
84, htpasswd -cbd /usr/local/nginx/conf/authfile //Create access control file
85, df //View disk space and current number of disks
86 , fdisk -l //View the number of all disks
87, alsamixer //After entering, the m key can mute
88, killall httpd //Kill all httpd processes
89, killall -9 mysqld_safe //Some processes cannot be stopped by super users, -9 is forced deletion
90, echo "AaDCbd23″ |tr "[A-Z]" "[a-z]" capitalization changed Lowercase, echo "AaDCbdc23" |tr -c b-d = Replace strings other than b-d with =
91, echo "ADSF" | iconv -f UTF8 -t GBK //Convert characters from utf8 to gbk -f is the abbreviation of from and -t is like the abbreviation of terminal
92, cat -n file //The line number will be displayed in front of the content
93, chattr +i file //Only Reading and root users cannot modify it
94, tar -tzvf test.tar.gz //List archive contents
95, du -ah //View file list size
96, du -sh //View the total size of all files
97, groups //Check all groups where the current user is located
98, usermod -g Group name user//This method is an overwriting method. Be careful when using it. If user A is different from mysql usermod -g php mysql, then it only
belongs to php.
99 , usermod -G group name user // This method is to add, if user A is different from mysql usermod -g php mysql, mysql will belong to 2 groups
100, bc //Enter Go to
in mathematical calculations. The above are 100 commonly used commands in Linux. Collect the useful ones quickly.
Related recommendations:
The latest Linux command collection
Share a complete collection of Linux command shortcuts
The above is the detailed content of 100 commonly used Linux commands. 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)

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.

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).

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)

After CentOS is stopped, users can take the following measures to deal with it: Select a compatible distribution: such as AlmaLinux, Rocky Linux, and CentOS Stream. Migrate to commercial distributions: such as Red Hat Enterprise Linux, Oracle Linux. Upgrade to CentOS 9 Stream: Rolling distribution, providing the latest technology. Select other Linux distributions: such as Ubuntu, Debian. Evaluate other options such as containers, virtual machines, or cloud platforms.
