Raspberry_Pi_Education_Manual

Notes:

Change access to directories and files

When you use the “-l” switch to see the long list of information a directory’s contents, the results you see are all preceded by a string of letters and dashes. For instance:

-rw-rw-r--. 1 fred students 10919 Apr 2 19:52 brotplot.odt

The first character in the sequence, in this case a dash, tells us what the object is. The most commonly-used characters are:

d Indicates a directory l Indicates a link - Indicates a file

Our example above starts with a dash, so we know it’s a file. In this case, it’s actually a word processor file.

The nine characters that follow, describe access rights for the owner (user), group and the world (everyone else who may be able to access the file), in that order, each with three characters. The characters used here are:

r Read access w Write access x Permission to execute the program - No access of this type

So, if all three groups had all three types of access, we would see “rwxrwxrwx”. However, whenever someone doesn’t have an access type, its letter is replaced with a dash.

If we again look at our example above, we can see that:

l  Brian has read and write access to the file. l  Members of the group called “students” also have read and write access to the file. l  Everyone else (the “world”) has only read access to the file.

The “x” flag is not listed at all. Remember, x stands for the ability to execute a file. If the x flag is not set then the file will not run as a program.

But what if we want to change the file’s permissions? There are various ways to use the “ chmod ” command to do this, but probably the easiest is to use these groups:

u for user/owner g for group o for other (everyone else) a for all three

The Linux Command Line

159

Made with FlippingBook flipbook maker