This page is a work in progress if you have an input post below and I may add the content to this blog.
The useradd and adduser commands add new user to the UNIX based system.
Affected files:
/etc/passwd
/etc/shadow
/etc/usr_attr
/etc/groups
Some System Administrators add accounts to there systems by editing the above files by hand or with a script. It can be done this way without any problems, but using the useradd and adduser commands are better because they copy the default files to the new users home directory and set the proper permissions
useradd command syntax
useradd [options] {username}
Example:
root@earth> useradd -u 25 -g staff -G ftp,users -m -d /export/home/newuser -c "newuser" -s /bin/bash newuser
Explained
-u | Sets users ID to 25 |
-g | Sets primary group membership to staff |
-G | Sets secondary groups memberships to ftp,users |
-m | Makes the uses home directory |
-d | Sets path to home directory |
-s | Puts in a comment into the /etc/passwd file. |
-s | Sets users default shell |
newuser | Put the name of the account at the end |
-f | Sets the number days the account can be inactive before it is locked (Solaris). For Linux systems it sets the number of days after the users password expires before the account is locked. |
-e | Sets account expiration date |
In many Linux distros you need only to do is this.
useradd newuser
The OS will fill in the rest for you based on the system default.
adduser [-u uid [-o]] [-g group] [-G group,...]
[-d home] [-s shell] [-c comment] [-m [-k template]]
[-f inactive] [-e expire mm/dd/yy] [-p passwd] [-n] [-r] name
adduser -D [-g group] [-b base] [-s shell] [-f inactive] [-e expire mm/dd/yy]
If you make a mistake then you can use usermod to modify an existing account. The usermod command works just like useradd,
passwd command changes the password of a user account.
passwd username
Remove password hash in /etc/shadow for a user.
passwd -d username
passwd newuser
- Note: if you don't put a user name at the end of the passwd command then it will change the root password.
No comments:
Post a Comment