8.5 Notes

  • File-related commands

      1, create, and delete operations

        touch touch, modification timestamp (atime mtime ctime), if the file is not created file

          -c does not create any files

          -top view the process

          -a modify the access time

        rm is used to delete a file or directory

          -find [range] -file d -name a * [properties]

          One by one asked to confirm the deletion before -i

          -f even if the original file is set to read-only property, but also delete, without having to confirm each

          -r directory under the file one by one and delete

          -exec command {} \; -ok command {} \; | xargs command;

      2, copy and move files

        cp is mainly used to copy a file or directory

          -a carry a copy of all file attributes

        mv used to rename a file or directory, or other file or directory into position

          mv ab will file a renamed b

      3, view the file contents

        cat-time view of all document content;

        a more a turning;

          / String: represented at the show's content, down keyword search string;

          q: representatives immediately leave more, no longer displays the contents of the file;

        less turning page after page, in more cases, view large files, we use less;

        Check tail end of the line, the default view down dozens of lines; tail -n 20 filename simplification: -20;

          -f Do not exit the file, real-time view file contents;

        View of the line head -n number // head 20 of the top 20 rows display -n;

      4, Other

        echo Print

          -n not wrap output

          -e handle special characters if the character appears in the string, then to be treated specially, it will not output as normal text         

            \ A warning

                                \ T Space

                                \ N newline, carriage return

                                \ R cursor to the beginning of the line, but do not wrap

                                Echo –n –e “hello world \t”

        Redirect> and >>

           fd file identifier

            0 - standard input

            1 - Standard Output

            2 - error output

           = Program instructions (code) + data (variable)

            States: the default standard input - a keyboard, a standard output - a display;

            Output redirection:

              > Redirect the default work cover can not be removed using this function set -c; simultaneously> | can be forced redirection (set + c redirection cover open);

              >> append redirection, in the original file, you can add additional data;

            Extended:

              In Linux, in addition to the default output command output, it also returns the result of a command execution state; 0 is returned for a successful command execution, and returns a failure is non-zero;

              $? Name of the store a result of the execution status

              At work, we often do not need the results of the command output, but only command execution state, we will use the redirect will redirect the output to an empty file (/ dev / null)

              Cat a.txt > /dev/null

              Input redirection:

                <The back of the document, the previous command to be executed;

                tr The foregoing is replaced with the content of the latter, tr abc ABC <a.txt

               << multiple simultaneous input content, with the cat command

                cat >> << EDF file

                >a 

                > EDF

             Error Redirection:

                2> need to bring FD (file identifier)

                >> 2 additional error output redirection

             Extended Optimization:

                 cat a.txt > /dev/null

                                           Cat a.txt 2> /dev/null

                                           &> / Dev / null command execution, whether correct or not, will specify the output content to / dev / null

                                           & >> [Trivial File]

                                      pipeline

                                             Command 1 | command 2 | ...... preceding command execution results, outputs a command to the back;

                                          [Linux idea: combine a small function, perform complex functions]

                                             Tail -7 /etc/fstab | cut –d’ ‘ –f1

                                             Cut Cut

                                                      -d develop separator '

                                                       1,3 -f taken columns 1-3

  • Linux Remote

      1, view or configure the network card information

        Ethernet and IP addresses

          ifconfig

          Without this command, we need to install the network tools package (net-tools)

          apt install net-tools

          If the card is not up, we need to modify the default network card configuration file;

         /etc/network/interfaces
           vim /etc/network/interfaces

          1, dynamic - dhcp
            Auto eth0
            iface eth0 inet dhcp
            [modify the configuration file, you need to restart the service]
            /etc/init.d/networking restart
          2, static - to manually configure the
            address 192.168.94.10
            Netmask 255.255.255.0
            Gateway 192.168.94.1    

      2, remote management mechanism

           Ssh Open ssh Ubuntu port monitoring function; TCP-22 is
           the netstat -tnl T // - TCP protocol n - is not resolved
           if not: the install OpenSSH APT -Y-Server
           /etc/init.d/ssh Start
          [Ubuntu ordinary users can only use the default remote connection]
          ssh [email protected]
          under centos, directly from the root user can telnet;
          SSH [email protected]

        no remote login password

  • System Information related commands  

            1, time and containers

        Date  --  系统时钟

        Cal  --  日历

      2、磁盘和目录空间

        Df  --  挂载

        Du  --  文件大小

        Wc  --  文件统计

      3、进程信息

        Ps  --  进程查看

        Ps aux

        Top

        Kill -9 强制关闭进程

        Kill -9 进程号(PID)


            

 

 

 

              

 

Guess you like

Origin www.cnblogs.com/byq1/p/11304950.html
8.5