Linux with Operating System Concepts



Download 5,65 Mb.
Pdf ko'rish
bet41/254
Sana22.07.2022
Hajmi5,65 Mb.
#840170
1   ...   37   38   39   40   41   42   43   44   ...   254
Bog'liq
Linux-with-Operating-System-Concepts-Fox-Richard-CRC-Press-2014

permissions file(s)
where 
permissions
can be specified using one of three different approaches described below. 
The parameter 
file(s)
is one or more files (or directories). As with the previous file system 
commands, if multiple files are to be altered, you may list them with spaces between their 
names or use wildcards if appropriate.
The first approach for specifying permissions is to describe the changes to be applied as 
a combination of u, g, o along with r, w, x. To add a permission, use 
+
and to remove a per-
mission, use –. Let us assume that we have the file file1.txt, which is currently readable and 
writable by u and g and readable by o. We want to remove writable by group and remove 
readable by other. The command would be
chmod g

w,o

r file1.txt
Notice in this command that there are no spaces within the permission changes itself. 
We see that g is losing w (group is losing writability) and o is losing r (other is losing read-
ability). If instead we wanted to add execute to owner and group, it would be
chmod u 
+
x,g 
+
x file1.txt


Navigating the Linux File System

101
If you want to change a permission on all three of u, g, and o, you can use ‘a’ instead for 
all. For instance, given the original permissions, we want to add execute to everyone. This 
could be done with
chmod a
+
x file1.txt
The second approach to altering permissions uses an 
=
instead of 
+
or –. In this case
you assign new permissions rather than a change to the permissions. For instance, if you 
want to make file1.txt readable, writable, and executable to the user, readable to the group, 
and nothing to the world, this could be done with
chmod u=rwx,g=r,o= file1.txt
In this case, since we want other to have no access, we place no letters after the o
=
. You 
can omit u
=
, g
=
, or o
=
if no change is taking place to that particular party.
Additionally, you can combine 
=

+
, and 

as in
chmod u 
=
rwx,g

w,o

r file1.txt
You can make multiple changes by combining 
+
and 

to any of u, g, and o, as in
chmod u 
=
rwx,g


+
x,o

r file1.txt
The final approach is similar to the 
=
approach in that you are changing all of the per-
missions. In this approach, you replace the letters with a 3-digit number. Each digit is the 
summation of the access rights granted to that party (user, group, other) where readability 
is a 4, writability is a 2, and executability is a 1.
Readability, writability, and executability would be 4 
+

+

=
7. Readability and exe-
cutability would be 4 
+

=
5. No access at all would be 0. Let us assume that we want file1.
txt to have readable, writable, and executable access for the owner, readable, and executable 
access for the group and no access for the world. The command would be
chmod 750 file1.txt
Another way to think of each digit is as a binary number. Assume that a 1 bit means 
“access” and a 0 bit means “no access.” The readability bit comes first followed by the writ-
ability bit followed by the executability bit, or rwx. To provide rwx, this would be 111 
which is binary for 7 (4 
+

+
1). For rw- (i.e., readable and writable but not executable), this 
would be 110 
=
6 (4 
+
2). For r-x (readable and executable), this would be 101 
=
5 (4 
+
1). 
For r-- (read only), this would be 100 
=
4.
The combinations rwx, rw-, r-x, r-- might look familiar to you, as well they should. 
When you do a long listing (
ls -l
), the first 10 characters of a line are a combination 
of letters and hyphens. The first letter denotes the type of file (as we discussed in the find 


102

Linux with Operating System Concepts
command). The remaining nine characters denote the permissions. For instance, 
rwxr-
xr-- 
means that the user has read, write, and execute access, the group has read and exe-
cute access and other has only read access. Figure 3.6 illustrates the grouping of these first 
10 characters. The leading hyphen indicates the file is a regular file (whereas a ‘d’ would 
refer to a directory and an ‘l’ means a symbolic link; we discuss the other types in Chapter 
10). Here, we see a file whose access rights are rwxr-x--x which makes it readable, writable, 
and executable by user, readable and executable by group and executable by world. The 
three-digit value for this item is 751.
While you are free to use any of the three combinations for chmod, the 3-digit approach 
is the least amount of typing. But it does require learning the possible values. See Table 3.8 
File type
(- means
regular file)
u permissions
g permissions
o permissions
- rwx r-x --x
FIGURE 3.6 
Reading permissions.
TABLE 3.8 
Example 3-Digit Permissions

Download 5,65 Mb.

Do'stlaringiz bilan baham:
1   ...   37   38   39   40   41   42   43   44   ...   254




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish