Linux learning road (1)

Linux basic commands

  Command format:    command name [parameter] [object] 

  Long and short forms of command arguments:   

            Long form: man -- help

            Short form: man - h

  1.   Common system work orders

    1. The echo output statement format is: echo [string | $variable]

    2. date is used to display the system time set time or date format is: date [options] [+specified format] 

                              Parameters in date: %t tab [tap key]

                                     %H hours (0~23)

                                     %I hours (0~11)

                                     %M minutes (0~59)

                                     %S seconds (0~59)

                                     %j day of the year  

      3. reboot is used to restart the system. The format is: reboot

      4. poweroff is used to shut down the system. The format of the reboot command is the same as that of the reboot command. Hardware permissions are involved. Only administrators can shut down the computer.

      5. The format of wget download network file in the terminal is: wget [parameter] download address

                          wget parameter: -b background download mode

                                  -P download to the specified directory

                                  -t maximum number of attempts

                                  -c resume the upload from a breakpoint

                                  -p Download all resources on the page, including videos and pictures

                                  -r download recursively

      6.ps is used to view the system process status. The format is: ps [parameter]

                          ps parameter: -a show all processes (including processes of other users)

                                 -u user and other details

                                  -x show processes without a controlling terminal

                           5 common process states: R (running), S (interrupted), D (uninterruptible), Z (zombified), T (stopped)

                           Linux allows the ps command to be written directly as ps aux

      7.top can be seen as the task manager in windows format top   

      8. pidof is used to query the PID value of a specified service process. The format is "pidof [parameter] [service name]

      9.kill terminates a service process with a specified PID The format is "kill [parameter] [process PID]

      10.killall is used to terminate all processes corresponding to a service with a specified name, the format is: "killall [parameter] [process name]

   2. System status detection command

      1. The ifconfig command is used to obtain information such as network card configuration and network status. The format is "ifconfig [network device] [parameter]"

      2. The uname command is used to view information such as the system kernel and system version, the format is "uname [-a]"

      3.uptime is used to view the load information of the system, the format is uptime

      4. free is used to display the memory usage information in the current system, the format is "free [-h]". 

      5.who is used to view the user terminal information currently logged in to the host, in the format of "who [parameter]". 

      6. The last command is used to view the login records of all systems, the format is "last [parameter]". 

      7. The history command is used to display the commands executed in history, the format is "history [-c]". The initial value can store 1000 historical commands

      8. The sosreport command is used to collect system configuration and architecture information and output diagnostic documents in the format of sosreport

  3. Working directory switching command

      1. The pwd command is used to display the current working directory of the user in the format of "pwd [options]"

      2. The cd command is used to switch the working path, the format is "cd [directory name]"

      3. The ls command is used to display the file information in the directory, the format is "ls [option] [file]"

                    Use the "-a" parameter of the ls command to see all files (including hidden files), and use the "-l" parameter to view detailed information such as file attributes, size, etc. If you want to view directory attribute information,

                    You need to add an additional -d parameter

  4. Text file editing commands

       1. The cat command is used to view plain text files (with less content) in the format "cat [options] [files]". 

       2. The more command is used to view plain text files (with more content) in the format of "more [options] files". 

       3. The head command is used to view the first N lines of a plain text document in the format "head [options] [files]". 

       4. The tail command is used to view the last N lines of a plain text document or to continuously refresh the content. The format is "tail [options] [files]". 

       5. The tr command is used to replace characters in a text file in the format "tr [original character] [target character]". 

       6. The wc command is used to count the number of lines, words and bytes of the specified text, the format is "wc [parameter] text". 

                   wc parameter: -l only display the number of lines -w only display the number of words -c only display the number of bytes 

       7. The stat command is used to view the specific storage information and time of the file, and the format is "stat file name". 

       8. The cut command is used to extract text characters by "column" in the format "cut [parameter] text". 

       9. The diff command is used to compare the differences of multiple text files, the format is "diff [parameter] file". 

  5. File directory management commands

          1. The touch command is used to create a blank file or set the time of the file in the format of "touch [options] [files]". 

                    Parameters: -a only modify the "read time" (atime) -m only modify the "modification time" (mtime) -d modify both atime and mtime 

       2. The mkdir command is used to create a blank directory in the format "mkdir [options] directory". 

       3. The cp command is used to copy a file or directory in the format "cp [option] source file target file". 

                         Parameters: -p preserve the attributes of the original file -d if the object is a "linked file", preserve the attributes of the "linked file" -r recursively continue copying (for directories)

                           -i If the target file exists, ask whether to overwrite -a is equivalent to -pdr (p, d, r are the above parameters) 

       4. The mv command is used to cut or rename a file, the format is "mv [option] source file [destination path|destination file name]". 

       5. The rm command is used to delete a file or directory in the format "rm [options] file". 

                    Parameters: -f force delete file -r force delete directory

       6. The dd command is used to copy files or convert files according to the specified size and number of data blocks, the format is "dd [parameter]".           

                    Parameters: if input file name of output file name bs set the size of each "block" count set the number of "blocks" to be copied

       7. The file command is used to view the type of the file, the format is "file file name". 

    6. Package compression and search commands

         1. The tar command is used to compress or decompress files in the format of "tar [options] [files]". 

                    Parameters: -c create a compressed file -x decompress the compressed file -t view which files are in the compressed package -z compress or decompress with Gzip -j compress or decompress with bzip2

                        -v show the process of compressing or decompressing -f target file name -p keep original permissions and attributes -P use absolute path to compress -C specify the directory to decompress     

                The "tar -czvf archive name.tar.gz directory to be packed" command packs and compresses the specified file; the corresponding decompression command is "tar -xzvf archive name.tar.gz"

        2. The grep command is used to perform a keyword search in the text and display the matching results in the format of "grep [options] [files]". 

                    Parameters: -b search executable file (binary) as text file (text) -c only show number of lines found -i ignore case -n show line number -v reverse selection - only list no "key" word" line 

       3. The find command is used to find files according to the specified conditions, the format is "find [find path] search condition operation". 

                    Parameters: -name match name 

                        -perm matches permissions (mode is full match, -mode is inclusive)
                        -user matches owner
                        -group matches all groups
                        -mtime -n +n matches the time to modify the content (-n means within n days, +n means n days ago)
                        -atime -n +n match the time of accessing the file (-n refers to within n days, +n refers to n days ago)
                        -ctime -n +n match the time to modify file permissions (-n refers to within n days, + n means n days ago)
                        -nouser matches files without owner
                        -nogroup matches files without owning groups
                        -newer f1 !f2 matches files newer than file f1 but older than f2
                        --type b/d/c/p/l /f matches the file type (the following letter parameters represent block devices, directories, character devices, pipes, link files, text files in turn

                        -size   matches the size of the file (+50KB to find files over 50KB and -50KB to find files smaller than 50KB) 

                        -prune ignores a directory
                        -exec ... {}\; can be followed by commands for further processing of search results (shown below)

  

 

Guess you like

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