First, the basic command
1. Immediately shutdown and restart, execute the following command:
Shutdown-r Now or reboot
2, immediately shutdown, execute the following command:
Shutdown-h now or Poweroff
3, wait 2 minutes to shutdown and restart, execute the following command:
Shutdown-r 2
4, wait 2 minutes shutdown, execute the following command:
Shutdown-h 2
5, using the current user's history command, do the following:
History
Each command and its ordinal number that you have used will be displayed, and the command can be executed repeatedly with an ordinal number.
For example, enter! 1 and enter, the 1th Historical command will be executed repeatedly.
You can also use the UP and down cursor keys to bring up a history command, and then press ENTER to repeat.
You can also use the UP and down cursor keys to bring up a history command, modify and press ENTER to execute.
6, clear the current user's history command, execute the following command:
History-c
Using the UP cursor key at this point will not make any history commands.
7, display the kernel version number, execute the following command:
Uname-r
Note: The kernel version number differs from the software release version number.
For example, the kernel version number for RHEL 5.4 is 2.6.18-164.EL5 and the software release version number is 5.4.
8. Clear the screen and execute the following command:
Clear
9. Display the operating system clock, execute the following command:
Date
10. Load the disc to/media and execute the following command:
Mount/dev/cdrom/media
11. Unmount the disc and execute the following command:
Umount/dev/cdrom or Umount/media
Note: Do not execute this command in/media or its subdirectories, or a "device busy error" will occur.
12. To view the storage device, execute the following command:
Fdisk–l
13. Load USB drive to/media
Mount/dev/sdb1/media
14, unmount the USB stick, execute the following command:
UMOUNT/DEV/SDB1 or Umount/media
Note: Do not execute this command in/media or its subdirectories, or a "device busy error" will occur.
15. Interrupt Shell command
CTRL + C
Second, the file directory Operation command
1. Display the current absolute path, execute the following command:
Pwd
2. Change the current directory, e.g. execute the following command:
Cd/etc/yum
The current directory will be changed to/etc/yum.
3. Go back to the parent directory of the current directory and execute the following command:
Cd..
4, create the directory, for example, execute the following command:
Mkdir/usr/tigger
5, delete the directory, for example, execute the following command:
Rmdir/usr/tigger
Note: When using the RmDir command, the directory to be deleted must be empty.
6. List the contents of the directory, for example, execute the following command:
LS/
7. List all content in the directory (including hidden files or point files), for example, execute the following command:
Ls/root-a
You will see a "." The file names that begin with, which are called point files. If the command "Ls/root" is not visible to them.
8. List the contents of the directory in long format, and execute the following command:
Ls/boot-l
Note: In Linux, if a command has several switches, you can merge these switches together. For example, the command ls-a-L has the same effect as the command ls-al or Ls-la.
9. Create an empty file, for example, execute the following command:
Touch/a.dat
10. Copy the file, e.g. execute the following command:
Cp/etc/host.conf/root
The file host.conf in directory/etc will be copied to the directory/root with the same file name.
11. Copy the entire subdirectory (without changing the directory name), for example, execute the following command:
Cp-r/usr/include/root will copy the entire subdirectory/usr/include (without changing the directory name) to the directory/root.
12. Copy the entire subdirectory (change directory name), for example, execute the following command:
Cp-r/usr/include/root/include2
The entire subdirectory/usr/include will be copied to the directory/root and the directory name will be changed from include to Include2.
13. Move the file or rename the file, for example, execute the following command:
To rename a file:
Mv/root/host.conf/root/myfile
To move a file:
Mv/root/myfile/
Move file name change at the same time:
Mv/myfile/root/myfile2
14, delete the file, for example, execute the following command:
Rm/root/myfile2
Press the Y key to confirm.
Rm-f/a.dat no need to confirm.
15, delete the non-empty directory, for example, execute the following command:
Mkdir/root/mysub/root/mysub/new
Rmdir/root/mysub
System prompt directory is not empty
Rm-rf/root/mysub
The system has no error prompts.
Ls/root
You will see that there is no mysub directory in the directory/root.
16, sub-screen display the contents of the file, for example, execute the following command:
More/etc/services
Press the SPACEBAR to display the next screen and press the Q key to return to the command line status.
Note: More as a pipe command, can be combined with some other commands, for example: ls/etc |more history |more
17, display the contents of the file, for example, execute the following command:
More _filename the display of one screen at a time, a space or a carriage return to display the next screen.
Less _filename the display of one screen at a time, a space or a carriage return displays the next screen.
Cat _filename show everything at once
Cat _file1 _file2 > File3 writes the contents of File1 and File2 to File3 and overwrites the original contents of File3.
Cat _file >> _file2 append File1 content to file2,file2 original content.
Head _filename only shows the first 10 lines of the file
Head-n _filename Displays the first n rows of the file.
Tail _filename only show the following 10 lines of the file
Tail-n _filename Displays the following n rows of the file.
NL _filename Displays the contents of the file all at once in the form of a file number. Ignores spaces.
18. merge files, e.g. execute the following command:
Cat/etc/resolv.conf/etc/yum.conf >/b.dat
Perform the following command to verify:
Ls-l/b.dat
Displays the length of the file as 814 bytes.
The same functionality can be achieved with two commands:
Cat/etc/resolv.conf >/c.dat
At this point the file length is 26 bytes.
Cat/etc/yum.conf >>/c.dat
At this point the file length is 814 bytes.
Note:> and >> are redirect symbols, if the redirected file already exists,
Use > will overwrite the original content with new content,
With >>, new content is added to the back of the original content.
19. File Search
find [path] [options]
20, File Content Search
Grep
Third, VI Editor
Create or modify a text file, for example, execute the following command:
Vi/b.dat
The VI editor has 2 modes: Command mode and edit mode.
VI after the launch of the command mode, in the command mode by pressing the I key to enter the editing mode.
Press the <Esc> key in edit mode to return to the command mode.
Press the I key to start editing.
When the edits are complete, press the <Esc> key to return to the command mode.
Enter: Wq after press ENTER to save the file, or enter: q! after press ENTER no disk to exit.
To delete the line where the cursor is located, return to command mode and press the D key two times.
To delete several rows that start at the beginning of the line where the cursor is located, such as 5 rows, return to command mode, press 5, and then press the D key two times. The deleted content enters the vi buffer at the same time.
To paste the contents of the VI buffer after the current position, return to command mode and press the P key.
To undo the most recent operation, return to command mode, and then press the U key. Press the U key repeatedly to undo the most recent multiple operations.
To copy the row of the cursor to the VI buffer, go back to command mode and press the Y key two times.
To copy a number of rows (for example, 5 rows) from the line where the cursor is located to the vi buffer, return to command mode, press 5, and then press the Y key two times.
To find a string, such as hostname, from the current position, go back to command mode, then enter/hostname and press ENTER.
To continue looking down, enter/then press ENTER.
VI when editing a file, a temporary file is generated, and the file is "." Begins and ends with ". SWP".
Normal exit of the file is automatically deleted, if an unexpected exit such as a sudden power outage, the file will not be deleted.
You can simply delete the file manually at this point.
: Set NU Displays line number
: Setnonu Cancel Line number
Iv. Package Installation Commands
1. To view all installed packages, execute the following command:
Rpm-qa |more
2. View all packages that contain a string in the installed name, for example, execute the following command:
Rpm-qa |grep Net
3. Verify all installed packages and execute the following command:
Rpm-va
Note: This command lists all files that have been modified by the system and the user since the package was installed.
4. View the purpose of a package that has been installed, for example, execute the following command:
Rpm-qi net-tools-1.60-37.el4.8
5. To see which package a file belongs to in the system, for example, execute the following command:
Rpm-qf/sbin/ifconfig
The result should show that the file belongs to net-tools-1.60-102.el6.i686
6. Install a package, for example, execute the following command:
RPM-IVH ***********.rpm
Note:-V for display Information option,-H for Show process options
Linux Common shell command Daquan