0% found this document useful (0 votes)
49 views

Chmod Command

The chmod command sets file permissions by defining read, write, and execute access for the file owner, group, and others. File permissions are represented by strings of characters that indicate these privileges. The chmod command can set permissions using either three-digit numbers representing the owner, group, and other privileges, or by specifying the permissions directly.

Uploaded by

Anudeep Putchala
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
49 views

Chmod Command

The chmod command sets file permissions by defining read, write, and execute access for the file owner, group, and others. File permissions are represented by strings of characters that indicate these privileges. The chmod command can set permissions using either three-digit numbers representing the owner, group, and other privileges, or by specifying the permissions directly.

Uploaded by

Anudeep Putchala
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

chmod

The chmod command sets the file permissions flags on a file or folder. The flags
define who can read, write to or execute the file. When you list files with the -l
(long format) option you’ll see a string of characters that look like

-rwxrwxrwx

If the first character is a - the item is a file, if it is a d the item is a


directory. The rest of the string is three sets of three characters. From the left,
the first three represent the file permissions of the owner, the middle three
represent the file permissions of the group and the rightmost three characters
represent the permissions for others. In each set, an r stands for read, a w stands
for write, and an x stands for execute.

If the r, w, or x character is present that file permission is granted. If the


letter is not present and a - appears instead, that file permission is not granted.

One way to use chmod is to provide the permissions you wish to give to the owner,
group, and others as a 3 digit number. The leftmost digit represents the owner.
The middle digit represents the group. The rightmost digit represents the others.
The digits you can use and what they represent are listed here:

0: No permission
1: Execute permission
2: Write permission
3: Write and execute permissions
4: Read permission
5: Read and execute permissions
6: Read and write permissions
7: Read, write and execute permissions
Looking at our example.txt file, we can see that all three sets of characters are
rwx. That means everyone has read, write and execute rights with the file.

To set the permission to be read, write, and execute (7 from our list) for the
owner; read and write (6 from our list) for the group; and read and execute (5 from
our list) for the others we’d need to use the digits 765 with the chmod command:

chmod -R 765 example.txt

To set the permission to be read, write and execute (7 from our list) for the
owner, and read and write (6 from our list) for the group and for the others we’d
need to use the digits 766 with the chmod command:

chmod 766 example.txt

You might also like