
16.12 Ownership and Permissions 245
That was one demonstration of Linux’s security features. Linux, like UNIX, is a multi-user system,
and file permissions are one way the system uses to protect against any type of tampering – malicious
or accidental.
One way to gain entry when we see we’re denied permission is to su to root, as we learned earlier.
That’s because whoever knows the root password has complete access.
[billy@localhost billy]$ su root
Password: (your root password)
[root@localhost billy]# cd /root
[root@localhost /root]#
But switching to superuser isn’talwaysconvenient– or smart, since it’s so easy to mistakenly mess
up important configuration files.
All files and directories are “owned” by the person who created them. We created the file sneak-
ers.txt in our login directory, so sneakers.txt “belongs” to us.
That means, we can specify who’sallowedtoreadthefile, write to the file or, if it were an application
instead of a text file, who can execute the file.
Reading, writing and executing are the three main settings in permissions.
Since every user on the system is placed into a group when that user is created, then we can also
specify whether certain groups can read, write to, or execute our file.
Let’s take a closer look at sneakers.txt with the ls command using the -l (long) option (see
Figure 16.16).
[billy@localhost billy]$ ls -l sneakers.txt
-rw-rw-r-- 1 billy billy 150 Mar 19 08:08 sneakers.txt
There’s quite a bit of detail here. We can see who can read (r)andwriteto(w)thefile,aswellaswho
created the file (billy) and to which group the owner belongs (billy).
Tip: Remember that, by default, your group was the login name you chose.
Other information to the right of the group includes the file name, date and time of its creation as
well as size.
How do all those dashes and letters fittogether?It’s not as hard to read as it might seem. Let’s take
a look:
-rw-rw-r--
Komentarze do niniejszej Instrukcji