permissions
Manage who can do what on the system.
users
create user
Either useradd
or adduser
$ sudo adduser -m <name> # create user + home dir
# now it's time to make the user the owner of the home dir,
# and set the right permissions for all files within.
$ chown <user>:<user> -R ~/<user> # recursively change owner
$ chmod 700 /home/<user> # hide dir from other users
$ chsh -s /usr/local/bin/bash <user> # change login shell
or alternatively:
$ sudo adduser -m <user> # does all of the above in a single command except
groups
Groups have combined settings; individual users can be added to groups which then inherit the permissions of the group.
create group
$ groupadd <name>
add user to group
$ sudo usermod -G <group> <user>
$ sudo usermod -a -G docker ec2-user
add hostname to /etc/hosts
Sometime a 'host not found' error pops up. This means that the host is not in the hostfile. This is a common error on remote servers. In order to add the ip, create a mapping such as:
127.0.0.1 localhost # alias localhost to 127.0.0.1
passwords
edit password
# opens interactive session
$ sudo passwd <user>
namespaces
[tbi]
default dir permissions
$ chmod 07555
give specific user permissions for dir
# change owner
$ sudo chmod <username>: <dirname>
# give write permissions
$ sudo chmod u+w <dirname>
# add user to group associated with directory
$ sudo usermod -a -G <groupname> <username>
# give group write permissions
$ sudo chmod g+w <dirname>
Change user
# possibly prepend with "sudo"
$ su - <username>
$ whoami
# => <username>