Linux Default User Environment: /etc/skel, Profile Files, Aliases, and Login Messages 

By LinuxCert.Guru Team·

Objective

The default user environment is everything a user gets the moment an account exists: the files in their home directory, the shell settings, the aliases, the environment variables, and the messages they see at login. Configuring it once means every user starts with consistent, correct settings. This guide covers the files and commands involved. By the end, you will know how to:

  • Customize /etc/skel so new accounts start with the files you want
  • Understand which shell startup files run, and in what order
  • Create system-wide environment variables with /etc/profile.d/ and /etc/environment
  • Provide default aliases and shell behaviour for all users
  • Customize login messages with /etc/motd, /etc/issue, and an SSH banner
  • Test and troubleshoot environment changes correctly
  • Apply these skills to LFCS exam tasks and real multi-user systems

Without a deliberate default environment, every new account is a blank slate, and administrators end up fixing the same small problems one user at a time: a missing alias, the wrong editor, a PATH that lacks the company tools directory. Setting this up properly takes minutes and saves hours.

How a New User's Environment Is Built

The environment is assembled in two stages: when the account is created, and each time the user starts a shell.

  1. Account creation. When you run useradd -m, the tool creates the home directory and copies the contents of /etc/skel into it. The copied files are then given to the new user as owner.
    • This is a one-time copy. Changes to /etc/skel later do not reach users that already exist.
  2. Login. When the user logs in, the shell reads system-wide startup files first, then the user's own files in their home directory.
  3. Each new shell. Opening a terminal window or starting a subshell reads a slightly different set of files, which is why the same alias can work in one place and seem missing in another.

Which Configuration File Does What

