-
Notifications
You must be signed in to change notification settings - Fork 0
Users and permissions
Austin Kong edited this page Apr 14, 2019
·
5 revisions
$ adduser username
$ sudo groupadd --system webapps
$ sudo useradd --system --gid webapps --home-dir /home/webapp1 webapp1
$ sudo usermod -aG group user
Add user to sudo
ers group
$ usermod -aG sudo username
Switch accounts to new user
$ su - username
$ deluser newuser
$ id
$ groups
0 No permission ---
1 Execute permission --x
2 Write permission -w-
3 Execute and write permission: 1 (execute) + 2 (write) = 3 -wx
4 Read permission r--
5 Read and execute permission: 4 (read) + 1 (execute) = 5 r-x
6 Read and write permission: 4 (read) + 2 (write) = 6 rw-
7 All permissions: 4 (read) + 2 (write) + 1 (execute) = 7 rwx
Change file permission
chmod [ugo][+-=][rwxs] file
Set files to inherit group membership as set. Source. More reading.
chmod g+s dir
Change ownership of a directory/file
sudo chown -R user/scratch
Change group of file
chown :friends file
chgrp friends file
Change user and group
chown user:friends file
Show/set default file permissions
umask -S # Show symbolically
umask 0027 #u=rwx,g=rx
umask 0077 #u=rwx
This is a collection of tips and reminders for me on how to do things. What is documented here is derived from personal experience and from all over the web (some instruction or information has been copied verbatim). Original sources are provided for some of them. I have built these up over time so it has not been documented properly until now.