The shell command under Linux

Source: Internet
Author: User
Tags parent directory switches

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 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:
The history will display each command and its ordinal number used, and the command can be executed repeatedly with an ordinal. 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 this time with the UP cursor key will not make any history command.
7, command Prompt key <tab>: Enter the command at the beginning of one or several letters, and then press 1 times "tab" key, the system will automatically fill the recognized parts, and then press 1 "tab" key, the system displays all the commands that match the criteria for the user to select. For example, after entering group two times <Tab> key, all commands starting with group will be displayed
8, 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.
9. Clear the screen and execute the following command: Clear
10. Display the operating system clock, execute the following command: Date
11, load the CD to/media, execute the following command: Mount/dev/cdrom/media
12. 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.
13, check the storage device, execute the following command: Fdisk–l
14. Load USB drive to/mediamount/dev/sdb1/media
15, uninstall the USB flash drive, execute the following command: UMOUNT/DEV/SDB1 or Umount/media Note: Do not execute this command in/media or its subdirectories, or you will see a "Device busy error". 16 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, for example, execute the following command: Cd/etc/yum will change the current directory 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 will see "." The file names that begin with, which are called point files. If the command "Ls/root" is not visible to them.
8, in a long format to list the contents of the directory, 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, for example, execute the following command: Cp/etc/host.conf/root will copy the files in the directory/etc host.conf to the directory/root, the file name is not changed.
11, copy the entire subdirectory (do not change 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 will copy the entire subdirectory/usr/include to the directory/root, and change the directory name from include to Include2.
13, move the file or rename the file, for example, execute the following command: Rename the file: Mv/root/host.conf/root/myfile Move File: Mv/root/myfile/Move file name change: mv/myfile/root/myfile2
14, delete the file, for example, execute the following command: Rm/root/myfile2 Press 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 prompts the directory non-empty rm-rf/root/mysub system without error prompts. Ls/root will see no mysub directory in directory/root
16, split screen display file content, such as the following command: More/etc/services press the SPACEBAR to display the next screen, 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: cat/etc/services
18, merge files, for example, execute the following command: Cat/etc/resolv.conf/etc/yum.conf >/b.dat performs the following command to verify: Ls-l/b.dat shows that the file length is 814 bytes. The same functionality can also be achieved with two commands: cat/etc/resolv.conf >/c.dat The file length is 26 bytes at this time. cat/etc/yum.conf >>/c.dat The file is now 814 bytes long. Note:> and >> are redirect symbols, and if the redirected file already exists, using > will overwrite the original content with the new content, while using >> will add the new content to the back of the original content.

VI Editor Create or modify a text file, for example, execute the following command: The Vi/b.dat 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.
After editing, press the <Esc> key to return to the command mode, enter: Wq after pressing ENTER to save the file after the exit, or enter: q! after press ENTER does not 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. Delete Content at the same time into VI

The shell command under Linux

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.