Hackernoon logoYSK #1: chmod by@austin

YSK #1: chmod

Austin Pocus Hacker Noon profile picture

@austinAustin Pocus

Do not attempt to adjust your set. We are controlling transmission.

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!]

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?

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,
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 

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

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


Join Hacker Noon

Create your free account to unlock your custom reading experience.