Which directorys contents are copied to the users home directory upon account creation?
The /etc/skel directory contains files and directories that are automatically copied over to a new user's home directory when such user is created by the useradd program. Show
A home directory, also called a login directory, is the directory on Unix-like operating systems that serves as the repository for a user's personal files, directories and programs, including personal configuration files. It is also the directory that a user is first in after logging into the system. The /etc directory and its subdirectories contain the many important configuration files for the system. The useradd program is located in the /usr/sbin/ directory, and on most systems it is accessible only by the root (i.e., administrative) user. On some systems this program might be called adduser. /etc/skel allows a system administrator to create a default home directory for all new users on a computer or network and thus to make certain that all users begin with the same settings or environment. Several user configuration files are placed in /etc/skel by default when the operating system is installed. Typically they might include .bash_profile, .bashrc, .bash_logout, dircolors, .inputrc and .vimrc. The dots preceding the names of these files indicate that they are hidden files, i.e., files that are not normally visible in order to avoid visual clutter and help reduce the chances of accidental damage. The contents of /etc/skel can be viewed by using the ls (i.e., list) command with its -a option (which shows all files and directories, including hidden ones), i.e.,
The location of /etc/skel can be changed by editing the line that begins with SKEL= in the configuration file /etc/default/useradd. By default this line says SKEL=/etc/skel. It is usually better to keep /etc/skel as small as possible and put system-wide configuration items into global configuration files such as /etc/profile. This is because the latter makes it much easier to update existing users' files because its settings take effect as soon as the system is turned on and apply to new users and old uses alike. When a user is removed from the system by an administrator with the userdel command, that user's home directory, including the files and directories that have been copied into it from /etc/skel, remains intact. The name of the directory skel is derived from the word skeleton, because the files it contains form the basic structure for users' home directories. Created June 25, 2005. I created some users with:
and I forgot to specify the parameter I thought about creating the directories, chowning them to the corresponding user, copying all the skeleton files and chowning them to the corresponding user. but if there's a command like asked Sep 9, 2009 at 14:33
3 This might sound like a silly idea, but if the users aren't actually doing anything, you could do:
Then edit /tmp/users.list to only contain the users you want. Then do:
However, many Redhat based distributions will create you a new home directory when you first login, providing it is specified in /etc/passwd where the directory should be. To test that, do an "su - " and see if it does "the right thing". If it doesn't, the above script will work quite nicely, I think.
quanta 50.6k19 gold badges153 silver badges213 bronze badges answered Sep 9, 2009 at 15:02
dotwaffledotwaffle 6574 silver badges8 bronze badges 7 Also you can use
answered May 17, 2013 at 3:59
Rahul PatilRahul Patil 2,8513 gold badges13 silver badges10 bronze badges 4 You will need to create the users directory manually. This requires three steps:
BTW: I always miss the Edit: Added answered May 12, 2012 at 16:14
mathmath 4433 silver badges10 bronze badges 7
That should do the trick I believe
answered Sep 9, 2009 at 14:49
8 You can use something like pam_mkhomedir to prevent this from ever being an issue with any users in the future. pam_mkhomedir is a PAM module that automatically creates a user's home directory on login if it doesn't exist, and populates it with files from /etc/skel (or whatever skel directory you specify). This is also a nicely scalable approach because it will continue to solve this problem if you ever switch your user repository over to a directory service like LDAP in the future. answered May 12, 2012 at 16:29
jgoldschrafejgoldschrafe 4,38518 silver badges18 bronze badges In my case, the home volume was corrupted and I decided just rebuild it from scratch since not much data involved but I want to keep users' login information, so I recreated the home directories manually with this script:
answered Oct 8, 2012 at 16:45
If you edit
then home directories will be automatically created for any future users, unless you tell the system not to do so. Another option is to use PAM for logins, and use the pam_mkhomedir module to automagically create the homedir on the first login. answered Dec 12, 2013 at 8:28
Jenny DJenny D 27.4k21 gold badges74 silver badges110 bronze badges Login with the user john and write from a shell:
That's it! Don't use sudo or su, you don't need root access to create some directories. From a root account, you can use:
That way, you will execute the command as john, that can be useful if you made the mistake with more than one user. answered Feb 7, 2018 at 19:44
My first step after doing
a Creates the home directories, copies skeletons, etc - at least on the CentOS 4 box I do that on most frequently. answered Sep 9, 2009 at 14:35
warrenwarren 17.9k23 gold badges82 silver badges134 bronze badges This is exactly what the answered Jun 18, 2015 at 8:43
AmandasaurusAmandasaurus 30.4k62 gold badges186 silver badges247 bronze badges 1 You could simply edit /etc/passwd. The second to the last field is the user's home directory.
answered Sep 9, 2009 at 19:19
GreeblesnortGreeblesnort 1,7498 silver badges10 bronze badges 2
or
and read
;) answered Apr 6, 2015 at 9:23
1 Which directory's contents are copied to the user's home directory upon account creation?The /etc/skel directory contains files and directories that are automatically copied over to a new user's when it is created from useradd command.
Which directory contains the home directories of all the user accounts in the system?The /home directory is a place where by default all user home directories are created.
What folder contains the home directories for all user accounts created on the system Linux?The Unix superuser has access to all directories on the filesystem, and hence can access home directories of all users. The superuser's home directory on older systems was /, but on many newer systems it is located at /root (Linux, BSD), or /var/root (Mac OS X).
What is contained in the home directory?A home directory is the directory or folder commonly given to a user on a network or Unix or Linux variant operating system. With the home directory the user can store all their personal information, files, login scripts, and user information.
|