Recently I found that in I needed to add all the interactive users on my system to the same user group, in this case to allow them access to the network manager applet. If you only have a couple of user accounts doing this by hand isn’t too difficult, but I have quite a few different accounts on my system so I wanted to see if I could come up with a ‘one liner’ to do the job…
In order to add a user to a group you need to be running as root.
$ sudo -i
First you need work out how to get a list of user accounts on the system, in this case I’m doing this by extracting all the username fields from the password file.
# cat /etc/passwd | cut -d ':' -f1
# cat /etc/passwd | grep /home | cut -d ':' -f1
# for ID in $(cat /etc/passwd | grep /home | cut -d ':' -f1); \
> do (adduser $ID netdev);done
The user `user1' is already a member of `netdev'.
Adding user 'user2' to group 'netdev' ...
Adding user user2 to group netdev
Adding user 'user3' to group 'netdev' ...
Adding user user3 to group netdev
- Installing Firefox and Thunderbird on a Raspberry Pi
- Installing Cinnamon on Debian 8.0 (Jessie)
- Installing Skype on Debian 8.0 (Jessie)
- Minimal GNOME 3 Install on Debian (jessie)
- Installing MATE on Raspbian/Debian 8.0 (jessie)
- Enable root logins using ssh in Debian 8.0 (Jessie)
- Raspberry Pi 3 Wireless Networking
- Remote Desktop using VNC
- Creating a seperate home partition (Raspberry Pi)
- Installing Lighttpd with Python CGI support
- 277,574 hits