Distribute file access with chmod command
Network administration - Unix and Linux operating systems decentralize access to files and directories by using three access parameters, read (read), write (write) and execute (run) to delegate to three groups of objects statues, including: system owners, administrative groups and users.
If you list the properties of a file in detail with the ls command with the -l switch (for example, ls -l [filename] ), this command will return information with the form -rwe-rw-r- ( ie, decentralize read, write and execute to the system owner, grant read and write permissions to the administrative group, and only read permissions to other user objects).
Each of these access privileges corresponds to a value:
- read = 4
- write = 2
- execute = 1
The values for some access rights corresponding to each group are added together to form a value between 0 and 7 (can be used to change or decentralize using the chmod command - change mode ).
For example, enter the command chmod 764 [filename] to grant access to a certain file, in which the value of 764 is generated from:
- rwe = 4 (read) + 2 (write) + 1 (execute) = 7
- rw = 4 (read) + 2 (write) = 6
- r = 4 (read) = 4
You can use the chmod command to assign permissions to files and directories, but you should keep in mind the correct chmod command, not the uppercase characters in the command.
The chmod command is often used
Here are some common chmod commands:
- chmod 777 filename : Grant full access to all user objects.
- chmod 775 filename : Grant full access to the system owner and administrative group, the user object can only read (read) and run (execute) the file.
- chmod 755 dirname : Grant full access to the system owner, only allow the administrative group and user objects to read and run the files in the directory.
- chmod 700 filename : Only grant full access to the system owner and block access to all other objects.
- chmod 500 dirname : Do not allow administrators and users to access files in the directory, and limit the read and run system owner permissions to avoid deleting and changing files in this directory.
- chmod 660 filename : Allows system owners and administrators to read, edit, delete and write data to the file, but do not grant access to other users.
See more:
- Basic Shell commands in Linux
- 12 best Linux server operating systems
You should read it
- How to Change File Permissions on Windows 7
- How to use the temporary permission feature of Android 11 on any phone?
- How to edit application permissions on Android
- How to limit access to su command in Linux
- How to Get Full Root Privileges in Linux
- How to access Linux files on Windows 10
- The reason and how to edit sudoers file in Linux
- How to check application access on macOS
May be interested
- How to change the file's attributes using the Attrib commandin windows, file attributes are settings associated with files on a computer that grant or deny certain rights to users or operating systems associated with accessing that file. the following article will show you how to change the properties of any file using attrib command in command prompt.
- The cacls command in Windowsthe cacls command displays or modifies an arbitrary access control list (dacl) on the specified file. the command applies to windows server (semi-annual channel), windows server 2016, windows server 2012 r2, windows server 2012.
- Fsutil command in Windowsthe fsutil command performs tasks related to file allocation table (fat) and ntfs file systems, such as managing reparse points, managing sparse files, or canceling a drive mount.
- The convert in Windows commandthe convert command converts file allocation table (fat) and fat32 to the ntfs file system, keeping existing files and folders intact. the drives that have been converted to ntfs file systems cannot be converted to fat or fat32 anymore.
- Open folder in Command Prompt (CMD)do you need to access a certain folder from the command prompt or windows command prompt? although it looks classic, this program is really easy to use if you know some basic commands. today's tipsmake will show you how to use the 'cd' command to open a folder in windows command prompt. besides, you will also learn great tips to immediately open the command prompt in any folder on windows file explorer.
- Fsutil command sparse in Windowsthe fsutil sparse command manages sparse files (a sparse file is a type of computer file that tries to use system space more efficiently when the file is partially empty).
- Setlocal command in Windowsthe setlocal command helps start the process of differentiating environment variables in a batch file. this process will continue until paired with the appropriate endlocal command or the batch file end.
- How to Open Folders in CMDdo you need to access something from the command prompt or the windows command prompt? although it looks classic, this program is really easy to use if you know some basic commands. today's tipsmake will show you how to use the 'cd' command to open a folder in windows command prompt. besides, you will also know more great tips to instantly open command prompt in any folder on windows file explorer.
- How to use the Install command to copy files in Linuxinstall is a flexible file copying command in linux and macos suitable for professional users. read this article to discover how to use the install command.
- How to Create a File in Unixthis wikihow teaches you different ways to create a new file at the unix command prompt. to quickly create a blank file, use the touch command. to create a new text file from scratch, try the vi text editor or the cat command. if you want...