Linux Documentation
Linux Documentation
What is Linux
Linux is an open source operating system (OS). An operating system is the software that directly
manages a system's hardware and resources, like CPU, memory, and storage. The OS sits between
applications and hardware and makes the connections between all of your software and the physical
resources that do the work. In a simple word Linux is a Unix-like, open source and community-
developed operating system (OS) for computers, servers, mainframes, mobile devices and
embedded devices. It is supported on almost every major computer platform, including x86, ARM
and SPARC, making it one of the most widely supported operating systems.
Linux file system is generally a built-in layer of a Linux operating system used to handle the
data management of the storage. It helps to arrange the file on the disk storage. It manages
the file name, file size, creation date, and much more information about a file.
Directory Description
/(root file It contains all of the databases or folders or files.
system)
/bin User executable files.
/boot To boot Linux computer
/dev This is the directory contains the device files for every hardware device attached
to the system.
/etc Local system configuration file for the host computer
/home Each user has a subdirectory in /home
/lib Contains shared library files that are required to boot the system
/media A place to mount external removable device such as USB that may be connected
to the host
/mnt It’s a temporary mount point for a system while admin is working or repairing file
system
/opt Optional files such as vendor supplied application programs should be located
here
/root This is home directory for the root user
/sbin These are binary files and executable used for system administration
/tmp It is used to store temporary files
/user These are shareable , read only files, including executable binaries and libraries,
man files and other documentation.
/var Variable data files are stored here like MySQL, webserver date file etc.
There are two types of path variable:-
1.Absolute Path :
An absolute path refers to the complete details needed to locate a file or folder, starting from the
root element and ending with the other subdirectories. Absolute paths are used in websites and
operating systems for locating files and folders. An absolute path is also known as an absolute
pathname or full path.
2.Relative path :
Relative path is defined as the path related to the present working directly(pwd). It starts at your
current directory.
Command Result
clear If you want clear the terminal
Logname for display the current user
tty for the current terminal
pwd To check the path
uptime Time of OS
uname Name of the OS
uname -p Processer of OS
uname -r Version of OS
uname -v Release date of OS
uname -n Host name of OS
uname -a Info of OS
uname -m Hardware name
hostname Ubuntu
hostname -a Alies name of Hostname
hostname -f Fully hostname
hostname -i IP address of the hostname
hostname -s Display the short
namewho Who connected to the server
who am i User
who -b System boot time
who -d Dead process
who -h Display heading
who -l Ideal time
who -u list of user login
w -V Display version
w Logged in avg load
cal calendar
exit To exit from the terminal
id –u To check the user id
id -g To check the group id
Output: delhi
Downloads
guru
line.text
prwatech
Templates
4. list of all hidden objects without (.) and (..) , click ls-A press enter
5. to check the details of directories , click ls -l press enter
6. To display the objects which are ends with “ / , @ , * , = ” , press ls -F press enter
10. for getting the object in Recursive order , type ls -R , press enter
11. for getting objects w.r.t their modification time , type ls -t , press enter
13. for getting list of objects in multiple columns , type ls -x , press enter
14. for getting list of objects with inode number , type ls -I , press enter
Output : 416170 bad 408070 Documents 416165 hydrabad 408072 Pictures 408360 test.txt
408142 data.text 408067 Downloads 416166 kerala 416163 prwatech 408073 Videos
15. to list out display in human readable format , type ls -h , press enter
16. To list out all the objects with 7 column formate w.r.t modification time(t) , type ls -lt , press
enter
17.for getting the objects with its size , type ls -s , press enter
Output:
4 bad 4 Desktop 4 good 4 line.text 4 prwatech 4 test.txt
18. To list out all the objects w.r.t size (size in bits) , type ls -S , press Enter
19. To list out all the objects w.r.t their access time(u) , type ls -u , press enter
20. to list out all the objects in reverse order along with 7 column formative wrt modification time(t)
21.for getting list of all the objects in reverse order along with w.r.t. theire access time(u)
22. for getting the list of all objects in reverse order along with their sizes , type ls -lrs , press enter
23. for getting list of all the objects with 7 column formate w.r.t. their id number and group id
number type ls -n , press enter
24.for getting all the objects and hidden file present in entire file system type ls -lar , press enter
CAT Command:
Note : - to return main directory after executing above command press ctrl+d.
3. In case you want to append the content type cat >>test.text , press enter then add what you
want to add.
4. for checking the number of lines in the content , type cat -n test.txt , press enter
5.for neglecting the blank (b) spaces and numbering the remaining lines type cat -b test.txt , press
enter
6.for dropping all the content from the file type cat test.txt>test.txt , press enter
8.for ending the content line with $ symbol type cat -e test.txt , press enter
9. for copying one file content to other file cat test.txt>new.txt , press enter
10. for appending the one files with another file content type cat test.txt>>start.txt, press enter
11. for adding one or more file to new file , type cat p.txt q.txt r.txt >w.txt
12. To squeeze the number of blank lines to one blank line cat -s line.txt and press enter
MKDIR COMMAND:
2. For creating simultaneously directory type mkdir delhi banglore hydrabad , press enter
3. For creating folder in directory without going inside it, type mkdir ecotech/office , press enter
4. for creating simultaneously two or more folder inside the folder in a single command type
5. If we don’t need any message after creating the directory then, type mkdir -p good or mkdir -pv
good or mkdir -v bad or mkdir -vp bad, press enter
6. if you want to give permission before modifying type mkdir -m421 week
Remove (RM) COMMAND:
1. for removing the file from the current directory type rm test.txt, press enter
3. For removing the file completely type rm -rf test.txt or rm -f test.txt , press enter
NOTE: we can’t open directory using cat command, to open command we have to use cd <name>
7. for removing the all the objects from the directory type rm * and type enter
2. for copying one directory content to another directory type cp -r lin banglore , press enter
3. for asking for permission before overwriting the file type, cp -r new.text prwa.text, press enter
4. if you want replace but want to keep your backup type , cp -r new.text prwa.text , press enter
Note: (new.text) is source
(prwa.text) is destination
5. if you want to overwrite without any modification time then type, cp -I backup.text siri.txt
MOVE COMMAND:
1.for moving the one file to another type mv prwa.txt lin, press enter
2. To rename file without changing modification time then type mv a.txt b.txt , press enter
3.for moving file and keeping a backup of it type mv a.text b.text , press enter
4. for asking permission before replacing or renaming the file mv -i nex.txt n.txt
1. To display first 10 line of the file type, head ipl.txt , hit enter
2. for displaying nth line in the file type, head -n corona.txt , hit enter
3.for extracting middle lines from the file type , head -5 ipl.txt|tail-2 , hit the enter
4. To display the last 10 lines of the file type , tail corona.txt , hit the enter
5. To display last nth lines in the file type ,n corona.txt , hit the enter
6. To extract middle some lines from the file type ,tail -3 corona.txt|head -2, hit the enter