Posted under » Ubuntu on 1 October 2015
One of the most basic tasks to that you should know how to do on a fresh Linux server is add and remove users.
When you create a new server, you are only given the root account by default. While this gives you a lot of power and flexibility, it is also dangerous. Effective user management will allow you to separate users and give them only the access that they are required to do their job.
It is good to add an additional, unprivileged user to do common tasks. You also should create additional accounts for any other users you may have on your system. Each user should have a different account.
You can still acquire administrator privileges when you need them through SUDO.
Before adding, check and list all users
cut -d: -f1 /etc/passwd
If you are the root user, you can create a new user at any time by typing:
adduser gohcoktoong or useradd gohcoktoong
You will be asked a series of questions.
To delete the user itself, without deleting any of his files by typing this as root:
deluser newuser
If you want to delete the user's home directory when the user is deleted,
deluser --remove-home newuser
If your new user should have the ability to execute commands with root (administrative) privileges, you will need to give the new user access to sudo.
usermod -aG sudo gohcoktoong
Use the su command to switch to the new user account
su - gohcoktoong
It is good to change the password once in a while
passwd username
You can check login of sudo via "/var/log/auth.log"
older copies look like
/var/log/auth.log.0
/var/log/auth.log.1.gz
/var/log/auth.log.2.gz
You can also look at "/var/log/syslog" for anything suspicious.