Linux System Administration

0 of 77 lessons complete (0%)

Managing User Accounts

/etc/skel – Default User Environment

You don’t have access to this lesson

Please register or sign in to access the course content.

/etc/skel – Default User Environment

/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 Example Output

๐Ÿงช /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!