Basic chmod examples
In our previous post we discussed how to change the permission or mode of a file with chmod command. Now lets see few basic examples regarding how to use chmod via Command Line Interface
#1)
Now lets change the permission of above file, so that
- calypso can read, write and execute the file,
- group IT_Dept can read and execute the file,
- all other users can only execute the file
#1)
- calypso can read, write and execute the file,
- group IT_Dept can read and execute the file,
- all other users can only execute the file
chmod u+wx,g+x,o-r+x my_executable
or
chmod 751 my_executable
#2) To change the permission of my_executable file, so that all users have read, write and execute permission
chmod a+rwx my_executable
or
chmod 777 my_executable
#3) To view the mode changed without running a separate ls -l command, type
chmod -v u+wx,g+x,o-r+x my_executable
Sample Output
mode of ‘my_executable’ changed from 0444 (r--r--r--) to 0751 (rwxr-x--x)
#4) So far we have seen chmod examples on a file. But when it comes to directories read, write and execute permission have the following meaning.
read - To list the contents of a directory
write- To create new files and sub-directories inside a directory
execute - To enter or change path to the directory
The below command line screenshot displays the significance of read, write and execute permissions on directory named my_files
In the above example even though calypso is the owner of my_files directory, user failed to change directory, list contents of the directory and create a new file. After adding execute permission user could change directory but could not list the contents or create a new file inside my_files directory. By adding read and write permission user can list and create files inside the directory respectively.
chmod -R 700 my_files
tybustelna_Provo Kim Chandler https://wakelet.com/wake/UFE3C9RZODtrGVcHs5ibR
ReplyDeletedielowloudons