Unix Users and Groups
Article by
on August 7, 2012, last modified on May 25, 2014Users
CRUD
Just see:
Chris Fidao's article on SFH: http://serversforhackers.com/editions/2014/05/06/permissions-users/
http://www.cyberciti.biz/faq/howto-add-new-linux-user-account/
http://www.cyberciti.biz/faq/howto-linux-add-user-use-adduser-command/
Adding a User
$ groupadd george $ useradd -d /home/george -g george -s /bin/bash george $ mkdir /home/george $ chown george:george /home/george
Adding a User Without a Home Directory
$ groupadd george $ useradd -M -g george -s /bin/false george
Adding an FTP-Only User
Replace "ftp" with whatever you want to call the user:
$ useradd -d /home/ftp -g ftp -s /bin/false ftp
Article on using /bin/false:
http://www.semicomplete.com/articles/ssh-security/
http://www.cyberciti.biz/tips/linux-prevent-normal-users-from-logging-into-system.html
Add a User to a Group
$ usermod -a -G wheel george
http://www.cyberciti.biz/faq/howto-linux-add-user-to-group/
Adding a Sudoer
On most computers you only need to add the user to a group that is a sudoer group, i.e. the "wheel" and "sudo" groups are common. Here is one example:
$ adduser george sudo
http://linuxpoison.blogspot.com/2008/12/configuring-sudo-and-adding-users-to.html
Groups
CRUD
http://www.cyberciti.biz/faq/howto-linux-add-user-to-group/
http://www.cyberciti.biz/faq/unix-add-user-to-group/
Users and Groups on a Mac
For some unknown reason Macs do not have usermod. Instead, Macs use dscl. Here are some examples:
Users
Adding a User to a Group
Thank you user1256923, whoever you are, for posting how to do this on Stack Exchange:
$ dscl . append /Groups/wheel GroupMembership george
Where "wheel" is the group and "george" is the user. Note that this does not change the user's primary group.