Linux common commands search command, help command, decompression command and network communication command

search command

            
            file search command

                    1. Command name: which
                       Command path: /usr/bin/which
                     Execution authority: all users
                    Function description: Search the directory and alias where the system command is located
                    Syntax: which [command name]

                    Ex:which ls

                    2.. Command name: whereis
                       Command path: /usr/bin/whereis
                     Execution authority: All users
                    Function description: The path where the search command (only system commands are found) and the location of the help documentation

                    Syntax: whereis [command name]

                     Options:
                            -b: Find executable files
                            only -m: Find help files only

                    Ex:whereis -b ls

                          whereis -m ls

                    Note: (The cd command shell comes with it, so the file cannot be found through this)

           file search command
                        1. Command name: find
                        Command path: /usr/bin/find
                        Execution permission: all users
                        Function description: Find a file or directory

                        Syntax: find [search path] [search keyword]

                        There are many search keywords for the find command, some of which are introduced below

                    find /etc -name init
                    finds files with the name init in the directory /etc, the -name option is based on the name search
                    find / -size +204800
                    finds files larger than 100 M in the root directory, the -size option is based on the size Retrieve
                    find / -user sam to find files with owner sam in the root directory, -user is to retrieve                    find /etc -ctime -1
                   based on username

                   Find files or directories whose attributes have been modified within 24 hours under /etc  

                                Here -ctime is based on the number of days to retrieve, -1 is within one day, +1 is one day ago

                               - atime file access time
                                -ctime change file attribute time.

                                -mtime change file content time

                                Can also be cmin amin mmin means minutes

                  find    /etc   -size  +163840  -a  -size  -204800

                  Find files larger than 80M and smaller than 100M under /etc

                                #The 80 megabytes and 100 megabytes are calculated according to the minimum unit of the Linux file system is 512b, for example, the unit of 204800 is 512b

                                then its so 204800*512b/1024*1024=100M

                  find   /etc    -name inittab -exec  Is -l {} \;

                  Find the inittab file under /etc and display the details

                        #: exec command{} \;You can put it after any command to continue executing the command after exec

                            For example, in this example, find will find things into {}, and then ls will display them. When exec is replaced with -ok, the same effect can be achieved, but each time it asks whether it is how or not. This works great when deleting

                   find /root -nouser
                   finds files without an owner

                        #Explanation: ------- A file without an owner is a garbage file in Linux, but it is
                        generated by the kernel in sys and proc and cannot be regarded as a file. In addition, foreign files such as CD-ROM, U disk, etc. cannot be deleted. In addition to this, non-user files

                         All are junk files and can be deleted.

                2. Command name: locate
                        Command original meaning: list files in databases
                        Command path: /usr/bin/locate
                    Execution authority: all users
                        Function description: Find files and directories
                    Syntax: locate [command name]
                    Ex:locate file
                          list all files with file Related Documents
                    #Note

                                locate file name (can only search by file name, not by size, file type, etc.)

                                The background database searched by the locate command------so locate generally cannot search for newly created files in real time, because
                                it is necessary to update the database before searching. The search is in the /var/lib/mlocate directory, so Benefits are

                                Can be faster. (usually update the database one day)

                            The command to update the data road is:

                             updatedb

                    3. Command name: grep
                      command original meaning:
                     command path: /bin/grep
                     execution authority: all users
                    Function description: search the file for the line matching the string and output

                    Syntax: grep [specified character] [source file]

                    Options:
                           -i ignore case
                           -v exclude the specified string, even if it means negated

                    Ex:grep ftp /etc/services

    help command

                    

                1.
                     Command name: man
                    Command original meaning: manual
                    command path: /usr/bin/man
                    Execution authority: all users
                    Function description: Get help information
                    Syntax: man [command or configuration file]
                    Ex: man ls
                          View the help information of the Is command
                      man services

                          View the help letter for the configuration file services

                2. Command --help #Get
                        help command
                  such as
                        ls --help
                  help shell internal command #Get
                        shell internal command
     . whereis cd #Determine
                        whether it is an internal command
     . help cd ------ can only get internal commands, but no command location in bin subdirectory

                        # get internal commands

                    3. Command name: info
                    Command original meaning: information
                    Command path: /usr/bin/info
                    Execution authority: All users
                  Function description: Get help information
                  Syntax: info [any keyword]
                    Ex:info ls

                           View help information for the Is command

 Compression and decompression command:

                

                        Before writing common commands, I want to popularize a knowledge, although many people do not need my popularization, that is, the definitions of packaging, unpacking and compression and decompression

            Packing: that is to organize different folders or files into one folder, unpacking is the opposite

            Compression: It is to recombine files or folders into a smaller file according to certain rules according to a certain algorithm, and decompression is the opposite.

        The following are commonly used commands, which do not follow the above format.

                Commonly used compression formats
                 1----: .zip .gz .bz2
                 2----: .tar.gz .tar.bz2
                 1) zip compressed file name source file
                    #compress file
                   zip -r compressed file name source directory
                    #compress Directory
                (zip is the same as Windows, and can be transferred to each other)
                      decompress:
                       unzip compressed file -d directory Compress the file into the directory #decompress
                        the .zip file
             2) gzip source file
                    # compress the compressed file in .gz format, The source file will disappear
                    gzip -c source file > compress file
                    #compress to .gz format, the source file retains
                    gzip -r directory
                    #all sub-files in the compressed directory, but the directory cannot be compressed.
                    gzip -d compresses files
                    #decompress the file
                    gunzip compressed file
                    #decompress the file
                gunzip -r compress the directory #decompress
                the compressed file in the directory
         3) bzip2 source file
                #compress to .bz2 format, do not keep the source file
                bzip2 -k source file #retain the source file
                after compression
                Note: The bzip2 command cannot compress the directory
                bzip2 -d compressed file #decompress
                , -k keep compressed file
                bunzip2 compressed file #compress
                file, -k keep compressed file
         4)
               tar -cvf package file name source file
                option
                -c: package
                -v : show process
                -f ; specify the name of the packaged file
               . For example
                    tar -cvf longzls.tar longzls
                   unpacking command
               tar -xvf packing file name
               option;
                -x : unpacking
         5) tar -jcvf archive name .tar.bz2 source file
             option
                -j : compressing to .tar.bz2 format
                 tar - jxvf archive name.tar.bz2
            #decompress
         6) tar -zcvf archive name.tar.bz2 source file
             option
            -z: compress to .tar.bz2 format
                 tar -zxvf archive name.tar.bz2 #decompress
            tar
                 - zxvf
                 archive name.tar.bz2 -C directory-------extract to
            the specified directory
             tar -ztvf archive name.tar.bz2
                  Options

                -t; view the compressed file, but modify

            Description: The f command must be placed after options such as zcvtj, otherwise an error will be reported.

