Linux File System

Mar 18, 2018 · 2 min read · 252 Words · -Views -Comments

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