/etc/passwd



sudo -i
tail /etc/passwd


lightdm:x:111:114:Light Display Manager:/var/lib/lightdm:/bin/false
pulse:x:112:115:PulseAudio daemon,,,:/var/run/pulse:/bin/false
avahi:x:113:118:Avahi mDNS daemon,,,:/var/run/avahi-daemon:/bin/false
colord:x:114:119:colord colour management daemon,,,:/var/lib/colord:/bin/false
saned:x:115:120::/var/lib/saned:/bin/false
hplip:x:116:7:HPLIP system user,,,:/var/run/hplip:/bin/false
kl:x:1000:1000:kl,,,:/home/kl:/bin/bash
geoclue:x:117:121::/var/lib/geoclue:/bin/false
libvirt-qemu:x:64055:123:Libvirt Qemu,,,:/var/lib/libvirt:/bin/false
Debian-exim:x:118:122::/var/spool/exim4:/bin/false


Fields
1. username
2. password, move to /etc/shadow
3. user ID
4. group ID
5. user info (email, phone etc.)
6. home directory
7. default shell

# Show number of users (service + created)
cat /etc/passwd | wc -l


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

/etc/shadow



tail /etc/shadow


lightdm:*:18001:0:99999:7:::
pulse:*:18001:0:99999:7:::
avahi:*:18001:0:99999:7:::
colord:*:18001:0:99999:7:::
saned:*:18001:0:99999:7:::
hplip:*:18001:0:99999:7:::
kl:$6$HQljOPVP$xQNAU0XfiCBZX5VMlW81ekMSteyn12.JRJA8t92HDryUWHY/8SM7VxtjvepbJsb9ByEhT8i0Fk3r2whpvNGBj0:18001:0:99999:7:::
geoclue:*:18001:0:99999:7:::
libvirt-qemu:!:18001:0:99999:7:::
Debian-exim:!:18005:0:99999:7:::


Fields
1. username
2. password (hashed)
◇ * means user can't login
◇ ! means login is disabled

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

/etc/group



tail /etc/group


colord:x:119:
saned:x:120:
kl:x:1000:
geoclue:x:121:
kvm:x:123:kl
libvirt:x:124:kl
libvirt-qemu:x:64055:libvirt-qemu
ubridge:x:125:kl
vboxusers:x:126:
Debian-exim:x:122:


1. group name
2. ?
3. group id
4. group members

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

/etc/skel


• Stuff to put in a new user's home directory e.g. examples.desktop

ls /etc/skel


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Management Commands



# add user
useradd -m -d /home/testuser -s /bin/bash
# -m create directory
# -d define directory
# -s specify shell to use (optional)

tail /etc/passwd
tail /etc/shadow
ls /home                    # check if home dir was created
grep testuser /etc/group


testuser:!:18007:0:99999:7::: ← Can't login yet. Need to set passwd

# set password
passwd testuser

tail /etc/shadow


test:$6$jNbx6Ele$VVzwRlyqDZv3rEsey06w5T8tsHcNLpJxAYTpr45nxJjxQvwVJV0rZLczYuG0Mj9NQ55dtC7PeGLhMdLdxW16r/:18007:0:99999:7:::

# lock user
usermod -L testuser

# unlock user
usermod -U testuser

tail /etc/shadow


# delete user
userdel testuser

tail /etc/shadow
tail /etc/group
tail /etc/passwd


• The /home/test user directory still exists after user removal

ls /home | grep test


drwxr-xr-x 2 1001 1001 4096 Apr 21 12:51 test ← username lookup failed, show 1001

# remove deleted user home directory
rm -rf /home/test/


• Use “/usr/sbin/newusers” to create new users in batch

man newusers



Index