Linux File System

This post explains the Linux file system hierarchy and common directory meanings to help you choose proper install paths.

Mar 18, 2018 · 2 min read · 252 Words · -Views -Comments · Programming
Linux 🇨🇳 阅读中文版
Read with AI

Choose an AI assistant

ChatGPT Open in a new tab with the article link and prompt
Claude Copy the prompt, then open Claude

Open Claude
Trouble reading the article?

If the prompt is missing, copy the full prompt below into your AI assistant. If the AI cannot read the article, paste the visible passage you want to discuss and add your question.

I was driving a company’s CI/CD and used Linux more often. I had used it before, but since my main role was system development, my fundamentals were not solid. When installing Tomcat, JDK, FTP, etc., I often wondered where software should be installed or which path is appropriate. This wasted time. So I decided to dig into it to save time.

This article is based on research across multiple sources.

For the Linux file system, you should read the Filesystem Hierarchy Standard, which explains the origin of these names.

  • /bin - binaries
  • /boot - boot files
  • /dev - device files
  • /tmp - temporary files, writable by everyone
  • /etc - inherited from early Unix, for configuration files
  • /home - home directories
  • /lib - libraries
  • /media - mount points for removable media
  • /mnt - mounted file systems
  • /opt - optional add-on software
  • /run - runtime variable data
  • /sbin - usually for root
  • /usr - inherited from Unix, stands for user, shared among users
  • /var - inherited from Unix, stands for variable
  • /srv - stands for serve, used for hosting static files, /srv/http for static sites, /srv/ftp for FTP

/opt vs /usr/local

/usr/local is typically for things installed into /usr or overrides of /usr. /opt keeps everything in one folder or special cases.

When /tmp is cleared

If you put files in /tmp, they may disappear after a while because CentOS has a scheduled task tmpwatch that cleans old files (over 10 days) in /tmp. Other systems like Debian clear /tmp on startup.

References

Authors
Developer, digital product enthusiast, tinkerer, sharer, open source lover