Linux Learning Notes (common commands)

Specifies the run level

  • Run Level Description
         0 off
         a single user
         over two user state without network service
         over three user network service
         4 system is not reserved for use by the user
         5 GUI
         6 restart
    the typical operating levels are 3 and 5, may be used init switch init [012345 ]

Ubuntu set the root password

Ubuntu, the installation is complete, the default root user password is not set, so we have to own to set the root password to set password .CentOS installation.
Command sudo passwd for the first time to enter the password after the current user's password, after that set the root password to use the su command to switch to root user after the setup is complete

Supplementary (forget the root password)

Single-user mode (single-user mode without a password can log in directly), you can change your password.

Common commands

  • Help command
  1. man get help
    basic syntax
         man [command or configuration file]

    When we are not familiar with the instructions for one when you can use this command to get help

  2. help command
    basic syntax
        help command

    Shell built-in commands to get help information

  • Class instruction file directory
  1. pwd command displays the absolute path to the current working directory of
    basic grammar
        pwd

  2. ls command to display the current directory information
    basic syntax
        ls [options] [directory or file]
    Common Options
        -a: Displays the current directory and all files, including hidden
        -l: Displays information in a manner listHere Insert Picture Description

  3. cd instruction to switch to the specified directory
    basic syntax
        cd [parameters]

    Common parameters
        absolute and relative paths
    cd ~ or cd: to return to their home directory
    cd ... back to the parent directory of the current directory
    cd / root using an absolute path back to the / root directory

  4. Create a directory mkdir command
    basic syntax
        mkdir [options] directory to create
    common options
        -p: create multi-level directory

  5. rmdir command to delete empty directories
    basic syntax
        rmdir to delete empty directories
    Here Insert Picture Description

  6. touch command to create an empty file
    basic syntax of
        basic grammar
        touch the file name
    Here Insert Picture Description

  7. cp command [copy files to the specified directory]
    The basic syntax of
        cp [options] file name specified path
    common options
        -r: recursive copy implemented
    Here Insert Picture Description

  8. rm command to delete the specified file or directory
    basic syntax
        rm [options] files to delete
    popular options
        -r: recursive delete entire file
        -f: Force deleted without prompt
    Here Insert Picture Description

  9. mv command to move or rename files and directories
    basic syntax of
        mv old new file name (rename)
        mv file name of the directory (move files)
    Here Insert Picture Description

  10. cat command to view the contents of the file in read-only mode to open the
    basic syntax of
        cat [Options] to view the file
    Common Options
        -n: display the line number
    Here Insert Picture Description

  11. more instruction
    more instruction is a text-based editor vi filter, which displays the contents of the text file by page (where a number of shortcut keys see operating instructions) in a full-screen manner
    basic syntax of
        the file name to see more

  12. less instructions
    less split-screen instructions to view the file contents, and more similar to, but more powerful than more, support a variety of terminals displayed in the display, load based on the content to be displayed, for large files, the higher the efficiency of
    basic grammar
        less to see the file name

  13. > >> instructions and commands
    > output redirection will cover the contents of the original file
    >> does not overwrite the original contents of the file, but the file appended to the end of
    basic grammar (it will create the file if the file does not exist)
         LS the -l> file (write to the list of documents under cover)
         LS -al >> file (ls -l content appended to the end of the file)
    Here Insert Picture Description

  14. echo command output content to the console
    basic syntax
        echo [options] [output content]
    Here Insert Picture Description

  15. the beginning of the head command displays the file (the default display the first ten lines)
    basic syntax
        head (ten lines before viewing the file)
        head -n 3 (see the first three lines of the file)
    Here Insert Picture Description
    16.tail command to display the file at the end portion (the default display at the end of ten line)
    basic syntax
        tail file (see the end of the ten lines)
        tail -n 3 file (see the end of the three lines)
        tail -f file (updated real-time tracking of all documents)
    Here Insert Picture Description

  • ln command to create soft links like shortcuts in windows
    The basic syntax
        ln -s [the original file or directory] [soft link name] (the original file to create a soft link)
    When we use the pwd view the path of any course is the directory where the soft linkHere Insert Picture Description
  • View historical history instruction instruction executed in the past
    The basic syntax of
        history (see past history instruction execution)
        ! N (n is the number of instruction execution)
         History n (n see instructions executed in the past)
    Here Insert Picture Description
  • date The date and time related instruction operations
    1.date command
    basic syntax
        DATE (current time)
        DATE + '% the Y' (display the current year)
        DATE + '% m' (current month)
        DATE + '% D' (currently displayed day)
        DATE + ' % Y-% d% H:% M:% S '( year, month, day, hour display)
        dATE -s string time (set date and time)
    Here Insert Picture Description
    2.cal command
    basic syntax of
        CAL [option] (without display option month calendar)
    Here Insert Picture Description
  • Search Find command
    The basic syntax
        find [search] [Option] (option to use the help command lookup)
    Here Insert Picture Description
    grep command and | grep filtering lookup, '|' represents the result of processing the previous command is output to the rear edge of the command processing
    basic syntax
          grep [options] Find what source file (common options: -n display matching lines and line numbers; -i ignore the case of letters)
    Here Insert Picture Description
  • Compression, decompression
    And instructions 1.gzip gunzip
    gunzip to decompress the file; gzip archive for
    basic syntax
        gzip file (compressed file .gz format) *
        gunzip .gz file (unzip the file)
    Here Insert Picture Description
    file 2.tar instruction packing instructions, the final package love you * .tar.gz
    basic grammar
        tar [option] * .tar.gz packaged content (after packing directory, compressed * .tar.gz format, the option to use self-help instruction view)
    Here Insert Picture Description

While studying records, if any deficiencies welcome message pointing ...

Published 63 original articles · won praise 1 · views 2028

Guess you like

Origin blog.csdn.net/qq_45061361/article/details/104592534