/etc/skel Directory
Creating a Default Environment for New Users
๐ What is /etc/skel
?
The /etc/skel
directory (short for “skeleton”) contains default files and configuration settings
that are automatically copied to a new user’s home directory when the account is created.
๐งฑ Common Files in /etc/skel
.bashrc
โ Shell settings and aliases.profile
โ Environment variables and login setup.bash_logout
โ Commands executed on logout- Any custom files (e.g.,
README.txt
,.vimrc
)
๐ ๏ธ Example: Customizing New Users
Suppose you want all new users to see a welcome message and have helpful aliases:
# Create a message file sudo nano /etc/skel/README.txt # Edit .bashrc in /etc/skel sudo nano /etc/skel/.bashrc # Add aliases at the end alias ll='ls -alF' alias gs='git status'
๐ค Create a New User
sudo useradd -m -s /bin/bash alice sudo passwd alice
After this, /home/alice
will include all files from /etc/skel
by default!
โ Benefits
- Standardized user setup
- Saves admin time
- Onboarding and guidance for new users
๐งช /etc/skel Practical Example
Terminal Output Simulation for New User Setup
๐ฏ Objective
Create a new user alice
with a custom welcome message and aliases using /etc/skel
.
โ Step 1: Create Welcome Message
$ sudo nano /etc/skel/README.txt
๐ File Content:
Welcome to our server! Some useful commands: - To update the system: sudo apt update && sudo apt upgrade - To check disk space: df -h Please read the policy document at /etc/policy.txt
โ Step 2: Add Aliases to .bashrc
$ sudo nano /etc/skel/.bashrc
๐จโ๐ป Add this at the end:
# Custom aliases for all new users alias ll='ls -alF' alias gs='git status'
โ Step 3: Create New User
$ sudo useradd -m -s /bin/bash alice $ sudo passwd alice Enter new UNIX password: Retype new UNIX password: passwd: password updated successfully
โ Step 4: Verify User’s Home Directory
$ ls -a /home/alice . .. .bash_logout .bashrc .profile README.txt
โ Step 5: Test the Environment
$ su - alice $ cat README.txt Welcome to our server! Some useful commands: - To update the system: sudo apt update && sudo apt upgrade - To check disk space: df -h Please read the policy document at /etc/policy.txt $ ll # Executes: ls -alF $ gs # Executes: git status (if inside a Git repository)
๐ Final Result
- User
alice
has a pre-configured welcome file and useful aliases. - All this setup came automatically from the
/etc/skel
directory. - Easy and consistent environment setup for new users!