LFS201 - Lab 32.1. Using chmod - incorrect instructions?
LFS201 - Lab 32.1. Using chmod
Here the original text:
One can use either the octal digit or symbolic methods for specifying permissions when using
chmod. Let’s elaborate some more on the symbolic method.
It is possible to either give permissions directly, or add or subtract permissions. The syntax is pretty obvious. Try the following
examples:
$ chmod u=r,g=w,o=x afile
$ chmod u=+w,g=-w,o=+rw afile
$ chmod ug=rwx,o=-rw afile
Unfortunately u=+... or u=-... etc. don't work as expected, neither on Ubuntu nor on Centos.
What works is this:
chmod u+w,g-w,o+rw
that is without the "=".
The quiz at the end of Chapter 32 is correct.
Here the proof:
heiko@LM20-heiko:~$ ll file -rw-r--r-- 1 heiko heiko 0 Jul 19 13:41 file heiko@LM20-heiko:~$ chmod g=+w file heiko@LM20-heiko:~$ ll file -rw--w-r-- 1 heiko heiko 0 Jul 19 13:41 file heiko@LM20-heiko:~$ chmod 644 file heiko@LM20-heiko:~$ ll file -rw-r--r-- 1 heiko heiko 0 Jul 19 13:41 file heiko@LM20-heiko:~$ chmod g+w file heiko@LM20-heiko:~$ ll file -rw-rw-r-- 1 heiko heiko 0 Jul 19 13:41 file heiko@LM20-heiko:~$
Comments
-
Hi @heiko_s ,
I think it works, but the logic is kind of weird. So, when we say u=+something, it adds it up. When we say u=-something, it removes everything, at least we specify other permissions with +something for user in this case. The same applies to "g" and "o".
Try to apply these rules to the following examples:
luis@ubuntu18server:~$ touch afile
luis@ubuntu18server:~$ chmod 777 afile
luis@ubuntu18server:~$ ls -l afile
-rwxrwxrwx 1 luis luis 0 Kun 19 17:11 afile
luis@ubuntu18server:~$ chmod u=+w,g=-w,o=+rw afile
luis@ubuntu18server:~$ ls -l afile
--w----rw- 1 luis luis 0 Kun 19 17:11 afile
luis@ubuntu18server:~$ chmod 000 afile
luis@ubuntu18server:~$ ls -l afile
---------- 1 luis luis 0 Kun 19 17:11 afile
luis@ubuntu18server:~$ chmod u=+rwx,g=+r,o=+r afile
luis@ubuntu18server:~$ ls -l afile
-rwxr--r-- 1 luis luis 0 Kun 19 17:11 afile
luis@ubuntu18server:~$ chmod 777 afile
luis@ubuntu18server:~$ ls -l afile
-rwxrwxrwx 1 luis luis 0 Kun 19 17:11 afile
luis@ubuntu18server:~$ chmod u=-x,g=+rwx,o=rwx afile
luis@ubuntu18server:~$ ls -l afile
----rwxrwx 1 luis luis 0 Kun 19 17:11 afile
luis@ubuntu18server:~$ chmod 777 afile
luis@ubuntu18server:~$ chmod u=+r+w-x,g=+rwx,o=rwx afile
luis@ubuntu18server:~$ ls -l afile
-rw-rwxrwx 1 luis luis 0 Kun 19 17:11 afileMany regards,
Luis.0 -
Sorry to say, but this forum software sucks! I have replied in detail and the entire post seems lost now that I tried to edit it.
So I make my reply short:
According to the chmod man page, you are NOT supposed to use =, - and + together, but either one of it [=-+].
and - should add or subtract the permission(s). Here is the relevant part from the man page:
The format of a symbolic mode is [ugoa...][[-+=][perms...]...], where
perms is either zero or more letters from the set rwxXst, or a single
letter from the set ugo. Multiple symbolic modes can be given, sepa‐
rated by commas.A combination of the letters ugoa controls which users' access to the
file will be changed: the user who owns it (u), other users in the
file's group (g), other users not in the file's group (o), or all users
(a). If none of these are given, the effect is as if (a) were given,
but bits that are set in the umask are not affected.The operator + causes the selected file mode bits to be added to the
existing file mode bits of each file; - causes them to be removed; and
= causes them to be added and causes unmentioned bits to be removed ex‐
cept that a directory's unmentioned set user and group ID bits are not
affected.
To use your example, the correct way to do it is this:
heiko@LM20-heiko:~$ chmod u=w,g=,o=rw file heiko@LM20-heiko:~$ ll file --w----rw- 1 heiko heiko 0 Jul 19 13:41 file
"=+" and "=-" should NOT be used! If one wants to use "+" and "-" to add or subtract permissions, then here is the way to do it:
heiko@LM20-heiko:~$ chmod 777 file heiko@LM20-heiko:~$ ll file -rwxrwxrwx 1 heiko heiko 0 Jul 19 13:41 file* heiko@LM20-heiko:~$ chmod u+w,g-w,o+rw file heiko@LM20-heiko:~$ ll file -rwxr-xrwx 1 heiko heiko 0 Jul 19 13:41 file*
At least that's how I read the man page and how it works on the command line.
0 -
Luis is pointing out to you things you already know as best I can tell and let me address what you said directly.
You are right in some sense and but in another sense you are reading too much into the wording, more than was intended . In your post you say:
"Unfortunately u=+... or u=-... etc. don't work as expected, neither on Ubuntu nor on Centos.
What works is this: ...."The problem is with the phrase "as expected" by which you mean "as I expected". There is nothing in the lab that indicates the = sign should not perform as it actually does. The purpose of the exercise is to try different things and see what happens, and voila you learned something. I suppose the lab should not say "The syntax is pretty obvious" as that is the source of the confusion and we will eliminate it in the next version. So thanks for pointing this out. I'm always amazed when someone raises something about a phrasing that has been there for a number of years, and has never caused confusion before. Keeps us on our toes.
As to the forums software suck, the only time I have ever seen a complaint is when someone tried to keep composing for a time that exceeded some built in time limit we have never run into (15 minutes perhaps) as no one apparently as ever tried to edit that long in the years we have had this running. I suggest that if you need to craft some thing over a longer time period (if that is what occurred) you work in an external editor and then paste it in when done. Also note the "save draft" button as that probably will work to make sure things don't get lost. I suppose there is no "autosave" feature (I don't know).
For email I never ever write a long post in an online platform unless drafts are being saved. For this reason.
If you were editing and the forum went down or something, that's a different matter. I would hope drafts would get saved but I've never tested it.
0 -
Thanks coop. Of course I meant "I expected...". It was surely a learning exercise, and that is what I'm here for.
The forum software is not too intuitive. Not sure why there is a 15 minutes edit limit. I'm using frequently and infrequently several dozen different forums. Posting code is where many forums struggle.
This forum software is quite different from what I'm used to on, for example Ubuntu forum, Manjaro, Linux Mint, bugs launchpad, etc. Limitations of forum software have led me to run my own private website to share some stuff. Mine is far from being perfect, either .
In fact, my only problems with this forum is when editing stuff and the 15 minutes grace period.0
Categories
- All Categories
- 219 LFX Mentorship
- 219 LFX Mentorship: Linux Kernel
- 793 Linux Foundation IT Professional Programs
- 354 Cloud Engineer IT Professional Program
- 179 Advanced Cloud Engineer IT Professional Program
- 82 DevOps Engineer IT Professional Program
- 147 Cloud Native Developer IT Professional Program
- 137 Express Training Courses
- 137 Express Courses - Discussion Forum
- 6.2K Training Courses
- 47 LFC110 Class Forum - Discontinued
- 71 LFC131 Class Forum
- 42 LFD102 Class Forum
- 227 LFD103 Class Forum
- 19 LFD110 Class Forum
- 38 LFD121 Class Forum
- 18 LFD133 Class Forum
- 7 LFD134 Class Forum
- 18 LFD137 Class Forum
- 71 LFD201 Class Forum
- 5 LFD210 Class Forum
- 5 LFD210-CN Class Forum
- 2 LFD213 Class Forum - Discontinued
- 128 LFD232 Class Forum - Discontinued
- 2 LFD233 Class Forum
- 4 LFD237 Class Forum
- 24 LFD254 Class Forum
- 697 LFD259 Class Forum
- 111 LFD272 Class Forum
- 4 LFD272-JP クラス フォーラム
- 12 LFD273 Class Forum
- 149 LFS101 Class Forum
- 1 LFS111 Class Forum
- 3 LFS112 Class Forum
- 2 LFS116 Class Forum
- 4 LFS118 Class Forum
- LFS120 Class Forum
- 7 LFS142 Class Forum
- 5 LFS144 Class Forum
- 4 LFS145 Class Forum
- 3 LFS146 Class Forum
- 3 LFS147 Class Forum
- 1 LFS148 Class Forum
- 15 LFS151 Class Forum
- 2 LFS157 Class Forum
- 30 LFS158 Class Forum
- 7 LFS162 Class Forum
- 2 LFS166 Class Forum
- 4 LFS167 Class Forum
- 3 LFS170 Class Forum
- 2 LFS171 Class Forum
- 3 LFS178 Class Forum
- 3 LFS180 Class Forum
- 2 LFS182 Class Forum
- 5 LFS183 Class Forum
- 32 LFS200 Class Forum
- 737 LFS201 Class Forum - Discontinued
- 3 LFS201-JP クラス フォーラム
- 18 LFS203 Class Forum
- 134 LFS207 Class Forum
- 2 LFS207-DE-Klassenforum
- 1 LFS207-JP クラス フォーラム
- 302 LFS211 Class Forum
- 56 LFS216 Class Forum
- 52 LFS241 Class Forum
- 48 LFS242 Class Forum
- 38 LFS243 Class Forum
- 15 LFS244 Class Forum
- 2 LFS245 Class Forum
- LFS246 Class Forum
- 49 LFS250 Class Forum
- 2 LFS250-JP クラス フォーラム
- 1 LFS251 Class Forum
- 153 LFS253 Class Forum
- 1 LFS254 Class Forum
- 1 LFS255 Class Forum
- 9 LFS256 Class Forum
- 1 LFS257 Class Forum
- 1.3K LFS258 Class Forum
- 10 LFS258-JP クラス フォーラム
- 119 LFS260 Class Forum
- 159 LFS261 Class Forum
- 42 LFS262 Class Forum
- 82 LFS263 Class Forum - Discontinued
- 15 LFS264 Class Forum - Discontinued
- 11 LFS266 Class Forum - Discontinued
- 24 LFS267 Class Forum
- 24 LFS268 Class Forum
- 30 LFS269 Class Forum
- LFS270 Class Forum
- 202 LFS272 Class Forum
- 2 LFS272-JP クラス フォーラム
- 1 LFS274 Class Forum
- 4 LFS281 Class Forum
- 9 LFW111 Class Forum
- 259 LFW211 Class Forum
- 181 LFW212 Class Forum
- 13 SKF100 Class Forum
- 1 SKF200 Class Forum
- 1 SKF201 Class Forum
- 796 Hardware
- 199 Drivers
- 68 I/O Devices
- 37 Monitors
- 103 Multimedia
- 174 Networking
- 91 Printers & Scanners
- 85 Storage
- 758 Linux Distributions
- 82 Debian
- 67 Fedora
- 17 Linux Mint
- 13 Mageia
- 23 openSUSE
- 148 Red Hat Enterprise
- 31 Slackware
- 13 SUSE Enterprise
- 353 Ubuntu
- 468 Linux System Administration
- 39 Cloud Computing
- 71 Command Line/Scripting
- Github systems admin projects
- 93 Linux Security
- 78 Network Management
- 102 System Management
- 47 Web Management
- 63 Mobile Computing
- 18 Android
- 33 Development
- 1.2K New to Linux
- 1K Getting Started with Linux
- 371 Off Topic
- 114 Introductions
- 174 Small Talk
- 22 Study Material
- 805 Programming and Development
- 303 Kernel Development
- 484 Software Development
- 1.8K Software
- 263 Applications
- 183 Command Line
- 3 Compiling/Installing
- 987 Games
- 317 Installation
- 97 All In Program
- 97 All In Forum
Upcoming Training
-
August 20, 2018
Kubernetes Administration (LFS458)
-
August 20, 2018
Linux System Administration (LFS301)
-
August 27, 2018
Open Source Virtualization (LFS462)
-
August 27, 2018
Linux Kernel Debugging and Security (LFD440)