In Part 1 we looked at the root directory (/) and /etc. In this part we cover three places you will use every day: /home, /root, and /tmp.
/home: where regular users live
Every regular user gets a personal folder inside /home. This is where your documents, downloads, projects, and personal settings are stored.
ls /home
safal guest
Your own folder is /home/<username>. You can jump to it from anywhere with:
cd ~
The ~ symbol is a shortcut for your home directory. You can also print it:
echo $HOME
/home/safal
Typical contents
ls ~
Desktop Documents Downloads
Music Pictures Videos
Hidden files (dotfiles)
Files and folders that start with a dot are hidden. Programs store your personal settings in them. Use -a to see them:
ls -a ~
. .. .bashrc .profile .ssh
.config .local .cache
| Dotfile | Purpose |
|---|---|
.bashrc |
Bash settings and aliases |
.profile |
Login shell settings |
.ssh/ |
SSH keys and known hosts |
.config/ |
Settings for many apps |
.cache/ |
Cached data, safe to clear |
Check how much space you use
du -sh ~
4.2G /home/safal
Permissions
Home folders are private to each user by default:
ls -ld ~
drwxr-x--- 15 safal safal 4096 Nov 2 10:15 /home/safal
On many newer distributions, other users cannot read your home folder, which is good for privacy.
/root: the home of the root user
/root is the home directory of the root (administrator) user. It is not inside /home, so it stays available even if /home is on a separate disk that fails to mount.
ls -ld /root
drwx------ 5 root root 4096 Nov 2 09:40 /root
Only root can enter it. To look inside, use sudo:
sudo ls -a /root
Do not confuse these three:
| Path | Meaning |
|---|---|
/ |
Root of the whole filesystem |
/root |
Home folder of the root user |
root |
The administrator account |
/tmp: temporary files
/tmp is a shared place for short-lived files. Programs use it for scratch data, and any user can write to it.
ls -ld /tmp
drwxrwxrwt 18 root root 4096 Nov 2 10:20 /tmp
Notice the t at the end of the permissions. This is the sticky bit. It means everyone can create files in /tmp, but you can only delete or rename your own files.
Create a safe temporary file
Use mktemp instead of inventing a file name, so two programs never clash:
mktemp
/tmp/tmp.Xk3j9fA2bQ
Create a temporary folder:
mktemp -d
Files may disappear
Many systems clear /tmp on reboot, and some also delete old files automatically. Never store anything important there.
If you need temporary files that survive a reboot, look at /var/tmp, which we will cover in the /var part.
Security tip
Because /tmp is writable by everyone, avoid putting passwords, keys, or private data there. Also avoid predictable file names in scripts, and prefer mktemp.
Quick comparison
| Directory | Owner | Survives reboot? |
|---|---|---|
/home/user |
That user | Yes |
/root |
Root only | Yes |
/tmp |
Everyone | Often no |
Summary
-
/home/<user>is your personal space, with hidden dotfiles for settings. -
/rootis the private home folder of the administrator. -
/tmpis shared and temporary, so never keep important data there.
Next in the series: Part 3, /var (logs, cache, and spool).
Found a mistake or have a tip? Leave a comment below.
Top comments (0)