Files in Linux system

Note: Everything in Linux is a file, and the files mentioned here also include directories

File attributes

 Ordinary file (-)    Ordinary file is a file in the ordinary sense, used to save text, data or programs

  Directory file (d)   Directory is a special file used to form the tree structure of the file system

  Device files  (c, b)   Linux regards devices as a special file, and device files are divided into character device files and block device files

  Symbolic link file (l) A  symbolic link file is a special file whose content is a link to another file for file sharing

  Pipe file (P) : Pipe file is a special file used to transfer data between running programs

 

                  

File ownership

  Linux is a multi-user system. The system needs to be able to distinguish the ownership of files. Each file in the Linux system has two attributes that describe its ownership.

     Owner (Owner): the owner of the file is the owner of the file (usually the person that created the file), with its user name identity

     Group owner: Linux divides users into user groups, and the file's belonging group is the user group to which the file belongs, identified by the group name

 

File access

  1) File access permissions

2) The distribution range of file permissions If an unauthorized operation is performed on a file, the system will refuse to execute it and display a Permission denied message

 

 

Linux   classification authorization permission distribution method  (root users are not restricted by access permissions)

     

 

The role of permissions                                                   


In addition to the above three types of user permissions, the basic file access control mechanism (ACL) of the Linux system also allows additional permissions to be set for individual users or user groups 

 

File attributes under Kali

As shown above, each file has its own attributes, including information such as access permissions and file size, file name, etc.

Where d means it is a directory 

rwx | rx | rx    File owner's permissions Group user's permissions Other people's permissions

 represents rwx owner has read and write execute permissions

 rx means that the group user only has the permission to read and execute

 

 

Number representation

  There is also a digital representation for file access permissions. The rule: use the number 1, 0 to represent the permission character, the bit with the corresponding permission is 1, and if there is no, it is 0

  Form a 9-digit binary number, which can be represented by a 3-digit octal number

           Such as: rwx rx rx expressed as binary: 111 101 101 converted to octal: 7 5 5   

 

 The Linux system stipulates that non-empty directories cannot be deleted. An empty directory is equivalent to a file, and its delete permission depends on the w permission of the upper-level directory

 

Default permissions for new files

  When creating a new file or directory, the system will set an initial permission for it, and the initial permission of the file is determined by the  file creation mask ( creation mask )

   The mask is a 9-digit binary number represented by a 3-digit octal number. The default mask of the system is generally 022.

   

 Command umask to view the default mask

   

 Modify the default mask (Note: only valid during system startup, it will become 022 upon restart)

 

 

The default permissions of files are divided into three cases (the default mask is 022)

As shown below: a.out is an executable file    Dir is the  directory   hello.txt as  non-executable files

                  

Other attributes of the file ( some attributes other than file name, file type, attribution and access authority )

  1) Time stamp of the file

  • Modify time (modify time): the last time the file content was modified
  • Access time (access time): the time when the file was last accessed
  • Change time (change time): the most recent time the file attribute was changed

2) The size of the file, that is, the number of bytes occupied by the file

3) The number of file connections, that is, the number of hard links to this file

 

 

Related commands

ls - List the contents of the directory

file - Determine the file type

less - browse file content

 

List directory contents

  ls no parameters

     List all files in the current working directory by default (excluding hidden files)

 ls <specified directory>

 Single directory

Multiple directories

ls -l (Long mode: detailed output file information)

Determine the type of file

 

Browse file contents

less file_name

Carriage return        overturn

Space   page down

         Page up

⬆ ⬇ Up and down

         exit

 

 

 

 

 

Guess you like

Origin blog.csdn.net/weixin_43495262/article/details/114753982