How to Change permission of a file in Linux

chmod command is used to change the permission of a file in Linux. In Linux, there is a set of rules for each file that defines who can access that file, and how they can access it. These rules are called file permissions or file modes. The command name chmod stands for “change mode”, and it is used to define the way a file can be accessed.
 
Syntax:
chmod [options] <permissions> <filename>
 
Note: If no options are specified, chmod modifies the permissions of the file specified by filename to the permissions specified by permissions.
Permissions defines the permissions for the owner of the file (the “user”), members of the group who owns the file (the “group”), and anyone else (“others”). There are two ways to represent these permissions: with symbols (alphanumeric characters), or with octal numbers (the digits 0 through 7).
 
Example[with symbols]: chmod u=rwx,g=rx,o=r test_file
Change permission of a file in Linux
This is an example of using symbolic permissions notation which change the permission of a file in Linux. The letters u, g, and o stand for “user”, “group”, and “other”. The equals sign (“=”) means “set the permissions exactly like this,” and the letters “r”, “w”, and “x” stand for “read”, “write”, and “execute”, respectively.
 
Example[with octal numbers]: chmod 754 test_file
Change permission of a file in Linux
Here the digits 7, 5, and 4 each individually represent the permissions for the user, group, and others, in that order. Each digit is a combination of the numbers 4, 2, 1, and 0:
4 stands for “read”,
2 stands for “write”,
1 stands for “execute”, and
0 stands for “no permission.”
So 7 is the combination of permissions 4+2+1 (read, write, and execute), 5 is 4+0+1 (read, no write, and execute), and 4 is 4+0+0 (read, no write, and no execute).
You may want to see
How to sort contents of a file

The sort command is used to sort the contents of a file. You can sort the data in a text Read more

How to use sed command in Linux

sed, short for "stream editor", allows you to filter and transform text. A stream editor is used to perform basic Read more

How to use crontab in Linux

Cron is the system process that will automatically perform tasks for you according to a set schedule. The schedule is Read more

How to extract archive file in Linux

To extract archive file in Linux, you can use the tar command, used for extracting content from the archive files. "tar" Read more

Leave a Reply

Your email address will not be published. Required fields are marked *