Basic usage of linux commands

1. Terminal shortcut
    Ctrl shift + enlarge font
    Ctrl - reduce font
    Ctrl l Clear screen
    Ctrl c Terminate program process

    Tab key auto-completion


2. ls list list
    -a all All files and folders
        will not be displayed by default with . start files and directories <hidden files>
    -l long show file details in long format
    -h human being friend show file size in a human friendly way

3. touch filename  
    create an empty file <if file exists modified file time>


4. Wildcards - match some characters with a special character
    * match any number of any characters
        ls *.py
    ? match 1 any character
        ls ?.py

    [] means match any character in the set

        match file is 1 numeric character ( Any character between 1-9) of the py program file
        ls [123456789].py
        ls [1-9].py
        ls [11-99].py

    [-] Indicates the range of character matching
        A py program file that matches one lowercase character in the file name
        ls [az].py

5. cd switch working directory
    using the format cd destination directory

    cd or cd ~ switch to the user's home directory <home directory>
    cd . Enter the current directory
    cd . . Enter the upper directory

    pwd to view the

    relative path
        of the current directory The path information described from the current

    absolute path The path information described
        from the / root directory

6. Create a directory
    mkdir directory name
        mkdir test
    mkdir -p multi-level directory  
        mkdir -p 1/2/3

    delete file directory remove remove
    rm file name
        rm 1.py
        rm *.py
    rm -r directory name recursively delete
        rm -r 1

7. Copy files or directories cp copy
    using format cp source data destination directory
    cp can Modify the file name while copying the file
            cp source data destination directory/destination file

name8. Cut move move
    using format mv source data destination directory9.

tree display the structure of the specified directory10.

display file content
    cat
        display a certain file content cat file name
        merge file cat file 1 file 2 >
            When the new file merges the file, if the new file exists, the overwrite does not exist, then the new

    more command can display the output redirection in split screen when viewing the content of a file
        
    - change the original output direction of a data and output it to another specified target Medium
        > Overwrite
        >> Append

    cat 1.txt
    cat 1.txt cat.txt > 2.txt
    cat 1.txt cat.txt >> 2.txt

11. Find files according to file name permissions size
    find top directory -name 'filename '


12. Search based on file data

    grep 'hello' grep.txt
    grep feature filename
13. ln link link file
    link file - quick access to source files based on linked file

    Soft link ln -s Source file Soft link file

    Features
        Soft link file takes up very little space
        Once the source file is deleted, the soft link file is unavailable,
        you can modify the source file according to the soft link file
        Soft link can create soft links across partition directories

    Hard links ln source files
    Features of hard link files
        Hard link files occupy the same size as the source file.
        Once the source file is deleted, the hard link file is still available.
        You can modify the

        nature of the source file according to the hard link file: The hard link file and the source file are actually one file data with different names and the
             data has been deleted . A name of the file does not affect the data of the file's data unless all name

    extensions of the file are removed:
        ls -i View the iNode number of all files (a unique number is assigned to each file)

        ls -l The second column in the details The meaning of the data is the number of hard links

        Ctrl c terminates the process

14. The output of the pipeline
    command is used as the input of another command
    | Display the
    data of a file in a split screen cat file | more

    display the detailed information of all files in the current directory Split screen display ls -al | more

    Display the detailed information of the directory under the current directory ls -l | grep '^d'

15. tar archive     By     default
    , only packaging is not compressed
    and packaged and compress tar -zcvf x.tar.gz list of compressed files         tar -zcvf 1.tar.gz linux_test/     gzip unpack and unpack tar -zxvf x.tar.gz         tar -zxvf 1.tar.gz     bzip2 pack and Compressed tar -jcvf x.tar.bz2 List of compressed files         tar -jcvf 1.tar.bz2 bak/     bzip2 Unpacked and decompressed tar -jxvf x.tar.bz2          tar jxvf 1.tar.bz2 16. which command to view the system Command location 17. Permission     - means that the permission is not set     r read read 4     w write write 2     x eXecute execute permission 1     user group other all






















    u go o a
    file belongs to user file belongs group other
    rw- r-- r--
    6 4 4

    modify    

        chmod u+x desktop.zip
        chmod or desktop.zip
        chmod a+w desktop.zip
        chmod u=rw desktop.zip

        chmod ux,g +w desktop.zip

    digital modification method


        chmod 744 desktop.zip
        chmod 740 desktop.zip

18. User
    root user super administrator
    python user administrator -- can borrow super administrator privileges
    xiaohei ordinary user -- sudoer control administrator list

    sudo The command can borrow the superuser administrative privileges to run the command
    sudo -s to switch to the root user

    whoami to view the current user name

    passwd user name

    When switching to another user exit Exit the user you are using
    exit exit the terminal


19. Software installation
    1. Network installation of CentOS YUM install package
       
    2. Offline
        CentOS .rpm rpm -ivh *.rpm
        UBUNTU .deb dpkg -i *.deb

    3 . Source installation
        .c .cpp
        ./configure && make && make install

    4. Update software source
        download speed is fast Tsinghua Ali 163
        sudo vim /etc/apt/source.list Save
        sudo apt-get update Connect server to server to compare software information Ubuntu apt-get install package

       sudo apt-get remove tree

       sudo apt-get install sl tree
    

20. Connect to the remote server
    ifconfig Check the IP address of the server
         ifconfig
    to ensure network connectivity with the remote server The virtual machine should try to maintain bridge mode
        ping 192.168.27.73

    server install openssh-server
        sudo apt-get install openssh-server

    connect server
        ssh [email protected]

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324578888&siteId=291194637