Linux command summary

Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
This link: https://blog.csdn.net/Stars_min/article/details/79045246

                                                                         Linux Command Summary

1      ls          

Display file or directory

    -l           lists the file details l (list)

    -a           list all files and directories in the current directory, including hidden a (all)

    -F view files in a directory           

    -r           Reverse ( Reverse ). List the contents of the directory from back to front

    -R           recursively ( recursive This ). This option recursively list all directories (below the current directory) contents.               

     -s        size ( size ). Sorted by file size.

 

2、      mkdir        

Create a directory

    -p           create a directory, if not the parent directory, create p (parent)

3cd             

Change directory

      cd / back to the root directory


       cd ..
go back one level

       cd- return to recently used directory

 

3 touch          

Create an empty file

-t  set the time and date, and date formats same, yyyyMMddhhmm

5echo

A text output on the display - the standard output device.

例:echo “hello”

6cat                 

View the file contents

           cat e1 browse files e1 content

           cat e1 e2 browse the contents of multiple files

           cat -n e1 browse files e1 content and displays the line number

7 , cp  copies

Example: ( . 1 ), CP file1 file2 copy a file

       ( 2 ), cp dir / *. Copy all files in a directory to the current working directory

       ( 3 ), cp -a / tmp / dir1. Copy a directory to the current working directory

        ( 4 ), cp -a dir1 dir2 copy a directory

8mv             

Move or rename

-i, - interactive interactive operation. If the source file and the target file or target directory file with the same name, the user is asked whether overwrite the destination file. The user input "y", represents the coverage of the target file; an input "n", indicates to cancel movement of the source file. This prevents files mistakenly overwritten.

-f with the "-i" Instead, it prohibits interactive operation. When overwrite the existing target file, do not give any hints.


9rm             

Delete Files

    -r             recursive delete, delete files and subdirectories

    -f             forced to delete

Example:

       ( 1 ), RM -f file1 delete called 'file1' file '

       ( 2 ), rmdir dir1 delete called 'dir1' directory '

       ( 3 ), RM -rf dir1 delete called 'dir1' directory and delete its contents

       ( 4 ), RM -rf dir1 dir2 simultaneously remove two directories and their contents

 

10find             

Finding qualified file or directory

find / etc -name * ab * ab is included

find / etc -name ab * ab beginning


 11wc               

Count the number of rows of text, words, characters

              -c --bytes  statistics bytes

              -l --lines    statistics row

              -w --words word count

12grep           

In one or more file contains the given search string

grep ‘the’ 1.txt 

-a: Search as a text file

 -c number of calculations to find the line with the line

 -i ignore case

-n way output line number

-v adverse selection, that line does not find the search string


13rmdir         

Delete empty directories

dirname represents the directory name. This command deletes a subdirectory or more items from a catalog. 

Note: Before a directory is deleted must be empty. You must also have write access to the parent directory To delete a directory

- p: After deleting the specified directory, parent directory of the directory has become an empty directory, and delete the one

Note :   recursive delete, delete after that is the inner layer, the outer layer is empty, then be deleted


14tree / lstree           

Display the directory tree, tree need to install package

15pwd           

 Displays the current directory

16more、less  

Page display the contents of a text file

17head、tail    

Display file header, footer content

18date

Displays the system date

19cal 2007

Show 2007 year calendar

20cd /home

Enter '/ home' directory '

Users and Groups

1、    groupadd group_name

Create a new user group

2、    groupdel group_name

To delete a user group

3、    groupmod -n new_group_name old_group_name

Renaming a user group

4、    useradd user1

Create a new user

5、    userdel -r user1

To delete a user ( '-r' eliminates home directory )

6、    passwd

Change password

7、    passwd user1

Change a user password ( only root execution )

System Management Commands

1、      stat            

Details Displays the specified file, than ls more detail

2、      who             

Display the online login

3、      Whoami        

Displays the current user operation

4、      Hostname    

 Show hostname

5、      uname          

Information Display System

6、      top               

Dynamically displays the current most resource-intensive process information

7、      ps                 

Display instant process status ps -aux

8,      the                 

Check directory size du -h / home with directory information display unit

9、      df                 

Check disk space usage

-a list all file systems, including system-specific / proc file system, etc..


-k in KB display file system


         -m to mb Displays each file system


         -h display format to gb


         -T display file format type of the physical file system.


         -i inode number to be displayed

 

10、   man               

Command is not used, looking for a man  such as: man ls

11 , the Clear clear screen             

12kill               

Kill the process, you can use ps to view the process id or top command, then use the kill command to kill the process.

 

1.shutdown

    -r             shutdown restart

    -h             off without rebooting

    now           immediately shut down

2 , the HALT shutdown             

3reboot / shutdown -r now         重启

4 , Zimbabwe Logout logout

Use vim

vim three modes: command mode, insert mode, edit mode. Use ESC or i or: to switch modes.

In command mode:

: q                      Quit

: q!                    forced to quit

: W save not only quit

 

: wq                  to save and exit

: ZZ if only as by modifying the contents of the buffer is written to the file.

: X and: ZZ same.

Additional command

after insertion of a cursor, the cursor may be anywhere in the line.

A text is added in the end of the line the cursor line

Move to the first line of command (key):

^ Move the cursor to the first non-blank character in the current row (non tabs or spaces)

                                        0 Always move the cursor to the first character of the current line, regardless of whether it is a whitespace

Move to end of line command (key): $

To the specified command line (bond): [row number] G

To the specified command (key) column: [column number] |

Press the forward command word (key):

w - word or punctuation is defined as the white space (tab, newline or space) separated alphanumeric string

W - word is defined as non-empty string

Press shift command word (key):

b - the word is defined as the white space or punctuation (tab, newline or space) separated alphanumeric string

                                             B-- words are defined as non-empty string

: set number    display line numbers    

: set nonumber  hide line numbers    

/ apache            find in the document apache press n go on to the next, shift + n a 

yyp                  copy cursor line, and paste 

ctrl u    go row

ctrl w    to a

yy    Copy

p     Paste

dd   Delete

u     withdrawal  

h ( left one character ←) , J (next line ↓), k (upper row ↑), l (right one character →)

File permissions of using the "+" to set permissions, use the "-" is used to cancel

1 , LS -LH Show Permissions

2 , LS / tmp | PR -T5 -W $ CO.'S LUMNS terminal is divided into five columns show    

Chmod

For access or change the settings file or directory

. 3 , the chmod + rwx directory1 Ugo all set directory (U) , the group (g) and others (o) to read (r), write (w) and execute (x) permissions

4 , chmod-rwx directory1 Go To delete a group (g) and others (o) to read and write execute permissions on the directory

5 , chown user1 file1 change owner of a file's properties

. 6 , chown -R & lt user1 directory1 change all attributes of a directory and simultaneously change the properties of all files in the directory change

7 , chgrp group1 file1 group change file

8 , chown user1: group1 file1 change user and group ownership of a file

. 9 , the chmod + U S / bin / file1 set SUID of a binary digit - a user runs the file and are each assigned to the same owner permissions

10 , chmod US / bin / file1 disable SUID binary file a bit

. 11 , the chmod + G S / Home / public provided a directory SGID bit - Similar SUID, but this is for the directory 

Guess you like

Origin blog.csdn.net/Stars_min/article/details/79045246