fbpx

Linux File System

Linux File System

If you are in IT Field or thinking of getting into it. Then a deep understanding of Linux is very important. In this article, we are going to get a decent understanding of Linux File System.

What is a File System ?

OS stores data on disk drives using a structure called a file system, consisting of files, directories and the information needed to access and locate them. There are many different types of file systems. In general, improvements have been made to file systems with new releases of operating systems and each new filesystem has been given a different name.

E.g. EXT3;EXT4;XFS;NTFS;FAT etc

Unlike windows, Linux filesystems store information in a hierarchy of directories and files.

File Structure

All the files and folders in Linux is structured in an hierarchy order. the uses of each file folder is listed as follows

File Structure

 

  • /boot                        Contains file that is used by the bootloader (grub.cfg)
  • /root                         Root user’s home directory
  • /dev                         System devices (e.g. disk, cdrom, speakers, flash drive, keyboard etc.)
  • /etc                          Configuration Files
  • /bin -> /usr/bin         Everyday User Commands
  • /sbin -> /usr/sbin     System/Filesystem Commands
  • /opt                          Optional add-on applications (Not part of OS apps)
  • /proc                        Running Processes (Only exit in Memory)
  • /lib -> /usr/lib           C programming library files needed by commands and apps
  • /tmp                         Directory for temporary files needed by commands and apps
  • /home                      Directory of User
  • /var                          System Logs
  • /run                         System daemons that start very early to store PID files
  • /mnt                         To mount external filesystems
  • /media                     For cdrom Mounts

File Types in Linux

  •  –     Regular File
  • d      Directory
  • l        Link
  • c        Device File
  • s        Socket File
  • p       Named File
  • b       Blockfile

File Paths

There are two paths to navigate to a filesystem :

  • Absolute Path
  • Relative Path

An absolute path always begins with a “/”.This indicates that the path starts at the root directory. An example of an absolute path is :

cd  /var/log/httpd

A relative path does not begin with a “/”.It identifies a location relative to your current position. An example of a relative path is :

cd /var

cd log

cd httpd

Navigation Through Terminal

These are some important command for navigating in an UNIX filesystem:

  • cd
  • pwd
  • ls

“cd” stands for change directory. It is the primary command for moving you around the file system. “pwd” stands for print working directory. It tells you where you are in the system. “ls” stands for list. It lists all the contents in a directory.

Now, here some attributes can be used with ls to increase its capabilities.

ls -al
ls -a

When we are using -al along with ls we can see the items are listed in a detailed manner,to understand every aspect of the result, have a look to the file types section of the article. The result explains :

TYPE

No. of Links

Owner

Group

Size

Month

Day

Time

Name

drwxr-xr-x 21 root root 4096 May 27 10:20 var
drwxr-xr-x 1 root root 15 May 27 10:22 bin
-rw-r-r– 1 root root 0 Jun 2 11:15 testfile

File System Color Codes

  • Blue = Directory
  • White = File
  • Green = Executable
  • Sky Blue = Symbolic Link
  • Pink = Graphic Image File
  • Red = Archive file (tar)
  • Red with black background = Broken Link

Coping Files and Folders

Coping and moving files and folders from one directory to another can be done with these commands:

  • Copying Specific Files
    • cp oldfilepath newfilepath
  • Moving Files
    • mv oldfilepath newfilepath
  • Copying Directories
    • cp -r olddirpath newdirpath
  • Moving Directories
    • mv -r olddirpath newdirpath

Creating Files and Directories

A file can be created in linux with the help of touch command or through a text editor like nano. For creating a blank file using touch, this command can be used:

touch testfile

And for creating a directory, “mkdir” command is used:

mkdir testfile

Reading and Removing Files and Directories

A file can be read with the cat command for example:

cat testfile.txt

And for removing a file “rm can be used”. For removing a directory -r attribute must be specified:

rm testfile
rm -r testdir

That’s all for now. If you want to know something more, don’t forget to check out our YouTube channel for a better understanding. For any doubt you can reach us through the comments or through the contact us page.

 

Share the Post...
WhatsApp

About Cybervie

Cybervie provides best cyber security training program in hyderabad, India.This cyber security course enables you to detect vulnerablities of a system, wardoff attacks and manage emergency situations. Taking a proactive approach to security that can help organisations to protect their data, Cybervie has designed its training module based on the cyber security industry requirements with three levels of training in both offensive and defensive manner, and use real time scenarios which can help our students to understand the market up-to its standard certification which is an add on advantage for our students to stand out of competition in an cyber security interview.

More Info – Click Here

Recent Posts

Follow Us on Youtube

Cyber Security Training Program 2020

Cyber security Course offered by Cybervie prepares students for a path of success in a highly demanding and rapidly growing field of cyber security. The course is completely designed with an adaptable mindset, where the program allows the student to complete the course work at their own pace while being able to complete weekly assignments. Hence, also making it convenient for busy working professionals to pursue the training to help them advance their career in cyber security.

Cybervie has designed the training module based on the cyber security industry requirements in both offensive and defensive manner, using real time scenarios which help our students to understand the market standards.

Sign up for our Newsletter

Interested in Cyber Security Training Program 2020 – Click Here

Open chat
1
Hello 👋
How can we help you?