- Root Filesystem Definition
- Linux File System
- What is Linux File System?
- / (root)
- /bin
- /boot
- /dev
- /etc
- /home
- /lib
- /media
- /mnt
- /opt
- /srv
- /sbin
- /sys
- /tmp
- Understanding UNIX / Linux File Systems
- What is a file in Linux or Unix?
- How to list directory contents
- More on the file mode
- What is a directory?
- How to create a directory
- Linux supports numerous file system types
- What is a UNIX/Linux File system?
- But what is in a File system?
Root Filesystem Definition
The root filesystem is the filesystem that is contained on the same partition on which the root directory is located, and it is the filesystem on which all the other filesystems are mounted (i.e., logically attached to the system) as the system is booted up (i.e., started up).
A partition is a logically independent section of a hard disk drive (HDD). A filesystem is a hierarchy of directories (also referred to as a directory tree) that is used to organize files on a computer system. On Linux and and other Unix-like operating systems, the directories start with the root directory, which contains a series of subdirectories, each of which, in turn, contains further subdirectories, etc. A variant of this definition is the part of the entire hierarchy of directories (i.e., of the directory tree) that is located on a single partition or disk.
The exact contents of the root filesystem will vary according to the computer, but they will include the files that are necessary for booting the system and for bringing it up to such a state that the other filesystems can be mounted as well as tools for fixing a broken system and for recovering lost files from backups. The contents will include the root directory together with a minimal set of subdirectories and files including /boot, /dev, /etc, /bin, /sbin and sometimes /tmp (for temporary files).
Only the root filesystem is available when a system is brought up in single user mode. Single user mode is a way of booting a damaged system that has very limited capabilities so that repairs can be made to it. After repairs have been completed, the other filesystems that are located on different partitions or on different media can then be mounted on (i.e., attached to) the root filesystem in order to restore full system functionality. The directories on which they are mounted are called mount points.
The root filesystem should generally be small, because it contains critical files and a small, infrequently modified filesystem has a better chance of not becoming corrupted. A corrupted root filesystem will generally mean that the system becomes unbootable (i.e., unstartable) from the HDD, and must be booted by special means (e.g., from a boot floppy).
A filesystem can be mounted anywhere in the directory tree; it does not necessarily need to be mounted on the root filesystem. For example, it is possible (and very common) to have one filesystem mounted at a mount point on the root filesystem, and another filesystem mounted at a mount point contained in that filesystem.
Created April 18, 2006.
Copyright © 2006 The Linux Information Project. All Rights Reserved.
Источник
Linux File System
In this lesson, we will focus on Linux File System. We will learn what is Linux File System? The files that resides in this file system one by one.
Table of Contents
What is Linux File System?
Linux has different directories. These directory structure are defined by Linux File System Hierarchy Standard (FHS). All these directories are defined under the root directory (/). Some of these directories are standard and some of them are added according to the installed sub systems. Here, we will focus on File System of Linux and we will learn what is Linux File System detailly.
We will cover common directories during the explanation of what is Linux File System. These directories are given below:
- / (root)
- /bin
- /boot
- /dev
- /etc
- /home
- /lib
- /media
- /mnt
- /opt
- /srv
- /sbin
- /tmp
- /usr
- /proc
- /var
Now, let’s focus on each of these directories used in Linux File System and learn what are they.
/ (root)
The main answer of what is Linux File System quesiton is Root directory. Root directory (/) is the top of the all directories in this File System. All the other directories are connected to this directory. Only root user has write permission under root directory (/).
Below, you can see the directories under root directory in kali Linux.
kali@kali:/$ ls
bin dev home initrd.img.old lib32 libx32 media opt root sbin sys usr vmlinuz
boot etc initrd.img lib lib64 lost+found mnt proc run srv tmp var vmlinuz.old
/bin
There are different binary programs that are needed during booting, upgrading, repairing etc. The executable binary programs are stored in /bin directory. It is also the directory of the basic Linux commands.
Below, you can see some parts of the content of /bin directory:
kali@kali:/bin$ ls
atobm gunzip pager systemd-resolve
attr guymager pa-info systemd-run
autoexpect gv2gml pamon systemd-socket-activate
automat-visualize3 gv2gxl paperconf systemd-stdio-bridge
autopasswd gvcolor paplay systemd-sysusers
autopsy gvgen parec systemd-tmpfiles
awk gvmap parecord systemd-tty-ask-password-agent
axel gvmap.sh parole systemd-umount
b2sum gvpack parse-edid sz
base32 gvpr partx tabs
base64 gxl2dot passmass tac
basename gxl2gv passwd tail
bash gzexe paste tapestat
/boot
/boot directory holds the important files for boot-up process. In other words it includes boot loader files. It is one of the other answer of what is Linux File System question.
Below, you can see the content of /boot directory.
kali@kali:/boot$ ls
config-5.4.0-kali2-amd64 grub initrd.img-5.4.0-kali3-amd64 System.map-5.4.0-kali3-amd64 vmlinuz-5.4.0-kali3-amd64
config-5.4.0-kali3-amd64 initrd.img-5.4.0-kali2-amd64 System.map-5.4.0-kali2-amd64 vmlinuz-5.4.0-kali2-amd64
/dev
/dev directory includes all the device files. These devices can be any physical devices like cpu, usb, storages etc.
Below you can see some parts of the content of /dev directory.
kali@kali:/dev$ ls
agpgart cpu_dma_latency hidraw1 mqueue rfkill snd tty13 tty23 tty33 tty43 tty53 tty63 vcs vcsa3 vcsu6
autofs cuse hpet net rtc sr0 tty14 tty24 tty34 tty44 tty54 tty7 vcs1 vcsa4 vcsu7
block disk hugepages null rtc0 stderr tty15 tty25 tty35 tty45 tty55 tty8 vcs2 vcsa5 vfio
bsg dmmidi initctl nvram sda stdin tty16 tty26 tty36 tty46 tty56 tty9 vcs3 vcsa6 vga_arbiter
/etc
/etc directory is another important directory of Linux File System. This file contains configuration files of the applications and different start and stop scritpts.
kali@kali:/etc$ ls
adduser.conf default hosts localtime openvpn request-key.conf subgid-
adjtime deluser.conf hosts.allow logcheck opt request-key.d subuid
alsa dhcp hosts.deny login.defs os-release resolv.conf subuid-
alternatives dictionaries-common idmapd.conf logrotate.conf PackageKit resolvconf subversion
apache2 discover.conf.d ifplugd logrotate.d pam.conf responder sudoers
/home
/home is the home directory of all users. Each user’s personal files are stored in this directory in Linux Directory System. /home directory contains user directories like downloads, documents, desktop etc.
/lib
/lib directory contains library files that support binaries that resides in /bin and /sbin. Kernel modules and shared library images are also stored here.
kali@kali:/lib$ ls
apache2 file libDeployPkg.so.0 libvmtools.so.0 pppd
apparmor firefox-esr libDeployPkg.so.0.0.0 libvmtools.so.0.0.0 proxychains3
apt firmware libdiscover.so.2 linux-boot-probes pulse-13.0
arj galera libdiscover.so.2.0.1 llvm-8 python2.7
aspell gcc libdlrpc.so locale python3
/media
/media directory is used as a temporary mount directory for removable devices. For example, this can be a cdrom.
ali@kali:/media$ ls
/mnt
/mnt directory is the temporary directory where we can mount filesystems in Linux Directory systems.
/opt
/opt directory contains the 3th party applications. These applications can be installed directly under /opt or under any other sub directory under /opt.
/srv
/srv directory contains server specific services data. Srv is the abbreviation of service.
/sbin
/sbin is the directory in Linux directory systems that includes system binary executable programs. This can be ifconfig, reboot, iptables, init, route etc.
Some part of the /sbin directory content is given below:
kali@kali:/sbin$ ls
a2disconf e2label ip6tables-nft-restore nftl_format sm-notify
a2dismod e2mmpstatus ip6tables-nft-save nginx snmpd
a2dissite e2scrub ip6tables-restore nmbd split-logfile
a2enconf e2scrub_all ip6tables-restore-translate nologin sshd
a2enmod e2undo ip6tables-save ntfsclone ssldump
a2ensite e4crypt ip6tables-translate ntfscp sslh
a2query e4defrag ipmaddr ntfslabel sslh-select
/sys
/sys directory includes virtual filesystem that stores the modifications that we do on the connected devices.
kali@kali:/sys$ ls
block bus class dev devices firmware fs hypervisor kernel module power
/tmp
/tmp directory is another directory used in Linux File System. /tmp directory stores temporary files of the user and the system. After a reboot it id deleted. In other words, it stores the files between reboots.
Источник
Understanding UNIX / Linux File Systems
A conceptual understanding of the file system, especially data structure and related terms will help you become a successful system administrator. I have seen many new Linux system administrator without any clue about the file system. The conceptual knowledge can be applied to restore the file system in an emergency situation.
What is a file in Linux or Unix?
A file is a collection of data items stored on disk. Or, it is a device which can store the information, data, music (mp3 files), picture, movie, sound, PDF book and more. All data must be stored on your computer in the form of a file. Files are always associated with devices like hard disk, floppy disk, USB pen drive and more. A file is the last object in your file system tree. See Linux/UNIX – rules for naming file and directory names.
How to list directory contents
Use the ls command:
ls
ls -l
ls -Fl
ls -l /etc/
Using ls command to list information about the files on Linux and Unix-like systems
The following information is displayed for each file from above outputs:
Field | Description |
---|---|
drwxr-xr-x | File mode |
3 | Number of links to file |
root | File owner name |
root | File group name |
4096 | number of bytes in the file |
Apr 4 2018 | Abbreviated month, day-of-month file was last modified, hour file last modified, and minute file last modified |
acpi | The pathname/filename |
The acpi is a directory indicated by first character d in drwxr-xr-x and the adduser.conf is a file indicated by first character — in —rw-r—r— . Let us try to understand meaning of drwxr-xr-x in ls command output.
More on the file mode
To understand the drwxr-xr-x file mode let us divide into three groups:
- group 1 : d
- group 2 : rwx
- group 3 : r-x
- group 4 : r-x
The file mode (group 1) printed consists of the file type and the permissions. The entry type character (group 1) describes the type of file, as follows:
Character | File type |
---|---|
— | Regular file. |
b | Block special file. |
c | Character special file. |
d | Directory. |
l | Symbolic link. |
p | FIFO. |
s | Socket. |
w | Whiteout. |
The next three groups are for owner permissions (group 2), group permissions (group 3), and other permissions (group 4). So each field has three character positions:
- r : Read only file permission
- w : Write only file permission
- x : Execute only file permission
- – : No permission
So group 2 has rwx permission it means you have read, write and executable permission on the file.
- No ads and tracking
- In-depth guides for developers and sysadmins at Opensourceflare✨
- Join my Patreon to support independent content creators and start reading latest guides:
- How to set up Redis sentinel cluster on Ubuntu or Debian Linux
- How To Set Up SSH Keys With YubiKey as two-factor authentication (U2F/FIDO2)
- How to set up Mariadb Galera cluster on Ubuntu or Debian Linux
- A podman tutorial for beginners – part I (run Linux containers without Docker and in daemonless mode)
- How to protect Linux against rogue USB devices using USBGuard
Join Patreon ➔
What is a directory?
A directory is a group of files. A directory is divided into two types:
- Root directory – Strictly speaking, there is only one root directory in your Linux and Unix-like system, which is denoted by / (forward slash). It is root of your entire file system and can not be renamed or deleted.
- Sub directory – Directory under root (/) directory is subdirectory which can be created, renamed by the user.
Directories are used to organize your data files, programs more efficiently.
How to create a directory
Use the mkdir command:
mkdir dir1
Next list newly created directory with the help of ls command:
ls -ld dir1
To change the working directory use the cd command:
cd dir1
To print the current working directory, run the pwd command:
pwd
Let us create two sub-directories and a file, run:
mkdir foo
mkdir -v bar
Next create a file named demo.txt in Linux/Unix from a bash shell prompt, run:
echo «This is a test» > demo.txt
List everything:
ls -l
Creating a new directory, sub-directories, and file on Linux
Linux supports numerous file system types
- Ext2: This is like UNIX file system. It has the concepts of blocks, inodes and directories.
- Ext3: It is ext2 filesystem enhanced with journalling capabilities. Journalling allows fast file system recovery. Supports POSIX ACL (Access Control Lists).
- Isofs (iso9660): Used by CDROM file system.
- Sysfs: It is a ram-based filesystem initially based on ramfs. It is use to exporting kernel objects so that end user can use it easily.
- Procfs: The proc file system acts as an interface to internal data structures in the kernel. It can be used to obtain information about the system and to change certain kernel parameters at runtime using the sysctl command. For example, you can find out CPU information on Linux with following cat command:
- Or you can enable or disable routing/forwarding of IP packets between interfaces with following command:
# cat /proc/sys/net/ipv4/ip_forward
# echo «1» > /proc/sys/net/ipv4/ip_forward
# echo «0» > /proc/sys/net/ipv4/ip_forward
- NFS: Network file system allows many users or systems to share the same files by using a client/server methodology. NFS allows sharing all of the above file system.
- Linux also supports Microsoft NTFS, vfat, and many other file systems. See Linux kernel source tree Documentation/filesystem directory for list of all supported filesystem.
You can find out what type of file systems currently mounted with mount command.
$ mount
OR
$ cat /proc/mounts
mount running on OpenBSD Unix box and display /proc/mounts on Linux
What is a UNIX/Linux File system?
A UNIX file system is a collection of files and directories stored on disk. Each file system is stored in a separate whole disk partition. The following are a few of the file system:
- / – Special file system that incorporates the files under several directories including /dev, /sbin, /tmp and more
- /usr – Stores application programs
- /var – Stores log files, mails and other data
- /tmp – Stores temporary files
But what is in a File system?
Again file system divided into two categories:
- User data – stores actual data contained in files
- Metadata – stores file system structural information such as superblock, inodes, directories
Next time I will write more about Metadata objects – superblock, inodes, directories with actual linux commands so that you can understand and master the concepts 🙂
Continue reading rest of the Understanding Linux file system series:
Category | List of Unix and Linux commands |
---|---|
Documentation | help • mandb • man • pinfo |
Disk space analyzers | df • duf • ncdu • pydf |
File Management | cat • cp • less • mkdir • more • tree |
Firewall | Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04 |
Linux Desktop Apps | Skype • Spotify • VLC 3 |
Modern utilities | bat • exa |
Network Utilities | NetHogs • dig • host • ip • nmap |
OpenVPN | CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04 |
Package Manager | apk • apt |
Processes Management | bg • chroot • cron • disown • fg • glances • gtop • jobs • killall • kill • pidof • pstree • pwdx • time • vtop |
Searching | ag • grep • whereis • which |
Shell builtins | compgen • echo • printf |
Text processing | cut • rev |
User Information | groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w |
WireGuard VPN | Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04 |
Comments on this entry are closed.
I would like to post my comments regarding file and directories definitation.
It contains the metadata which includes inodes, date and stamp, rights and ownership filesize and type. It also has the link to the datablock which stores data on it.
Directories are also files which contains filename to inode associations in its datablock so people says there are only files in Unix.
Nice ashish! I appreciate your post 🙂
Procfs: The proc
___^____________
cat /proc/mounts
_______________^
You didn’t mention Reiserfs which I think is a little short sighted. Many users prefer it to ext3, XFS, and JFS journaling filesystems. Once reiserfs v4 is merged we’ll see some cool features being made available to all other filesystems as well.
Anonymous, thanks. I really appreciate your help for spotting out typos and your post.
Yes, I just missed reiserfs v3 was quite stable v4 will take some to stable under 2.6 kernel.. I will update the post for reiserfs. Thanks for suggestion.
Quote “It contains the metadata which includes inodes, date and stamp, rights and ownership filesize and type. It also has the link to the datablock which stores data on it.”
I think this definition is wrong, a file by definition is a stream of data -the meta data is exactly that, its data about data.
The inode may be part of the operating systems fileing system, but it is NOT part of the file. For example if I copy a file from my linux system onto my windows system i lose the date/time/inode/mode/group – but I still have my “file”
When you copy a file from linux to windows or within the same OS, you are creating a new file. You are not losing the date/time or anything that you have mentioned. The new file is just getting updated with its values. Copying copies only the data, not the metadata. File “data” is not everything. Its just another attribute of a file. Data + Metadata = File.
This brings another querry in my mind.
Where file is storing the information about date, stamp, permissions, ownership and filesize?
BTW, I really do not have much information about windows file system. Is it same like Unix file system? Is it having inodes and other stuff?
Thanks!
Ashish Pathak
“A conceptual understanding of file system, especially data structure and related terms will help you become a successful system administrator”
———————-
But his job is easily taken away
by future s/w that manages all objects
files and folders , w/o a cmd line .
Automating objects , reduces the
kernel size , runs much faster .
————————
Pocket boxes are $5 cpu , & 64MB .
And Intel lost its grip ( 20 countries
make ARM !). No more WinTel .
Ppl will hack h/w and s/w into
a pocket box that will run fast
enuf to do everything .
OpSys that has NO cmd line , true G.U.I.
uses images ONLY , has no text keyboard.
But since OpSys is non-text , one
can create apps in hours ! Most of
the proceedures will be in kernel ,
all you need is to chain these proc’s
in the proper order to create your app .
Yes , i know Linux is your paycheck ,
sorry …..
dear sir,
please send me a good material about red hat linux to i become a good
and skilled system administration in linux.above my e.mail address
Hey friends can any one answer this following questioon plz.. it’s urgent.. I need ur help.
” Now a days memories are large and cheap.Therefore,when a file is opened it is simpler and faster to fetch a new copy of the i-node into the i-node table, rather than searching the entire table to see if it is already there” True or False?? – Justify
Thomas, a question : How does your hypothetical keyboard-less OS stores your resume to begin with? or any data? Just curious.
And what if someone wants to create something new? How do these “most procedures” cope with that then? Sheesh!
If you don’t understand computers, or are plain simple drunk, why bother commenting at all? Why not just sleep off the effect of the wonderful liquor you have imbibed?
I honestly do not think that this is the place that someone such as abhi, should be making disparaging remarks about someone who has a query about an issue he is facing. He approached this forum of ‘professionals’ to seek advice, and this unscrupulous individual abhi decides to attack his intelligence. For all you know “MR. ABHI”, Mr. Scott could be fairly new to this industry in a new environment about something he understands enough to get the job, but is having difficulty in overcoming an issue. Not everyone is blessed with the omniscience of computer workings. I am pretty sure that if you took your CCNA exam, and failed it the first time, you went and asked for help. Even then, IF you enrolled in school, and learned it from someone else, THEY had the patience to answer your questions when you didn’t know. Give the guy a break. As for you MR. Scott, if these people don’t help you, don’t get discouraged. Keep looking, you’ll find the answer from someone who will be patient enough to give it to you.
^ Here we have an excellent example of “white knighting.”
Источник