Common shell commands,

Source: Internet
Author: User

Common shell commands,

Directory

 

I. Directory operations

A) ls --View files/Directory:

Common: ls-l view detailed file list

B) pwd --View the current directory:

C) cd --Change the working directory:

Common ①: cd ../jump to the upper-level directory

Common ②: cd/boot/jump to the specified directory

D) mkdir --Create directory:

Frequently used: Create an empty folder in mkdir 123

E) rm --Delete a file/Directory:

Frequently used: rm-rf 123 deletes a directory folder and files in the directory are also deleted.

F) mv --Move file/Directory Rename and move:

Move file: mv 1.sh./123 * mv target file to a directory

Renamed file: mv 1.sh 123.sh à mv original file to be modified

G) ln --Establish a soft connection and a hard connection:

Soft connection: ln-s 123.sh ../à ln-s source file to be placed in the path

Hard connection: ln 123.sh ../à ln source file to be placed in the path

H) rmdir --Delete an empty directory:

Ii. File Operations

A) cat --View the file content,If the file does not exist, create the corresponding file:

Common: cat 1.txt

B) cp --Copy files and directories:

Backup: cp 123.sh 1.sh à cp source file target file

Copy to a path: cp 123.sh ../à cp source file target path

C) chmod --Modify file permissions:

Frequently used: chmod 777 1.sh gives 1. sh the highest permission

Normal Mode: chmod + rw 1.sh only the current user has read and write permissions for 1. sh

D) touch --Create a file:

Commonly used: touch./1.sh à touch path + name

F) vim --Create and open a file:

Commonly used: vim./1.sh à vim path + name

G) find --Find the files that meet the conditions in the specified directory:

Search by [file name + type]: find./-name "*. *" à find path-nama "pre-find file name + type"

Search by [file name]: find./-path "* 1 *" à find path-path "pre-find file name"

Search by file type: find.-type parameter

H) grep --Search for content in the file:

Find the content from the specified file: grep h./file.txt à grep content path

Search for content from the cache area: ps-ef | grep 5799 à a display command | grep content

I) tar --Decompress the file:

Compression:

Tar-cvf 1.tar *. * // pack all files in the Directory into 1.tar

Rar a 1.rar *. * // rar format Compression

Zip 1.zip *. * // zip Compression

Decompress:

Tar-xvf file.tar // decompress the tar package

Tar-xzvf file.tar.gz // decompress tar.gz

Unrar e file.rar // extract rar

Unzip file.zip // decompress the zip file

J) file --Display the type of the specified file:

K) head --Show file header content:

L)Show the content at the end of the file:

Iii. User System and permission management operations

A) su --User Type switching:

B) adduser --Add User:

C) passwd --Set (Change) user password:

D) usermod --Set User attributes:

E) ps --Displays the list of user processes in the current system:

Commonly used: ps-ef displays detailed processes of all users in the current system

-A: displays all programs.

F) kill --Delete the processes in execution:

Commonly used: kill 123 à kill pid

Force Process Termination: kill-9 123 à kill-9 pid

Iv. Help commands

A) man --Query command reading Manual

B) help --Query command reading Manual

V. Network-related commands

A) ifconfigView network information and set ip

B) pingTest network connection status

VI,UDisk operation commands

A) fdisk-lRecognize usbStorage Device

B) mount-T vfat/dev/sdb/mnt/udiskUse mountCommand to mount UDisk

C) umount/mnt/udiskUnmount UDisk

7. Install software package commands

A) rpm

 


Common commands

I. Directory operations

A) ls --View the file/directory:

Common: ls-l view detailed file list

 

 

B) pwd --View the current directory:

 

 

C) cd --Change the working directory:

Common ①: cd ../jump to the upper-level directory

 

Note: [./] the upper-level directory of the current directory [../]

 

Common ②: cd/boot/jump to the specified directory

 

Note: The specified directory must be a complete path, such as the file path of win.

 

D) mkdir --Create directory:

Frequently used: Create an empty folder in mkdir 123

 

 

E) rm --Delete a file/directory:

Frequently used: rm-rf 123 deletes a directory folder and files in the directory are also deleted.

 

Note: You can directly use the [rm] command to delete only empty directories.

-R Delete directory-f force delete file or directory

 

F) mv --Rename and move a mobile file/directory:

