Linux learning (1)

1. Enter the linux command line, enter cd / to enter the root directory, and then enter ll to view the list information

Description: For example: dr-xr-xr-x. 2 root root 4096 April 26 12:53 bin, the first d: means directory, folder, - means ordinary binary file, l means link, means soft link file , similar to the desktop shortcut in Windows;

The following r-xr-xr-x, three are a group, the first rx represents the owner (user), the second rx represents the group (group), and the third rx represents the other person (other); The 2 represents the number of hard links; the first of the following 2 root represents the owner, and the second represents the owner

The group to which it belongs; 4096 indicates the size of the file; the following 4096 April 26 12:53 indicates the creation or modification time; bin indicates the file or directory name, here indicates the directory.

2. Permission description of the file: the above rwx, r represents the read permission, w represents the write permission, x represents the execute permission, the above r-xr-xr-x, 3 are a group, the first rx ( The owner user has read and execute permissions), the second rx (the owning group has read and write permissions), the third rx (indicates that others have read and write permissions)

3. Common file processing commands:

  1) ls description: display file directory syntax: ls option [-al] [file or directory], option a means display all files (including hidden files), l means display detailed information, for example: ls -al do not write files or directories , which refers to the current directory

       2) touch description: Create an empty file Syntax: touch file name, for example: touch a.txt Create an empty file named a.txt in the current directory

     3) mkdir description: create a folder syntax: mkdir option [-p means recursively create a folder] folder name, for example: mkdir d1, mkdir -p d1/d2/d3

       4)cp description: copy file or folder syntax: cp [source file] [destination file] ||cp option [-r] [source directory] [destination directory] cp log.txt /test/log2.txt

       5) mv description: move the file or modify the file name

       6) cat description: view the content of the file, the content is too much, the display is incomplete Syntax: cat [file]

       7)more description: you can view the file content, space to view the next page, carriage return to display the next line

     8) head description: view the first lines of the file, syntax: head -number [file name]; for example: head -100 a.txt

        9) tail description: check how many lines after the file, syntax: tail -number [file name]; for example: tail -100 a.txt

       10)ln description: create a link file, syntax: ln [-s with this option means soft link, no means hard link] [source file] [object file], note: the hard link file is synchronized with the source file, modify one of them , are modified

4. Permission processing command

  11) chmod description: change model, change the permissions of files or folders; syntax: chmod [{ugo}{+-=}{rwx}] [file or directory] or chmod [mode=421] [file or directory]; E.g:

chmod u+w filename means to modify the user permission of the file to add write permission; chmod 755 means to give rwx permission to user, rx permission to group, and rx permission to other

Notice:

  rwx permissions for the file:

  r: Read operations such as catch and more can be performed. w: Modify the content of the file and other write operations, but it does not mean that you can delete the file. x: Perform an operation on the file.

  rwx permissions for the directory:

  r: Readable operation, you can list the contents of a directory, such as the ls command. w: Indicates the permission to create or delete files in the directory. x: Indicates that you can enter this directory (basically all directories will have rx permissions).

       12)su description: switch user command Syntax: su -username  

       13) chown description: Modify the owner of the file Syntax: chown username file name; for example: chown zhanghao f1.txt

       14) chgrp description: Modify the group to which the file belongs Syntax: chgrp group file name; for example: chgrp zhanghao f1.txt

5. File search command

   First of all, you need to understand the data size of Linux. It is not the installation bit, but the data block size. The size of a data block is equal to 512bit, that is to say, 1k=2 data blocks, 100M=100*1024*2block

        find command

    1) Search according to file size, syntax: find [search path range path] -size [+-file size, + means greater than, - means less than], for example: find /etc -size +1024

              2) Search according to the owner of the file, the syntax find [search path range path] -user, for example: find /etc -user

              3) Search according to time, syntax: find [time option, day: ctime/atime/mtime, minute: cmin/amin/mmin] [-+ specific value, - means inside, + means outside], the beginning of the character Meaning: c means: change means to change file attributes (such as owner, group, permission change), a means: access means to have been accessed (such as been viewed, etc.), m means: modify means to change content; Example: find /etc -ctime -1

        4) Find the connector of the application: -a (and, logical and) -o (or, logical or), for example: find /etc -size +1024 -o -ctime -1

             5) Find according to the file type: find -type [f: binary file, l: soft link, d: directory]

            

     

        

        

 

Guess you like

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