Q. How do I add a new user called foo under existing group bar?
A. You need to use useradd command, which create a new user or update default new user information. You need to pass -g option to useradd command. It specifies the group name or number of the user’s initial login group. The group name must exist. A group number must refer to an already existing group. The default group number is 1 or whatever is specified in /etc/default/useradd file.
Task: Make sure group sales exists
# grep 'sales' /etc/group
Task: Add a new user tom to group sales
# useradd -g sales tom
# passwd tom
You can add existing user jerry to group sales with usermod command:
# usermod -g sales jerry
You can add existing user jerry to secondary group purchase with usermod command:
# usermod -G purchase jerry
Please note that above commands works with Solaris UNIX, FreeBSD and UNIX like oses.
You should follow me on twitter here or grab rss feed to keep track of new changes.
Featured Articles:
- 30 Handy Bash Shell Aliases For Linux / Unix / Mac OS X
- Top 30 Nmap Command Examples For Sys/Network Admins
- 25 PHP Security Best Practices For Sys Admins
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- Linux: 20 Iptables Examples For New SysAdmins
- Top 20 OpenSSH Server Best Security Practices
- Top 20 Nginx WebServer Best Security Practices
- 20 Examples: Make Sure Unix / Linux Configuration Files Are Free From Syntax Errors
- 15 Greatest Open Source Terminal Applications Of 2012

- My 10 UNIX Command Line Mistakes
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- The Novice Guide To Buying A Linux Laptop













{ 4 comments… read them below or add one }
Hi,
How can i add an user who has root permissions.
Regards
Eagle
can i add an user who has root permission if yes then, how is it.
PARAMJEET SINGH
i installed oracle 10g on linux 5.4 but running time i am getting this problem
Xlib: connection to “:0.0″ refused by server Xlib: No protocol specified
i installed oracle 10g on linux 5.4 but running time i am getting this problem
Xlib: connection to “:0.0″ refused by server Xlib: No protocol specified