100 practical shell commands

Source: Internet
Author: User
Tags php mysql

1. 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.
2. chmod go + w-r/home/zhangy // Add write permissions to group users and other users
3, tar-tzvf test.tar.gz // list the archive content
4, Du-Ah // view the file list size
5, Du-SH // view the total size of all files
6, Echo '1 + 2' | BC-l // mathematical operation
7. uname-A // view the Linux kernel and other information
8. badblocks-S/dev/SDA // shows the progress during bad track scan.
9, Time Command // view the command running time
10, LS-LRT // sort by time in reverse order
11. Rsync-P // The synchronization progress is displayed.
12. History-C // clear historical commands
13, CD-// returns the last directory
14. Tree // display the directory tree
15, umount-N/mnt/hda2 // force uninstall
16, Echo ~ /// Display the user's home directory
17, Echo $ [5*5] // arithmetic operation
18, Echo $ (5*5) // arithmetic operation
19, Eval ls; PS aux | grep httpd // both commands can be executed
20, free-M // memory displayed in MB
21. uptime // shows 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 login users are there, the average load of the system in the past 1 minute, 5 minutes, and 15 minutes
22. addition operation
[Root @ krlcgcms01 mytest] # Let A = 34 + 3;
[Root @ krlcgcms01 mytest] # echo $;
23, export // view all environment variables
24, Echo $ PATH // view a single variable
25, CMP file1 file2 // File Content Comparison
26, clear // clear screen
27, Echo 23423 | awk -- Re-interval '/[0-9] {3,}/' // if re-interval is not added, it is not displayed
28, Cal // get a neat calendar format
29, WC-l // number of statistical rows, WC-W statistical words
30, Echo "aadcbd23" | TR "[A-Z]" "[A-Z]" Small write, echo "aadcbdc23" | tr-c B-d = replace a string other than B-d with =
31, Echo "adsf" | iconv-F utf8-t gbk // convert the character from utf8 to GBK-F is from and simplified, and-T is short for terminal.
32, cat-N file // The line number is displayed before the content
33. chattr + I file // read-only, and cannot be modified by the root user
34, lsattr file // View File Attributes
35, CAT/etc/passwd | awk-F: '{print $1}' // view all users in the system
36, CAT/etc/group // view all groups in the system
37. Groups // check all groups of the current user
38. usermod-G group name users // This method is covered. Be careful when using this method. If user a is similar to MySQL usermod-g php MySQL, only
PHP,
39. usermod-G group name user // This method is added. If user a is like MySQL usermod-g php MySQL, MySQL will belong to two groups.
40, BC // enter the mathematical computation
41. umask 003 U permission is 7, G permission is 7, and other users are 4, that is, 774,777-003 = 774
42. mkfs-T vfat/dev/hda6 // format a partition in the mobile hard drive into vfat format.
43. Mount/dev/CDROM/Media/CDROM // Mount CDROM
44, getent group 532 // you can use the group ID to find the group information.
45. Last // logon success user record
46. lastb // records of unsuccessful logon users
47. Dump-S/dev/sda2 // check the capacity to be backed up by/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 the backup information
50, restore-r-F/dev/hda2/sda2_bak.dump // restore the backup
51, FC-list // view the fonts INSTALLED IN THE SYSTEM
52, find./-type F-exec grep-Q "root" {}\;-exec echo {}\; // find the character string contained in the file in the directory
53. vmstat 5 // displays the system information, CPU, memory, and I/O information every 5 times.
54. Sorting of Shift + P processes after top
55. Sort the memory occupied by SHIFT + m after top
56, iptraf-G // view the traffic of each interface
57. ostat-D-x/dev/sda2 2 // use iostat to view disk I/O information of Disk/dev/sda2, Which is refreshed every two seconds.
58, paste-sd' | \ n' test // each of the four lines of the file is converted into one line and separated by |.
59, lsof-I: 22 // You know what port 22 is running. Program
60, lsof-c abc // display the files currently opened by the ABC process
61, lsof-p 12 // check which files are opened by the process whose process number is 12
63, route // view route information
64, IFUP // enable the NIC
65, ifdown // disable the NIC
66, route del-net 172.160.0 netmask 255.255.0.0 Dev eth0 // Delete the 172.168 CIDR Block
67, route add-net 172.1610.0 netmask route 255.255.0 Dev eth0 // Add a route
68, netstat-tunl // list the listening network service ports
69, netstat-tun // list the connected network service ports
70, NMAP-SP 172.30.4.0/24 // how many users are operating on my host in this network segment, a good security check tool
71. vgdisplay // view available space in the system
72, lvextend-L + 20g/dev/tank/Part1 // Add 20g space to the partition Part1
73, lvresize-L-10G/dev/tank/Part2 // reduce the space by 10 Gb to the Part2 Partition
74, pvdisplay // view disk Information
75, mplayer-loop 10/mnt/song/music/Hua Er opened the loop // played for 10 times
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, the light starts with nominal Motion
80, CTRL + E // move the cursor to the end of the command line
81, cut-D:-F 1-4 test // use: to split the file, take the first-4 columns after the split
82, file/home/zhangy/test. php // used to view some basic information about the file
83, touch test.txt // create an empty file text.txt
84, htpasswd-CBD/usr/local/nginx/CONF/AuthFile // create an access control file
85, DF // view the disk space and the current number of disks
86, fdisk-l // view the number of all disks
87. After alsamixer // enters, the M key can be muted.
88, killall httpd // kill all httpd Processes
89, killall-9 mysqld_safe // some process superusers cannot stop,-9 is force Delete
90, mirror/MySQL // download the MySQL directory
91, mirror-r/MySQL // upload the MySQL directory
92, rmmod pcspkr // turn off the tab prompt
93, modprobe pcspkr // enable the tab prompt
94, gpasswd-A zhangy wheel // Add the user zhangy to the group
95, dd If =/dev/Zero of =/virtual/ubuntu. virt. img bs = 1 m COUNT = 4096 // create a 4g img Image
96, lspic // display PCI device
97, lsusb // display USB device
98, history | less // less root is more like, it feels more comfortable to use less
99, Ln-S // if you forget-S, it turns into a hard link.
100, tar zxvf test.tar.gz-C/home/zhangy // decompress the content to the specified directory

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.