{"id":29706,"date":"2022-04-24T04:47:37","date_gmt":"2022-04-24T04:47:37","guid":{"rendered":"https:\/\/www.devopsschool.com\/blog\/?p=29706"},"modified":"2022-12-23T06:19:29","modified_gmt":"2022-12-23T06:19:29","slug":"linux-tutorials-root-file-systems-in-linux","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/linux-tutorials-root-file-systems-in-linux\/","title":{"rendered":"Linux Tutorials: root file systems in linux"},"content":{"rendered":"\n<p>The root filesystem should generally be small, since it contains very critical files and a small, infrequently modified filesystem has a better chance of not getting corrupted. A corrupted root filesystem will generally mean that the system becomes unbootable except with special measures (e.g., from a floppy), so you don&#8217;t want to risk it.<\/p>\n\n\n\n<p>The root directory generally doesn&#8217;t contain any files, except perhaps on older systems where the standard boot image for the system, usually called\u00a0\/vmlinuz\u00a0was kept there. (Most distributions have moved those files the the\u00a0\/boot\u00a0directory. Otherwise, all files are kept in subdirectories under the root filesystem:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2022\/04\/linux-file-system-tutorial-1.png\"><img loading=\"lazy\" decoding=\"async\" width=\"950\" height=\"450\" src=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2022\/04\/linux-file-system-tutorial-1.png\" alt=\"\" class=\"wp-image-29707\" srcset=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2022\/04\/linux-file-system-tutorial-1.png 950w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2022\/04\/linux-file-system-tutorial-1-300x142.png 300w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2022\/04\/linux-file-system-tutorial-1-768x364.png 768w\" sizes=\"auto, (max-width: 950px) 100vw, 950px\" \/><\/a><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2022\/04\/linux-file-system-tutorial-2.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"564\" src=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2022\/04\/linux-file-system-tutorial-2-1024x564.png\" alt=\"\" class=\"wp-image-29708\" srcset=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2022\/04\/linux-file-system-tutorial-2-1024x564.png 1024w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2022\/04\/linux-file-system-tutorial-2-300x165.png 300w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2022\/04\/linux-file-system-tutorial-2-768x423.png 768w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2022\/04\/linux-file-system-tutorial-2-1536x846.png 1536w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2022\/04\/linux-file-system-tutorial-2.png 1817w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"558\" height=\"813\" src=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2022\/04\/linux-file-system-tutorial-3.png\" alt=\"\" class=\"wp-image-29709\" srcset=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2022\/04\/linux-file-system-tutorial-3.png 558w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2022\/04\/linux-file-system-tutorial-3-206x300.png 206w\" sizes=\"auto, (max-width: 558px) 100vw, 558px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"602\" height=\"623\" src=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2022\/04\/linux-file-system-tutorial-4.jpg\" alt=\"\" class=\"wp-image-29710\" srcset=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2022\/04\/linux-file-system-tutorial-4.jpg 602w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2022\/04\/linux-file-system-tutorial-4-290x300.jpg 290w\" sizes=\"auto, (max-width: 602px) 100vw, 602px\" \/><\/figure>\n\n\n\n<p>The following list provides information about the contents of some of the subdirectories of the&nbsp;\/&nbsp;(root) file system.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Item<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td>\/etc<\/td><td>Contains configuration files that vary for each machine. Examples include:\/etc\/hosts\/etc\/passwdThe&nbsp;\/etc&nbsp;directory contains the files generally used in system administration. Most of the commands that previously resided in the&nbsp;\/etc&nbsp;directory now reside in the&nbsp;\/usr\/sbin&nbsp;directory. However, for compatibility, the&nbsp;\/usr\/sbin&nbsp;directory contains symbolic links to the locations of some executable files. Examples include:\/etc\/chown&nbsp;is a symbolic link to&nbsp;\/usr\/bin\/chown.\/etc\/exportvg&nbsp;is a symbolic link to&nbsp;\/usr\/sbin\/exportvg.<\/td><\/tr><tr><td>\/bin<\/td><td>Symbolic link to the&nbsp;\/usr\/bin&nbsp;directory. In prior&nbsp;UNIX&nbsp;file systems, the&nbsp;\/bin&nbsp;directory contained user commands that now reside in the&nbsp;\/usr\/bin&nbsp;directory.<\/td><\/tr><tr><td>\/sbin<\/td><td>Contains files needed to boot the machine and mount the&nbsp;\/usr&nbsp;file system. Most of the commands used during booting come from the boot image&#8217;s RAM disk file system; therefore, very few commands reside in the&nbsp;\/sbin&nbsp;directory.<\/td><\/tr><tr><td>\/dev<\/td><td>Contains device nodes for special files for local devices. The&nbsp;\/dev&nbsp;directory contains special files for tape drives, printers, disk partitions, and terminals.<\/td><\/tr><tr><td>\/tmp<\/td><td>Serves as a mount point for a file system that contains system-generated temporary files. The&nbsp;\/tmp&nbsp;file system is an empty directory.<\/td><\/tr><tr><td>\/var<\/td><td>Serves as a mount point for files that vary on each machine. The&nbsp;\/var&nbsp;file system is configured as a file system since the files it contains tend to grow. See&nbsp;<a href=\"https:\/\/www.ibm.com\/docs\/pl\/ssw_aix_71\/devicemanagement\/fs_var.html#fs_var\" target=\"_blank\" rel=\"noopener\">\/var file system<\/a>&nbsp;for more information.<\/td><\/tr><tr><td>\/u<\/td><td>Symbolic link to the&nbsp;\/home&nbsp;directory.<\/td><\/tr><tr><td>\/usr<\/td><td>Contains files that do not change and can be shared by machines such as executables and ASCII documentation.Standalone machines mount the root of a separate local file system over the&nbsp;\/usr&nbsp;directory. Diskless machines and machines with limited disk resources mount a directory from a remote server over the&nbsp;\/usr&nbsp;file system. See&nbsp;<a href=\"https:\/\/www.ibm.com\/docs\/pl\/ssw_aix_71\/devicemanagement\/fs_usr.html#fs_usr\" target=\"_blank\" rel=\"noopener\">\/usr file system<\/a>&nbsp;for more information about the file tree mounted over the&nbsp;\/usr&nbsp;directory.<\/td><\/tr><tr><td>\/home<\/td><td>Serves as a mount point for a file system containing user home directories. The&nbsp;\/home&nbsp;file system contains per-user files and directories.In a standalone machine, the&nbsp;\/home&nbsp;directory is contained in a separate file system whose root is mounted over the&nbsp;\/home&nbsp;directory root file system. In a network, a server might contain user files that are accessible from several machines. In this case, the server copy of the&nbsp;\/home&nbsp;directory is remotely mounted onto a local&nbsp;\/home&nbsp;file system.<\/td><\/tr><tr><td>\/export<\/td><td>Contains the directories and files on a server that are for remote clients.See&nbsp;<a href=\"https:\/\/www.ibm.com\/docs\/pl\/ssw_aix_71\/devicemanagement\/exp_dir.html#exp_dir\" target=\"_blank\" rel=\"noopener\">\/export directory<\/a>&nbsp;for more information about the file tree that resides under the&nbsp;\/export&nbsp;directory.<\/td><\/tr><tr><td>\/lib<\/td><td>Symbolic link to the&nbsp;\/usr\/lib&nbsp;directory. See&nbsp;<a href=\"https:\/\/www.ibm.com\/docs\/pl\/ssw_aix_71\/devicemanagement\/fs_usr.html#fs_usr\" target=\"_blank\" rel=\"noopener\">\/usr file system<\/a>&nbsp;for more information.<\/td><\/tr><tr><td>\/tftpboot<\/td><td>Contains boot images and boot information for diskless clients.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p><strong>\/bin<\/strong><\/p>\n\n\n\n<p>Commands needed during bootup that might be used by normal users (probably after bootup).<\/p>\n\n\n\n<p><strong>\/sbin<\/strong><\/p>\n\n\n\n<p>Like\u00a0\/bin, but the commands are not intended for normal users, although they may use them if necessary and allowed.\u00a0\/sbin\u00a0is not usually in the default path of normal users, but will be in root&#8217;s default path.<\/p>\n\n\n\n<p><strong>\/etc<\/strong><\/p>\n\n\n\n<p>Configuration files specific to the machine.<\/p>\n\n\n\n<p><strong>\/root<\/strong><\/p>\n\n\n\n<p>The home directory for user root. This is usually not accessible to other users on the system<\/p>\n\n\n\n<p><strong>\/lib<\/strong><\/p>\n\n\n\n<p>Shared libraries needed by the programs on the root filesystem.<\/p>\n\n\n\n<p><strong>\/lib\/modules<\/strong><\/p>\n\n\n\n<p>Loadable kernel modules, especially those that are needed to boot the system when recovering from disasters (e.g., network and filesystem drivers).<\/p>\n\n\n\n<p><strong>\/dev<\/strong><\/p>\n\n\n\n<p>Device files. These are special files that help the user interface with the various devices on the system.<\/p>\n\n\n\n<p><strong>\/tmp<\/strong><\/p>\n\n\n\n<p>Temporary files. As the name suggests, programs running often store temporary files in here.<\/p>\n\n\n\n<p><strong>\/boot<\/strong><\/p>\n\n\n\n<p>Files used by the bootstrap loader, e.g., LILO or GRUB. Kernel images are often kept here instead of in the root directory. If there are many kernel images, the directory can easily grow rather big, and it might be better to keep it in a separate filesystem. Another reason would be to make sure the kernel images are within the first 1024 cylinders of an IDE disk. This 1024 cylinder limit is no longer true in most cases. With modern BIOSes and later versions of LILO (the LInux LOader) the 1024 cylinder limit can be passed with logical block addressing (LBA). See the\u00a0<strong>lilo<\/strong>\u00a0manual page for more details.<\/p>\n\n\n\n<p><strong>\/mnt<\/strong><\/p>\n\n\n\n<p>Mount point for temporary mounts by the system administrator. Programs aren&#8217;t supposed to mount on\u00a0\/mnt\u00a0automatically.\u00a0\/mnt\u00a0might be divided into subdirectories (e.g.,\u00a0\/mnt\/dosa\u00a0might be the floppy drive using an MS-DOS filesystem, and\u00a0\/mnt\/exta\u00a0might be the same with an ext2 filesystem).<\/p>\n\n\n\n<p><strong>\/proc,\u00a0\/usr,\u00a0\/var,\u00a0\/home<\/strong><\/p>\n\n\n\n<p>Mount points for the other filesystems. Although\u00a0\/proc\u00a0does not reside on any disk in reality it is still mentioned here. See the section about\u00a0\/proc\u00a0later in the chapter.<\/p>\n\n\n\n<p><strong>The following table provides a very brief list of the standard, well-known, and defined top-level Linux directories and their purposes.<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Directory<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td>\/ (root filesystem)<\/td><td>The root filesystem is the top-level directory of the filesystem. It must contain all of the files required to boot the Linux system before other filesystems are mounted. It must include all of the required executables and libraries required to boot the remaining filesystems. After the system is booted, all other filesystems are mounted on standard, well-defined mount points as subdirectories of the root filesystem.<\/td><\/tr><tr><td>\/bin<\/td><td>The \/bin directory contains user executable files.<\/td><\/tr><tr><td>\/boot<\/td><td>Contains the static bootloader and kernel executable and configuration files required to boot a Linux computer.<\/td><\/tr><tr><td>\/dev<\/td><td>This directory contains the device files for every hardware device attached to the system. These are not device drivers, rather they are files that represent each device on the computer and facilitate access to those devices.<\/td><\/tr><tr><td>\/etc<\/td><td>Contains the local system configuration files for the host computer.<\/td><\/tr><tr><td>\/home<\/td><td>Home directory storage for user files. Each user has a subdirectory in \/home.<\/td><\/tr><tr><td>\/lib<\/td><td>Contains shared library files that are required to boot the system.<\/td><\/tr><tr><td>\/media<\/td><td>A place to mount external removable media devices such as USB thumb drives that may be connected to the host.<\/td><\/tr><tr><td>\/mnt<\/td><td>A temporary mountpoint for regular filesystems (as in not removable media) that can be used while the administrator is repairing or working on a filesystem.<\/td><\/tr><tr><td>\/opt<\/td><td>Optional files such as vendor supplied application programs should be located here.<\/td><\/tr><tr><td>\/root<\/td><td>This is not the root (\/) filesystem. It is the home directory for the root user.<\/td><\/tr><tr><td>\/sbin<\/td><td>System binary files. These are executables used for system administration.<\/td><\/tr><tr><td>\/tmp<\/td><td>Temporary directory. Used by the operating system and many programs to store temporary files. Users may also store files here temporarily. Note that files stored here may be deleted at any time without prior notice.<\/td><\/tr><tr><td>\/usr<\/td><td>These are shareable, read-only files, including executable binaries and libraries, man files, and other types of documentation.<\/td><\/tr><tr><td>\/var<\/td><td>Variable data files are stored here. This can include things like log files, MySQL, and other database files, web server data files, email inboxes, and much more.<\/td><\/tr><\/tbody><\/table><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>The root filesystem should generally be small, since it contains very critical files and a small, infrequently modified filesystem has a better chance of not getting corrupted. A corrupted root filesystem will generally mean that the system becomes unbootable except with special measures (e.g., from a floppy), so you don&#8217;t want to risk it. The&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"_kad_post_classname":"","_joinchat":[],"footnotes":""},"categories":[2],"tags":[],"class_list":["post-29706","post","type-post","status-publish","format-standard","hentry","category-uncategorised"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/29706","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=29706"}],"version-history":[{"count":1,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/29706\/revisions"}],"predecessor-version":[{"id":29711,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/29706\/revisions\/29711"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=29706"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=29706"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=29706"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}