Move file: mv 1.sh./123 * mv target file to a directory

 

 

Renamed file: mv 1.sh 123.sh à mv original file to be modified

 

 

G) ln --Establish a soft connection and a hard connection:

Soft connection: ln-s 123.sh ../à ln-s source file to be placed in the path

Similar to the shortcut in the window, the principle is consistent.

Ln-s/root/desktop/Shared Folder/armQT // root/desktop

 

Hard connection: ln 123.sh ../à ln source file to be placed in the path

Copy an object and the object is independent from the deletion of the source file. The two files are modified simultaneously regardless of the content of the source or target file.

 

 

H) rmdir --Delete an empty directory:

 

Ii. File Operations

A) cat --View the file content. If the file does not exist, create the corresponding file:

Common: cat 1.txt

 

B) cp --Copy files and directories:

Backup: cp 123.sh 1.sh à cp source file target file

 

Copy to a path: cp 123.sh ../à cp source file target path

 

C) chmod --Modify file permissions:

Frequently used: chmod 777 1.sh gives 1. sh the highest permission

 

Note: read, write, and run permissions can be expressed in numbers, that is, r = 4, w = 2, x = 1.

777 is rwxrwxrwx, which means that the login user (which can be viewed by command id), the group in which he is located, and others have the highest permissions.

Normal Mode: chmod + rw 1.sh only the current user has read and write permissions for 1. sh

 

D) touch --Create a file:

Commonly used: touch./1.sh à touch path + name

 

F) vim --Create and open a file:

Commonly used: vim./1.sh à vim path + name

 

G) find --Find the files that meet the conditions in the specified directory:

Search by [file name + type]: find./-name "*. *" à find path-nama "pre-find file name + type"

 

Search for a file named "123". * indicates that the type is not limited.

Find ./! -Name "*. txt" à: After filtering txt files, other files are displayed.

Note:-name is case sensitive-iname is case insensitive

-O connector, for example

 

Search by [file name]: find./-path "* 1 *" à find path-path "pre-find file name"

 

Search for all files named "1"

 

Search by file type: find.-type parameter

 

H) grep --Search for content in the file:

Find the content from the specified file: grep h./file.txt à grep content path

Search for content from the cache area: ps-ef | grep 5799 à a display command | grep content

(Search for text lines with "5799" in the Process List)

 

 

I) tar --Decompress the file:

Compression:

Tar-cvf 1.tar *. * // pack all files in the Directory into 1.tar

Rar a 1.rar *. * // rar format Compression

Zip 1.zip *. * // zip Compression

Decompress:

Tar -xvffile.tar // decompress the tar package

Tar -xzvffile.tar.gz // decompress tar.gz

Unrar efile.rar // extract rar

Unzipfile.zip // decompress the zip file

 

J) file --Display the type of the specified file:

 

Iii. User System and permission management operations

A) su --User Type switching:

B) adduser --Add User:

C) passwd --Set (Change) user password:

D) usermod --Set User attributes:

E) ps --Displays the list of user processes in the current system:

Commonly used: ps-ef displays detailed processes of all users in the current system

-E: displays all programs. -F: displays the UID, PPIP, C, and STIME fields.

-A: displays all programs.

 

F) kill --Delete the processes in execution:

Commonly used: kill 123 à kill pid

Force Process Termination: kill-9 123 à kill-9 pid

 

Iv. Help commands

A) man --Query command reading Manual

Man kill à queries all information about [kill]

Man 2 kill à queries only the second message about [kill]

B) help --Query command reading Manual

 

V. Network-related commands

A) ifconfigView network information and set ip

B) pingTest network connection status

6. USB flash drive commands

A) fdisk-lIdentify usb storage devices

B) mount-T vfat/dev/sdb/mnt/udiskMount the USB flash drive using the mount command

C) umount/mnt/udiskDetach a USB flash drive

 

 

7. Install software package commands

A) rpm

Common combined commands:

-Ivh: the installation progress is displayed. -- install -- verbose -- hash
-Uvh: Upgrade the software package -- Update;
-Qpl: lists the file information in the RPM Package [Query Package list].
-Qpi: lists the RPM Package description [Query package install Package (s)];
-Qf: Find the RPM package of the specified File [Query File];
-Va: Check all RPM software packages and find the missing file [View Lost].
-E: delete a package

 

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.