Engineers Garage

  • Projects and Tutorials
    • Electronic Projects
      • 8051
      • Arduino
      • ARM
      • AVR
      • PIC
      • Raspberry pi
      • STM32
    • Tutorials
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Products News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • EE Resources
    • DesignFast
    • LEAP Awards
    • Oscilloscope Product Finder
    • White Papers
    • Webinars
  • EE Learning Center
    • Design Guides
      • WiFi & the IOT Design Guide
      • Microcontrollers Design Guide
      • State of the Art Inductors Design Guide
  • Women in Engineering

Introduction To File System In Linux (Part 6/15)

By Ashish Vara

File System in Linux

We always keep hearing and speaking about file of different kinds like text file, word file, video file, audio file, image file etc But do you know that everything in Linux is a file? Understanding a file system is necessary part of Linux which we are going to discuss here.

What is the file?

File is nothing but linear stream  or a small block of byte. User can read, write or execute the file. Linux system is used for multiuser purpose so each user can access the file and modify it. The administrator can also set the permission so that noone can modify it without his/her permission. User can be classified in three categories:

User – Owner of the file who generates the file.

Group – Group of users for specific file

Another-  Another person who can access the file after administrator’s permission.

Total nine permission bits are associated with single file. Each of the three bits is associated with all three categories.

–

r

w

x

r

w

x

r

w

x

Here, (-) dash is an indication of regular file. The symbol ‘r’ is for read, ‘w’ is for write and ‘x’ is for execute. Each group of rwx is associated with user, group and another category respectively. System doesn’t  understand the file name, it just understands digital value. When file is created by a user or group of users, it is stored as a numerical value in system called User ID Group ID.

 Suppose I have created the file named as engineersgarage.txt by touch command:

            touch engineersgarage.txt

Now, enter the following command:

ls -l engineersgarage.txt

The following output is displayed on terminal:

-rw-rw-r– 1 ashish ashish 0 Mar  1 10:12 engineersgarage.txt

Here, you can show how to assign permission to the file. First and second combinations of three bit rw- are associated with user and group respectively. It provides read and write permission to user. Last combination of three bit r– is associated with another group which only reads the file.

What is Directory

 A folder in Windows is called a directory in Linux. It’s a special file which associates file names with specific collection or group of files. You can store various files in a single directory. File name contains only valid 8 bit expect Null and forward slash (/) while Directory is a collection of metadata information called inode that contains all the information expect file data. It contains type, owner, permission, modification, time, location of file data, etc also known as metadata.

User can read, write or execute permission with directory but not like file. Read permission is associated with search in directory which  is contained by the file. Write permission allows  removing or creating file in directory and execute permission lets you go through directory while  it’s open.

Executable File

 In Linux, there are 2 kinds of information- instruction (code) and useful data,    whereby the former is called binary object file. Compiler compiles the file and creates object file which is linked with library file and creates executable file. When you create executable file, by default it is generated as a.out file. Refer to the tutorial How to make first C programming in Linux for understanding how to execute file.

Linux File System

Linux File System

Everything in Linux is a file. Kernel is  a collection of files which are written in C language  as well as assembly language. File system is hierarchical structure in Linux which has a different meaning associated with each inode. It is standard tree hierarchical structure  comprising various meaningful directories and files. One special directory file which has the permission to do everything is called root directory. Root is main directory in Linux file system and is indicated as forward slash ( / ). User ID of root is zero in system. Each and every directory is associated under the root.

One of the most important features of Linux is that it supports various file systems types like ext, ext2, xia, minix, umsdos, msdos, vfat, proc, smb, ncp, iso9660, sysv, hpfs, affs etc.  which ensures flexibility.

When the disk is initialized and partitioned in logical block, each partitioned structure contains one type of file system like ext2. File systems arrange files into logical hierarchical structures with directories, soft links and so on held in blocks on physical devices. Devices that contain file systems are known as block devices. EXT2 stand for second extended file system while EXT3 is  animproved version of EXT2 file system. Each file system has different characteristic and performance.

Various directories are located under the root directory in Linux file system. If you want to see all directories  present in Linux file system, check once you are in root.  

Enter the following command to see hierarchical structure of file system:

                     $ ls

The following output is displayed on terminal:

bin   cdrom  etc    lost+found  mnt  proc  run   srv  tmp  var

boot  dev    home  lib  media    opt  root  sbin  sys  usr  vmlinuz

It represents all directories as Linux file hierarchical system.

Fig. 1: Image showing Linux File Hierarchical System

