Execute (x)<\/strong>: Member can execute any file like shell or bash scripts or access the directory and files<\/li><\/ul>\n\n\n\nThe symbols above placed in the brackets represent the roles and permissions and are used when setting the respective permissions of files and directories. they can be used individually or combined.<\/p>\n\n\n\n
For example, you can target more than one role by combining symbols like this: User+Group (ug), User+Group+Other (ugo), User+Other(uo).<\/p>\n\n\n\n
Similarly, you can do the same with permissions like Read+Write (rw), Read+Execute (rx), Read+Write+Execute (rwx).<\/p>\n\n\n\n
Using Symbolic Notation<\/h2>\n\n\n\n Let’s look at some usage examples starting with the chmod command syntax:<\/p>\n\n\n\n
chmod [PERMISSIONS] [FILE]\u2026<\/code><\/p>\n\n\n\nIn this example you can give the user read and execute permissions:<\/p>\n\n\n\n
$ chmod u+rx filename<\/code><\/pre>\n\n\n\nWhile in this example you can do the same and include the group:<\/p>\n\n\n\n
$ chmod u+rx,g+rx filename<\/code><\/pre>\n\n\n\nor this shortcut option:<\/p>\n\n\n\n
$ chmod ug+rx filename<\/code><\/pre>\n\n\n\nIf you are giving the different roles different permissions then you must separate them with a comma as follows:<\/p>\n\n\n\n
$ chmod u+rwx,g+rx,o+r filename<\/code><\/pre>\n\n\n\nThe above example gives users to read, write, and execute permissions. Group gets read and execute permissions while Other gets read permissions.<\/p>\n\n\n\n
Using Octal Notation<\/h2>\n\n\n\n Using the octal notation you can set permissions using numbers between 0-7. Each number is calculated with the sum of:<\/p>\n\n\n\n
Read (4),<\/li> Write (2)<\/li> Execute (1).<\/li><\/ul>\n\n\n\nFor example, if you set permission 7, it means 4 + 2 + 1 (read + write + execute). If you set permission 5 means 4 + 1 (read + execute) and so on.<\/p>\n\n\n\n
The permissions are set in triplets representing the three roles, user, group, and others in that order. For example if you set permission 755, it means user => 7, group => 5 and other => 5.<\/p>\n\n\n\n
These are the possible combinations for the 0 – 7 in order of least to most restrictive:<\/p>\n\n\n\n
7 – 4+2+1 (rwx) (Read + Write + Execute) 6 – 4+2 (rw-) (Read + Write) 5 – 4+1 (r-x) (Read + Execute) 4 – 4 (r–) (Read) 3 – 2+1 (-wx) (Write + Execute) 2 – 2 (-w-) (Write) 1 – 1 (–x) (Execute) 0 – 0 (—) (None)<\/p>\n\n\n\n
Time for some examples. Here we set the user to read, write, and execute, the Group can read and execute, while Other can read and execute as well. Therefore:<\/p>\n\n\n\n
7 is for User combined with read (4) + write (2) + execute (1)<\/li> 5 is for Group combined with read (4) + execute (1)<\/li> 5 is for Other is combined with read (4) + execute (1)<\/li><\/ul>\n\n\n\nSnippet:<\/p>\n\n\n\n
$ chmod 755 filename<\/code><\/pre>\n\n\n\nHere is another example setting:<\/p>\n\n\n\n
6 is for User combined with read (4) + write (2)<\/li> 4 is for Group is read (4)<\/li> 4 is for Other is read (4)<\/li><\/ul>\n\n\n\n$ chmod 644 filename<\/code><\/pre>\n\n\n\nConclusion on chmod Command<\/h2>\n\n\n\n You now know how to use the chmod command to set file and directory permissions in Linux systems. Careful thought is required when setting permissions as you do not want to give any files more permissions than needed. For example;<\/p>\n\n\n\n
$ chmod 777 filename<\/code><\/pre>\n\n\n\nWhich gives read, write, and execute permission to literally everyone can be dangerous and is therefore not recommended.<\/p>\n","protected":false},"excerpt":{"rendered":"
These simple instructions show you how to manage file permissions using the chmod Command in Linux so as to protect your system from unauthorized access. The chmod command in Linux…<\/p>\n","protected":false},"author":1,"featured_media":9367,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,23,9,16],"tags":[121,183,193,313,354,526,572,573,598],"yoast_head":"\n
How to Manage File Permissions With Linux chmod Command<\/title>\n \n \n \n \n \n \n \n \n \n \n \n \n \n\t \n\t \n\t \n \n \n \n \n \n\t \n\t \n\t \n