Get the App
SLTechnology News&Howtos  ›  Servers  › 

Methods of access to Unix / Linux configuration files and directories

Shulou Source: shulou.com Published: 2022-06-02 04:35:36 10月06日 Update

This article mainly introduces the method of Unix / Linux configuration file and directory access, which can be used for reference by friends who need it. I hope you will learn a lot after reading this article. Next, let the editor take you to learn about it.

The Unix and Linux operating systems assign one of the three access types (read, write, and execute) to each of the three groups (owner, group, and other users) to set access to files and directories.

How do I view file and directory access?

We can use the ls command with the-l option to list the details of the file properties, such as

Ls-l filename

The above command returns information like-rwe-rw-r, indicating that the file has read, write, and execute permissions for the owner, read and write permissions for the group, and read-only permissions for all other users.

Each type of access has the associated values listed below:

Read = 4

Write = 2

Execute = 1

How do I configure file and directory access?

You can use the chmod command to assign access to files and directories.

When we add up the access values for each of the above groups, we get a value between 0 and 7, which can be used to assign or modify permissions using the chmod (change Mode) command.

You can specify access to related files by entering the following command, such as-rwe-rw-r-like information returned in the above example

Chmod 764 filename

The number 764 comes from:

Rwe = 4 (r) + 2 (w) + 1 (e) = 7

Rw = 4 (r) + 2 (w) = 6

R = 4 (r) = 4

Note: the UNIX/Linux command and object name are case sensitive and must use "chmod" instead of CHMod or any other combination of uppercase and lowercase letters.

Example of using the chmod command:

Everyone can access it, and you need to run the following command:

Chmod 777 filename

Set full access to owner and group permissions, but other user settings can only be read and executed:

Chmod 775 filename

Full access to the owner, but restrict groups and other user permissions to read and execute only files in the directory:

Chmod 755 dirname

Full access to the owner, no access or permission to anyone else:

Chmod 700 filename

Unable to access groups or other users in the directory and owners to restrict read and execute permissions to prevent accidental deletion or modification of files in the directory:

Chmod 500 dirname

Allows owners and groups to have read and write access to files, and allows others in the group to edit or delete files and owners, but cannot access other users:

Chmod 660filename thank you for reading this article carefully, hope that the editor to share Unix / Linux configuration files and directory access method content is helpful to everyone, but also hope that you support a lot, pay attention to the industry information channel, find problems, detailed solutions waiting for you to learn!

Tags: Permissions files directories commands owners users methods configurations information articles assignments sizes examples types facets restrictions accidents operating systems between Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux Shulou Tech Info Shulou Information Docker MySQL