This is all thanks to those ***** little numbers and letters that appear next to each file in the terminal.
Don’t Worry! In this guide, we’re going to break it all down for you in a way that won’t make your head spin like a spinning top (or a Linux command).
First things first the different types of permissions. There are three main categories: read (r), write (w), and execute (x). Read allows you to view the contents of a file, write lets you modify it, and execute is used for running programs or scripts.
Now that we know what each permission does, let’s see how they work together in practice. Each file has three sets of permissions one for the owner (the person who created the file), one for the group (a collection of users with similar needs and access levels), and one for everyone else (known as “others”).
To change these permissions, you can use the chmod command. There are two ways to do this absolute mode and symbolic mode. In absolute mode, each permission is represented by a number: r = 4, w = 2, x = 1. So if you want to give read-write access to everyone for a file called “myfile”, you would use the command chmod 666 myfile.
But what about symbolic mode? This is where things get really fun! Instead of using numbers, you can use letters and symbols to represent permissions. For example, u (user), g (group), o (others), + (add permission), (remove permission). So if you want to give read-write access to the owner and group for a file called “myfile”, but only read access to everyone else, you would use the command chmod go-rwx myfile && chmod ug+rw myfile.
Phew! That was quite an adventure, wasn’t it? But now that we understand how Unix file permissions work and how to change them using chmod, we can finally sleep soundly at night knowing our files are safe from prying eyes (or fingers).