Use of common commands for Linux systems

Source: Internet
Author: User
Tags echo command readable

Common ways to use commands:

1.echo

Echo-display a line of text

650) this.width=650; "src=" Https://s3.51cto.com/wyfs02/M00/08/65/wKiom1ngopOgixq6AAAsIrkT-rE013.png "title=" 2.png "alt=" Wkiom1ngopogixq6aaasirkt-re013.png "/>

Get more precise command operation with manual help

Outputting a string to a display device

650) this.width=650; "src=" Https://s3.51cto.com/wyfs02/M02/A7/1C/wKioL1ngn46ADp5IAAALRtFYMjQ558.png "title=" 1.png "alt=" Wkiol1ngn46adp5iaaalrtfymjq558.png "/>

Common options:

-N: No line break, 650) this.width=650; "src=" Https://s3.51cto.com/wyfs02/M01/08/65/wKiom1ngotbgW5yYAAAHU6zkT9I145.png "title = "3.png" alt= "Wkiom1ngotbgw5yyaaahu6zkt9i145.png"/>;

-e: The escape sequence that is booted with "\" takes effect

\ n: Line break

\ t: Horizontal tab

\v: Vertical tab

650) this.width=650; "src=" Https://s2.51cto.com/wyfs02/M00/A7/1C/wKioL1ngohuQntLQAAAkRLmOBE8693.png "title=" 4.png "alt=" Wkiol1ngohuqntlqaaakrlmobe8693.png "/>

Similar to the echo command is printf, is not limited by-e (in, only after the-e command takes effect, the following \ \, \a and other commands can take effect), you can directly \ n execute a line-break command, under echo other commands similar to, can be used directly, not affected by

-E Restrictions

650) this.width=650; "src=" Https://s1.51cto.com/wyfs02/M00/08/65/wKiom1ngpeyw-UYmAAAPNeGCeuw109.png "title=" 5.png "alt=" Wkiom1ngpeyw-uymaaapnegceuw109.png "/>

PS: To distinguish between a character and a variable name, generally add {} to distinguish between characters and variable names

650) this.width=650; "src=" Https://s3.51cto.com/wyfs02/M02/A7/1C/wKioL1ngqOPyymq7AAAM4oNJ7dI365.png "title=" 5.png "alt=" Wkiol1ngqopyymq7aaam4onj7di365.png "/>

2.cd

Internal commands, using Help for more detailed assistance

Change the shell working directory.

Switch working directory

650) this.width=650; "src=" Https://s1.51cto.com/wyfs02/M02/A7/1C/wKioL1ngpOTSdnOXAABundYgD2I290.png "title=" 1.png "alt=" Wkiol1ngpotsdnoxaabundygd2i290.png "/>


CD:CD [-l|[ -P [-e]] [dir] indicates the part that can be omitted in parentheses;


Cd/path/to/somedir (the last parameter is the directory, otherwise it will be an error, because we are switching directories instead of files)

: Switches the working directory to the directory represented by the parameter;

Use CD directly: Switch working directory to the home directory of the currently logged in user, equivalent to CD ~;

cd-: Switch The working directory to the last working directory before this time;

650) this.width=650; "src=" Https://s3.51cto.com/wyfs02/M02/08/66/wKiom1ngqRuRsZsvAAAMdwt0mQk536.png "title=" 2.png "alt=" Wkiom1ngqrurszsvaaamdwt0mqk536.png "/>

The shell provides two variables:

Pwd

Oldpwd

650) this.width=650; "src=" Https://s3.51cto.com/wyfs02/M02/08/66/wKiom1ngqkby0JGFAAATLLPVLUM593.png "title=" 3.png "alt=" Wkiom1ngqkby0jgfaaatllpvlum593.png "/>


Note: The method of getting variable values in the shell; Variable names are strictly case-sensitive;

Echo ${var_name}

{variable: The amount of memory space to assign}


cd~: Switch working directory to the home directory of the specified user

