If there is any issue at setup or connection contact support@k21technologies.com
Overview of Unix
Activity Guide 1
[Edition 1]
[Last Update 130815]
For any issues/help contact : support@k21technologies.com
If there is any issue at setup or connection contact support@k21technologies.com
Sno Topics
1 IntroductiontoUnix,History,Versions,Features.FileSystems
2 LoggingIn,Password,CreatingFilesandDir.Removingfilesanddir.
3 Additional commands (uname,mv,date,,lsoptions,finger,who,cal.
Copyingusing(absolute,relative)method,
Wild characters, redirection(?, *,[] ),(stdin, stdout, stderr)
4 Fileaccesspermissionschmod(absolute,symbolic),umask.Simplefilters(more,less,wc,sort,
cut,paste,tr)
5 Editors-vi(advance)-3modes-escape,insert,colon
6 Searchingfilesusingfindcommandbyusingvariousoptions,communicationstools-using
write,talk, mail, wall commands
7 Advancefilters(grep,sed,awk)
8 Linkingfilesusinghardlinkandshortlink,processscheduling-backgroundprocess,killing
process
If there is any issue at setup or
connection contact
support@k21technologies.com
CompaniesthatlaunchedMULTICS
If there is any issue at setup or connection contact
support@k21technologies.com
IBM Mainframe Computers
If there is any
issue at setup or
connection
contact
support@k21tec
hnologies.com
KenThompson
If there is any
issue at setup or
connection
contact
support@k21tec
hnologies.com
Linus Torvolds
Overview on Linux
Overview on Linux
If there is any issue at setup or
connection contact
support@k21technologies.com
General Operating SystemDiagram
Overview on Linux
Overview on Linux
If there is any issue at
setup or connection
contact
support@k21technolo
gies.com
FileSystemofUnix
If there is any issue at setup or connection contact
support@k21technologies.com
Directory Structure & its contents
OrdinaryFiles
If there is any issue at setup or connection contact support@k21technologies.com
Devi ces
Directories
Links
If there is any issue at setup or connection contact support@k21technologies.com
Basic Commands
Creating,Removing,Copying,Moving files& directories
Creatinga file inLinux
Usingcat command:
 Cat (concatenate) commandisusedtocreate a file andto displayandmodifythe contents
of a file.
 To create a file.
#cat > filename(sayktfile)
HelloWorld
Ctrl+d (to save the file)
 To Displaythe contentof the file
#cat filename (sayktfile)
 To append (edit)thedatainthe alreadyexistingfile
#cat >> <filename>
#cat >> ktfile
Ctrl+d (tosave the changes)
If there is any issue at setup or connection contact support@k21technologies.com
Creatingmultiplefilesatsame time usingtouchcommand andto checkthe fileswith“ls”command
#touch <filename1><filename><filename>
Creatinga Directory
#mkdir<dir name>
Making multipledirectoriesinside adirectory
Checkit byusingtree command or ls –R command
If there is any issue at setup or connection contact support@k21technologies.com
CopyingfilesintoDirectory
#cp <source filename><destinationdirectoryinwhichtopaste the file>
#cp file1ktdir
If there is any issue at setup or connection contact support@k21technologies.com
Copyingdirectoriesfromone locationtoother
#cp –rvfp<dir name><destinationname>
Movingfilesfromone locationtoother(cutand Paste)
#mv <filename><Destinationdirectory>
MovingDirectoryfromone locationto other
#mv <filename><Destinationdirname>
#mv ktdirktdir2
RenamingaFile
If there is any issue at setup or connection contact support@k21technologies.com
#mv <oldname> <newname>
RenamingaDirectory
The procedure andcommand forrenamingthe directoryisexactlysame asrenamingafile.
#mv <oldname><newname>
#mv ktdirkerneldir
RemovingaFile
#rm filename or#rm –f filename(withoutprompting)
If there is any issue at setup or connection contact support@k21technologies.com
RemovinganEmptyDirectory
#rmdir dirname
Removingadirectorywithfilesordirectoriesinside:
A di wichis havingsome contentsinsideitcannotbe removedbyrmdir command.There are two
waysto delete the direcotywithcontents.
Remove the contentsinsidethe directoryandthenrunrmdircommand
#rmdir –rf dirname( where rstandsforrecursive andf stands forforcefully).
If there is any issue at setup or connection contact support@k21technologies.com
VIMEDITOR
VIVisual Displayeditor
VIMVisual Displayeditorimproved
Thisis commandmode editorforfiles.OthereditorsinLinux are emacs,gedit.Vi editorismost
popularithas 3 modes(1 CommandMode,2 InsertMode,3 extendedcommandmode)
Note:whenyouopenthe vimeditor,itwill be inthe commandmode bydefault.
In the commandmode the cursor’scan be usedas h/l/k/j tomove cursorleft/right/up/down
Insert mode
i To begininsertmode atthe cursor position
I To insertat the beginningof line
a To appendto the nextword’sletter
A To appendat the endof the line
o To inserta newline belowthe cursorposition
O To inserta newline above the cursorposition
Command Mode
gg To go to the beginningof the page
If there is any issue at setup or connection contact support@k21technologies.com
G To go to the endof the page
w To move the cursor forward,wordby word
b To move the cursor backward,wordby word
nw To move the cursor forwardto n words(5W)
nb To move the cusor backwardto n words(5B)
u To undolast change (word)
U To undothe previouschanges(entire line)
Ctrl+R To redothe changes
Yy To copy a line
Nyy To copy n lines(5yyor4yy)
p To paste line belowthe cursorposition
P To paste line above the cursorposition
dw To delete the wordletterbyletter(like Backspace)
x To delete the worldletterbyletter(like DEL Key)
dd To delete the entire line
ndd To delete nno.Of linesfromcursor position(5dd)
/ To search a wordin the file
ExtendedMode:(ColonMode)
ExtendedMode isusedforsave and quitor save withoutquitusing“Esc” keywith“:”
Esc+:w To Save the changes
Esc+:q To quit(Withoutsaving)
Esc+:wq To save and quit
Esc+:w! To save forcefully
Esc+wq! To save and quitforcefully
Esc+:x To save and quit
Esc+:X To give passwordtothe file andremove password
Esc+:20(n) To go to line no.20 or n
Esc+: se nu To setthe line numberstothe file
Esc+:se nonu To Remove the setline numbers
To openmultiple filesinvimeditor
#vim–o file1file2
To Switchbetweenfilesuse Ctrl+w
ListingfilesandDirectories
If there is any issue at setup or connection contact support@k21technologies.com
#ls List the file names
#ls –l Long listof the file
#ls –l filename To see the permissionsof aparticularfile
#ls –al Showsthe filesinascendingorderof modification.
#ls p* All the filesstartwithp.
#ls ?ample Fileswithanyfirstcharacterand has ample
#ls –ldl* Directorylistingonly
#ls –lddirectoryname To see the permissionsof aparticulardirectory
#ls [ae]* Firstcharacter of the filename mustbe aor e.
#ls [!ae]* ! Symbol complementsthe conditionthatfollows.The charactersmust
not be a or e.
Typesof Files
Symbol Type of File
- Normal file
d Directory
l Linkfile (shortcut)
b Blockfile (Harddisk,Floppydisk)
c Character file (Keyboard,Mouse)
P A namedpipedfile isusedforinterprocesscommunication
S Its isa socketfile usedforinterprocesscommunication
D A doorfile .it isa special file forinterprocesscommunication (sunsolaris)
SymbolicLink
There are twotypesof Links:-
S.No. SoftLink Hard Link
1 Size of linkfile isequal tono.Of characters inthe name
of the original file.
Size of bothfile issame
2 Can be createdacross the partition Can’tbe createdacross the
partition.
3 inode no.Of source and linkfile isdifferent inode no.Of both file issame
4 If original file isdeleted,linkisbrokenanddataislost If original file isdeletedthen
alsolinkwill containdata
5 SHORCUT FILE BACKUPFILE
If there is any issue at setup or connection contact support@k21technologies.com
Creatinga softlink:
#ln -s<source file><destination>
CreatingHard Link
#ln <source file><Destination>
Grep:
Grep standsfor Global RegularExpression Print.It isusedto pickout the requiredexpressionfrom
the file andprintthe output.If grep iscombinedwithanothercommanditcan be usedto pickout
the selectedword,phrase fromthe outputof the firstcommandand printit.
Examplesof Grep
Let uspick the informationaboutrootfromthe file /etc/passwd(/etc/passwdconatainsinformation
aboutall the userspresentinthe system)
#grep root/etc/passwd
If there is any issue at setup or connection contact support@k21technologies.com
To avoidcase sensitivityof the word(i.e the wordmaybe uppercase of lowercase) use -i
#grep -i IT ktfile (letsgrepthe word IT whetherupperof lowercase inthe file ktfile)
To displayaword and 2 linesafterthe word
To displayaword and 2 linesafterthe word
To displaythe things exceptthe givenword
To displaythe searchedwordincolor
If there is any issue at setup or connection contact support@k21technologies.com
Combininggrepwithothercommands
FilterCommands:
filtercommandsare usedtofilterthe outputsothat the requiredthingscaneasilybe pickedup.The
commandswhichare used to filterthe outputare
 #less
 #more
 #head
 #tail
 #sort
 #cut
 #sed
If there is any issue at setup or connection contact support@k21technologies.com
less:- The lesscommand is usedto see the output line wise or page wise.
Note:-
pressEnterkeyto scroll downline byline (or)
Use d to go to nextpage
Use b to go to previouspage
use / to searchfor a wordin the file
Use v to go vi mode where youcan editthe file andonce yousave it youwill backto lesscommand
more: more isexactlysame like less
If there is any issue at setup or connection contact support@k21technologies.com
Ex: #more /etc/passwd
Note:-
pressEnter keyto scroll downline byline (or)
use d to go to nextpage
use / to searchfor a wordin the file
Use v to go vi mode where youcan editthe file andonce yousave ityou will backtomore command
head: it is usedto displaythe top 10 linesof the file.
ex:# head/etc/passwd
To display the custom lines
#head -n /etc/passwd (where n can be any number)
tail: It is usedto displaythe last 10 linesofthe file
#tail /etc/passwd
If there is any issue at setup or connection contact support@k21technologies.com
To display the custom lines
#tail -n /etc/passwd(where n can be any number)
sort: It is usedto sort the output in numeric or alphabeticorder
#sort filename
If there is any issue at setup or connection contact support@k21technologies.com
To sort the file accordingto numbers
#sort -dktfile
To remove the duplicate entriesfrom the output
#sort -uktfile
If there is any issue at setup or connection contact support@k21technologies.com
cut command:
The cut commandisusedto pick the givenexpression(incolumns) anddisplaythe output.
#cut -d -f filename(where dstandsfordelimiterex.:," "etcand f standsfor field)
If there is any issue at setup or connection contact support@k21technologies.com
To delimitspacesandprintthe field
#cut -d "" -f1 filename
To delimitcommasandprintthe field
#cut -d, f1 filename
sedcommand
sedstands forstreameditor,whichisusedtosearch a word inthe file andreplace itwiththe word
requiredtobe inthe output.
Note:- itwill onlymodifythe output,butthere will be nochange inthe original file.
sed's/searchfor/replacewith/g' filename
Redirection:Redirectionisaprocesswhere we cancopy the outputof anycommand(s),file(s) intoa
newfile.There are twowaysof redirectingthe outputintoafile.
Using> or >> filename afterthe command,and usingtee command
Note:if the givenname of the file isnotavilable anew file will be createdautomatically.If the file
alreadyexiststhenitwill overwrite contentsof thatfile.
If there is any issue at setup or connection contact support@k21technologies.com
Appendinganotheroutputinsame the same file
Likewise thereare manyoptionswhere we canuse redirections
Ex: copyingcontentsof twofilesinanew file
#cat file1file2>file3
Usingtee
The above optionsof redirectionswill notdisplayanyoutput,butdirectlysave the outputinafile.
usingtee commandwill notonlyredirectthe outputtonew file butitwill alsodisplaythe output.
Syntax:cat <filename>|tee <newfile name>
Note:If the givenof the file (newfile)isnotavailable anew file will be createdautomatically.If the
file alreadyexiststhenitwill overwrite contentsof the file.
#cat ktfile |tee ktf1
If there is any issue at setup or connection contact support@k21technologies.com
Appendingdatainthe same file usingtee command
Syntax: cat filname | tee -a filename2
#cat ktfile1| tee -a ktf1
FindCommand
findcommandis usedto findthe filesordirectory'spath, itisexactlylike the findoptioninwindows
where youcan searchfor a file.
Syntax: find / (underroot) - option filename
optionsthatcan be usedwithfindcommand:
Option Usage
-name For searchinga file withitsname
-inum For searchinga file withparticularinodenumber
-type For searchinga particulartype of file.
-user For fileswhose owner
-group For filesbelongingtoparticulargroup
If there is any issue at setup or connection contact support@k21technologies.com
Findingafile withname
#find/ -name test
#find/ -num5934
Findingthe files,whose ownerisausercalled"abc"
Findingthe fileswhose groupis"abc"
If there is any issue at setup or connection contact support@k21technologies.com
File Permissions
Permissionsare appliedonthree levels:-
 Owneror User level
 Group level
 Otherslevel
Accessmodesare of three types:-
 r readonly
 w write/edit/delete/append
 x execute/runacommand
Accessmodesare differentonfile anddirectory.
PERMISSIONS FILES DIRECTORY
r Openthe file 'ls' the contentsof dir
w Write,edit,append,deletefile Add/Del/Renamecontentsof
dir
x To run a command/shell script To enterintodirusing'cd'
r : For normal or directoryfile - viewthe contents
w: Editthe contentsof a normal or directoryfile
If there is any issue at setup or connection contact support@k21technologies.com
x: Runan executable file /Enterintodirectoryfile
Permissionscanbe seton any file/dirbytwomethods:-
1. Symbolicmethod (ugo)
2. Absolute method(numbers)
SymbolicMethod
Symbolicmode:General formof symbolicmode is
#chmod [who] [+/-/=] [permissions] file
who> to whomthe permissionstobe assigned
user/owner(u);group(g);others(o)
Example:- Assigndifferrentpermissionstothe file (user=rwx,group=rw andothers=r)
#chmod u=rwx,g=rw,o=r ktfile(where ktfileisthe name of the file)
If there is any issue at setup or connection contact support@k21technologies.com
Assigningfullpermissiontothe file i.e rwx toall
#chmod ugo=rwx <file name>
likewise youcanaddor remove permissionsfromanyfile foranyone(usergrouporother)
 #chmod u+x ktfile (addingexecutepermissionstouseronly)
 #chmod go-wx ktfile(Removingwrite andexecutepermissionsfromgroupandother)
 #chmod go+wx ktfile (Addingwriteandexecute permissionsfromgroupandother)
 #chmod go=r ktfile (Givingonlyreadpermissiontogroupandother)
ABSOLUTE METHOD(NUMBERS)
In Absolute methodwe use numbersinsteadof usingsymbolsi.e
 Read = 4
 Write = 2
 Execute = 1
Assigningdifferentpermissionstothe file (user=rwx,group=rw andothers=r)
#chmod 764 ktfile (where 7 means rwx i.e 4+2+1, rw=6 i.e 4+2 and 1 indicatesx)
If there is any issue at setup or connection contact support@k21technologies.com
Assigningfullpermissionstothe file i.e rwx toall
#chmod 777 ktfile
likewise youcangive differentpermissionsaccordingtoyour requirement
Removingall permissionsfromothers
#chmod 770 ktfile (where 0 indicatesno permissions)
Note:All the above permissionsandprocedure issame forfilesanddirectories
Umask
Whenwe create any file usingtouch,cator vi commandstheygetcreatedwithdefaultfile
permissionsasstoredinumask(userfilecreationmask).umaskisa4 digitoctal numberwhichtells
unix whichof the three permissionsare tobe deniedratherthangranted.Umask will decidethat
whatshouldbe the defaultpermissionsforafile anddirectorywhenitiscreated.
the defaultumask value is 0022
If there is any issue at setup or connection contact support@k21technologies.com
calculationof defaultpermissionsforfile anddirectory,basinguponthe umaskvalue
Note:For a file bydefaultitcannothave the execute permissions,sothe maximumfull permission
for a file atthe time of creationcan be 666 (i.e 777 -111 = 666), whereasadirectorycan have full
permissionsi.e777
The full permissionsforthe file 666
Minusthe umaskvalue -022
The defaultpermissionforfile is 644 (rw-,r--,r--)
The full permissionsforthe directory 777
Minusthe umaskvalue -022
The defaultpermissionforfile is 755 (rwx,r-x,r-x)
#umask002
The modifieddefaultpermissionforafile will be 666-002=664 i.e.rw,rw,r,andforthe directoryit
will be 777-002=775 i.e.rwx,rwx,r-x
If there is any issue at setup or connection contact support@k21technologies.com
Note:Create a file anda directoryandcheckfor the defaultpermissions.
These were the fewthings amongst the basics; keepworkingto furnishyour basics. After all,if the
foundationis good thenonly the buildingcan stand still"
=============End of the Activity 1 Guide========

More Related Content

PDF
SGN Introduction to UNIX Command-line 2015 part 2
PDF
SGN Introduction to UNIX Command-line 2015 part 1
PDF
Introduction to UNIX Command-Lines with examples
PPT
PDF
Unix command line concepts
PPTX
Know the UNIX Commands
PPT
Introduction to Unix
DOCX
lec1.docx
SGN Introduction to UNIX Command-line 2015 part 2
SGN Introduction to UNIX Command-line 2015 part 1
Introduction to UNIX Command-Lines with examples
Unix command line concepts
Know the UNIX Commands
Introduction to Unix
lec1.docx

What's hot (20)

DOC
58518522 study-aix
PDF
Operating system lab manual
PDF
Bozorgmeh os lab
PDF
Basic unix commands_1
PPT
8.1.intro unix
PDF
Devops for beginners
DOCX
Linux final exam
PDF
Windows command prompt a to z
PDF
Basic shell programs assignment 1_solution_manual
PDF
UNIX Command Cheat Sheets
PPT
Basic Unix
PPTX
Piping into-php
PDF
Lecture1 2 intro-unix
PDF
Tool Development 08 - Windows Command Prompt
PPT
101 3.4 use streams, pipes and redirects
PDF
Basic unix commands
PDF
basic-unix.pdf
PPT
011300 Intro To Dos
PDF
Os lab manual
58518522 study-aix
Operating system lab manual
Bozorgmeh os lab
Basic unix commands_1
8.1.intro unix
Devops for beginners
Linux final exam
Windows command prompt a to z
Basic shell programs assignment 1_solution_manual
UNIX Command Cheat Sheets
Basic Unix
Piping into-php
Lecture1 2 intro-unix
Tool Development 08 - Windows Command Prompt
101 3.4 use streams, pipes and redirects
Basic unix commands
basic-unix.pdf
011300 Intro To Dos
Os lab manual
Ad

Viewers also liked (14)

DOCX
Configuring vnc server in linux
DOCX
Administering Remote System in Linux
DOCX
Installing webmin on linux
PPTX
Colloque international (hs+pb) 14.10.14 (final version)
PDF
Installation of Oracle Linux 5.4 32 bit on vmware
PPTX
Latihan powerpoint2 001
PDF
Solaris 10 installation on vmware
DOCX
SHORT VITA 20140630
PDF
Backup and restore in linux
PDF
Histoire secteur hotelier en Haiti
PPTX
L'enseignement du tourisme en France et au Royaume-Uni: Histoire, comparaison...
PDF
User and group administration in Linux
PDF
Network configuration in Linux
DOCX
Resume of Aashish
Configuring vnc server in linux
Administering Remote System in Linux
Installing webmin on linux
Colloque international (hs+pb) 14.10.14 (final version)
Installation of Oracle Linux 5.4 32 bit on vmware
Latihan powerpoint2 001
Solaris 10 installation on vmware
SHORT VITA 20140630
Backup and restore in linux
Histoire secteur hotelier en Haiti
L'enseignement du tourisme en France et au Royaume-Uni: Histoire, comparaison...
User and group administration in Linux
Network configuration in Linux
Resume of Aashish
Ad

Similar to Overview on Linux (20)

PDF
Workshop on command line tools - day 1
PPTX
Linux System commands Essentialsand Basics.pptx
PPTX
Linux Command.pptx
PDF
Course 102: Lecture 12: Basic Text Handling
PDF
Linux Command Line - By Ranjan Raja
PPTX
PDF
Linux file commands and shell scripts
PDF
Linux practicals T.Y.B.ScIT
PPTX
File Commands - R.D.Sivakumar
PDF
Basic basic solaris quick referent card
PPT
HISTORY, TYPES OF EMBEDDED LINUX, COMMANDS,
PDF
CMake Tutorial
PDF
5_File_Handling_Commands__vi_editor_and_environment_variables
PDF
unix_ref_card.pdf
PDF
unix_ref_card.pdf
PDF
unix_ref_card.pdf
PDF
Presentation aix basic
DOC
Foss manual (1)
PPTX
Handling Files Under Unix.pptx
PPTX
Handling Files Under Unix.pptx
Workshop on command line tools - day 1
Linux System commands Essentialsand Basics.pptx
Linux Command.pptx
Course 102: Lecture 12: Basic Text Handling
Linux Command Line - By Ranjan Raja
Linux file commands and shell scripts
Linux practicals T.Y.B.ScIT
File Commands - R.D.Sivakumar
Basic basic solaris quick referent card
HISTORY, TYPES OF EMBEDDED LINUX, COMMANDS,
CMake Tutorial
5_File_Handling_Commands__vi_editor_and_environment_variables
unix_ref_card.pdf
unix_ref_card.pdf
unix_ref_card.pdf
Presentation aix basic
Foss manual (1)
Handling Files Under Unix.pptx
Handling Files Under Unix.pptx

Recently uploaded (20)

PDF
TrustArc Webinar - Click, Consent, Trust: Winning the Privacy Game
PPTX
Microsoft Excel 365/2024 Beginner's training
PPT
Module 1.ppt Iot fundamentals and Architecture
PDF
A Late Bloomer's Guide to GenAI: Ethics, Bias, and Effective Prompting - Boha...
PDF
Hindi spoken digit analysis for native and non-native speakers
PDF
Flame analysis and combustion estimation using large language and vision assi...
PDF
The influence of sentiment analysis in enhancing early warning system model f...
PDF
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
PDF
Consumable AI The What, Why & How for Small Teams.pdf
PDF
A review of recent deep learning applications in wood surface defect identifi...
PPTX
Configure Apache Mutual Authentication
PPTX
Benefits of Physical activity for teenagers.pptx
PDF
CloudStack 4.21: First Look Webinar slides
PPTX
Chapter 5: Probability Theory and Statistics
PPTX
2018-HIPAA-Renewal-Training for executives
PDF
UiPath Agentic Automation session 1: RPA to Agents
PDF
OpenACC and Open Hackathons Monthly Highlights July 2025
PDF
Hybrid horned lizard optimization algorithm-aquila optimizer for DC motor
PPTX
MicrosoftCybserSecurityReferenceArchitecture-April-2025.pptx
PDF
Taming the Chaos: How to Turn Unstructured Data into Decisions
TrustArc Webinar - Click, Consent, Trust: Winning the Privacy Game
Microsoft Excel 365/2024 Beginner's training
Module 1.ppt Iot fundamentals and Architecture
A Late Bloomer's Guide to GenAI: Ethics, Bias, and Effective Prompting - Boha...
Hindi spoken digit analysis for native and non-native speakers
Flame analysis and combustion estimation using large language and vision assi...
The influence of sentiment analysis in enhancing early warning system model f...
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
Consumable AI The What, Why & How for Small Teams.pdf
A review of recent deep learning applications in wood surface defect identifi...
Configure Apache Mutual Authentication
Benefits of Physical activity for teenagers.pptx
CloudStack 4.21: First Look Webinar slides
Chapter 5: Probability Theory and Statistics
2018-HIPAA-Renewal-Training for executives
UiPath Agentic Automation session 1: RPA to Agents
OpenACC and Open Hackathons Monthly Highlights July 2025
Hybrid horned lizard optimization algorithm-aquila optimizer for DC motor
MicrosoftCybserSecurityReferenceArchitecture-April-2025.pptx
Taming the Chaos: How to Turn Unstructured Data into Decisions

Overview on Linux

  • 1. If there is any issue at setup or connection contact support@k21technologies.com Overview of Unix Activity Guide 1 [Edition 1] [Last Update 130815] For any issues/help contact : support@k21technologies.com
  • 2. If there is any issue at setup or connection contact support@k21technologies.com Sno Topics 1 IntroductiontoUnix,History,Versions,Features.FileSystems 2 LoggingIn,Password,CreatingFilesandDir.Removingfilesanddir. 3 Additional commands (uname,mv,date,,lsoptions,finger,who,cal. Copyingusing(absolute,relative)method, Wild characters, redirection(?, *,[] ),(stdin, stdout, stderr) 4 Fileaccesspermissionschmod(absolute,symbolic),umask.Simplefilters(more,less,wc,sort, cut,paste,tr) 5 Editors-vi(advance)-3modes-escape,insert,colon 6 Searchingfilesusingfindcommandbyusingvariousoptions,communicationstools-using write,talk, mail, wall commands 7 Advancefilters(grep,sed,awk) 8 Linkingfilesusinghardlinkandshortlink,processscheduling-backgroundprocess,killing process
  • 3. If there is any issue at setup or connection contact support@k21technologies.com CompaniesthatlaunchedMULTICS
  • 4. If there is any issue at setup or connection contact support@k21technologies.com IBM Mainframe Computers
  • 5. If there is any issue at setup or connection contact support@k21tec hnologies.com KenThompson
  • 6. If there is any issue at setup or connection contact support@k21tec hnologies.com Linus Torvolds
  • 9. If there is any issue at setup or connection contact support@k21technologies.com General Operating SystemDiagram
  • 12. If there is any issue at setup or connection contact support@k21technolo gies.com FileSystemofUnix
  • 13. If there is any issue at setup or connection contact support@k21technologies.com Directory Structure & its contents OrdinaryFiles
  • 14. If there is any issue at setup or connection contact support@k21technologies.com Devi ces Directories Links
  • 15. If there is any issue at setup or connection contact support@k21technologies.com Basic Commands Creating,Removing,Copying,Moving files& directories Creatinga file inLinux Usingcat command:  Cat (concatenate) commandisusedtocreate a file andto displayandmodifythe contents of a file.  To create a file. #cat > filename(sayktfile) HelloWorld Ctrl+d (to save the file)  To Displaythe contentof the file #cat filename (sayktfile)  To append (edit)thedatainthe alreadyexistingfile #cat >> <filename> #cat >> ktfile Ctrl+d (tosave the changes)
  • 16. If there is any issue at setup or connection contact support@k21technologies.com Creatingmultiplefilesatsame time usingtouchcommand andto checkthe fileswith“ls”command #touch <filename1><filename><filename> Creatinga Directory #mkdir<dir name> Making multipledirectoriesinside adirectory Checkit byusingtree command or ls –R command
  • 17. If there is any issue at setup or connection contact support@k21technologies.com CopyingfilesintoDirectory #cp <source filename><destinationdirectoryinwhichtopaste the file> #cp file1ktdir
  • 18. If there is any issue at setup or connection contact support@k21technologies.com Copyingdirectoriesfromone locationtoother #cp –rvfp<dir name><destinationname> Movingfilesfromone locationtoother(cutand Paste) #mv <filename><Destinationdirectory> MovingDirectoryfromone locationto other #mv <filename><Destinationdirname> #mv ktdirktdir2 RenamingaFile
  • 19. If there is any issue at setup or connection contact support@k21technologies.com #mv <oldname> <newname> RenamingaDirectory The procedure andcommand forrenamingthe directoryisexactlysame asrenamingafile. #mv <oldname><newname> #mv ktdirkerneldir RemovingaFile #rm filename or#rm –f filename(withoutprompting)
  • 20. If there is any issue at setup or connection contact support@k21technologies.com RemovinganEmptyDirectory #rmdir dirname Removingadirectorywithfilesordirectoriesinside: A di wichis havingsome contentsinsideitcannotbe removedbyrmdir command.There are two waysto delete the direcotywithcontents. Remove the contentsinsidethe directoryandthenrunrmdircommand #rmdir –rf dirname( where rstandsforrecursive andf stands forforcefully).
  • 21. If there is any issue at setup or connection contact support@k21technologies.com VIMEDITOR VIVisual Displayeditor VIMVisual Displayeditorimproved Thisis commandmode editorforfiles.OthereditorsinLinux are emacs,gedit.Vi editorismost popularithas 3 modes(1 CommandMode,2 InsertMode,3 extendedcommandmode) Note:whenyouopenthe vimeditor,itwill be inthe commandmode bydefault. In the commandmode the cursor’scan be usedas h/l/k/j tomove cursorleft/right/up/down Insert mode i To begininsertmode atthe cursor position I To insertat the beginningof line a To appendto the nextword’sletter A To appendat the endof the line o To inserta newline belowthe cursorposition O To inserta newline above the cursorposition Command Mode gg To go to the beginningof the page
  • 22. If there is any issue at setup or connection contact support@k21technologies.com G To go to the endof the page w To move the cursor forward,wordby word b To move the cursor backward,wordby word nw To move the cursor forwardto n words(5W) nb To move the cusor backwardto n words(5B) u To undolast change (word) U To undothe previouschanges(entire line) Ctrl+R To redothe changes Yy To copy a line Nyy To copy n lines(5yyor4yy) p To paste line belowthe cursorposition P To paste line above the cursorposition dw To delete the wordletterbyletter(like Backspace) x To delete the worldletterbyletter(like DEL Key) dd To delete the entire line ndd To delete nno.Of linesfromcursor position(5dd) / To search a wordin the file ExtendedMode:(ColonMode) ExtendedMode isusedforsave and quitor save withoutquitusing“Esc” keywith“:” Esc+:w To Save the changes Esc+:q To quit(Withoutsaving) Esc+:wq To save and quit Esc+:w! To save forcefully Esc+wq! To save and quitforcefully Esc+:x To save and quit Esc+:X To give passwordtothe file andremove password Esc+:20(n) To go to line no.20 or n Esc+: se nu To setthe line numberstothe file Esc+:se nonu To Remove the setline numbers To openmultiple filesinvimeditor #vim–o file1file2 To Switchbetweenfilesuse Ctrl+w ListingfilesandDirectories
  • 23. If there is any issue at setup or connection contact support@k21technologies.com #ls List the file names #ls –l Long listof the file #ls –l filename To see the permissionsof aparticularfile #ls –al Showsthe filesinascendingorderof modification. #ls p* All the filesstartwithp. #ls ?ample Fileswithanyfirstcharacterand has ample #ls –ldl* Directorylistingonly #ls –lddirectoryname To see the permissionsof aparticulardirectory #ls [ae]* Firstcharacter of the filename mustbe aor e. #ls [!ae]* ! Symbol complementsthe conditionthatfollows.The charactersmust not be a or e. Typesof Files Symbol Type of File - Normal file d Directory l Linkfile (shortcut) b Blockfile (Harddisk,Floppydisk) c Character file (Keyboard,Mouse) P A namedpipedfile isusedforinterprocesscommunication S Its isa socketfile usedforinterprocesscommunication D A doorfile .it isa special file forinterprocesscommunication (sunsolaris) SymbolicLink There are twotypesof Links:- S.No. SoftLink Hard Link 1 Size of linkfile isequal tono.Of characters inthe name of the original file. Size of bothfile issame 2 Can be createdacross the partition Can’tbe createdacross the partition. 3 inode no.Of source and linkfile isdifferent inode no.Of both file issame 4 If original file isdeleted,linkisbrokenanddataislost If original file isdeletedthen alsolinkwill containdata 5 SHORCUT FILE BACKUPFILE
  • 24. If there is any issue at setup or connection contact support@k21technologies.com Creatinga softlink: #ln -s<source file><destination> CreatingHard Link #ln <source file><Destination> Grep: Grep standsfor Global RegularExpression Print.It isusedto pickout the requiredexpressionfrom the file andprintthe output.If grep iscombinedwithanothercommanditcan be usedto pickout the selectedword,phrase fromthe outputof the firstcommandand printit. Examplesof Grep Let uspick the informationaboutrootfromthe file /etc/passwd(/etc/passwdconatainsinformation aboutall the userspresentinthe system) #grep root/etc/passwd
  • 25. If there is any issue at setup or connection contact support@k21technologies.com To avoidcase sensitivityof the word(i.e the wordmaybe uppercase of lowercase) use -i #grep -i IT ktfile (letsgrepthe word IT whetherupperof lowercase inthe file ktfile) To displayaword and 2 linesafterthe word To displayaword and 2 linesafterthe word To displaythe things exceptthe givenword To displaythe searchedwordincolor
  • 26. If there is any issue at setup or connection contact support@k21technologies.com Combininggrepwithothercommands FilterCommands: filtercommandsare usedtofilterthe outputsothat the requiredthingscaneasilybe pickedup.The commandswhichare used to filterthe outputare  #less  #more  #head  #tail  #sort  #cut  #sed
  • 27. If there is any issue at setup or connection contact support@k21technologies.com less:- The lesscommand is usedto see the output line wise or page wise. Note:- pressEnterkeyto scroll downline byline (or) Use d to go to nextpage Use b to go to previouspage use / to searchfor a wordin the file Use v to go vi mode where youcan editthe file andonce yousave it youwill backto lesscommand more: more isexactlysame like less
  • 28. If there is any issue at setup or connection contact support@k21technologies.com Ex: #more /etc/passwd Note:- pressEnter keyto scroll downline byline (or) use d to go to nextpage use / to searchfor a wordin the file Use v to go vi mode where youcan editthe file andonce yousave ityou will backtomore command head: it is usedto displaythe top 10 linesof the file. ex:# head/etc/passwd To display the custom lines #head -n /etc/passwd (where n can be any number) tail: It is usedto displaythe last 10 linesofthe file #tail /etc/passwd
  • 29. If there is any issue at setup or connection contact support@k21technologies.com To display the custom lines #tail -n /etc/passwd(where n can be any number) sort: It is usedto sort the output in numeric or alphabeticorder #sort filename
  • 30. If there is any issue at setup or connection contact support@k21technologies.com To sort the file accordingto numbers #sort -dktfile To remove the duplicate entriesfrom the output #sort -uktfile
  • 31. If there is any issue at setup or connection contact support@k21technologies.com cut command: The cut commandisusedto pick the givenexpression(incolumns) anddisplaythe output. #cut -d -f filename(where dstandsfordelimiterex.:," "etcand f standsfor field)
  • 32. If there is any issue at setup or connection contact support@k21technologies.com To delimitspacesandprintthe field #cut -d "" -f1 filename To delimitcommasandprintthe field #cut -d, f1 filename sedcommand sedstands forstreameditor,whichisusedtosearch a word inthe file andreplace itwiththe word requiredtobe inthe output. Note:- itwill onlymodifythe output,butthere will be nochange inthe original file. sed's/searchfor/replacewith/g' filename Redirection:Redirectionisaprocesswhere we cancopy the outputof anycommand(s),file(s) intoa newfile.There are twowaysof redirectingthe outputintoafile. Using> or >> filename afterthe command,and usingtee command Note:if the givenname of the file isnotavilable anew file will be createdautomatically.If the file alreadyexiststhenitwill overwrite contentsof thatfile.
  • 33. If there is any issue at setup or connection contact support@k21technologies.com Appendinganotheroutputinsame the same file Likewise thereare manyoptionswhere we canuse redirections Ex: copyingcontentsof twofilesinanew file #cat file1file2>file3 Usingtee The above optionsof redirectionswill notdisplayanyoutput,butdirectlysave the outputinafile. usingtee commandwill notonlyredirectthe outputtonew file butitwill alsodisplaythe output. Syntax:cat <filename>|tee <newfile name> Note:If the givenof the file (newfile)isnotavailable anew file will be createdautomatically.If the file alreadyexiststhenitwill overwrite contentsof the file. #cat ktfile |tee ktf1
  • 34. If there is any issue at setup or connection contact support@k21technologies.com Appendingdatainthe same file usingtee command Syntax: cat filname | tee -a filename2 #cat ktfile1| tee -a ktf1 FindCommand findcommandis usedto findthe filesordirectory'spath, itisexactlylike the findoptioninwindows where youcan searchfor a file. Syntax: find / (underroot) - option filename optionsthatcan be usedwithfindcommand: Option Usage -name For searchinga file withitsname -inum For searchinga file withparticularinodenumber -type For searchinga particulartype of file. -user For fileswhose owner -group For filesbelongingtoparticulargroup
  • 35. If there is any issue at setup or connection contact support@k21technologies.com Findingafile withname #find/ -name test #find/ -num5934 Findingthe files,whose ownerisausercalled"abc" Findingthe fileswhose groupis"abc"
  • 36. If there is any issue at setup or connection contact support@k21technologies.com File Permissions Permissionsare appliedonthree levels:-  Owneror User level  Group level  Otherslevel Accessmodesare of three types:-  r readonly  w write/edit/delete/append  x execute/runacommand Accessmodesare differentonfile anddirectory. PERMISSIONS FILES DIRECTORY r Openthe file 'ls' the contentsof dir w Write,edit,append,deletefile Add/Del/Renamecontentsof dir x To run a command/shell script To enterintodirusing'cd' r : For normal or directoryfile - viewthe contents w: Editthe contentsof a normal or directoryfile
  • 37. If there is any issue at setup or connection contact support@k21technologies.com x: Runan executable file /Enterintodirectoryfile Permissionscanbe seton any file/dirbytwomethods:- 1. Symbolicmethod (ugo) 2. Absolute method(numbers) SymbolicMethod Symbolicmode:General formof symbolicmode is #chmod [who] [+/-/=] [permissions] file who> to whomthe permissionstobe assigned user/owner(u);group(g);others(o) Example:- Assigndifferrentpermissionstothe file (user=rwx,group=rw andothers=r) #chmod u=rwx,g=rw,o=r ktfile(where ktfileisthe name of the file)
  • 38. If there is any issue at setup or connection contact support@k21technologies.com Assigningfullpermissiontothe file i.e rwx toall #chmod ugo=rwx <file name> likewise youcanaddor remove permissionsfromanyfile foranyone(usergrouporother)  #chmod u+x ktfile (addingexecutepermissionstouseronly)  #chmod go-wx ktfile(Removingwrite andexecutepermissionsfromgroupandother)  #chmod go+wx ktfile (Addingwriteandexecute permissionsfromgroupandother)  #chmod go=r ktfile (Givingonlyreadpermissiontogroupandother) ABSOLUTE METHOD(NUMBERS) In Absolute methodwe use numbersinsteadof usingsymbolsi.e  Read = 4  Write = 2  Execute = 1 Assigningdifferentpermissionstothe file (user=rwx,group=rw andothers=r) #chmod 764 ktfile (where 7 means rwx i.e 4+2+1, rw=6 i.e 4+2 and 1 indicatesx)
  • 39. If there is any issue at setup or connection contact support@k21technologies.com Assigningfullpermissionstothe file i.e rwx toall #chmod 777 ktfile likewise youcangive differentpermissionsaccordingtoyour requirement Removingall permissionsfromothers #chmod 770 ktfile (where 0 indicatesno permissions) Note:All the above permissionsandprocedure issame forfilesanddirectories Umask Whenwe create any file usingtouch,cator vi commandstheygetcreatedwithdefaultfile permissionsasstoredinumask(userfilecreationmask).umaskisa4 digitoctal numberwhichtells unix whichof the three permissionsare tobe deniedratherthangranted.Umask will decidethat whatshouldbe the defaultpermissionsforafile anddirectorywhenitiscreated. the defaultumask value is 0022
  • 40. If there is any issue at setup or connection contact support@k21technologies.com calculationof defaultpermissionsforfile anddirectory,basinguponthe umaskvalue Note:For a file bydefaultitcannothave the execute permissions,sothe maximumfull permission for a file atthe time of creationcan be 666 (i.e 777 -111 = 666), whereasadirectorycan have full permissionsi.e777 The full permissionsforthe file 666 Minusthe umaskvalue -022 The defaultpermissionforfile is 644 (rw-,r--,r--) The full permissionsforthe directory 777 Minusthe umaskvalue -022 The defaultpermissionforfile is 755 (rwx,r-x,r-x) #umask002 The modifieddefaultpermissionforafile will be 666-002=664 i.e.rw,rw,r,andforthe directoryit will be 777-002=775 i.e.rwx,rwx,r-x
  • 41. If there is any issue at setup or connection contact support@k21technologies.com Note:Create a file anda directoryandcheckfor the defaultpermissions. These were the fewthings amongst the basics; keepworkingto furnishyour basics. After all,if the foundationis good thenonly the buildingcan stand still" =============End of the Activity 1 Guide========