Unix / Linux common command line operations

Time:2019-11-22

Introduction: in view of a period of timeMacThe frequency of using terminal operation after computer is increasing day by day. It’s mainly studious. To sort out the following terminal operation commands for the system

MacSystem andLIUNXThe system is based onUNIXThe developed ones are basically universal. Now I useMacFocus on common command lines

Common operation command

  1. File operation

    MKDIR // create a new folder
    Touch < filename > // create a new file
    Mvdir < oldpath > < newpath > // move file path
    MV < oldpath > < newpath > // move file path
    RM < File > // delete file or empty folder
    RM - RF < File > // clear a non empty folder
    Rmdir // delete folder
  2. Routine operation

    Ls // display the current file directory
        -A / A // all files in the current path are displayed, including the shadow files`
        -LA // detailed properties of the current file
    Which < modulename / Python > // view the installation path of the specified program
    PWD // view the detailed address of the current path
    VIM < File > // command line edit current file
        : w // save the current changes
        : q! // force exit
        : WQ // save and exit
    Env // view all currently set environment variables
    Man < order / LS > // view the current command description
    Diff < file1 > < File2 > // compare the differences between the two files

Special operation command

  1. command

    CP - R < source dir > < target dir > // copy a file
    File < file name > // view file type
    Find < file name > // find the file
    Open < file name > // open the file by default
    In - s < link > < link > // connect two files, - s is a soft connection
    Cat < File > // display file
        < file1 > < File2 > < File > // merge file1 and File2 files into file
    WC < File > // count the number of words in the file
    Uniq < File > // count duplicate lines in the file
    Grep < regex > // search files with regular expressions
    Ping < IP > // check the network
    History // view previously executed commands
    Hostname // the name of the current host in the network
    Date // get the current date
    Cal // display calendar
    Time // display system execution time
  2. Document property description
    [email protected] 1 xx staff 1391589 8 23 22:12 img.png
    Explain:

    -The horizontal bar of the file type indicates a normal file. If it is' d ', it indicates the file directory 
    Rw-r -- R -- access rights are divided into three groups: file access rights of users, groups and other users; 
    1 number of files only 1 file in this example 
    The user name of XX in this case is XX 
    Staff's group in this case, the user group is staff 
    1391589 file size bytes of the file in this example 
    8 23 22:12 modification date: 8-23 22:12 in this case 
    Img.png file name in this case, img.png
  3. Modify file access

    **Syntax * *: ` Chmod user operation permission file`  
    **User * *: 'U' means user, 'g' means group, 'o' means other user  
       `A ` indicates all users. If it is missing, it defaults to all users;  
    **Operation * *: '+' means to add permission, '-' means to cancel permission, '=' means to assign permission;  
    **Permission * *: 'R' for read, 'W' for write, 'x' for execute;  
    **File * *: when no file name is specified, the operation object is all files in the current directory.

    Case: ~ ~ ~
    $ chmod u+x img.png
    After amendment:
    [email protected] 1 xx staff 1391589 8 23 22:12 img.png

Tips

  1. UNIXFiles in are case sensitive
  2. MacUse iniTermThe terminal experience is better, and you can customize the theme and other operations

If you have more and better common commands, you can share them