650) this.width=650; "src=" Https://s2.51cto.com/wyfs02/M00/A7/1C/wKioL1ngp9DCS2eIAAAGRNLoPk0038.png "title=" 4.png "alt=" Wkiol1ngp9dcs2eiaaagrnlopk0038.png "/>

To return to the home directory.

3.pwd

Print the name of the current working directory

650) this.width=650; "src=" Https://s1.51cto.com/wyfs02/M02/A7/1C/wKioL1ngqgSBzHAxAAA1bVQVmwo290.png "title=" 6.png "alt=" Wkiol1ngqgsbzhaxaaa1bvqvmwo290.png "/>


4.ls

Ls-list Directory Contents

Note: The contents of the directory are file names

650) this.width=650; "src=" Https://s5.51cto.com/wyfs02/M02/08/66/wKiom1ngrcazHOx7AABuXyCdMJY626.png "title=" 7.png "alt=" Wkiom1ngrcazhox7aabuxycdmjy626.png "/>


ls [OPTIONS] ... [FILE] ...

The bracket option can be omitted


In the Linux file system, all with "." The file with the starting character of the most file name is the hidden file;

ls command to view the directory display sorted by character table, vertical display, long options and short options are the same;


Common options:

-a,--all: Show all files, including hidden files 650) this.width=650; "Src=" https://s5.51cto.com/wyfs02/M01/08/66/                           Wkiom1ngrqjwc3kgaaag1zjxvkc531.png "title=" 8.png "alt=" Wkiom1ngrqjwc3kgaaag1zjxvkc531.png "/> ;

-a,--almost-all: Display except "." and ".." All files, including hidden files 650) this.width=650; "Src=" https://s1.51cto.com/wyfs02/M02/A7/1C/                                       Wkiol1ngregaoqt1aaahbpbycnc265.png "title=" 9.png "alt=" Wkiol1ngregaoqt1aaahbpbycnc265.png "/> ;


--color[=when]: Display file names in different colors

-d,-directory: Displays the directory itself, not the file name in the directory 650) this.width=650; "Src=" https://s1.51cto.com/wyfs02/M00/A7/1C/ Wkiol1ngrscawfmwaaag0fq2vmo788.png "title=" 10.png "alt=" Wkiol1ngrscawfmwaaag0fq2vmo788.png "/> instead of

650) this.width=650; "src=" Https://s5.51cto.com/wyfs02/M01/08/66/wKiom1ngsA-BMEu6AAERk3HQQg0847.png "title=" 11. PNG "alt=" Wkiom1ngsa-bmeu6aaerk3hqqg0847.png "/> instead of displaying all the files in the ETC directory as shown;


-h,--human-readable: Displays a more readable form when displaying the size of a file

650) this.width=650; "src=" Https://s5.51cto.com/wyfs02/M01/08/66/wKiom1ngsSWh3UxdAABAEPIBxIU172.png "title=" 13. PNG "alt=" Wkiom1ngsswh3uxdaabaepibxiu172.png "/>;

Typically used with the-l option, such as 650) this.width=650; "Src=" https://s5.51cto.com/wyfs02/M00/A7/1C/                                                    Wkiol1ngrfcslvxdaabtmzukikm769.png "title=" 12.png "alt=" Wkiol1ngrfcslvxdaabtmzukikm769.png "/> Will add some symbols after the file;

-L: Display detailed properties of a file using a long column table

650) this.width=650; "src=" Https://s1.51cto.com/wyfs02/M00/08/66/wKiom1ngsViAOHkfAABAEPIBxIU678.png "title=" 13. PNG "alt=" Wkiom1ngsviaohkfaabaepibxiu678.png "/>

the format is interpreted as:

-RW-------. 1 root root 1876 September 17:48 anaconda-ks.cfg


-: Represents the file type;

RW--------: The file's permission bit settings;

.: Indicates whether the file has special attributes or extended attributes;

1: Indicates the number of times the file has been hard-linked;

Root (first): The owner of a file;

Root (second): The genus of a file;

1876: The size of the file, before using-h, the unit is byte;

September 17 17:48: One of the timestamp of the file, indicating the time of the last modification;

Anaconda-ks.cfg: File name


for device files:

