-
It seems that we can overwrite the contents of the file whose permission is
000(no read, write, execute perm for user, group, or others) withsudocommand and can the delete the file withoutsudo(because we are the user who owns that file). -
chmodcan be done withoutsudoif the file is owned by you. -
chmodugo-x, g+x, o-rand so on are sometimes more simpler to use than the octal numbers like666,776,770` etc. -
adduseris more friendly thanuseraddas it asks for the password for the new user, it creates new user's home dir and copies some basic files (from/etc/skellike.bashrc) into the new user's home dir. All of these is done without any option toadduser. However, ifuseraddis not given any option, then it will just create the new user and the group related to that user and add that user to that newly created group. It will not create home dir, not ask for password, and not copy files from/etc/skel. -
By default, the new user (who is not the first user of the system) will not be added to the
sudogroup. This can be verified bysudo su newuserfollowed bygroups. That is, changing to the new user and then listing their groups. As such, when the newuser tries to dosudothen such incident will be reported, and an entry will be placed under/var/log/auth.logas every instance of sudo (whether or not the user has permission for it) is recorder in that file. We can see one such result bygrep -a "NOT" /var/log/auth.log | grep sudo | grep fredwhere fred is the new user.
Sep 23 12:49:05 Ariana sudo: fred : user NOT in sudoers ; TTY=pts/0 ; PWD=/home/fred ; USER=root ; COMMAND=/usr/bin/less /var/log/auth.log-
We will have to add fred to sudo group using our main user account haiji like this -
sudo usermod -a -G sudo fred. -
Then we can switch to user fred again (
sudo su fred)(This will ask for haiji's password, ofcourse) and then see the list of groups for which fred is a member bygroups. -
Notice also that fred cannot read
/var/log/auth.logunless they are added to the group adm or prefix it withsudo. haiji can read it without prefixingsudo.
A new user fred has been added to Ariana and they are a member of groups fred and sudo (not adm).
I don't see a difference if the perm is -r--r----- or -rw-r----- I can always overwrite the file with :w! in vim. Since I can read the file as well therefore the previous content doesn't get lost. This is in contrast to permission 000 where the previous content would get lost if we try to write a file forcefully with :w! in vim (because we could not read the contents too).
Please tell me where I am wrong in this interpretation?
Yes, but this is a special feature of vim - and even in that case a simple :w will fail with an error message (prompting you that you can use "!") - AND this only works because as owner of the file, you have "the permission to override permissions" in this case. Thanks for the question - I've updated the notes based on this feedback)
