Skip to main content

Linux and servers · Beginner · 14 min

Find your way around the Linux filesystem: /etc, /var, /usr and the rest

By Padding · Updated 18 Nov 2026
Ubuntu 26.04.1 LTS · Nginx 1.28.3 (Ubuntu archive)

You will know what each top-level folder on an Ubuntu 26.04 server is for, find where any file came from with dpkg, which, file and findmnt, and have a map of where Nginx keeps its binary, config, data, logs and unit file.

On this page

Most "where is it?" questions on a server have the same answer: Linux puts files by job, not by program. Nginx's settings sit next to every other program's settings in /etc, its logs next to everyone else's logs in /var/log, and its binary next to ls in /usr. Once you know the jobs, you can guess the path before you look.

In this tutorial you will walk the top-level folders of an Ubuntu 26.04 server, learn four commands that answer "where does this live and who put it there?", and finish with a map of every place a packaged service keeps its files. The example service is Nginx from Ubuntu's own archive (version 1.28.3 at the time of writing).

The only changes to your server are two packages (Nginx and file) and one small script. The last step removes the script and shows how to remove the packages if you do not want to keep them.

A grid of twelve cards, one per top-level folder: /etc, /var/log, /var/lib, /usr, /bin /sbin /lib, /usr/local, /opt, /tmp, /var/tmp, /proc /sys, /home /root and /srv, each with a one-line purpose
The top-level folders by job. Keep this open while you work through the steps.

Step 1 · Install the tools and the example service

file tells you what kind of thing a file is, and Nginx gives you a real service to trace. Install both from the Ubuntu archive:

Bash
sudo apt update
sudo apt install -y nginx file

Then list the root of the filesystem:

Bash
ls -l /

You see around twenty entries. Some are folders (lines starting with d) and a few are symbolic links (lines starting with l, with an arrow such as bin -> usr/bin).

Check it worked

nginx -v prints a version starting nginx/1.28, and ls -l / shows at least one line with -> in it.

Step 2 · See that /bin and /sbin are really /usr

On older systems, /bin held the programs needed to boot and /usr/bin held everything else. Ubuntu has merged them: /bin, /sbin and /lib are now links into /usr. There is one copy of each program, under /usr.

Bash
ls -ld /bin /sbin /lib
readlink /bin /sbin
file /bin

readlink prints usr/bin and usr/sbin, and file reports /bin: symbolic link to usr/bin. Find out where a command really is with which, and follow any links with readlink -f:

Bash
which bash nginx
readlink -f /bin/bash

bash lives in /usr/bin and nginx in /usr/sbin, and readlink -f /bin/bash prints /usr/bin/bash. The sbin folders hold programs meant mainly for administrators; your sudo user still has them on its PATH.

The merge matters when you ask the package manager about a file. Packages record the /usr path, so look up the real path rather than the link:

Bash
dpkg -S "$(readlink -f "$(which bash)")"

This prints bash: /usr/bin/bash: the bash package installed that file. If dpkg -S /bin/something ever says no path found matching pattern, run it again on the readlink -f result.

Links can go deeper than the /usr merge. Since Ubuntu 25.10 the basic commands such as ls, cp and readlink come from uutils coreutils, written in Rust, and /usr/bin/ls is itself a link into one shared program under /usr/lib/cargo/bin/. Run readlink -f "$(which ls)" and you see that longer path, not /usr/bin/ls. That is why readlink -f matters: it follows every link to the file that really exists, which is the path to hand to dpkg -S.

Check it worked

readlink /bin prints usr/bin, and dpkg -S names bash as the owner of /usr/bin/bash.

Step 3 · Read /etc and its .d folders

/etc holds configuration: plain text files you read and edit. Packages put their defaults there, and the package manager keeps your edits when it upgrades (it asks before replacing a file you changed).

Many programs read one main file plus every file in a folder ending in .d. That folder is where you add your own settings, so an upgrade never has to merge your changes into the package's file. Look at a few:

Bash
ls /etc/apt/sources.list.d/ /etc/apt/apt.conf.d/ /etc/logrotate.d/
ls /etc/nginx/

Nginx follows the same pattern. Its main file pulls in two folders:

Bash
grep include /etc/nginx/nginx.conf

