{"id":1649,"date":"2024-03-02T00:00:00","date_gmt":"2024-03-02T05:00:00","guid":{"rendered":"https:\/\/molecularsciences.org\/content\/?p=1649"},"modified":"2024-03-10T00:00:53","modified_gmt":"2024-03-10T05:00:53","slug":"chmod-cheat-sheet","status":"publish","type":"post","link":"https:\/\/molecularsciences.org\/content\/chmod-cheat-sheet\/","title":{"rendered":"chmod Cheat Sheet"},"content":{"rendered":"\n<p>The <code>chmod<\/code> command in Unix-like operating systems is used to change the permissions of a file or directory. This cheat sheet covers essential <code>chmod<\/code> commands for managing file and directory permissions.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Introduction:<\/strong><\/h4>\n\n\n\n<p><code>chmod<\/code> is a command-line utility that allows users to change the permissions of files and directories on Unix-based systems. It uses a symbolic or octal notation to specify permission settings.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Basic Commands:<\/strong><\/h4>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Command<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td><code>chmod [permissions] [file\/directory]<\/code><\/td><td>Change permissions using symbolic notation.<\/td><\/tr><tr><td><code>chmod [octal_permissions] [file\/directory]<\/code><\/td><td>Change permissions using octal notation.<\/td><\/tr><tr><td><code>chmod +[permission] [file\/directory]<\/code><\/td><td>Add a specific permission.<\/td><\/tr><tr><td><code>chmod -[permission] [file\/directory]<\/code><\/td><td>Remove a specific permission.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Symbolic Notation:<\/strong><\/h4>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Symbol<\/th><th>Permission<\/th><\/tr><\/thead><tbody><tr><td><code>u<\/code><\/td><td>User\/Owner<\/td><\/tr><tr><td><code>g<\/code><\/td><td>Group<\/td><\/tr><tr><td><code>o<\/code><\/td><td>Others<\/td><\/tr><tr><td><code>a<\/code><\/td><td>All (u+g+o)<\/td><\/tr><tr><td><code>r<\/code><\/td><td>Read<\/td><\/tr><tr><td><code>w<\/code><\/td><td>Write<\/td><\/tr><tr><td><code>x<\/code><\/td><td>Execute<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Examples &#8211; Symbolic Notation:<\/strong><\/h4>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Command<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td><code>chmod u+r file.txt<\/code><\/td><td>Add read permission for the owner.<\/td><\/tr><tr><td><code>chmod go-w directory\/<\/code><\/td><td>Remove write permission for group and others.<\/td><\/tr><tr><td><code>chmod a+x script.sh<\/code><\/td><td>Add execute permission for all users.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Octal Notation:<\/strong><\/h4>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Octal<\/th><th>Permission<\/th><\/tr><\/thead><tbody><tr><td><code>4<\/code><\/td><td>Read<\/td><\/tr><tr><td><code>2<\/code><\/td><td>Write<\/td><\/tr><tr><td><code>1<\/code><\/td><td>Execute<\/td><\/tr><tr><td><code>0<\/code><\/td><td>No Permission<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Examples &#8211; Octal Notation:<\/strong><\/h4>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Command<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td><code>chmod 644 file.txt<\/code><\/td><td>Give read and write permission to the owner and read-only permission to others.<\/td><\/tr><tr><td><code>chmod 755 script.sh<\/code><\/td><td>Give read, write, and execute permission to the owner, and read\/execute permission to group and others.<\/td><\/tr><tr><td><code>chmod 600 sensitive_file.txt<\/code><\/td><td>Restrict permissions to read and write only for the owner.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Recursive Changes:<\/strong><\/h4>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Command<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td><code>chmod -R [permissions] [directory]<\/code><\/td><td>Recursively change permissions for a directory and its contents.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Special Permissions:<\/strong><\/h4>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Command<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td><code>chmod +s executable<\/code><\/td><td>Set the setuid\/setgid bit.<\/td><\/tr><tr><td><code>chmod +t directory<\/code><\/td><td>Set the sticky bit.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Miscellaneous:<\/strong><\/h4>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Command<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td><code>chmod --reference=[reference_file] [file\/directory]<\/code><\/td><td>Copy permissions from a reference file.<\/td><\/tr><tr><td><code>chmod --version<\/code><\/td><td>Display the <code>chmod<\/code> version information.<\/td><\/tr><tr><td><code>chmod --help<\/code><\/td><td>Display help and usage information for <code>chmod<\/code>.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Conclusion<\/h3>\n\n\n\n<p>The <code>chmod<\/code> command is a powerful tool for managing file and directory permissions on Unix-based systems. This cheat sheet provides essential commands using both symbolic and octal notation, covering basic permissions, recursive changes, special permissions, and more. Whether you are a regular user or a system administrator, understanding these <code>chmod<\/code> commands will help you control access to files and directories effectively.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The chmod command in Unix-like operating systems is used to change the permissions of a file or directory. This cheat sheet covers essential chmod commands for managing file and directory permissions. Introduction: chmod is a command-line utility that allows users to change the permissions of files and directories on Unix-based systems. It uses a symbolic [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1808,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[34,265],"tags":[35],"class_list":["post-1649","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux","category-reference","tag-linux"],"_links":{"self":[{"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/posts\/1649","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/comments?post=1649"}],"version-history":[{"count":1,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/posts\/1649\/revisions"}],"predecessor-version":[{"id":1650,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/posts\/1649\/revisions\/1650"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/media\/1808"}],"wp:attachment":[{"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/media?parent=1649"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/categories?post=1649"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/tags?post=1649"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}