User accounts and file permissions on Ubuntu (P2)

Tram Ho

In the article User accounts and file permissions on Ubuntu (P1), I introduced the user and management of user accounts on Ubuntu. In this article, I will talk about managing access on Ubuntu.

User groups

Each file or directory always belongs to a specific user and group. Each file contains 3 groups of users. The person who created them will belong to the owner group, and the group containing the person who created the file or directory will belong to the group. Any user other than the owner or group owner belongs to the others group. Each group

Access rights and permissions

Access rights

The file / folder permissions determine what actions the user can perform on that file / folder. Each user group as above will have a set of rights (r, w, x) defined, in which:

  • Reading permission ( r ):
    • Allows to display the contents of files or folders.
  • Write right ( w ):
    • Allows to change the content of the file.
    • Allows to add or delete files in a directory
  • Execution authority ( x ):
    • Lets execute the file in the form of a program
    • Allow to go to the directory that needs access.

Two formats of access

Linux file permissions are displayed in two formats, symbolic notation and numeric notation .

1. Symbolic notation format

This type of format is a string of 10 characters in which one character represents the file type and the other 9 characters represent the permissions to read, write, and execute the file in the order of owner, owner and other users. The hyphen (-) will be used in case the user is not allowed to exercise the permission. Suppose a file has the following executable permissions: -rwxr-xr-- . We can easily see that this file is a regular file with read, write and execute permissions for owner, read and execute for group and read-only to others. We can check the permissions of a file using the command ls -l <tên tệp> or check the permissions of a directory by using the command ls -l <tên thư mục>

2. Format numeric notation

The numeric notation format is a three-digit string, each number corresponding to the user, group, and other users. Each digit ranges from 0 to 7, and each digit value is obtained by summing the class permissions:

  • 0: Not allowed to exercise any rights
  • 1: Execution
  • 2: Write
  • 3: Write and execute
  • 4: Read
  • 5: Read and execute
  • 6: Read and write
  • 7: Read, write and execute

So, if a file with executable permissions is displayed in symbolic notation format -rwxr-xr-- then numeric notation will be 754.

Change permissions

To change the permissions of a file or directory, use the command $chmod <mode> <files> where chmod (change mode) is a system-level command, allowing you to change the file’s permission settings in a similar way. handmade. The chmod commands are frequently used to authorize an object like:

  • Chmod 644: allows the owner to access and modify the file, while all other users can only access it but cannot modify it. Besides, no one can execute the file even the owner.
  • Chmod 755: allows the owner to access and modify the file, while all other users can only access but not modify and everyone has the right to execute.
  • Chmod 555: The file cannot be modified by anyone except the superuser of the system.
  • Chmod 777: allows people to do whatever they want with the file. This is a huge security risk, especially on web servers, so you need to be cautious when granting 777 permission to any file.

Thus, through 2 articles, I introduced the basics of using accounts and decentralizing access on Ubuntu. Thank you for watching

Share the news now

Source : Viblo