Linux File System is the structure of all information stored on your operating system.
As Linux takes everything as a file hence here the directories are considered as the files containing information of other files. A directory can be used for storing a file or other directories. A file is represented by a structure known as index node (inode). It contains the description of the file.
|/sbin||Contains system binaries, System administration and Hardware Configuration.|
|/bin||Contains executable files.|
|/boot||Contains system.map file and also Linux Kernel.|
|/dev||Contains Device files.|
|/etc||Contains all configuration files of the system.|
|/home||Each user is assigned a specific directory which is can be assessed only by them and the system administrator and it also contains specific settings by the user.|
|/lib||Contains library files.|
|/mnt||Process to make a file system available to the system. Contains mount points or sub directories to mount external media like CD.|
|/usr||Contains user files. Also contains the source of Linux kernel.|
|/opt||Contains software and add on packages which are not the part of default installation.|
|/tmp||Contains temporary files. Some systems clear this directory after shutdown.|
Without using GUI i.e., Graphical User Interface you can control your Linux system. Just right click on your desktop and click Open Terminal. By typing the above given names of directories in the terminal will make you shift in that certain directory.
To know that in which Directory you are working:
Type: – pwd(press enter)
Remark: pwd stands for Present Working Directory
Command for creating a directory:
mkdir (the name you want to give)(press enter)
Remark: Will create a new working directory.
cp –R (directory1)(directory2)
Remark: Will copy the contents of directory1 to directory2.
rmdir<space><name of directory><press enter>
Remark: Command will work when the directory is empty of all files including the hidden files.
Deleting a directory:
rm –r<name of directory>
rm –rf<name of directory> forcefully removes the directory and its sub directories.
Basic File Handling Commands
For creating a directory:
Step 1: Move to home directory by typing cd.
Step 2: Check whether you are in your home directory or not by typing pwd<press enter>
Step 3: Create your directory by typing mkdir <name of your directory>
For creating a File:
cat> (name of file).doc
[For example: cat>lamp.doc, where lamp is the name of file]
Saving and exiting a file:
To view a file:
To copy a file:
Remarks: Will copy the contents of file1 to file2 and it will automatically create file2 if it is not created.
Remarks: Will copy the contents of file1, file 2, file3 to file4 but it will not create file4 if it is not there.
cp –i (file 1)(file2)
Remarks: Replaces file1 to file2
Deleting particular files:
rm (name of file)
Remarks: Will delete the particular file.
rm (file1)( file2)( file3)( file4) and so on……..for deleting number of files.
Renaming a file
mv <filename><changed filename>
ls command is a basic file command which lists the files in a directory and you can easily know what files are available. It is also used with –R, -S,-t, -i etc for other options.
ls –R: It provides a tree like listing of a directory.
ls –a: To view hidden files and folders.
ls –S: For sort listing by file size.
ls –t: For shorting by file modification time.
ls -i: For showing i-nodes.
ls –x: shows directory files.
ls –F: Shows directory of executable files
ls –v: Shorts in reverse order.
ls –d: Shows only directories.
ls –e: Modifies files according to time.
ls –lt: Shows last modification time.
ls –u: Shows last access time.
For listing the contents of other directories:
You don’t need to be in a certain directory for viewing its contents. Like2wise if you are in home and you want to view the contents of pictures folder then just type ls command followed by the name of directory in which you want to view the contents. Here we are viewing the contents of pictures folder from home hence we will type:
While using this command you will notice the some symbols with the names of files and directories:-
This command only changes the permission specified in the command line and leaves the other file permission unchanged. This command is given with the Category, Operation, Permission and the filename.
It is typed in the following way:
<category> <operation> <permission> <space> <filename>
- Category is for User, Groups etc.
- Operation is to assign or remove permission.
- Permission is for reading, writing and executing.
chmod +x <filename>: It makes the file executable for all the users
chmod u+s <filename>: It makes the ordinary user to execute the file like owner of that file.
chmod 644 <filename>: It makes the file readable for everyone and readable/writeable for the owner.
chmod 1777 <directory name>: Gives permission to everybody for reading, writing and executing the directory.