You get lines like include /etc/nginx/conf.d/*.conf; and include /etc/nginx/sites-enabled/*;. A new site goes in its own file under sites-available/, linked from sites-enabled/; you never need to edit nginx.conf for it.

To see what a file is before you open it, ask file:

Bash
file /etc/nginx/nginx.conf /etc/nginx/sites-enabled/default

The first is ASCII text. The second is a symbolic link to /etc/nginx/sites-available/default, which is how "enabled" works for Nginx sites on Ubuntu.

Check it worked

You can name the .d folder you would use to add your own log rotation rule (/etc/logrotate.d/), and grep include shows both Nginx include lines.

Step 4 · Find what changes in /var

/usr and /etc change when you install or configure something. /var changes while the server runs. Three parts matter most:

  • /var/log holds logs. Services that write their own files (Nginx, apt, dpkg) put them here. systemd's journal also lives under /var/log/journal on a server.
  • /var/lib holds state: databases, package lists, anything a service must keep between restarts. PostgreSQL puts its data in /var/lib/postgresql, Docker in /var/lib/docker.
  • /var/cache holds data that can be downloaded or rebuilt again, such as apt's .deb files.

Look at the logs and state on your server:

Bash
ls /var/log/ /var/log/nginx/
sudo tail -n 3 /var/log/dpkg.log
ls /var/lib/

dpkg.log ends with your Nginx install. In /var/lib/dpkg/info you find the package manager's own state: one .list file per package, holding every path that package installed. That is what dpkg -L reads.

Bash
ls /var/lib/dpkg/info/ | grep '^nginx'

Note for low-cost servers: /var is the folder that grows. On a small VPS with a 10 to 20 GB disk, logs and /var/lib are where space goes, so check them first when a disk fills up.

Check it worked

/var/log/nginx/ exists (Nginx writes access.log and error.log there once it runs), and the grep '^nginx' line lists files ending in .list.

Step 5 · Separate your own software from the system's

apt owns /usr/bin, /usr/lib and /usr/share. If you put files there yourself, an upgrade may overwrite them, and nobody can tell later where they came from. Use one of two places instead:

  • /usr/local for single programs and scripts you build or write. It has its own bin, lib and share, and /usr/local/bin comes before /usr/bin on the PATH.
  • /opt for a vendor's self-contained bundle, one folder per product (/opt/<product>/), as many commercial tools ship.

Install a small script into /usr/local/bin:

Bash
printf '#!/bin/sh\necho "fs-tour works"\n' > /tmp/fs-tour
sudo install -m 755 /tmp/fs-tour /usr/local/bin/fs-tour
rm /tmp/fs-tour
which fs-tour
fs-tour

Now ask the package manager who owns it:

Bash
dpkg -S /usr/local/bin/fs-tour || echo "No package owns this file"

dpkg reports no path found matching pattern, then the echo runs. That is the point: anything in /usr/local or /opt is yours to track, update and remove.

Check it worked

which fs-tour prints /usr/local/bin/fs-tour, and the script prints fs-tour works.

Step 6 · Tell /tmp from /var/tmp, and find which disk holds a path

Both folders are scratch space that any user can write to. The difference is how long files last:

  • /tmp is for short-lived files. Expect it to be empty after a reboot. On some systems it is a tmpfs, kept in memory.
  • /var/tmp is for temporary files that should survive a reboot, such as a half-finished download.

Both have the sticky bit, the t at the end of the permissions, so users can only delete their own files there:

Bash
ls -ld /tmp /var/tmp

Each line starts drwxrwxrwt. To see which mounted filesystem holds a path, and what type it is, use findmnt -T:

Bash
findmnt -T /tmp -o TARGET,SOURCE,FSTYPE
findmnt -T /var/log -o TARGET,SOURCE,FSTYPE

If the TARGET column says /, the path sits on the root disk. If it says /tmp with type tmpfs, your /tmp lives in memory and counts against RAM, not disk. On a server with a separate data volume, run the same command on your data folder to check it really lands on that volume.

systemd's clean-up rules decide when old files go. To read them on your server:

Bash
cat /usr/lib/tmpfiles.d/tmp.conf

Each rule line names a folder, its permissions and an age; files older than that age are removed during clean-up. If the file is missing, your server has no systemd clean-up rules for these folders.

Check it worked

Both ls -ld lines end their permission string in t, and findmnt -T prints a row for each path.

Step 7 · Look at /proc, /sys and the home folders

/proc and /sys are not on disk. The kernel makes their contents up when you read them, so they always show the current state:

Bash
cat /proc/uptime
head -n 3 /proc/meminfo
ls /sys/class/net/
cat /sys/class/net/lo/mtu
findmnt -T /proc -o TARGET,FSTYPE
findmnt -T /sys -o TARGET,FSTYPE

/proc/uptime gives seconds since boot, /proc/meminfo starts with MemTotal, and /sys/class/net/ lists your network interfaces (lo and one or more like eth0 or ens3). findmnt reports types proc and sysfs: virtual filesystems, not disks. Every running process also gets a folder, /proc/<pid>. /proc/self always means "the process reading it", and the shell variable $$ holds your shell's own process number, so you can look at your shell's folder:

Bash
readlink /proc/$$/exe

That prints the program your shell is running, something like /usr/bin/bash.

Last, the people folders:

  • /home/<user> belongs to each login user.
  • /root is the root user's home, kept apart from /home and closed to other users.
  • /srv is for data the server serves, such as /srv/www or /srv/git, when you want it outside any one user's home. Ubuntu leaves it empty.
Bash
ls -ld /home /root /srv

/root shows something like drwx------ root root: only root may enter.

Check it worked

cat /sys/class/net/lo/mtu prints 65536, and findmnt shows proc for /proc.

Step 8 · Map where Nginx keeps everything

Now put it together for one service. Start with what the packages installed. Nginx comes as two packages: nginx (the program) and nginx-common (configuration and other shared files):

Bash
dpkg -S /usr/sbin/nginx /etc/nginx/nginx.conf
dpkg -L nginx-common | grep -E '^/(etc|usr/lib/systemd)'

The first prints nginx: /usr/sbin/nginx and nginx-common: /etc/nginx/nginx.conf. The second lists the config files and the service unit, /usr/lib/systemd/system/nginx.service. Ubuntu ships units in /usr/lib/systemd/system; your own units and overrides go in /etc/systemd/system, which wins.

Some folders do not appear in any package list, because the package's install script created them. Check for /var paths in the list:

Bash
dpkg -L nginx-common | grep '^/var' || echo "No /var paths in the package list"

For those, ask the program and its config. nginx -V prints the paths compiled into the binary, and the default site names the web root:

Bash
nginx -V 2>&1 | tr ' ' '\n' | grep -E 'conf-path|temp-path|pid-path'
grep -E '^\s*(access|error)_log' /etc/nginx/nginx.conf
grep -E '^\s*root' /etc/nginx/sites-available/default

You see --conf-path=/etc/nginx/nginx.conf, temporary paths under /var/lib/nginx/, logs in /var/log/nginx/ and root /var/www/html;. The unit file itself you read with systemd:

Bash
systemctl cat nginx

The output starts with # /usr/lib/systemd/system/nginx.service, followed by the unit. That first line is a comment systemctl cat adds to tell you which file it read. You can also read the file directly and list its section headings:

Bash
grep -n '^\[' /usr/lib/systemd/system/nginx.service

You see [Unit], [Service] and [Install], each with its line number.

A table mapping six kinds of Nginx file to their paths: binary /usr/sbin/nginx, configuration /etc/nginx, web root and state /var/www/html and /var/lib/nginx, logs /var/log/nginx, service unit /usr/lib/systemd/system/nginx.service, log rotation /etc/logrotate.d/nginx, and which package or install step each comes from
The finished map for Nginx. The same six questions work for PostgreSQL, Redis or any other packaged service.

Remove the practice script. Leave Nginx installed if you plan to follow the Nginx tutorials next; otherwise remove it too with sudo apt purge -y nginx nginx-common (this deletes its config under /etc/nginx). If file was not on your server before this tutorial and you do not want it, remove it with sudo apt purge file. Other packages can depend on it, so read the list of packages apt plans to remove before you answer yes. Now delete the script:

Bash
sudo rm /usr/local/bin/fs-tour

Check it worked

You can fill in the map for Nginx without looking: binary, config, data, logs, unit file. Try it next on another package with dpkg -L <package> and dpkg -S <path>.

Next steps

  • Control who can read and change the files you found here: /tutorials/linux-file-permissions-chmod-chown
  • Track down which of these folders is filling your disk: /tutorials/find-what-is-using-disk-space-linux
  • Install the current stable Nginx and serve a page: /tutorials/install-nginx-on-ubuntu-26-04
  • Write your own unit file in /etc/systemd/system: /tutorials/run-an-app-as-a-systemd-service

Need this done for you?

Padding does this work for growing companies, from the first diagnosis to a system that keeps working.

Platform Engineering

Get new tutorials

New tutorials, about twice a month.