Users
Get root
user
su root OR sudo -s
Show users: less /etc/passwd
kacperbak:x:1000:1000:Kacper Bak,,,:/home/kacperbak:/bin/bash
Show users: less /etc/group
sudo:x:27:kacperbak kacperbak:x:1000:
File modes
User, Group, All
sudo chmod u+x fileName
sudo chmod a+w fileName
sudo chmod g+r fileName
Non privileged user
For security reasons it is very important to run services like a webserver or database as a user with very low privileges. This will prevent the exploitation of security flaws of the service. The following points should be matched for this user:
-
No login shell for this user.
-
Use only a home directory if necessary.
-
Disable the user login.
-
Add to a group with low privileges like
nogroup
.
Create a non privileged user
useradd -g nogroup -N -M -s /bin/false -c "Apache Tomcat" tomcat
Command/Parameter | Description |
---|---|
|
not interactive like |
|
add user to group |
|
do not create a user group with the same name as user, but respect the |
|
no home directory |
|
set a non login shell |
|
a comment about the created user. |
|
username |
Command/Parameter | Description |
---|---|
|
set |
User should be unable to login from login shell
and su tomcat
.
getent passwd tomcat
should result in containing :!:
tomcat:!:17174:0:99999:7:::
-
http://unix.stackexchange.com/questions/96892/what-does-adduser-disabled-login-do
-
Brittain, Darwin - Tomcat The Definitive Guide, Page 4, ISBN 978-0-596-10106-0