paint-brush
YSK #1: chmodby@austin
140 reads

YSK #1: chmod

by Austin PocusMay 7th, 2020
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

Chmod takes an octal number as its first arguments, as in 755 or 600. 4 means read, 2 means write, and 1 means execute. The first digit is you and you alone. The second digit is the group the file belongs to (but that’s another post) The third digit is everyone else. You can use the "R-R" flag to act on a directory and all its files, to make it recursive. Chmod #1: Chmod is a command that controls who can read and write your files (!!)

Company Mentioned

Mention Thumbnail

Coin Mentioned

Mention Thumbnail
featured image - YSK #1: chmod
Austin Pocus HackerNoon profile picture

chmod
changes who can read and write your files (!!) which is probably something you want to keep control over. the basics:

[author's note: the following was pretty much copy-pasted directly from our slack #protips channel. the lack of capitalization is entirely intentional. enjoy!]

chmod
works in octal (as opposed to decimal, binary, hex, etc. it's base 8). 4 means read, 2 means write, and 1 means execute. add together the digits for the behavior you want to get the number you need.

where do you put it though?

chmod
takes an octal number as its first arguments, as in 755 or 600. each digit is computed via the method described above, then each position means something different. the first digit is you and you alone. the second digit is the group the file belongs to (but that’s another post). the third digit is everyone else. mind you,
root
can read everything and ignores all this permissions stuff.

so let’s say you want a file that’s read+write only by you. that means you need a 4 for read, 2 for write, 4+2 = 6 for the “only by you” digit. that goes first. no one else should have any permissions, so that’s 0. so your command would be 

chmod 600 ./path/to/myfile.txt

one last protip: you can use the 

-R
 flag right after 
chmod
 to make it recursive, to act on a directory and all its files.

“keep it secret, keep it safe” 🧙‍♂️ happy hacking!