File or Directory Scope What It Is For Read By
/etc/skel/ Template for new users Files copied into every new home directory at account creation useradd -m
/etc/profile All users, login shells System-wide login shell settings, PATH, umask, and it runs the scripts in profile.d Bash login shells
/etc/profile.d/*.sh All users, login shells Modular scripts for variables, aliases, and functions. The preferred place for custom system-wide settings. Sourced by /etc/profile
/etc/bashrc (RHEL family) or /etc/bash.bashrc (Debian family) All users, interactive Bash System-wide interactive shell settings Interactive Bash shells
/etc/environment All users, all sessions Plain KEY=value variables, read by PAM rather than by the shell PAM (pam_env)
~/.bash_profile or ~/.profile One user, login shells Personal login settings Bash login shells
~/.bashrc One user, interactive shells Personal aliases, functions, and prompt Interactive Bash shells
~/.bash_logout One user Commands to run when a login shell exits Bash on logout
/etc/motd All users Message shown after a successful login PAM and sshd
/etc/issue Local console Message shown before the login prompt on a local terminal getty

The file names differ slightly between distribution families. The default /etc/skel on Red Hat family systems contains .bash_profile, .bashrc, and .bash_logout. On Debian and Ubuntu it contains .profile, .bashrc, and .bash_logout. The concepts are identical, and LFCS expects you to cope with either.

Customizing /etc/skel

The skeleton directory is the template for new home directories. Anything you place in it appears in every account created afterward with useradd -m.

# View the default skeleton files (includes hidden files)
ls -la /etc/skel

# Confirm which skeleton directory useradd uses
useradd -D | grep SKEL
# SKEL=/etc/skel

# Add a default alias for all future users
echo 'alias ll="ls -alh"' >> /etc/skel/.bashrc

# Add a default welcome file and a standard directory layout
echo "Welcome. Contact the help desk for access requests." > /etc/skel/README.txt
mkdir -p /etc/skel/projects /etc/skel/.config

# Create a test user and check what they received
useradd -m testuser
ls -la /home/testuser
grep "alias ll" /home/testuser/.bashrc

Three details worth knowing:

  • It only affects new accounts. Existing users keep the files they already have. To give an existing user a new default, copy it manually and be careful not to overwrite their changes, for example cp -n /etc/skel/README.txt /home/alice/ where -n refuses to overwrite.
  • Ownership is set for you. The copied files are owned by the new user, not by root, even though the originals in /etc/skel belong to root.
  • You can use a different template. useradd -m -k /etc/skel-contractor contractor1 copies from an alternate directory. The -k option only works together with -m. This is useful for giving different roles different starting environments.

Understanding Shell Startup Files

Bash reads different files depending on how it was started. This is the part that confuses people, because the same alias can appear to work in a terminal window but not after su.

How the Shell Starts Examples Files Read
Login shell Console login, SSH login, su -, bash -l /etc/profile (which runs /etc/profile.d/*.sh), then the first found of ~/.bash_profile, ~/.bash_login, ~/.profile
Interactive non-login shell Opening a new terminal window, running bash inside a session, su without the dash /etc/bashrc or /etc/bash.bashrc, then ~/.bashrc
Non-interactive shell Running a script, a cron job, ssh host command Usually no startup files. Environment comes from the caller.

Distributions connect the two paths for you. The default ~/.bash_profile on Red Hat family systems and ~/.profile on Debian family systems both load ~/.bashrc, so settings in ~/.bashrc reach login shells too. That is why ~/.bashrc is the usual home for personal aliases.

# Start a login shell as a user (reads /etc/profile and the user's profile file)
su - testuser

# Start a non-login shell as a user (reads only the interactive shell files)
su testuser

# Check whether the current shell is a login shell
shopt -q login_shell && echo "login shell" || echo "non-login shell"

# Reload your own startup file in the current shell without logging out
source ~/.bashrc

# Reload the system-wide profile in the current shell
source /etc/profile

System-Wide Environment Variables

There are two standard places to define a variable for every user, and they work differently.

Option 1: A Script in /etc/profile.d/

# Create a system-wide variable available in every login shell
echo 'export COMPANY_ENV=production' > /etc/profile.d/company.sh

# Make sure it is readable by everyone
chmod 644 /etc/profile.d/company.sh

# Add a directory to PATH for all users
cat > /etc/profile.d/company-path.sh << 'EOF'
# Add the company tools directory to PATH if it exists
if [ -d /opt/company/bin ]; then
    export PATH="$PATH:/opt/company/bin"
fi
EOF

# Test it in a fresh login shell
su - testuser -c 'echo $COMPANY_ENV'
su - testuser -c 'echo $PATH'
  • The file name must end in .sh and the file must be readable, otherwise /etc/profile skips it
  • It is a real shell script, so you can use export, variable expansion, and conditionals
  • It applies to login shells. On Red Hat family systems it also applies to interactive non-login shells, and on Debian family systems it generally does not, so always test the shell type you care about.

Option 2: /etc/environment

# Set a global editor variable
echo 'EDITOR=vim' >> /etc/environment

# View the file
cat /etc/environment
# EDITOR=vim

# The change takes effect at the next login (it is read by PAM, not by the shell)
# After logging in again:
echo $EDITOR
  • /etc/environment is not a shell script. It is a list of plain KEY=value lines read by PAM at login.
  • Do not rely on export, $VARIABLE expansion, or commands in it. Keep each line a simple assignment.
  • Because PAM reads it, it can apply to sessions that do not start a shell the usual way, such as some graphical logins

Which One Should You Use?

Need Best Choice Why
A simple fixed value for everyone, such as EDITOR=vim /etc/environment Simple and read at login for all session types
A value that depends on logic or another variable /etc/profile.d/*.sh It is a real script, so it can test conditions and expand variables
Extending PATH /etc/profile.d/*.sh Allows $PATH expansion so you append instead of replace
Aliases and functions /etc/profile.d/*.sh or ~/.bashrc These are shell features, so they need a shell file
A personal setting for one user ~/.bashrc or ~/.bash_profile Affects only that user
A default for future users only /etc/skel/ Copied into new home directories at creation

Default Aliases

An alias is a shortcut for a longer command. There are three levels where you can define one, depending on who should get it:

  • All users, system-wide: a script in /etc/profile.d/
  • All future users: /etc/skel/.bashrc
  • One user: that user's ~/.bashrc
# A system-wide alias file that only takes effect in interactive shells
cat > /etc/profile.d/aliases.sh << 'EOF'
# Only define aliases for interactive shells
case "$-" in
    *i*)
        alias ll='ls -alh'
        alias grep='grep --color=auto'
        alias cp='cp -i'
        alias mv='mv -i'
        ;;
esac
EOF

chmod 644 /etc/profile.d/aliases.sh

# Check that an alias exists in a login shell
su - testuser -c 'alias ll'

# List all aliases in the current shell
alias

Aliases are an interactive convenience. They do not apply inside scripts, so never rely on an alias for something a script must do. Aliasing a command to a safer version, such as cp -i, is helpful for people but will not protect you from a script.

Login Messages: motd, issue, and SSH Banners

Three different messages appear at three different moments, and mixing them up is common.

File When It Appears Typical Use
/etc/issue Before the login prompt on a local console System name, version, or a local-access notice
/etc/issue.net Before login on remote connections that use it, and as the SSH banner if configured A pre-login legal or access notice
/etc/motd (and /etc/motd.d/ on newer systems) After a successful login Welcome text, maintenance notices, policy reminders
SSH Banner setting Before SSH authentication, as soon as the connection is made Authorization warning shown to everyone who connects

The Message of the Day

# Set the message shown after login
echo 'Authorised users only. Activity may be monitored.' > /etc/motd

# Append a maintenance notice
echo 'Planned maintenance: Saturday 02:00 to 04:00 UTC.' >> /etc/motd

# View it
cat /etc/motd

# Newer systems also display every file in this directory
ls /etc/motd.d/

On Debian and Ubuntu systems, much of the login message is generated dynamically by scripts in /etc/update-motd.d/, and a static /etc/motd is shown as well. If your message does not look right, check for dynamic content as well as the static file.

The Pre-Login Issue File

# Set a pre-login notice for the local console
cat > /etc/issue << 'EOF'
Authorised access only.
Host: \n   Kernel: \r   Terminal: \l
EOF

# Show the file (the escape codes are expanded by the login prompt, not by cat)
cat /etc/issue

# Show the pre-authentication banner for SSH connections
# 1. Put the text in a file
echo 'Authorised access only. Disconnect now if you are not an authorised user.' > /etc/issue.net

# 2. Tell sshd to use it: add this line to /etc/ssh/sshd_config
#    Banner /etc/issue.net

# 3. Validate the configuration, then reload
sshd -t
systemctl reload sshd

The login prompt expands a few escape codes in /etc/issue:

Code Expands To
\n The hostname
\r The kernel release
\l The terminal line
\d The current date
\t The current time
\s The operating system name
\m The machine architecture

Wording for access notices is often a matter of organizational or legal policy. Have the exact text reviewed by whoever owns that policy rather than inventing it on the server.

Practical Example: Standardizing the Environment for New Hires

This workflow ties everything together. The goal: every new account gets a standard editor, helpful aliases, a company tools directory on its PATH, a README, and a login notice.

# 1. Standard variables and PATH for all users
echo 'EDITOR=vim' >> /etc/environment

cat > /etc/profile.d/company.sh << 'EOF'
export COMPANY_ENV=production
if [ -d /opt/company/bin ]; then
    export PATH="$PATH:/opt/company/bin"
fi
EOF
chmod 644 /etc/profile.d/company.sh

# 2. Default aliases for all users
cat > /etc/profile.d/aliases.sh << 'EOF'
case "$-" in
    *i*) alias ll='ls -alh' ;;
esac
EOF
chmod 644 /etc/profile.d/aliases.sh

# 3. Template files for future accounts
echo "Welcome to the team. See the wiki for onboarding steps." > /etc/skel/README.txt
mkdir -p /etc/skel/projects

# 4. Login notice
echo 'Authorised users only.' > /etc/motd

# 5. Create a test account and verify each piece
useradd -m newhire
ls -la /home/newhire
su - newhire -c 'echo "COMPANY_ENV=$COMPANY_ENV EDITOR=$EDITOR"'
su - newhire -c 'alias ll'
su - newhire -c 'echo $PATH'

# 6. Clean up the test account
userdel -r newhire

Verifying and Troubleshooting

When a setting does not appear, the cause is almost always the type of shell or the timing, not the file contents.

Symptom Likely Cause Fix
New setting not visible in the current terminal The shell read its startup files before you changed them Log out and back in, or run source /etc/profile or source ~/.bashrc
Works after su - user but not after su user The setting is in a login-shell file, and su without the dash starts a non-login shell Use su - to test, or put the setting in a file the other shell type reads
Existing users did not get the new default file /etc/skel is only copied at account creation Copy the file manually with cp -n
Script in /etc/profile.d/ is ignored File name does not end in .sh, or it is not readable Rename to .sh and set chmod 644
Variable missing in a cron job or a systemd service These do not read login shell files Set the variable inside the job, or use Environment= or EnvironmentFile= in the unit
/etc/environment variable looks wrong It is plain KEY=value, so expansion and commands are not processed Move logic into a /etc/profile.d/*.sh script
Login message not shown over SSH PrintMotd is disabled, or the message comes from a different file Check sshd -T | grep -i printmotd and the Banner setting
Alias works in the terminal but not in a script Aliases are interactive only Use the full command or a function or script instead
# Show the variables in the current environment
env
printenv EDITOR

# See exactly what a fresh login shell for a user sees
su - testuser -c 'env | sort'

# Trace which startup files bash reads (very useful for debugging)
bash -lx -c 'exit' 2>&1 | grep -E "profile|bashrc" | head -20

Common Mistakes

  • Editing /etc/skel and expecting existing users to change. It is a template for new accounts only.
    • For existing users, copy files manually, and avoid overwriting their own customizations
  • Testing with su user instead of su - user. Without the dash, you get a non-login shell and login-only files are not read, so correct configuration looks broken.
  • Treating /etc/environment as a script. It accepts plain assignments only. Put anything that needs $PATH expansion or logic in /etc/profile.d/.
  • Overwriting PATH instead of appending. export PATH=/opt/company/bin removes /usr/bin from the path and breaks commands. Use export PATH="$PATH:/opt/company/bin".
  • Forgetting the .sh extension or read permission on profile.d scripts. The loop in /etc/profile skips them silently.
  • Putting secrets in environment files. /etc/environment and /etc/profile.d/ are readable by every user. Never store passwords, API keys, or tokens there.
  • Making a syntax error in /etc/profile. A mistake there affects every login shell. Keep a root session open while you test, and prefer small files in /etc/profile.d/ over editing /etc/profile itself.
  • Confusing the login messages. /etc/issue is shown before login on the console, /etc/motd after login, and an SSH Banner before authentication.

Quick Reference

Task Command or File
View the skeleton files ls -la /etc/skel
Add a default alias for new users echo 'alias ll="ls -alh"' >> /etc/skel/.bashrc
Create a user with a different template useradd -m -k /path/to/skel username
Create a system-wide variable echo 'export VAR=value' > /etc/profile.d/name.sh
Set a simple global variable echo 'VAR=value' >> /etc/environment
Append to PATH for everyone export PATH="$PATH:/opt/dir" inside a /etc/profile.d/*.sh file
Set the post-login message echo 'text' > /etc/motd
Set the pre-login console message /etc/issue
Show a pre-authentication SSH banner Banner /etc/issue.net in /etc/ssh/sshd_config, then sshd -t and reload
Test as a user with a login shell su - username
Reload startup files in the current shell source /etc/profile or source ~/.bashrc
Show the current environment env or printenv VAR

Default User Environment and the LFCS Exam

Managing template user environments and system-wide environment profiles is part of the LFCS curriculum. Exam tasks in this area typically ask you to:

  • Add a file, alias, or directory to /etc/skel so that new users receive it
  • Create a system-wide environment variable using /etc/profile.d/ or /etc/environment
  • Change the message users see at login using /etc/motd or /etc/issue
  • Create a test user and verify the result with a login shell

The deciding habit is verification. Create a throwaway account and check it with su -, because a change that looks right in a file means nothing until a fresh login shell proves it. Also check the current LFCS curriculum, since the exact wording of objectives can change between versions.

Conclusion

A well-configured default environment means every user starts from the same, correct baseline, and you never fix the same problem twice. The key ideas are simple once the shell types are clear:

  • /etc/skel is a one-time template for new accounts. It never updates existing users.
  • /etc/profile.d/*.sh is the best place for system-wide variables, PATH changes, and aliases because it is a real script and is easy to manage as separate files
  • /etc/environment holds plain KEY=value lines read by PAM, with no expansion and no commands
  • Login shells and non-login shells read different files, so test with su -
  • /etc/issue appears before login, /etc/motd after login, and an SSH Banner before authentication
  • Append to PATH, never overwrite it, and never store secrets in files every user can read
  • Always verify with a throwaway account before relying on a change

With user accounts, groups, and default environments in place, the next piece of the picture is controlling how passwords behave over time: expiry, minimum ages, and warnings, which is the subject of password aging policies.

Start the Default User Environment lab at LinuxCert.Guru → https://linuxcert.guru/lfcs/?name=lfcs-default-user-environment

$_
Ready to go beyond reading? Manage Local Users and Groupsfree · auto-graded RHCSA lab, nothing to install Not sure where you stand? Take the 10-min RHCSA skill check →
Open lab →