1, Linux Study Notes: Linux common commands - document processing command

4.1 file processing command

4.1.1 command processing format and directory command ls

Command Format: Commands - [Options] - Parameters

例:ls -la /etc

Description: 1) the use of individual commands do not follow this format

2) When there are multiple options, you can write together

3) simplify and complete the options -a option -all equal

* Display file directory: ls

Command name: ls

Command English original intent: list

Path where the command: / bin / ls

Execute permissions: All users

Description: display the directory file

Syntax: ls [options] [-ald file or directory

-a show all files, including hidden files (all in all)

-l detailed information display (long length)

-d View Directory attributes ls -ld / etc

-h humane appear in the actual display unit (do not use this command, the default display bytes) (Humanity Human)

-i id file to view the file or folder

*-rw-r–r--

The first representative of the file type: - binary files

d directory file

l soft link file

Back nine into three groups (rwx): first group: u Owner

Second set: g belonging group

The third group: o others

r: read permission w: Write permission x: execute permission

4.1.2 directory processing command

* Create a new directory: mkdir

Command name: mkdir

Command English original intent: make directories

Path where the command: / bin / mkdir

Execute permissions: All users

Syntax: mkdir -p [directory name]

Description: Create a new directory

-p create recursive

Examples: $ mkdir -p / tmp / Japan / boduo (create a directory that does not exist in the directory to add -p)

$ Mkdir / tmp / Japan / longze / tmp / Japan / cangjing (you can create multiple directories under the directory already exists, separated by a space)

* Change directory: cd

Command name: cd

Command English original intent: change directory

Command the path: shell built-in commands

Execute permissions: All users

Syntax: cd [directory]

Description: Change directory

Examples: $ cd / tmp / Japan / boduo (switch to the specified directory)

$ Cd ... (return to parent directory)

* Displays the current directory: pwd

Command name: pwd

Command English original intent: print working directory

Path where the command: / bin / pwd

Execute permissions: All users

Syntax: pwd

Description: Displays the current directory

Examples: $ pwd

* Delete empty directory: rmdir

Command name: rmdir

Command English original intent: remove empty directories

Path where the command: / bin / rmdir

Execute permissions: All users

Syntax: rmdir [directory name]

Function: Delete empty directory

Examples: $ rmdir / tmp / Japan / boduo

* Copy the file or directory: cp

Command name: cp

English intended command: copy

Path where the command: / bin / cp

Execute permissions: All users

Syntax: cp -rp [the original file or directory] [destination directory]

-r copy directories

-p preserve file attributes

Description: Copy the file or directory

Examples: $ cp /etc/yum.conf / tmp / Japan copying files

$ Cp -r / tmp / Japan / cangjin / tmp / Japan / boduo -r copy directories need to add property

$ Cp -r / tmp / Japan / cangjin / tmp / Japan / hahaha123655 copy directories renamed same time

* Cut, rename the file or directory: mv

Command name: mv

Command English original intent: move

Path where the command: / bin / mv

Execute permissions: All users

Syntax: mv [the original file or directory] [destination directory]

Description: Cut, rename the file or directory

Examples: $ mv / tmp / Japan / cangjin / tmp / Japan / boduo shear directory

​ $mv /tmp/Japan/cangjin /tmp/Japan/nvsheng 改名

* Delete files or directories: rm

Command name: rm

Command English original intent: remove

Path where the command: / bin / rm

Execute permissions: All users

Syntax: rm -rf [file or directory]

`-R delete a directory

-f enforcement

Description: Delete a file or directory

Examples: $ rm -rf / tmp / Japan delete a directory

4.1.3 file processing command

* Create an empty file: touch

Command name: touch

English intended command: touch

Path where the command: / bin / touch

Execute permissions: All users

Syntax: touch [filename]

Description: Create an empty file

Examples: $ touch haha.list create a file

$ Touch "program files" to create a filename with spaces must be enclosed in double quotes

* Display file contents: cat (tac reverse display)

Command name: cat

Command English original intent: cat

Path where the command: / bin / cat

Execute permissions: All users

Syntax: cat [filename]

Description: The file contents

-n Display line numbers

Examples: $ cat / etc / issue display a file

$ Cat -n / etc / issue file with line numbers

* Page display file contents: more

Command name: more

Command English original intent: more

Path where the command: / bin / more

Execute permissions: All users

Syntax: more [filename]

(Spaces) or f page

(Carriage return) line feed

q or Q to exit

Description: page display file contents

Examples: $ more / etc / services display a page long document

* Display file contents page (page up available, searchable): less

Command name: less

Command English original intent: less

Path where the command: / usr / bin / less

Execute permissions: All users

Syntax: less [filename]

(Space) f or Down

Page up Page Up

(Carriage return) downward linefeed

Wrap Up arrow

/ Key words search keywords

n jump to the next search word

q or Q to exit

Description: page display file contents (available page up)

Examples: $ less / etc / services display a page long document

* Display the file in front of a few lines: head

Command name: head

Command English original intent: head

Path where the command: / usr / bin / head

Execute permissions: All users

Syntax: head [filename]

Function Description: Display the previous file lines

-n specified number of lines (the line 10 is displayed is not specified)

Examples: $ head -n 20 / etc / services file is displayed in front of the line 20

* Display last few lines of the file: tail

Command name: tail

Command English original intent: tail

Path where the command: / usr / bin / tail

Execute permissions: All users

Syntax: tail [filename]

Description: The last few lines of the display file

-n specified number of lines (the line 10 is displayed is not specified)

-f dynamic display file contents end

Examples: $ tail -n 20 / etc / services file displays the last 20 lines

$ Tail -f / var / log / messages dynamically display the log file does not automatically exit monitoring interface, you need to press ctrl + c

4.1.4 Link command

* Generate link files: ln

Command name: ln

Command English original intent: link

Path where the command: / bin / ln

Execute permissions: All users

Syntax: ln -s source file [file] [target]

-s Create a soft link (without the s is to generate a hard link)

Description: Create link files

Examples: $ ln -s jin.txt jin.yin generate a hard link

$ Ln jin.txt jin.ruan generate soft link

Hard link is equivalent to copy files, but both files synchronized with each other. Lost the original file is also all right, all the same properties as the original one, identifying nodes through i

Soft links permission is lrwsrwsrws, small file size, file name pointing

Released eight original articles · won praise 0 · Views 360

Guess you like

Origin blog.csdn.net/weixin_44570083/article/details/104622276