Linux Class Notes
Linux Class Notes
OperatingSystemissoftwarethatworksasaninterfacebetweenauserandthecomputer
hardware.Theprimaryobjectiveofanoperatingsystemistomakecomputersystemconvenientto
useandtoutilizecomputerhardwareinanefficientmanner.Theoperatingsystemperformsthe
basictaskssuchasreceivinginputfromthekeyboard,processinginstructionsandsendingoutputto
thescreen.
SomepopularOperatingSystemsincludeWindows,OSXandLinux.
Linux
Linux is an operating system or a kernel created by Linus Torvalds and is around us since mid 90s.
Today, supercomputers, smart phones, desktop, web servers, tablet, laptops and home appliances
like washing machines, DVD players, routers, modems, cars, refrigerators, etc use Linux OS.
LinuxAdvantage
Itisanopensourceoperatingsystemandprogrammerscandesigntheirownoperating
system
HighlySecuredyoudon'tneedanantivirus
Itsabsolutelyfreeandyoucaninstallitonasmanycomputersasyouwant.
TheLinuxoperatingsystemsnowoffermillionsofapplicationstochoosefrom,mostof
themfree.
LinuxistheOSofchoiceforServerenvironmentsduetoitsstabilityandreliability(Mega
companieslikeAmazon,Facebook,andGoogleuseLinuxfortheirServers).ALinuxbased
servercouldrunnonstopwithoutarebootforyearsonend.
LinuxDistributionsList
ThereareonanaveragesixhundredLinuxdistributorsprovidingdifferentfeaturessomeofwhich
regularlyusedare:
Unix Vs Linux
UNIX is called the mother of operating systems which laid out the foundation to Linux. Though
they might seem different, at core, they are essentially the same. Since, Linux is a clone of UNIX.
So learning one is same as learning another.
Hardware layer Hardware consists of all peripheral devices (RAM/ HDD/ CPU etc).
Kernel It is the core component of Operating System, interacts directly with hardware,
provides low level services to upper layer components.
Shell An interface to kernel, hiding complexity of kernel's functions from users. The shell
takes commands from the user and executes kernel's functions.
Utilities Utility programs that provide the user most of the functionalities of an operating
systems.
Linux Commands:
All the Linux commands are classified into 3 groups.
a) Basic Utility Commands
b) Directory Related Commands
c) File Related Commands
Syntax
The commands in Linux have the following syntax:
$command options arguments
COMMAND - echo
Description Used to display a message on the screen.
Syntax $ echo " comment "
Example $ echo " UBUNTU "
Description The echo command is used to display the values of a variable. One such
variable is HOME. To check the value of a variable precede the variable
with a $ sign.
Syntax $ echo $HOME
Example $ echo $HOME
COMMAND - tty
Description It is a teletype command and it Displays current terminal.
Syntax $ tty
Example $ tty
COMMAND - cal
Description Displays the calendar of the current month.
Syntax $ cal
Example July 2017
Description cal will display calendar for the specified month and year.
Syntax $ cal mm yyyy
Example cal 02 2017
COMMAND date
Description Displays current date and time.
Syntax $ date
COMMAND man
Description The man pages are properly documented pages. They have following
sections:
NAME: The name and one line description of the command.
SYNOPSIS: The command syntax.
DESCRIPTION: Detailed description about what a command does.
OPTIONS: A list and description of all of the command's options.
EXAMPLES: Examples of command usage.
FILES: Any file associated with the command.
AUTHOR: Author of the man page
REPORTING BUGS: Link of website or mail-id where you can report
any bug.
SEE ALSO: Any commands related to the command, for further
reference.
Syntax man command
Example $man date
COMMAND ispell
Description ispell is used to spell check a document and let you perform the correction on
line
Syntax $ispell (enter) {work for which spelling is to be checked}
Example $ispell (enter) admin
COMMAND who
Description to get all information of current users.
Syntax $who
COMMAND whoami
Description to get details of the current users.
Syntax $whoami
COMMAND uname
Description to get operating system name and edition
Syntax $uname
COMMAND history
Description to display all the current activities of the system.
Syntax $history
COMMAND passwd
Description to display all the current activities of the system.
Syntax $history
COMMAND - clear
Description to clears the display screen
Syntax $clear
COMMAND - ps
Description to get present process status
Syntax $ps
COMMAND - logout
Description to work out from log in session
Syntax $logout
COMMAND - bc
Description to active calculator
Syntax bc(enter)expression(enter) <cntrl+d>
Example bc(enter) 12+5(enter)
bc(enter) scale=2[to get digits after decimal] 15/2(enter)<cntrl+d>
bc(enter)ibase=2[to get base of 10 from binary value]10110(enter)<cntrl+d>
bc(enter)obase=2[to get base of binary value from base of 10 value ]10
(enter) <cntrl+d>
Directory Related Commands
COMMAND pwd
Description The pwd command (print working directory) writes the full pathname of the
current working directory to the standard output.
Example pwd
COMMAND cd / chdir
Description The cd command (change directory), is used to change the current working
directory in operating systems.
Example cd /etc
pwd
cd /bin
pwd
COMMAND cd ~
Description The cd is also a shortcut to get back into your home directory. Just typing cd
without a target directory, will put you in your home directory. Typing cd ~
has the same effect.
Example cd~ , cd
COMMAND cd ..
Description To go to the parent directory (the one just above your current directory )
Example pwd
cd ..
pwd
COMMAND cd -
Description to go to the previous directory
Example cd -
Path
A path is a unique location to a file or a folder in a file system of an OS. A path to a file is a
combination of / and alpha-numeric characters.
Absolute path name
An absolute path is a complete path from start of actual filesystem from / directory.
Example - /var/ftp/pub
Relative Path
A reative path does not begin with a slash ( / ). Generally you specifies location relative to your
current working directory. This is most useful to short a path name.
Example if your current working directory is /home/tom and if you would like to change directory to
/home/tom/docs/bio you can enter command cd docs/bio instead of cd /home/tom/docs/bio .
Example:
COMMAND ls
Description ls with no option list files and directories in bare format where we wont be
able to view details like file types, size, modified date and time, permission
and links etc.
COMMAND ls -l
Description ls -l shows file or directory, size, modified date and time, file or folder name
and owner of file and its permission. It gives you a long listing.
COMMAND ls -a
Description ls -a is used to show all files ( including the hidden files). When a file name
on a Linux file system starts with a dot, it is considered a hidden file and it
doesn't show up in regular file listings.
Example ls { you will see file without any . Symbol }
ls -a
COMMAND mkdir
Description The mkdir stands for 'make directory' and a new directory can be created
whenever required
Syntax mkdir <dirname>
Example mkdir FRUITS
COMMAND rmdir
Description When a directory is empty, rmdir is used to remove the directory.
Example rmdir FRUITS
Description To remove multiple directories
Example rmdir Apple Mango
COMMAND mv
Description The 'mv' (move) command can be used for renaming directories.
Syntax mv <directoryname> <newdirectoryname>
Example mv Banana fruits