/etc, /home and /var in Linux System Administration

What /etc, /home and /var hold on a Linux server, and how admins back them up, partition them, secure them and troubleshoot a full /var.

Jul 31, 2025 - 21:48
Nov 9, 2026 - 11:11
 0  91
TOPICDevOps BasicsPractical guide
/etc, /home and /var in Linux System Administration

On a Linux server, /etc holds system-wide configuration, /home holds the personal files of normal users, and /var holds data that changes while the system runs, such as logs, caches, spools and service state. Knowing which directory owns what tells you what to back up, what to mount separately, and where to look first when something breaks.

This guide treats the three directories as an administrator does day to day: backups, partitioning, permissions, troubleshooting and configuration management. If you are just starting with Red Hat systems, read our beginner's guide to setting up RHEL 10 first; it walks through the first boot and basic layout.

Key takeaways

  • /etc is configuration. It is small, changes rarely, and is the most valuable thing to back up and keep in version control.
  • /home is user data. It is never read-only, and users normally reach it through $HOME, not hardcoded paths.
  • /var is variable data that is written during normal operation: logs in /var/log, service state in /var/lib, caches in /var/cache.
  • A full /var is one of the most common causes of failed services. Separate partitions or volumes contain the damage.
  • Package managers own default files under /usr; your local changes belong in /etc, where upgrades preserve them.

Where the rules come from

Two documents describe the Linux directory layout. The Filesystem Hierarchy Standard (FHS 3.0), maintained by the Linux Foundation, is the traditional reference. Newer systemd-based distributions also follow the UAPI Group Linux File System Hierarchy specification, which the systemd file-hierarchy(7) manual points to. The two agree on the roles of /etc, /home and /var; the UAPI text is shorter and clearer about what may be read-only.

DirectoryHoldsWritable in normal operation?Typical sizeBack up?
/etcSystem-specific configurationChanges only when an admin or package changes config; the UAPI spec allows it to be read-onlyTens of megabytesAlways
/homeHome directories of normal usersAlways writableVaries widelyYes, on workstations and shared servers
/varPersistent variable data: logs, state, caches, spoolsAlways writableGrows over timeSelectively (/var/lib state yes, /var/cache no)

/etc: the configuration layer

Almost every service reads its settings from /etc. Change a file here and you change how the system behaves. Files you will meet on every server include:

File or directoryPurpose
/etc/passwd, /etc/groupUser and group accounts
/etc/shadowPassword hashes and ageing data, readable only by root
/etc/fstabFile systems mounted at boot
/etc/hosts, /etc/resolv.confLocal name resolution and DNS resolver settings
/etc/ssh/sshd_configOpenSSH server settings
/etc/sudoers, /etc/sudoers.d/Who can run what with sudo (edit with visudo)
/etc/systemd/system/Local unit files and drop-in overrides for systemd services
/etc/yum.repos.d/ or /etc/apt/sources.list.d/Package repositories

Our post on /etc/passwd vs /etc/shadow goes deeper into the account files.

Vendor defaults vs local changes

Packages ship their defaults under /usr (for example /usr/lib/systemd/system/ for unit files). You put changes in /etc, which takes priority. The cleanest way to change a service is a drop-in file instead of editing the vendor unit:

sudo systemctl edit nginx.service
# opens /etc/systemd/system/nginx.service.d/override.conf
sudo systemctl daemon-reload
sudo systemctl restart nginx

Many tools use the same pattern with .d directories (/etc/sudoers.d/, /etc/sysctl.d/, /etc/ssh/sshd_config.d/ on distributions whose default sshd_config includes it). Small files in a .d directory are easier to manage with automation than one large edited file.

Protecting /etc

  • Keep permissions tight. /etc/shadow should not be world-readable; check with ls -l /etc/shadow.
  • Validate before you restart. Use sshd -t, nginx -t or visudo -c so a typo does not lock you out.
  • Track changes. Configuration management (Ansible, for example) or a Git repository of /etc lets you see who changed what and roll back.
  • On RPM systems, rpm -Va lists package files that differ from what the package installed, which is a quick way to spot unexpected config edits.

/home: user space

/home contains one directory per normal user, such as /home/priya. The root user's home is /root, not /home/root, so the administrator can still log in if /home fails to mount. System service accounts usually have their home elsewhere, often under /var/lib.

What lives in a home directory

  • Shell startup files such as .bashrc and .bash_profile.
  • SSH keys and settings in ~/.ssh/, which must not be group or world writable or SSH will refuse them.
  • Per-user application settings under ~/.config and caches under ~/.cache.

Most of these are hidden dot files. Our guide to hidden files in Linux explains how to list and manage them.

Administering /home

# create a user with a home directory populated from /etc/skel
sudo useradd -m -s /bin/bash priya

