This tutorial will introduce the basics of system administration, i.e. configuration and management of users and groups. Here, we will be discussing about viewing system users on Ubuntu. By the end of this tutorial, you will learn about the basic concepts behind user management, monitoring and authentication logging. We will be using Ubuntu 12.04 VPS in this guide.
You can apply this information to other Linux distributions as well, because the fundamentals remain the same.
How to View Available Users on a VPS
All users on Linux systems will be stored in a file known as “/etc/passwd”. This info gets logged into the file on the time of account creation – whether it’s for administrative purposes or for a particular service or a system function.
If you want to have a look at the contents of the “/etc/passwd” file, type in as below:
root:x:0:0:root:/root:/bin/bash daemon:x:1:1:daemon:/usr/sbin:/bin/sh bin:x:2:2:bin:/bin:/bin/sh sys:x:3:3:sys:/dev:/bin/sh sync:x:4:65534:sync:/bin:/bin/sync games:x:5:60:games:/usr/games:/bin/sh . . .
If you examine carefully, you can see that each line describes a distinct user. The line is divided into fields and each field is delimited by a colon (:).
You can tailor this command to view only the user names by typing:
cut -d : -f 1 /etc/passwd
root daemon bin sys sync games . . .
From the above list, you will be able to recognize the administrative users as well as system users. You may see a number of users who will be configured as owners of particular web server processes. This is usually done for separating the functional privileges. In that case, if one account is misused or compromised, its affect will be isolated.
How to View Available Groups on a VPS
As with users in a system, there is a specific file for storing data about system groups. The file name is “/etc/group” and you can view its contents by using:
root:x:0: daemon:x:1: bin:x:2: sys:x:3: adm:x:4: tty:x:5: disk:x:6: . . .
Obviously, you can see many group names to be same as user names that we found earlier in the system. It’s part of a scheme of configuration generally known as ‘user private groups’ or UPG. These user private groups will create a private group for each of the users and will set that group as primary group. The umask will be changed to 002 from 022.
This configuration is quite helpful as it allows flexibility among shared directories. By setting the ‘setgid’ flag, the files inside the directory will be given the same group owner as the directory itself.
Below is the command to view the system group names alone, without corresponding data:
cut -d : -f 1 /etc/group
root daemon bin sys adm tty disk . . .
How to Find Logged In Users
Sometimes, situation arises where you will need to find out the active users on the system. This can be achieved by using ‘w’ command which lists all the logged in users along with their log-in time and command used.
w 19:37:15 up 5:48, 2 users, load average: 0.33, 0.10, 0.07 USER TTY FROM [email protected] IDLE JCPU PCPU WHAT root pts/0 rrcs-72-43-115-1 19:15 38.00s 0.33s 0.33s -bash demoer pts/1 rrcs-72-43-115-1 19:37 0.00s 0.47s 0.00s w
From the above snippet, you can make out the system uptime and logged in users.
Another variation of the command is ‘who’ which will list similar information on the users:
who root pts/0 2013-09-05 19:15 (rrcs-72-43-115-186.nyc.biz.rr.com) demoer pts/1 2013-09-05 19:37 (rrcs-72-43-115-186.nyc.biz.rr.com)
Linux distributions have many ways of authentication and system management. Here we have covered the basics with few simple yet helpful tools.