- Kali Linux Tutorial
- Kali Linux - Home
- Installation & Configuration
- Information Gathering Tools
- Vulnerability Analyses Tools
- Kali Linux - Wireless Attacks
- Website Penetration Testing
- Kali Linux - Exploitation Tools
- Kali Linux - Forensics Tools
- Kali Linux - Social Engineering
- Kali Linux - Stressing Tools
- Kali Linux - Sniffing & Spoofing
- Kali Linux - Password Cracking Tools
- Kali Linux - Maintaining Access
- Kali Linux - Reverse Engineering
- Kali Linux - Reporting Tools
- Kali Linux Useful Resources
- Kali Linux - Quick Guide
- Kali Linux - Useful Resources
- Kali Linux - Discussion
Linux Files Series
Linux is a popular operating system that is widely used by developers, system administrators, and users who seek more control over their computer systems. One of key features of Linux is its file system, which is different from those found in other operating systems like Windows or MacOS. In this article, we will explore Linux file system in detail, including its structure, file types, and permissions.
Linux File System Structure
The Linux file system is structured in a hierarchical manner, with all files and directories organized under a single root directory. root directory is denoted by a forward slash (/) and is top-level directory in file system hierarchy. All other directories and files are located within this root directory.
Directories in Linux are similar to folders in other operating systems. They can contain files, subdirectories, or both. In Linux, directories are also files, but they differ from regular files in that they contain a list of other files and directories. root directory contains several important directories, including −
/bin − This directory contains executable files that are essential for functioning of system. These files are used by all users, including root user.
/boot − This directory contains files that are required for boot process, such as Linux kernel and boot loader.
/dev − This directory contains device files that represent hardware devices connected to system, such as disk drives and printers.
/etc − This directory contains configuration files for system and applications.
/home − This directory contains home directories for users on system.
/lib − This directory contains libraries that are used by system and applications.
/mnt − This directory is used for temporarily mounting file systems, such as CD-ROMs or USB drives.
/proc − This directory contains information about processes running on system.
/root − This directory is home directory for root user.
/sbin − This directory contains executable files that are used by system administrator (root) to perform system maintenance tasks.
/tmp − This directory is used for temporary files created by applications or system.
/usr − This directory contains user-related files, such as applications, libraries, and documentation.
/var − This directory contains variable data files, such as log files and spool directories.
File Types in Linux
In Linux, files are classified into several types based on their purpose and contents. most common file types in Linux are −
Regular Files − These are normal files that contain data, such as text files, images, or audio files. Regular files can be read, written, or executed.
Directories − As mentioned earlier, directories are special files that contain a list of other files and directories.
Symbolic Links − These files are used to create a shortcut or alias to another file or directory.
Character Devices − These files represent hardware devices that transfer data one character at a time, such as serial ports and terminals.
Block Devices − These files represent hardware devices that transfer data in blocks, such as hard disk drives and CD-ROMs.
Named Pipes − These files are used to transfer data between processes or programs.
Sockets − These files are used for communication between processes over a network or a local machine.
File Permissions in Linux
In Linux, each file and directory has a set of permissions that determine who can access it and what actions they can perform. There are three types of permissions in Linux −
Read (r) − This permission allows a user to view contents of a file or directory.
Write (w) − This permission allows a user to modify contents of a file or directory.
Execute (x) − This permission allows a user to run an executable file or access a directory.
Permissions are assigned to three categories of users: owner, group, and others. owner is user who created file or directory, while group is a set of users with common permissions. "others" category refers to all users who are not owner or a member of group.
Permissions are represented by a series of characters, where each character corresponds to a particular permission. first character represents file type (e.g., "-" for regular files, "d" for directories, "l" for symbolic links, etc.), while next nine characters represent permissions for owner, group, and others. Each set of three characters represents read, write, and execute permissions, respectively.
For example, following permissions represent a regular file that can be read and written by owner, read-only for group, and read-only for others −
In this example, first character "-" indicates that it is a regular file. next three characters "rw-" indicate that owner can read and write file, but cannot execute it. following three characters "r--" indicate that group can only read file but cannot write or execute it. Finally, last three characters "r--" indicate that others can also only read file.
Changing Permissions in Linux
To change permissions of a file or directory in Linux, you can use "chmod" command. "chmod" command allows you to set or modify permissions for owner, group, and others.
For example, to give owner, group, and others read, write, and execute permissions for a file named "example.txt", you would use following command −
chmod 777 example.txt
In this example, "777" represents permissions you want to assign to file. first "7" represents read, write, and execute permissions for owner, second "7" represents same permissions for group, and third "7" represents same permissions for others.
The Linux file system is a powerful and flexible system that allows users to control their computer systems with precision. Understanding structure of file system, different types of files, and how permissions work is essential for using Linux effectively. By using command line and various tools available in Linux, users can manage their files and directories with ease, making it a popular choice for developers, system administrators, and power users.
- Related Articles
- Concatenating Files in Linux
- Linking to Files in Linux
- Decompressing Files in Linux with Gunzip
- Find and tar Files on Linux
- Move All Files Including Hidden Files Into Parent Directory in Linux
- Transfer Files Between Linux Machines Over SSH
- Displaying Files Side by Side in Linux
- Delete empty files and directories in Linux
- Move all files except one on Linux
- Increase number of maximum open files in linux
- Soft-Delete Files from the Terminal on Linux
- How to Count Number of Files in Linux
- Filtering Files Copied When Using rsync on Linux
- How to create links between files in the Linux?
- Understanding .a , .so and .la library files in Linux