650) this.width=650; "src=" Https://s1.51cto.com/wyfs02/M01/08/66/wKiom1ngsl7yLyhhAAAMoK5UPZE827.png "title=" 14. PNG "alt=" Wkiom1ngsl7ylyhhaaamok5upze827.png "/>

~]# ls-l/dev/sr0

Similar format:

BRW-RW----. 1 root cdrom 11,0 September 10:50/dev/sr0


11,0:major,minor

Major: The main device number that identifies the device type, and then determines what driver needs to be loaded;

Minor: The secondary device number that identifies the different devices in the same device type;


The device number is represented by default with a 8-bit binary, so the default device number range is 0~255;



-R,--Reverse: Reverse output 650) this.width=650; "Src=" https://s2.51cto.com/wyfs02/M02/08/66/ Wkiom1ngstrd1oweaaaszpia2bw004.png "title=" 15.png "alt=" Wkiom1ngstrd1oweaaaszpia2bw004.png "/>

-R,--Recursive: recursive display, if there is a subdirectory in the target directory, then recursively display the contents of the subdirectory, recursively go down 650) this.width=650; "Src=" https://s2.51cto.com/wyfs02/M01/A7/ 1c/wkiol1ngshudcvzhaaaq4rpngck764.png "title=" 16.png "alt=" Wkiol1ngshudcvzhaaaq4rpngck764.png "/>

Note The following commands are strictly forbidden in the server, 650) this.width=650; "Src=" https://s1.51cto.com/wyfs02/M01/08/66/ Wkiom1ngtcvjtndsaaaerewqema678.png "title=" 18.png "alt=" Wkiom1ngtcvjtndsaaaerewqema678.png "/>, and will traverse all subdirectories under the root directory

, the CPU and memory of the server are seriously consumed,

-Z,--Context: Display file's SELinux security context label 650) this.width=650; "Src=" https://s3.51cto.com/wyfs02/M01/08/66/ Wkiom1ngs17dnyhgaabzeih3jp0878.png "title=" 17.png "alt=" Wkiom1ngs17dnyhgaabzeih3jp0878.png "/>;


5.mkdir

Mkdir-make directories, create a new directory;


mkdir [OPTIONS] ... DIRECTORY ...

-p,--parents: When the parent directory is created, if its parent directory does not exist, it is created first;

-v,--verbose: Display a message for each directory created

650) this.width=650; "src=" Https://s2.51cto.com/wyfs02/M02/08/66/wKiom1ngtU7DlZZ7AAAXS5pq2Sk599.png "title=" 19. PNG "alt=" Wkiom1ngtu7dlzz7aaaxs5pq2sk599.png "/>


6.rm

(rmdir command can only delete empty directory, not very useful, now generally no one to use)

Rm-remove Files or directories

removing files or directories


RM [Options]]file ...

-F,--Force: Violence, forced deletion of 650) this.width=650; "Src=" https://s1.51cto.com/wyfs02/M00/A7/1D/ Wkiol1ngs2eq90ouaaakjs0oar0205.png "title=" 20.png "alt=" Wkiol1ngs2eq90ouaaakjs0oar0205.png "/> the directory cannot be deleted by default;

-r,-r,--Recursive: Recursively delete content in directories and directories

650) this.width=650; "src=" Https://s2.51cto.com/wyfs02/M00/A7/1D/wKioL1ngs87RQaBKAABBdAMlJFM865.png "title=" 21. PNG "alt=" Wkiol1ngs87rqabkaabbdamljfm865.png "/>;

Note that if you use a command that is very dangerous

650) this.width=650; "src=" Https://s1.51cto.com/wyfs02/M02/A7/1D/wKioL1ngtC3gNxqaAAARXgNbQyg600.png "title=" 22. PNG "alt=" Wkiol1ngtc3gnxqaaaarxgnbqyg600.png "/>

All files under the root directory will be deleted and the system will not be available, and the command in the virtual machine should take a snapshot in advance;

And on the real server do not make this command, the consequences can not be imagined, extremely dangerous.





Use of common commands for Linux systems

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.