[{"data":1,"prerenderedAt":944},["ShallowReactive",2],{"guide-chmod-guide":3},{"id":4,"title":5,"body":6,"date":932,"description":933,"extension":934,"meta":935,"navigation":319,"path":939,"readingTime":940,"seo":941,"stem":942,"__hash__":943},"guides\u002Fguides\u002Fchmod-guide.md","Chmod Guide — File Permission Commands Explained",{"type":7,"value":8,"toc":912},"minimark",[9,14,26,32,36,39,62,65,133,144,148,151,154,188,191,196,278,282,384,388,394,398,442,446,483,487,583,586,590,659,663,670,752,757,761,785,789,829,833,876,880,888,892,908],[10,11,13],"h2",{"id":12},"what-is-chmod","What Is chmod?",[15,16,17,18,22,23,25],"p",{},"The ",[19,20,21],"code",{},"chmod"," command changes file access permissions on Linux and Unix-like systems. Short for \"change mode,\" it controls who can read, write, or execute a file. Every file and directory on your system has a permission mode, and ",[19,24,21],{}," is the tool you use to modify it.",[15,27,28,29,31],{},"Without proper permissions, users cannot access files they need — or worse, can access files they should not. Understanding ",[19,30,21],{}," is essential for system administration, deployment, and security.",[10,33,35],{"id":34},"permission-basics","Permission Basics",[15,37,38],{},"Every file has three categories of users who can access it:",[40,41,42,50,56],"ul",{},[43,44,45,49],"li",{},[46,47,48],"strong",{},"Owner"," — the user who created the file",[43,51,52,55],{},[46,53,54],{},"Group"," — users who share the file's group assignment",[43,57,58,61],{},[46,59,60],{},"Others"," — everyone else on the system",[15,63,64],{},"Each category can have three types of access:",[66,67,68,87],"table",{},[69,70,71],"thead",{},[72,73,74,78,81,84],"tr",{},[75,76,77],"th",{},"Permission",[75,79,80],{},"Symbol",[75,82,83],{},"Effect on Files",[75,85,86],{},"Effect on Directories",[88,89,90,105,119],"tbody",{},[72,91,92,96,99,102],{},[93,94,95],"td",{},"Read",[93,97,98],{},"r",[93,100,101],{},"View file contents",[93,103,104],{},"List directory contents",[72,106,107,110,113,116],{},[93,108,109],{},"Write",[93,111,112],{},"w",[93,114,115],{},"Modify file contents",[93,117,118],{},"Add or remove files in directory",[72,120,121,124,127,130],{},[93,122,123],{},"Execute",[93,125,126],{},"x",[93,128,129],{},"Run the file as a program",[93,131,132],{},"Enter the directory (cd into it)",[15,134,135,136,139,140,143],{},"These two concepts combine to form the permission string you see in ",[19,137,138],{},"ls -l"," output, like ",[19,141,142],{},"rwxr-xr-x",".",[10,145,147],{"id":146},"numeric-octal-mode","Numeric (Octal) Mode",[15,149,150],{},"The numeric mode represents permissions as a three-digit octal number. Each digit corresponds to one user category: owner, group, and others.",[15,152,153],{},"The digit is the sum of these values:",[66,155,156,165],{},[69,157,158],{},[72,159,160,162],{},[75,161,77],{},[75,163,164],{},"Value",[88,166,167,174,181],{},[72,168,169,171],{},[93,170,95],{},[93,172,173],{},"4",[72,175,176,178],{},[93,177,109],{},[93,179,180],{},"2",[72,182,183,185],{},[93,184,123],{},[93,186,187],{},"1",[15,189,190],{},"Add the values for the permissions you want to grant. For example, read + write + execute = 4 + 2 + 1 = 7. Read + execute = 4 + 1 = 5.",[192,193,195],"h3",{"id":194},"common-numeric-modes","Common Numeric Modes",[66,197,198,211],{},[69,199,200],{},[72,201,202,205,208],{},[75,203,204],{},"Mode",[75,206,207],{},"Permissions",[75,209,210],{},"Typical Use",[88,212,213,223,234,245,256,267],{},[72,214,215,218,220],{},[93,216,217],{},"755",[93,219,142],{},[93,221,222],{},"Executable scripts, web directories",[72,224,225,228,231],{},[93,226,227],{},"644",[93,229,230],{},"rw-r--r--",[93,232,233],{},"Regular files, documents",[72,235,236,239,242],{},[93,237,238],{},"777",[93,240,241],{},"rwxrwxrwx",[93,243,244],{},"Temporary shared directories (avoid in production)",[72,246,247,250,253],{},[93,248,249],{},"600",[93,251,252],{},"rw-------",[93,254,255],{},"SSH private keys, secret config files",[72,257,258,261,264],{},[93,259,260],{},"700",[93,262,263],{},"rwx------",[93,265,266],{},"User-only directories",[72,268,269,272,275],{},[93,270,271],{},"640",[93,273,274],{},"rw-r-----",[93,276,277],{},"Files shared within a group",[192,279,281],{"id":280},"numeric-examples","Numeric Examples",[283,284,289],"pre",{"className":285,"code":286,"language":287,"meta":288,"style":288},"language-bash shiki shiki-themes github-light github-dark","# Set file to 755 (rwxr-xr-x)\nchmod 755 script.sh\n\n# Set file to 644 (rw-r--r--)\nchmod 644 document.txt\n\n# Set SSH key to 600 (rw-------)\nchmod 600 ~\u002F.ssh\u002Fid_rsa\n\n# Apply to a directory and all contents recursively\nchmod -R 755 \u002Fvar\u002Fwww\u002Fhtml\n","bash","",[19,290,291,300,314,321,327,338,343,349,360,365,371],{"__ignoreMap":288},[292,293,296],"span",{"class":294,"line":295},"line",1,[292,297,299],{"class":298},"sJ8bj","# Set file to 755 (rwxr-xr-x)\n",[292,301,303,306,310],{"class":294,"line":302},2,[292,304,21],{"class":305},"sScJk",[292,307,309],{"class":308},"sj4cs"," 755",[292,311,313],{"class":312},"sZZnC"," script.sh\n",[292,315,317],{"class":294,"line":316},3,[292,318,320],{"emptyLinePlaceholder":319},true,"\n",[292,322,324],{"class":294,"line":323},4,[292,325,326],{"class":298},"# Set file to 644 (rw-r--r--)\n",[292,328,330,332,335],{"class":294,"line":329},5,[292,331,21],{"class":305},[292,333,334],{"class":308}," 644",[292,336,337],{"class":312}," document.txt\n",[292,339,341],{"class":294,"line":340},6,[292,342,320],{"emptyLinePlaceholder":319},[292,344,346],{"class":294,"line":345},7,[292,347,348],{"class":298},"# Set SSH key to 600 (rw-------)\n",[292,350,352,354,357],{"class":294,"line":351},8,[292,353,21],{"class":305},[292,355,356],{"class":308}," 600",[292,358,359],{"class":312}," ~\u002F.ssh\u002Fid_rsa\n",[292,361,363],{"class":294,"line":362},9,[292,364,320],{"emptyLinePlaceholder":319},[292,366,368],{"class":294,"line":367},10,[292,369,370],{"class":298},"# Apply to a directory and all contents recursively\n",[292,372,374,376,379,381],{"class":294,"line":373},11,[292,375,21],{"class":305},[292,377,378],{"class":308}," -R",[292,380,309],{"class":308},[292,382,383],{"class":312}," \u002Fvar\u002Fwww\u002Fhtml\n",[10,385,387],{"id":386},"symbolic-mode","Symbolic Mode",[15,389,390,391,143],{},"Symbolic mode uses letters to specify who gets what permission. The format is ",[19,392,393],{},"who operator permission",[192,395,397],{"id":396},"who-user-classes","Who (User Classes)",[66,399,400,410],{},[69,401,402],{},[72,403,404,407],{},[75,405,406],{},"Letter",[75,408,409],{},"Meaning",[88,411,412,420,427,434],{},[72,413,414,417],{},[93,415,416],{},"u",[93,418,419],{},"Owner (user)",[72,421,422,425],{},[93,423,424],{},"g",[93,426,54],{},[72,428,429,432],{},[93,430,431],{},"o",[93,433,60],{},[72,435,436,439],{},[93,437,438],{},"a",[93,440,441],{},"All (same as ugo)",[192,443,445],{"id":444},"operators","Operators",[66,447,448,457],{},[69,449,450],{},[72,451,452,455],{},[75,453,454],{},"Operator",[75,456,409],{},[88,458,459,467,475],{},[72,460,461,464],{},[93,462,463],{},"+",[93,465,466],{},"Add permission",[72,468,469,472],{},[93,470,471],{},"-",[93,473,474],{},"Remove permission",[72,476,477,480],{},[93,478,479],{},"=",[93,481,482],{},"Set exact permission (removes others)",[192,484,486],{"id":485},"symbolic-examples","Symbolic Examples",[283,488,490],{"className":285,"code":489,"language":287,"meta":288,"style":288},"# Add execute permission for the owner\nchmod u+x script.sh\n\n# Remove write permission for group and others\nchmod go-w document.txt\n\n# Set exact permissions: owner read\u002Fwrite, group read, others nothing\nchmod u=rw,g=r,o= document.txt\n\n# Add read permission for everyone\nchmod a+r readme.md\n\n# Copy group permissions to others\nchmod o=g file.txt\n",[19,491,492,497,506,510,515,524,528,533,542,546,551,561,566,572],{"__ignoreMap":288},[292,493,494],{"class":294,"line":295},[292,495,496],{"class":298},"# Add execute permission for the owner\n",[292,498,499,501,504],{"class":294,"line":302},[292,500,21],{"class":305},[292,502,503],{"class":312}," u+x",[292,505,313],{"class":312},[292,507,508],{"class":294,"line":316},[292,509,320],{"emptyLinePlaceholder":319},[292,511,512],{"class":294,"line":323},[292,513,514],{"class":298},"# Remove write permission for group and others\n",[292,516,517,519,522],{"class":294,"line":329},[292,518,21],{"class":305},[292,520,521],{"class":312}," go-w",[292,523,337],{"class":312},[292,525,526],{"class":294,"line":340},[292,527,320],{"emptyLinePlaceholder":319},[292,529,530],{"class":294,"line":345},[292,531,532],{"class":298},"# Set exact permissions: owner read\u002Fwrite, group read, others nothing\n",[292,534,535,537,540],{"class":294,"line":351},[292,536,21],{"class":305},[292,538,539],{"class":312}," u=rw,g=r,o=",[292,541,337],{"class":312},[292,543,544],{"class":294,"line":362},[292,545,320],{"emptyLinePlaceholder":319},[292,547,548],{"class":294,"line":367},[292,549,550],{"class":298},"# Add read permission for everyone\n",[292,552,553,555,558],{"class":294,"line":373},[292,554,21],{"class":305},[292,556,557],{"class":312}," a+r",[292,559,560],{"class":312}," readme.md\n",[292,562,564],{"class":294,"line":563},12,[292,565,320],{"emptyLinePlaceholder":319},[292,567,569],{"class":294,"line":568},13,[292,570,571],{"class":298},"# Copy group permissions to others\n",[292,573,575,577,580],{"class":294,"line":574},14,[292,576,21],{"class":305},[292,578,579],{"class":312}," o=g",[292,581,582],{"class":312}," file.txt\n",[15,584,585],{},"Symbolic mode is useful when you want to modify specific permissions without recalculating the full numeric value. It also makes your intent clearer in scripts.",[10,587,589],{"id":588},"numeric-vs-symbolic-when-to-use-each","Numeric vs Symbolic: When to Use Each",[66,591,592,605],{},[69,593,594],{},[72,595,596,599,602],{},[75,597,598],{},"Scenario",[75,600,601],{},"Recommended Mode",[75,603,604],{},"Reason",[88,606,607,618,629,639,649],{},[72,608,609,612,615],{},[93,610,611],{},"Setting exact permissions from scratch",[93,613,614],{},"Numeric",[93,616,617],{},"Unambiguous, concise",[72,619,620,623,626],{},[93,621,622],{},"Modifying one permission bit",[93,624,625],{},"Symbolic",[93,627,628],{},"Avoids recalculating full mode",[72,630,631,634,636],{},[93,632,633],{},"Writing deployment scripts",[93,635,614],{},[93,637,638],{},"Reproducible, easy to document",[72,640,641,644,646],{},[93,642,643],{},"Quick one-off adjustments",[93,645,625],{},[93,647,648],{},"Faster mental model",[72,650,651,654,656],{},[93,652,653],{},"Copying permissions from a reference",[93,655,614],{},[93,657,658],{},"Direct mapping to octal",[10,660,662],{"id":661},"recursive-changes","Recursive Changes",[15,664,665,666,669],{},"Use the ",[19,667,668],{},"-R"," flag to apply permissions to a directory and everything inside it. Be careful — a blanket recursive change can break things.",[283,671,673],{"className":285,"code":672,"language":287,"meta":288,"style":288},"# Safe: make directories executable but files read-only for group\u002Fothers\nfind \u002Fvar\u002Fwww -type d -exec chmod 755 {} +\nfind \u002Fvar\u002Fwww -type f -exec chmod 644 {} +\n\n# Dangerous: makes everything world-writable\nchmod -R 777 \u002Fvar\u002Fwww  # Do not do this in production\n",[19,674,675,680,708,729,733,738],{"__ignoreMap":288},[292,676,677],{"class":294,"line":295},[292,678,679],{"class":298},"# Safe: make directories executable but files read-only for group\u002Fothers\n",[292,681,682,685,688,691,694,697,700,702,705],{"class":294,"line":302},[292,683,684],{"class":305},"find",[292,686,687],{"class":312}," \u002Fvar\u002Fwww",[292,689,690],{"class":308}," -type",[292,692,693],{"class":312}," d",[292,695,696],{"class":308}," -exec",[292,698,699],{"class":312}," chmod",[292,701,309],{"class":308},[292,703,704],{"class":312}," {}",[292,706,707],{"class":312}," +\n",[292,709,710,712,714,716,719,721,723,725,727],{"class":294,"line":316},[292,711,684],{"class":305},[292,713,687],{"class":312},[292,715,690],{"class":308},[292,717,718],{"class":312}," f",[292,720,696],{"class":308},[292,722,699],{"class":312},[292,724,334],{"class":308},[292,726,704],{"class":312},[292,728,707],{"class":312},[292,730,731],{"class":294,"line":323},[292,732,320],{"emptyLinePlaceholder":319},[292,734,735],{"class":294,"line":329},[292,736,737],{"class":298},"# Dangerous: makes everything world-writable\n",[292,739,740,742,744,747,749],{"class":294,"line":340},[292,741,21],{"class":305},[292,743,378],{"class":308},[292,745,746],{"class":308}," 777",[292,748,687],{"class":312},[292,750,751],{"class":298},"  # Do not do this in production\n",[15,753,17,754,756],{},[19,755,684],{}," approach is the recommended way to set different permissions for files versus directories.",[10,758,760],{"id":759},"practical-tips","Practical Tips",[40,762,763,766,769,772,779,782],{},[43,764,765],{},"Always set the most restrictive permissions that allow your application to function",[43,767,768],{},"A file must be readable and executable to run as a script",[43,770,771],{},"A directory must be executable for users to enter it, even if they can read its listing",[43,773,774,775,778],{},"Scripts with a shebang line (like ",[19,776,777],{},"#!\u002Fbin\u002Fbash",") need execute permission",[43,780,781],{},"Config files containing secrets should be mode 600, owned by the service account",[43,783,784],{},"Web server document roots typically use 755 for directories and 644 for files",[10,786,788],{"id":787},"common-mistakes","Common Mistakes",[40,790,791,797,813,823],{},[43,792,793,796],{},[46,794,795],{},"Using 777 for convenience",": This grants full access to everyone. It masks permission problems instead of solving them.",[43,798,799,802,803,805,806,809,810,812],{},[46,800,801],{},"Forgetting execute on directories",": Without ",[19,804,126],{},", users cannot ",[19,807,808],{},"cd"," into the directory, even with ",[19,811,98],{}," permission.",[43,814,815,818,819,822],{},[46,816,817],{},"Ignoring umask",": Your umask determines default permissions for new files. Check it with ",[19,820,821],{},"umask"," before relying on defaults.",[43,824,825,828],{},[46,826,827],{},"Recursive 777 on web roots",": Attackers can overwrite any file. Use 755\u002F644 instead.",[10,830,832],{"id":831},"key-takeaways","Key Takeaways",[40,834,835,840,843,856,859,862],{},[43,836,837,839],{},[19,838,21],{}," controls read, write, and execute access for owner, group, and others",[43,841,842],{},"Numeric mode uses octal values: read=4, write=2, execute=1",[43,844,845,846,849,850,849,853],{},"Symbolic mode uses ",[19,847,848],{},"u\u002Fg\u002Fo\u002Fa"," + ",[19,851,852],{},"+\u002F-\u002F=",[19,854,855],{},"r\u002Fw\u002Fx",[43,857,858],{},"Use 755 for executables, 644 for regular files, 600 for secrets",[43,860,861],{},"Always prefer the most restrictive permissions that work",[43,863,864,865,867,868,871,872,875],{},"Use ",[19,866,684],{}," with ",[19,869,870],{},"-type d"," and ",[19,873,874],{},"-type f"," for safe recursive changes",[10,877,879],{"id":878},"try-it-yourself","Try It Yourself",[15,881,882,883,887],{},"Experiment with different permission combinations using our free ",[438,884,886],{"href":885},"\u002Ftools\u002Fchmod-calculator","chmod calculator",". It converts between numeric and symbolic notation in real time, so you can see exactly what each mode does before running the command.",[10,889,891],{"id":890},"related-guides","Related Guides",[40,893,894,901],{},[43,895,896,900],{},[438,897,899],{"href":898},"\u002Fguides\u002Flinux-file-permissions","Linux File Permissions Explained"," — deep dive into the owner\u002Fgroup\u002Fothers model and special permission bits",[43,902,903,907],{},[438,904,906],{"href":905},"\u002Fguides\u002Funix-permissions-reference","Unix Permissions Reference"," — quick reference for format conversion, ACLs, and web server best practices",[909,910,911],"style",{},"html pre.shiki code .sJ8bj, html code.shiki .sJ8bj{--shiki-default:#6A737D;--shiki-dark:#6A737D}html pre.shiki code .sScJk, html code.shiki .sScJk{--shiki-default:#6F42C1;--shiki-dark:#B392F0}html pre.shiki code .sj4cs, html code.shiki .sj4cs{--shiki-default:#005CC5;--shiki-dark:#79B8FF}html pre.shiki code .sZZnC, html code.shiki .sZZnC{--shiki-default:#032F62;--shiki-dark:#9ECBFF}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":288,"searchDepth":302,"depth":302,"links":913},[914,915,916,920,925,926,927,928,929,930,931],{"id":12,"depth":302,"text":13},{"id":34,"depth":302,"text":35},{"id":146,"depth":302,"text":147,"children":917},[918,919],{"id":194,"depth":316,"text":195},{"id":280,"depth":316,"text":281},{"id":386,"depth":302,"text":387,"children":921},[922,923,924],{"id":396,"depth":316,"text":397},{"id":444,"depth":316,"text":445},{"id":485,"depth":316,"text":486},{"id":588,"depth":302,"text":589},{"id":661,"depth":302,"text":662},{"id":759,"depth":302,"text":760},{"id":787,"depth":302,"text":788},{"id":831,"depth":302,"text":832},{"id":878,"depth":302,"text":879},{"id":890,"depth":302,"text":891},"2026-05-28","Complete guide to chmod syntax, numeric modes, and symbolic notation. Learn how to set file permissions on Linux and Unix systems.","md",{"keywords":936},[937,938],"chmod-calculator","chmod-guide","\u002Fguides\u002Fchmod-guide",null,{"title":5,"description":933},"guides\u002Fchmod-guide","OsXcz9leT9Z7iNbwD9w-AK-QA6R2tWB54bGqXdbfryk",1780401328397]