Each directory contains various files according to specific use and configuration. Here I will shortly explain as to which type of file is contained under the various directories. User can see each directory and associated file from command prompt.

Root –   Each directory and single file  starts with root. Root has only write privileges to do anything with file.

Etc –  It contains configuration file of application or program.

Bin – It contains binary executable file. Linux commands are located under bin directory like ps, cp, grep, chmod etc. 

Sbin – It also contains system binary executable file but is located in system administrator command like ifconfig, reboot, fdisk etc.

Proc – It contains information of system process. It is virtual file system and contains all information of running process and shared resource with Process ID.

Tmp – It is a temporary directory which contains all temporary files created by system and user. All files under this directory are deleted when system is rebooted.

Usr – It contains User program and application like binary file, source code, documentation etc. The usr directory contains  various sub directories for specific collection of file.

Home – It is a directory where user can store his/her personal data. User can also create new directory  here.

Lib – It contains system library.

Mnt – It is temporary mount directory where system administrator can mount file systems.

Media – It is temporary mount directory for removable devices like cdrom  andfloppy disk which are located under media directory.

Srv – It stores the related information of specific server services.

Boot – It contains file related to boot loader. 


Filed Under: Tutorials

 

Questions related to this article?
👉Ask and discuss on EDAboard.com and Electro-Tech-Online.com forums.



Tell Us What You Think!! Cancel reply

You must be logged in to post a comment.

HAVE A QUESTION?

Have a technical question about an article or other engineering questions? Check out our engineering forums EDABoard.com and Electro-Tech-Online.com where you can get those questions asked and answered by your peers!


Featured Tutorials

  • Introduction to Brain Waves & its Types (Part 1/13)
  • Understanding NeuroSky EEG Chip in Detail (Part 2/13)
  • Performing Experiments with Brainwaves (Part 3/13)
  • Amplification of EEG Signal and Interfacing with Arduino (Part 4/13)
  • Controlling Led brightness using Meditation and attention level (Part 5/13)
  • Control Motor’s Speed using Meditation and Attention Level of Brain (Part 6/13)

Stay Up To Date

Newsletter Signup

Sign up and receive our weekly newsletter for latest Tech articles, Electronics Projects, Tutorial series and other insightful tech content.

EE Training Center Classrooms

EE Classrooms

Recent Articles

  • What are the battery-selection criteria for low-power design?
  • Key factors to optimize power consumption in an embedded device
  • EdgeLock A5000 Secure Authenticator
  • How to interface a DS18B20 temperature sensor with MicroPython’s Onewire driver
  • Introduction to Brain Waves & its Types (Part 1/13)

Most Popular

5G 555 timer circuit 8051 ai Arduino atmega16 automotive avr bluetooth dc motor display Electronic Part Electronic Parts Fujitsu ic infineontechnologies integratedcircuit Intel IoT ir lcd led maximintegratedproducts microchip microchiptechnology Microchip Technology microcontroller microcontrollers mosfet motor powermanagement Raspberry Pi remote renesaselectronics renesaselectronicscorporation Research samsung semiconductor sensor software STMicroelectronics switch Technology vishayintertechnology wireless

RSS EDABOARD.com Discussions

  • Op amp non inverting amplifier not working
  • Making a ducted soldering fan?
  • Characterization values of a MOSFET in PDK
  • USBASP Programmer Mod
  • Measure AC current accurateley (100mA to 10A)

RSS Electro-Tech-Online.com Discussions

  • Need a ducted soldering fan for solder smoke extraction
  • How to search component to replace my burn RF inductor?
  • Question about ultrasonic mist maker
  • Someone please explain how this BMS board is supposed to work?
  • bluetooth jammer
Engineers Garage
  • Analog IC TIps
  • Connector Tips
  • DesignFast
  • EDABoard Forums
  • EE World Online
  • Electro-Tech-Online Forums
  • Microcontroller Tips
  • Power Electronic Tips
  • Sensor Tips
  • Test and Measurement Tips
  • 5G Technology World
  • About Us
  • Contact Us
  • Advertise

Copyright © 2022 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Projects and Tutorials
    • Electronic Projects
      • 8051
      • Arduino
      • ARM
      • AVR
      • PIC
      • Raspberry pi
      • STM32
    • Tutorials
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Products News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • EE Resources
    • DesignFast
    • LEAP Awards
    • Oscilloscope Product Finder
    • White Papers
    • Webinars
  • EE Learning Center
    • Design Guides
      • WiFi & the IOT Design Guide
      • Microcontrollers Design Guide
      • State of the Art Inductors Design Guide
  • Women in Engineering