All the data in linux is organized into files. All files are then organized into directories, and these directories are further organized into a tree structure which is called as filesystem.
A linux operating system have following directory structure.
Let's understand each directory and purpose of the directory in linux operating system:
|It is called root directory. Every single directory starts from root file system.Only root user has write permission to this directory.
|/bin directory contains user binariy executables like ls, ping, grep commands etc...Command linux commands that you use are located in this directory.
|/sbin contains system binrary executable.This directory contains commands that are used by system administrator for maintenance purpose. i.e. ipconfig, iptables etc...
|/etc directory contains configuration files for different programs. For example if you have installed php in your operating system configurations for your php will be stored here.
|this directory contains terminal device files i.e. usb device etc...
|this directory contains file regarding processes running on your operating system
|this directory contains variable files. i.e. system logs, mysql logs or any other logs can be found here.
|this directory contains temporary files. Files in this directory can be deleted when system is rebooted.
|this directory contains library, binary or documentation files. In this directory we have /bin and /sbin directories for user programs,
|this directory is used to store user personal data. For each user it will create a new directory inside /home directory
|this directory contains files that are necessary when system is booted
|this directory contains system libraries that are installed in /bin and /sbin. /bin and /sbin contains executable files that depends on library files which can be stored in /lib directory.
|this directory contains some optional files required by third party software or applications
|this directory called mount directory. You can mount CD or USB device etc... data here.
|this directory contains files used by removable media devices like CD, Floppy or USB etc..
|this directory contains service data
Different types of file types
In linux two mostly used file types are files and directories. However there are more file types when you actually work with linux. Some of the file types are listed below:
|regular file i.e. text files, images, binary files, shared libraries etc..
|charcter device file
|block device file
|local socker file
How to check file type in linux?
Now, that you know 7 types of file types in linux you are curious to know how you can identify these types. You can use ls command to check file type.
For example: let's create a directory and check the file type:
# create a new directory mkdir test # check the file type of this directory ls -ld test/ # sample output from above command drwxr-xr-x 3 sandip programmer 96 5 Aug 11:39 test/
Let's understand above output what does each word mean in above output:
|First letter in above output show the file type
|Next nine letters
|Next nine letters show the file permissions for user, group and others i.e. r-read, w-write, x-execute
|the number of different directory entries that all point to the inode associated with the object.
|shows creator of the file type
|shows group for owner
|total size of current file type
|last modified date
|shows last modifled date for given file type
|shows name given to current file type
Useful commands for file management
The followings are some of the commands commonly used when working with files and directories in linux:
|prints the current working directory i.e. shows you which directory you are on right now
|change directory or navigate to different directory
|shows you all files and directories for given location
|to create a new blank file
|to create a new directory
|to view huge files without opening huge file at once
|copy files from one to other location
|move file from one to other location or rename a file
|check the type of the file
|unsed to control the display of output of a file, lets you page through the results
|to show content of the given file
|remove a file
|remove a directory
|it is used to count the characters, words, and lines in text files
|command is used to convert and copy a file
|command is used to make soft or hard link between files
|prints the last 10 lines of the file
|prints the first 10 lines of the file