100 commonly used Linux commands

Nov 18, 2017 pm 03:19 PM
linux Order

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:

Linux command line summary

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!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1655
14
PHP Tutorial
1253
29
C# Tutorial
1227
24
Linux Architecture: Unveiling the 5 Basic Components Linux Architecture: Unveiling the 5 Basic Components Apr 20, 2025 am 12:04 AM

The five basic components of the Linux system are: 1. Kernel, 2. System library, 3. System utilities, 4. Graphical user interface, 5. Applications. The kernel manages hardware resources, the system library provides precompiled functions, system utilities are used for system management, the GUI provides visual interaction, and applications use these components to implement functions.

vscode terminal usage tutorial vscode terminal usage tutorial Apr 15, 2025 pm 10:09 PM

vscode built-in terminal is a development tool that allows running commands and scripts within the editor to simplify the development process. How to use vscode terminal: Open the terminal with the shortcut key (Ctrl/Cmd). Enter a command or run the script. Use hotkeys (such as Ctrl L to clear the terminal). Change the working directory (such as the cd command). Advanced features include debug mode, automatic code snippet completion, and interactive command history.

How to check the warehouse address of git How to check the warehouse address of git Apr 17, 2025 pm 01:54 PM

To view the Git repository address, perform the following steps: 1. Open the command line and navigate to the repository directory; 2. Run the "git remote -v" command; 3. View the repository name in the output and its corresponding address.

Where to write code in vscode Where to write code in vscode Apr 15, 2025 pm 09:54 PM

Writing code in Visual Studio Code (VSCode) is simple and easy to use. Just install VSCode, create a project, select a language, create a file, write code, save and run it. The advantages of VSCode include cross-platform, free and open source, powerful features, rich extensions, and lightweight and fast.

How to run java code in notepad How to run java code in notepad Apr 16, 2025 pm 07:39 PM

Although Notepad cannot run Java code directly, it can be achieved by using other tools: using the command line compiler (javac) to generate a bytecode file (filename.class). Use the Java interpreter (java) to interpret bytecode, execute the code, and output the result.

What is the main purpose of Linux? What is the main purpose of Linux? Apr 16, 2025 am 12:19 AM

The main uses of Linux include: 1. Server operating system, 2. Embedded system, 3. Desktop operating system, 4. Development and testing environment. Linux excels in these areas, providing stability, security and efficient development tools.

vscode Previous Next Shortcut Key vscode Previous Next Shortcut Key Apr 15, 2025 pm 10:51 PM

VS Code One-step/Next step shortcut key usage: One-step (backward): Windows/Linux: Ctrl ←; macOS: Cmd ←Next step (forward): Windows/Linux: Ctrl →; macOS: Cmd →

vscode terminal command cannot be used vscode terminal command cannot be used Apr 15, 2025 pm 10:03 PM

Causes and solutions for the VS Code terminal commands not available: The necessary tools are not installed (Windows: WSL; macOS: Xcode command line tools) Path configuration is wrong (add executable files to PATH environment variables) Permission issues (run VS Code as administrator) Firewall or proxy restrictions (check settings, unrestrictions) Terminal settings are incorrect (enable use of external terminals) VS Code installation is corrupt (reinstall or update) Terminal configuration is incompatible (try different terminal types or commands) Specific environment variables are missing (set necessary environment variables)

See all articles