input license here

What is chmod? Instructions for using Chmod Linux




In the process of using Linux, not everyone has used the chmod command. Especially for users who perform operations with folders and files or encounter errors without permission. However, those who are new to Linux will not know chmod. The following article BKNS will send to you What is Chmod?? Instructions for using Chmod Linux.


>> Learn more: Basic Commands in Linux



What is chmod?

What is chmod?



1. What is Chmod?


Chmod (full name is Change Mod) in Linux operating system is the command used to change the permissions of the object file system (files and directories).


1.1 Syntax of chmod command in linux


chmod [options] mode [mode] file1 file2 file3 ....

1.2 List of options



  • -v: verbose, display processed object

  • -f: force, set permissions in case of an error

  • -R: Recursive, applies to all files and folders inside


If it is a symbolic link, the target object will be affected.



























































#PermissionrwxBinary
7read, write and executerwx111
6read and writerw-110
5read and executer-x101
4read onlyr–100
3write and execute-wx011
2write only-w-010
1execute only–x001
0none000

CEO: In case mode = 777 (Alphanumeric type)



  • With folder => drwxrwxrwx

  • With file => -rwxrwxrwx


– The first character is the letter [d] then folder, if it's a dash [] then it's file


– The next 3 characters are the owner's read, write, and execute permission (File/folder creator)


– The next 3 characters are read, write and execute permissions of Owner Group (Group of file/folder creator)


– The last 3 sequences are the read, write, and execute permissions of EveryOne (All remaining users)


Syntax of chmod command in linux


2. Install chmod in cpanel


Step 1: Login to cPanel site admin account


Install chmod in cpanel


Step 2: choose "File Manager”.


Install chmod in cpanel 1


Then the interface of “File Manager


Install chmod in cpanel 2


Step 3: Set chmod



  • Set chmod command for each file or folder: click on column "Perms" or select "Change Permissions” by right clicking, then change the parameters.


Install chmod in cpanel 3



  • Set the chmod command for the entire folder or file: choose "Select all, then right click and select “Change Permissions, proceed to customize


Set chmod command for each file or folder: click on the “Perms” column or select “Change Permissions” by right-clicking, then change the parameters.  4


2. Instructions for using chmod on Linux


2.1 View and understand file permissions


You can use option -l (long format) to get a list ls file permissions for files and folders.


ls -l

View and understand file permissions


On each line, the first character identifies the type of entry being enumerated. If it is a dash () then it's 1 file. But if it's a word d then it is a directory.


The next 9 characters represent the settings for the 3 sets of permissions.



  • First 3 characters: shows the permissions for the user who owns the file. (user rights)

  • 3 characters in between: visible to the members of the file group.

  • Last 3 characters: shows for permissions for anything that isn't in the first 2 items (the others).


There are 2 characters in a permission set. The characters are indicators for the presence or absence of 1 of the permissions. They are dashes (-) or letters. If it is a dash then the permission is not granted. If the character is r,w there are x then the right is granted.


The letters represent:



  • r : read permission. The file can be opened, and its contents viewed.

  • w : write permission. Files can be edited, modified and deleted.

  • x : execute permission. If the file is a script or a program, it can be run (executed).


Eg:



  • means no permissions are granted at all.

  • rwx means full permission has been granted. Read, write and execute metrics are all present.


In our screenshot, the first line starts with a d . This line refers to a folder named “archive". The owner of the folder is “dave, the name and name of the group to which the folder belongs is also called “dave”.



  • The next three characters are the user permissions for this folder. These show that the owner has full rights. The characters r , w and x are all present. This means that the user has read, write, and execute permissions for that directory.

  • The second set of three characters are group permissions, these are rx . They show that members of the dave group have read and execute permissions for this directory. That means they can list files and their contents in the directory and they can cd (executable) into that directory. They don't have write permissions, so they can't create, edit, or delete files.

  • The last three characters are also rx . These rights apply to people who are not covered by the first two sets of rights. These people (called other people) have read and execute permissions on this directory.


So to summarize, group members and others have read and execute permissions. The owner, a user called dave, also has write permissions.


For all other files (apart from the mh.sh script file), dave and members of the dave group have read and write attributes on the files, and the other files have read-only permissions.


For the special case of the mh.sh script file, owner dave and team members have read, write and execute permissions and others only read and execute permissions.


2.2 Setting and modifying permissions


Let's say you have a file that everyone has full permissions on.


ls -l new_ file.txt

Install and modify permissions


If you want users to have read and write permissions, other groups of objects or users to have read only, you can do so by using the following command:


chmod u = rw, og = r new_file.txt

Install and modify permissions 1


Using the “=” operator means you have the power to wipe any existing permissions and then set the specified ones.


Check for new permissions on the following file:


Install and modify permissions 2


As shown in the image above, the existing permissions have been deleted and the new permissions have been reset.


To perform the addition of permissions without removing the existing permission settings, you can do the following:


Let's say you have a script file that you've finished editing. You need to make it for all users. Its current permissions will be as follows:


ls -l new_script.sh

Install and modify 3 . permissions


You can add execute permission for everyone with the following command:


chmod a + x new_script.sh

Install and modify permissions 4


If you look at the permissions, you'll see that execute permissions are now available to everyone, and the existing permissions are still in effect.


ls -l new_script.sh

Install and modify permissions 5


The following commands can also do this:


chmod + x new_script.sh

2.3 Check file/folder permissions


ls -l /duong-dan-file-hoac-folder

Check file/folder permissions


So the article on BKNS has provided you What is chmod? Instructions for using Chmod Linux. If you have any questions about this article, please leave a comment below for support. Don't forget to visit the website https://www.bkns.vn/ for more useful information.


Related Posts
Diệp Quân
Nguyen Manh Cuong is the author and founder of the vmwareplayerfree blog. With over 14 years of experience in Online Marketing, he now runs a number of successful websites, and occasionally shares his experience & knowledge on this blog.
SHARE

Related Posts

Subscribe to get free updates

Post a Comment

Sticky