28.09.2018 Views

Linux Dummies 9th

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 6: Getting to Know the <strong>Linux</strong> Filesystem<br />

117<br />

✓ The third character is either an x or a dash. The x stands for execute permission.<br />

If x is set, the triplet allows the entity it stands for to access the<br />

files contained in this directory or to run the particular program in this file.<br />

In all cases, if the dash sits in place of r, w, or x, the triplet doesn’t allow the<br />

entity the read, write, or execute permission.<br />

The following sections describe owners and groups in more detail.<br />

Beware of owners<br />

You may have noticed by now that we talk a great deal about owners (users)<br />

and groups in <strong>Linux</strong>. Every file and directory has both of these components:<br />

a user from the /etc/passwd file that’s assigned as its owner and a group<br />

from the /etc/group that’s assigned as the group.<br />

Although an everyday user probably doesn’t need to change file ownerships<br />

often, the root user does so regularly. If you add the file comments,<br />

for example, to /home/tom while you’re logged on as the superuser (another<br />

term for the Administrator, who is the person who owns the root account),<br />

the root user owns that file. The user tom can’t do anything with it unless the<br />

file’s owner (root) sets the last triplet’s permissions to allow the other folks<br />

(those who aren’t the file’s owner or in the specified group) to read and write<br />

to the file. But this method is a pretty sloppy way of doing things because the<br />

whole idea of permissions is to reduce access, not to give everyone access.<br />

Instead, remember to change the file’s owner to the user tom. You do this<br />

with the chown (change owner) command. For example, by typing chown<br />

mike comments, rich changes the ownership over to mike. Then mike can<br />

work with this file and even change its permissions to something he prefers:<br />

rich@testbox:~$ ls -al comments<br />

-rw-r--r-- 1 rich rich 5 2009-05-16 14:25 comments<br />

rich@testbox:~$ sudo chown mike comments<br />

[sudo] password for rich:<br />

rich@testbox:~$ ls -al comments<br />

-rw-r--r-- 1 mike rich 5 2009-05-16 14:25 comments<br />

rich@testbox:~$<br />

Hanging out in groups<br />

Groups are more interesting to work with than owners. You use groups to<br />

allow the root user to assign multiple users the ability to share certain filesystem<br />

areas. For example, in many versions of <strong>Linux</strong>, all users are added to<br />

a group named users (openSuSE does this, for example). Then rather than a<br />

long-format file listing such as the one shown earlier in this chapter, you may<br />

see the following:

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!