Linux top 50 cmd
(Page:1)
Linux top 50 cmd - Chmod
The chmod command is used to change the permissions associated with the object (typically a file or directory). What you are really doing is changing the file mode. There are two ways of specifying the permissions of the object. You can use the numeric coding system or the letter coding system. If you recall, there are three sets of users associated with every object: the owner of the object, the group for the object, and everybody else. Using the letter coding system, they are referred to as u for user, g for group, o for other, and a for all. There are three basic types of permissions that you can change: r for read, w for write, and x for execute. These three permissions can be changed using the plus (+) and minus (-) signs. For example, to add read and execute to owner and group of the file test1, you would issue the following command: chmod ug+rx test1 To remove the read and execute permissions from the user and group of the test1 file, you would change the plus (+) sign to a minus (-) sign: chmod ug-rx test1 This is called making relative changes to the mode of the file. Using the numeric coding system, you always have to give the absolute value of the permissions, regardless of their previous permissions. The numeric system is based upon three sets of base two numbers. There is one set for each category of user, group, and other. The values are 4, 2, and 1, where 4 equals read, 2 equals write, and 1 equals execute. These values are added together to give the set of permissions for that category. With the numeric coding you always specify all three categories. Therefore, to make the owner of the file test1 have read, write, and execute permissions, and no one else to have any permissions, you would use the value 700, like this: chmod 700 test1 To make the same file readable and writable by the user, and readable by both the group and others, you would follow the following mathematical logic: For the first set of permissions, the user, the value for readable is 4, and the value for writable is 2. The sum of these two is 6. The next set of permissions, the group, only gets readable, so that is 4. The settings for others, like the group, are 4. Therefore, the command would be chmod 644 test1. The format for the command, using either method, is the same. You issue the chmod command followed by the permissions, either absolute or relative, followed by the objects for which you want the mode changed: chmod <permissions> <file>