network communication commands

                                    

                1. Command name: write
                Command original meaning:
                command path: /usr/bin/write
                Execution authority: all users
                Function description: Send a message to another user, ending with ctrl+D
                Syntax:
                      write <username>

                    Ex:write webmaster

                2. Command name: wall
                command original meaning:
                command path: /usr/bin/wall

                Execute permission: all users                   

                Function description: broadcast information to all users

                Syntax:
                      wall [message] [filename]

                    Ex:wall Happy New Year

           3. Command name: ping
                command original meaning:
                command path: /usr/sbin/ping

                Execute permission: all users                   

                Function description: Test network connectivity

                Syntax:
                     ping 192.168.1.120

             4. Command name: ifconfig
                Command original meaning:
              Command path: /usr/sbin/ifconfig
             Execution authority: root
             Function description: View network setting information
            Syntax:
                  ifconfig option [network card device identification]
                  -a Display all network card information
                  Ex:ifconfig -a

    Linux Shutdown and Restart Commands

            shutdown [options] time (can be now, or a specified time) (&: if you add an and symbol after it, it means it can be placed in the background without affecting the current terminal, if not, you can add Ctrl+c to stop current command)
    option;
      -c: cancel the previous shutdown command
      -h: shutdown
      -r: restart (date is; the command to get the current time in Linux)
  other shutdown commands
     halt Enter-----shutdown
     poweroff Enter -----Shut down
     init 0 Enter -----Shut down
     (these three are not particularly safe, try to shutdown)
  Other reboot commands
    reboot











                     



Guess you like

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