Table of Contents
Notes on Unix and Linux user admin such as managing users and groups.
Users and Groups
add user to secondary group
# usermod -a -G <GROUP> <USER> # usermod -a -G ftp tony
add new user (Debian only), easy version of
# adduser <USER> <GROUP>
/etc/adduser.conf : Default configuration for new users.
create group (Debian only), easy version of groupadd.
# addgroup <GROUP>
/etc/passwd: contains user’s name and shell.
<UID>: unique # identifying a user. Adduser will generate unique #.
<GID>: group that the user belongs to. Every user belongs to at least one group. To belong to more than 1 group, use ‘/etc/group’.
To disable account without deleting it, prepend * in password field.
In Linux, it might be “!” instead of “*”. Also this can be done via
/etc/shadow: Encrypted user’s passwords. This corresponds exactly to /etc/passwd file.
/etc/group: Contains lists of all the groups and the user that belongs to that group.
<group name>:<password>:<GID>:<users> student:*:300:dkim,dsanders,psam faculty:*:301:bpeterson
<Password>: usually *.
<GID>: group id ie unique group #.
- some groups are reserved for system like root, etc.
- User may belong to more than 1 group.
delgroupcan be used but editing this file is easy.
deluser: Delete user (or userdel on some other system). To disable account, see ‘/etc/passwd’
passwd [user]: Change user’s password. Only root can change other user’s password.
Monitor user activity
/dev/tty*: tty, native terminal device.
/dev/vcs*: virtual console, Linux only.
/dev/pts/*: SSH, Telnet (pseudo terminal slave)
w :find out which tty/vcs/pts I am on.
$ tty /dev/pts/0 $ who vagrant pts/0 2016-03-01 17:03 (10.0.2.2) $ w 18:00:11 up 1:02, 1 user, load average: 0.00, 0.01, 0.01 USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT vagrant pts/0 10.0.2.2 17:03 0.00s 0.06s 0.00s w