# find the biggest home directories
sudo du -sh /home/* | sort -h | tail

# check home directory permissions
ls -ld /home/*

New home directories are populated from /etc/skel, which is a neat link between the two directories: change /etc/skel and every new user gets the change. On shared servers, set disk quotas so one user cannot fill the file system. On servers that are cattle rather than pets, /home may hold almost nothing because nobody logs in to work there.

/var: data that changes

/var holds data that must survive a reboot but changes during normal operation. The UAPI spec notes that components needed in early boot should not depend on it, because /var may be a separate mount that is not ready yet.

PathContentsSafe to delete?
/var/logSystem and service logs; the systemd journal in /var/log/journal when persistentRotate or vacuum, do not delete blindly
/var/libPersistent service state: databases (for example /var/lib/mysql), container images (/var/lib/docker, /var/lib/containers), package databasesNo; this is data
/var/cacheNon-essential cache, such as downloaded packagesYes; programs should rebuild it, possibly more slowly
/var/tmpLarger temporary files that persist across rebootsOld files usually yes, after checking
/var/spoolQueues for mail, print and cron jobsOnly once you know what is queued

When /var fills up

A full /var stops logging, breaks package installs, and can stop databases and container runtimes. This is the most common real-world problem tied to these directories. A safe way to investigate:

df -h /var
sudo du -xh /var --max-depth=2 | sort -h | tail -20

# how much space the journal uses, and trim it
journalctl --disk-usage
sudo journalctl --vacuum-size=500M

# clear package caches
sudo dnf clean all        # RHEL, Fedora
sudo apt-get clean        # Debian, Ubuntu

Also check for deleted files that a process still holds open; the space is not freed until the process restarts. sudo lsof +L1 lists them.

Long term, set log rotation with logrotate and journal limits (such as SystemMaxUse= in /etc/systemd/journald.conf), and alert on disk usage before it reaches 100 percent. Our post on RHEL 10 log management covers rotation and central logging in detail.

Partitioning: why these three often get their own volumes

Separate file systems for /home and /var (or /var/log and /var/lib) stop one runaway area from filling the root file system. They also let you apply mount options. CIS benchmarks, for example, recommend separate partitions for several of these paths and options such as nodev, nosuid and noexec where they fit.

# /etc/fstab example with LVM logical volumes
/dev/mapper/vg0-root   /          xfs   defaults                0 0
/dev/mapper/vg0-home   /home      xfs   defaults,nodev,nosuid   0 0
/dev/mapper/vg0-var    /var       xfs   defaults,nodev          0 0
/dev/mapper/vg0-varlog /var/log   xfs   defaults,nodev,nosuid,noexec 0 0

With LVM you can grow a volume later without repartitioning. See how LVM and disk partitioning work together. Test mount options before rolling them out: some software expects to run scripts from paths you might mark noexec.

Backup and restore strategy by directory

DirectoryStrategyNotes
/etcBack up every change; keep in Git or rebuild from configuration managementSmall, high value. Restoring it alone often brings a server back
/homeRegular file-level backupsExclude ~/.cache to save space
/var/libApplication-aware backupsBack up databases with their own tools (dumps or snapshots), not by copying live files
/var/logShip to a central log systemLocal copies are evidence, but a dead disk takes them too
/var/cache, /var/tmpSkipRebuildable

Containers, cloud images and immutable systems

The same roles apply in modern setups, with a twist. In a container image, /etc is baked into the image and overridden with Kubernetes ConfigMaps or mounted files. Anything the container writes under /var is lost when the container is replaced unless you mount a volume there. On image-based or immutable distributions, /usr is read-only and /etc and /var are the places where a machine keeps its own state, so knowing these directories matters more, not less.

Troubleshooting checklist

  1. Service will not start: run systemctl status and journalctl -u, then check its config in /etc with the tool's own syntax test.
  2. Disk full: run df -h, then du under /var, the journal, package caches and open deleted files.
  3. User cannot log in with SSH keys: check ownership and permissions on /home/user, ~/.ssh and authorized_keys.
  4. Change vanished after an upgrade: you probably edited a vendor file under /usr; move the change to /etc or a drop-in.
  5. Server boots to emergency mode: a bad line in /etc/fstab is a frequent cause; boot to the rescue target and correct it.

These are core tasks in our Linux administration training and the RHCSA course, both available in our Kharadi, Pune classroom and live online. For interview practice, see Linux FAQs asked in IT and DevOps interviews.

Frequently asked questions

What is the /etc directory used for in Linux?

/etc holds system-wide configuration files, such as user accounts, mounted file systems, network and DNS settings, SSH and sudo rules, and local systemd overrides. It contains configuration, not user data or logs.

What is stored in /home?

/home contains one directory per normal user with their personal files, shell startup files, SSH keys and per-user application settings. The root user's home is /root, and service accounts usually live elsewhere.

What does /var contain?

/var holds persistent data that changes while the system runs: logs in /var/log, service state such as databases and container images in /var/lib, caches in /var/cache, persistent temporary files in /var/tmp and queues in /var/spool.

Why should /var be on a separate partition?

Logs and service data in /var grow over time. A separate partition or LVM volume stops a runaway log or database from filling the root file system, and lets you apply mount options such as nodev.

Is it safe to delete files in /var/log?

Do not delete active logs blindly. Rotate them with logrotate, trim the journal with journalctl --vacuum-size or --vacuum-time, and check for deleted files still held open with lsof +L1.

Which of the three directories matters most for backups?

/etc is small and holds the configuration that defines the server, so back it up on every change or keep it in configuration management. Back up /home with file-level backups and /var/lib with application-aware tools.

Why did my change to a config file disappear after an update?

You probably edited a vendor default under /usr. Packages can overwrite those. Put local changes in /etc, ideally as a drop-in file, because /etc takes priority and upgrades preserve it.

How do /etc, /home and /var work in containers?

In containers, /etc comes from the image and is usually overridden with ConfigMaps or mounted files, and anything written to /var disappears with the container unless a volume is mounted there.

References

Interested in learning more?Get a callback from our training advisors.

What's Your Reaction?

Like Like 0
Dislike Dislike 0
Love Love 0
Funny Funny 0
Angry Angry 0
Sad Sad 0
Wow Wow 0
Mridul I am a passionate technology enthusiast with a strong focus on DevOps, Cloud Computing, and Cybersecurity. Through my blogs at DevOps Training Institute, I aim to simplify complex concepts and share practical insights for learners and professionals. My goal is to empower readers with knowledge, hands-on tips, and industry best practices to stay ahead in the ever-evolving world of DevOps.