Beruflich Dokumente
Kultur Dokumente
ACCESS
GRANTED!
Marquis, www.photocase.com
A sophisticated system of users and permissions precisely
line, you can define ownership with the chmod, chgrp, and
G
ranular access privileges for files for more granular permission assign- • Execute permission: For programs, ex-
and directories are what make ments to files. ecute permission means that the user
Linux a safe operating system. is permitted to run the program. Exe-
A precise definition of who is permitted Rights and Obligations cute for a directory means that the
to read, modify data, or execute specific For every file (and thus for directories,
programs provides excellent protection device files, and so on), Linux precisely Table 1: Permissions
against any prying eyes and intentional defines who is permitted to read, write, Overview
misconfiguration. and execute that file. Additionally, every
Octal number Letters
The administrator, root, is subject to file belongs to a user and to a group.
0 ---
no restrictions, and this includes assign- The three permissions are assigned sepa-
1 --x
ing read, write, and execute permissions rately for these three categories and for
2 -w-
to other users throughout the system. If users who do not belong to any of the
3 (= 2+1) -wx
you are the owner of a file or directory, three categories:
4 r--
you can grant access to these resources • Read permission: Users can display
5 (= 4+1) r-x
to other accounts. If you are also a mem- the content of a file or folder on
6 (= 4+2) rw-
ber of a specific group, you can modify screen, copy the file, and do a few
7 (= 4+2+1) rwx
the group ownership of files and folders other things.
The chmod program also understands Let’s imagine you just set up a new ac- The use of find can help you avoid
letters. When you run the tool, you can count called mike, and you’ve set up a this kind of dilemma:
pass in three- or four-digit octal numbers home directory for Mike and copied criti-
instead of letters. cal configuration files from /etc/skel. find directory -type f -exec
You can calculate the numbers as fol- Your last step would be to give Mike chmod a-x "{}" ";"
lows: 4 stands for read permission, 2 for the permissions he needs to set up shop
write permission, and 1 for execute per- and use his home directory and the sub- The find command first discovers the
mission. The first number refers to the directories below it. files (-type f) and then runs chmod
owner, the second number to the group, The following command hands over against them, ignoring the directory.
and the third to all others. the home directory and all the files in
On this basis, you can see that, for it (including the hidden configuration From the Beginning
example, 644 would mean u=rw,go=r files) to the user mike: The umask specifies the default permis-
(resulting in rw-r--r--), or 777 would be sions assigned to newly created files and
a=rwx (resulting in rwxrwxrwx). The chown -R mike /home/mike directories. Typing the umask command
“Permissions Overview” table provides without setting any parameters reveals
more details. The -R option used here tells chown to the current setting:
To set the s or t bit, you need to add act recursively (this will be explained
this as a fourth number at the start of more later). It is also useful to be able to $ umask
the block of three. define a new group owner for the data at 0022
The number 4 represents the s bit for the same time:
the owner (setuid), 2 sets the s bit for What you see here is a four-digit octal
the group (setgid), and 1 sets the t bit. chown -R mike:mike /home/mike number that specifies what to subtract
Listing 1 gives an example. from the the default values (0666 for
In other words, you just append the files, 0777 for directories). In other
Changing Group group name (some distributions have a words, new files are assigned 0644
Memberships default group called users, whereas other (rw-r--r--), and new folders are assigned
As a “normal” user, you are allowed to distributions use the account name as 0755 (rwxr-xr-x) when they are created.
assign your own files to specific groups; the default group), with a colon to sepa- To change the umask, enter the file and
however, this assumes that you are a rate it from the account name. the new value at the command line:
member of the group in question. The
following command tells you your own Across the Board umask 0077
group memberships: All three tools – chmod, chgrp, and
chown – support an -R parameter for re- This entry means that new files and
$ groups cursive actions. For example, if you want directories are only available to their
huhn dialout cdrom U to permit the members of the video owner. The umask is valid for the cur-
floppy audio group to access a directory and the files rent shell, but you can add an entry to
video it contains, just type: your bash configuration file ~/.bashrc
to make the change permanent. Working
To assign a file to the audio group, you chgrp -R video directory as root, you also could add a global
just type: entry to /etc/profile to modify the umask
The -R option can also save you much for the system. ■
chgrp audio Datei typing when used in combination with
the chmod command. INFO
Changing Owners To remove read, write, and execute
[1] Octal numbers:
and Groups permissions from this folder for all users
http://en.wikipedia.org/wiki/Octal
On a Linux system, the system adminis- who are not the owner or members of
trator is allowed to assign new owners the video group, just type:
and new groups to files and directories. Heike Jurzik studied
chmod -R o-rwx directory German, Computer
Science and English
Listing 1: Example
THE AUTHOR