Linux Change Default User Home Directory While Adding A New User
Q. By default user is added to /home directory. I'd like to add user to /iscsi/home/${user} directory instead of default /home. How do I force useradd to add user to /iscsi/home under CentOS / RHEL / Fedora Linux?
A. Default values for account creation defined in /etc/default/useradd file under CentOS / RHEL / Fedora / Debian / Ubuntu and other Linux distros. Simply open this file using a text editor:
# vi /etc/default/useradd
The default home directory defined by HOME variable, find line that read as follows:
HOME=/home
Replace with:
HOME=/iscsi/user
Save and close the file. Now you can add user using regular useradd command:
# useradd vivek
# passwd vivek
Verify user information:
# finger vivek
Output:
Login: vivek Name: Vivek Gite
Directory: /iscsi/user/vivek Shell: /bin/bash
Last login Thu Sep 13 07:58 2007 (IST) on pts/1 from 10.16.15.2
No mail.
No Plan.
Subscribe to our free e-mail newsletter or RSS feed to get all updates.
You can Email this page to a friend.
Related Linux / UNIX FAQ:
- Linux or UNIX change file permissions recursively ( conditional )
- Linux setup shared directory
- Linux add a user using command line tools
- Linux change or rename user name and UID (user-id)
- Understanding Linux / UNIX Relative Pathname
Discussion on This FAQ
Leave a Reply
We encourage your comments, and suggestions. But please stay on topic, be polite, and avoid spam. Please do not use the comment form to ask for help / question. Ask your question on the excellent Linux tech support forum. Thank you very much for stopping by our site!
Tags: /etc/default/useradd, account creation, default home, default user, default values, fedora linux, finger command, home directory, passwd_command, user information, useradd_command ~ Last updated on: May 5, 2008



May 6th, 2008 (2 weeks ago) at 12:25 pm
or specify the home with -d in useradd command