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
- 50 LFX Mentorship
- 103 LFX Mentorship: Linux Kernel
- 575 Linux Foundation IT Professional Programs
- 304 Cloud Engineer IT Professional Program
- 125 Advanced Cloud Engineer IT Professional Program
- 53 DevOps Engineer IT Professional Program
- 60 Cloud Native Developer IT Professional Program
- 5 Express Training Courses
- 5 Express Courses - Discussion Forum
- 2K Training Courses
- 19 LFC110 Class Forum
- 7 LFC131 Class Forum
- 27 LFD102 Class Forum
- 156 LFD103 Class Forum
- 20 LFD121 Class Forum
- 1 LFD137 Class Forum
- 61 LFD201 Class Forum
- 1 LFD210 Class Forum
- LFD210-CN Class Forum
- 1 LFD213 Class Forum - Discontinued
- 128 LFD232 Class Forum
- LFD237 Class Forum
- 23 LFD254 Class Forum
- 611 LFD259 Class Forum
- 105 LFD272 Class Forum
- 1 LFD272-JP クラス フォーラム
- 1 LFD273 Class Forum
- 2 LFS145 Class Forum
- 24 LFS200 Class Forum
- 739 LFS201 Class Forum
- 1 LFS201-JP クラス フォーラム
- 10 LFS203 Class Forum
- 75 LFS207 Class Forum
- 300 LFS211 Class Forum
- 54 LFS216 Class Forum
- 47 LFS241 Class Forum
- 41 LFS242 Class Forum
- 37 LFS243 Class Forum
- 11 LFS244 Class Forum
- 34 LFS250 Class Forum
- 1 LFS250-JP クラス フォーラム
- LFS251 Class Forum
- 140 LFS253 Class Forum
- LFS254 Class Forum
- 1.1K LFS258 Class Forum
- 10 LFS258-JP クラス フォーラム
- 93 LFS260 Class Forum
- 132 LFS261 Class Forum
- 33 LFS262 Class Forum
- 80 LFS263 Class Forum
- 15 LFS264 Class Forum
- 11 LFS266 Class Forum
- 18 LFS267 Class Forum
- 17 LFS268 Class Forum
- 23 LFS269 Class Forum
- 203 LFS272 Class Forum
- 1 LFS272-JP クラス フォーラム
- LFS274 Class Forum
- LFS281 Class Forum
- 233 LFW211 Class Forum
- 172 LFW212 Class Forum
- 7 SKF100 Class Forum
- SKF200 Class Forum
- 902 Hardware
- 219 Drivers
- 74 I/O Devices
- 44 Monitors
- 115 Multimedia
- 209 Networking
- 101 Printers & Scanners
- 85 Storage
- 763 Linux Distributions
- 88 Debian
- 66 Fedora
- 15 Linux Mint
- 13 Mageia
- 24 openSUSE
- 142 Red Hat Enterprise
- 33 Slackware
- 13 SUSE Enterprise
- 357 Ubuntu
- 479 Linux System Administration
- 41 Cloud Computing
- 70 Command Line/Scripting
- Github systems admin projects
- 95 Linux Security
- 78 Network Management
- 108 System Management
- 49 Web Management
- 68 Mobile Computing
- 23 Android
- 30 Development
- 1.2K New to Linux
- 1.1K Getting Started with Linux
- 537 Off Topic
- 131 Introductions
- 217 Small Talk
- 21 Study Material
- 826 Programming and Development
- 278 Kernel Development
- 514 Software Development
- 928 Software
- 260 Applications
- 184 Command Line
- 3 Compiling/Installing
- 76 Games
- 316 Installation
- 62 All In Program
- 62 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)