Unix tutorial Contact as

Adduser and rmuser unix commands. How to add and remove FreeBsd users

This tutorial will help to manage the system users on your server. We will show how to add and remove system users by means the adduser and rmuser unix commands.
The best way to add the users in FreeBsd system using the script adduser. You can adjust this script by means the /etc/adduser.conf configuration file. In example below we will create username "testuser" with home directory /home/testuser, group "guest" and shell /bin/ksh.

# adduser
Use option ``-silent'' if you don't want to see all warnings and questions.

Reading /etc/shells
Check /etc/master.passwd
Check /etc/group

Ok, let's go.
Don't worry about mistakes. I will give you the chance later to correct any input.
Enter username [a-z0-9_]: testuser
Enter full name []: Test FAQ User
Enter shell csh ksh nologin sh [ksh]: ksh
Uid [1002]: <Enter>
Login group testuser [testuser]: guest
Login group is ``guest''. Invite testuser into other groups: guest no
[no]: no
Enter password []:
Enter password again []:

Name: testuser
Password: ****
Fullname: Test FAQ User
Uid: 1002
Gid: 31 (guest)
Groups: guest
HOME: /home/testuser
Shell: /bin/ksh
OK? (y/n) [y]: y
Added user ``testuser''
Copy files from /usr/share/skel to /home/testuser
Add another user? (y/n) [y]: n

To remove the system user on FreeBsd system you can use the rmuser command. This command will remove the all crontab of this user, home directory and all mail messages. Also this command will remove the records from /etc/passwd and /etc/group files.
Now we will remove the username created in previous example.

# rmuser
Enter login name for user to remove: testuser
Matching password entry:

testuser:$2a$07$ZWnBOsbqMJ.ducQBfsTKUe3PL97Ve1AHWJ0A4uLamniLNXLeYrEie:1002:31::0:0:Test FAQ User:/home/testuser:/bin/ksh
Is this the entry you wish to remove? y
Remove user's home directory (/home/testuser)? y
Updating password file, updating databases, done.
Updating group file: done.
Removing user's home directory (/home/testuser): done.

Back to main page

Copyright © 2003-2016 The UnixCities.com
All rights reserved