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 Skype on Debian 8.0 (Jessie)
- Installing Cinnamon on Debian 8.0 (Jessie)
- Enable root logins using ssh in Debian 8.0 (Jessie)
- Installing MATE on Raspbian/Debian 8.0 (jessie)
- Video Streaming using Netcat
- Installing Lighttpd with Python CGI support
- Remote Desktop using VNC
- Yet another desktop - Compiling CDE on Debian 8.0 (Jessie)
- Enable verbose startup messages in Debian 8.0 (Jessie)
- 244,307 hits