Welcome to UltratechHost Forum, Guest. Please take the time to register if you haven't, or click

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5

[-]
Tags
guide to “useradd” command in linux part 3

RedHat Guide to “useradd” Command in Linux [Part 3]
#1
Hello,

This thread is about special case for useradd command

Previous Posts:
Code:
http://forums.ultratechhost.com/thread-208.html
http://forums.ultratechhost.com/thread-209.html

Add a User with Specific Home Directory, Default Shell and Custom Comment

The following command will create a user ‘santa‘ with home directory ‘/var/www/santa‘, default shell /bin/bash and adds extra information about user.

Code:
# useradd -m -d /var/www/santa -s /bin/bash -c "Santa Banta" -U santa

In the above command ‘-m -d‘ option creates a user with specified home directory and the ‘-s‘ option set the user’s default shell i.e. /bin/bash. The ‘-c‘ option adds the extra information about user and ‘-U‘ argument create/adds a group with the same name as the user.

Add a User with Home Directory, Custom Shell, Custom Comment and UID/GID

The command is very similar to above, but here we defining shell as ‘/bin/zsh‘ and custom UID and GID to a user ‘raj‘. Where ‘-u‘ defines new user’s UID (i.e. 1000) and whereas ‘-g‘ defines GID (i.e. 1000).

Code:
# useradd -m -d /var/www/raj -s /bin/zsh -c "Raj" -u 1000 -g 1000 raj

Add a User with Home Directory, No Shell, Custom Comment and User ID

The following command is very much similar to above two commands, the only difference is here, that we disabling login shell to a user called ‘nat‘ with custom User ID (i.e. 1019).

Here ‘-s‘ option adds the default shell /bin/bash, but in this case we set login to ‘/usr/sbin/nologin‘. That means user ‘nat‘ will not able to login into the system.

Code:
# useradd -m -d /var/www/nat -s /usr/sbin/nologin -c "Natwarlal" -u 1019 nat



Dinesh Kumar Mohanty
Ultra Web Solutions®
Bhubaneswar, Odisha, India.

UltratechHost - Your One Stop Offshore & Onshore Hosting Provider
Server Locations : Netherlands, Germany, Russia, Singapore & USA
Service Offers: Shared hosting | Reseller hosting | Cloud server | Dedicated server | VPS Hosting



Forum Jump:


Users browsing this thread: 1 Guest(s)