Vous êtes sur la page 1sur 26

Linux

BasicCommands
Y.Shashidhar
shashi@cse.iitb.ac.in

BasicLinuxCommands
FileHandling
TextProcessing
SystemAdministration
ProcessManagement
Archival
Network
FileSystems
AdvancedCommands

Sourcestolearncommands??

Primaryman(manual)pages.

man<command>showsallinformationaboutthe
command
<command>helpshowstheavailableoptions
forthatcommand

SecondaryBooksandInternet

FileHandlingcommands

mkdirmakedirectories
Usage:mkdir[OPTION]DIRECTORY...
eg.mkdirprabhat

lslistdirectorycontents
Usage:ls[OPTION]...[FILE]...
eg.ls,lsl,lsprabhat

cdchangesdirectories
Usage:cd[DIRECTORY]
eg.cdprabhat

FileHandling(contd...)

pwdprintnameofcurrentworkingdirectory
Usage:pwd

vimViImproved,aprogrammerstexteditor
Usage:vim[OPTION][file]...
eg.vimfile1.txt

FileHandling(contd...)

cpcopyfilesanddirectories

Usage:cp[OPTION]...SOURCEDEST

eg.cpsample.txtsample_copy.txt
cpsample_copy.txttarget_dir

mvmove(rename)files

Usage:mv[OPTION]...SOURCEDEST

eg.mvsource.txttarget_dir
mvold.txtnew.txt

FileHandling(contd...)
rmremovefilesordirectories
Usage:rm[OPTION]...FILE...
eg.rmfile1.txt,rmrfsome_dir

findsearchforfilesinadirectoryhierarchy
Usage:find[OPTION][path][pattern]
eg.findfile1.txt,findnamefile1.txt
historyprintsrecentlyusedcommands
Usage:history

Pattern
A Pattern is an expression that describes a set of
strings which is used to give a concise description
of a set, without having to list all elements.
eg. ab*cd matches anything that starts with ab and
ends with cd etc.
ls *.txt prints all text files

TextProcessing

catconcatenatefilesandprintonthestandardoutput
Usage:cat[OPTION][FILE]...
eg.catfile1.txtfile2.txt

catnfile1.txt

echodisplayalineoftext
Usage:echo[OPTION][string]...
eg.echoIloveIndia
echo$HOME

TextProcessing(contd...)

grepprintlinesmatchingapattern
Usage:grep[OPTION]PATTERN[FILE]...
eg.grepiapplesample.txt

wcprintthenumberofnewlines,words,andbytesinfiles
Usage:wc[OPTION]...[FILE]...
eg.wcfile1.txt
wcLfile1.txt

TextProcessing(contd...)
sortsortlinesoftextfiles
Usage:sort[OPTION]...[FILE]...
eg.sortfile1.txt
sortrfile1.txt

LinuxFilePermissions

3typesoffilepermissionsread,write,execute
10bitformatfrom'lsl'command
12345678910
filetypeownergroupothers
eg.drwxrwrmeansownerhasallthreepermissions,
grouphasreadandwrite,othershaveonlyread
permission
readpermission4,write2,execute1
eg.rwxrwr=764
673=rwrwxwx

SystemAdministration

chmodchangefileaccesspermissions
Usage:chmod[OPTION][MODE][FILE]
eg.chmod744calculate.sh

chownchangefileownerandgroup
Usage:chown[OPTION]...OWNER[:[GROUP]]FILE...
eg.chownremomyfile.txt

SystemAdministration(contd...)
suchangeuserIDorbecomesuperuser
Usage:su[OPTION][LOGIN]
eg.suremo,su
passwdupdateausersauthenticationtokens(s)
Usage:passwd[OPTION]
eg.passwd
whoshowwhoisloggedon
Usage:who[OPTION]
eg.who,whob,whoq

ProcessManagement

psreportasnapshotofthecurrentprocesses
Usage:ps[OPTION]
eg.ps,psel

killtokillaprocess(usingsignalmechanism)
Usage:kill[OPTION]pid
eg.kill92275

Archival

tartoarchiveafile
Usage:tar[OPTION]DESTSOURCE
eg.tarcvf/home/archive.tar/home/original
tarxvf/home/archive.tar

zippackageandcompress(archive)files
Usage:zip[OPTION]DESTSOURSE
eg.ziporiginal.ziporiginal
unziplist,testandextractcompressedfilesinaZIParchive
Usage:unzipfilename
eg.unziporiginal.zip

Network

sshSSHclient(remoteloginprogram)
sshisaprogramforloggingintoaremotemachineandfor
executingcommandsonaremotemachine
Usage:ssh[options][user]@hostname

eg.sshXguest@10.105.11.20
scpsecurecopy(remotefilecopyprogram)
scpcopiesfilesbetweenhostsonanetwork
Usage:scp[options][[user]@host1:file1][[user]@host2:file2]
eg.scpfile1.txtguest@10.105.11.20:~/Desktop/

FileSystems
fdiskpartitionmanipulator
eg.sudofdiskl
mountmountafilesystem
Usage:mountttypedevicedir
eg.mount/dev/sda5/media/target
umountunmountfilesystems
Usage:umount[OPTIONS]dir|device...
eg.umount/media/target

FileSystems(contd...)

duestimatefilespaceusage
Usage:du[OPTION]...[FILE]...
eg.du

dfreportfilesystemdiskspaceusage
Usage:df[OPTION]...[FILE]...
eg.df

quotadisplaydiskusageandlimits
Usage:quota[OPTION]
eg.quotav

AdvancedCommands
rebootrebootthesystem
Usage:reboot[OPTION]
eg.reboot

poweroffpoweroffthesystem
Usage:poweroff[OPTION]
eg.poweroff

Suggested Material
TheUNIXProgrammingEnvironment
byKernighanandPike(PrenticeHall)
YourUNIX:TheUltimateGuide
bySumitabhaDas

ThankYou

Editorcommands

kateKDEAdvancedTextEditor
Usage:kate[options][file(s)]
eg.katefile1.txtfile2.txt

vimViImproved,aprogrammerstexteditor
Usage:vim[OPTION][file]...
eg.vihello.c

geditAtextEditor.Usedtocreateandeditfiles.
Usage:gedit[OPTION][FILE]...
eg.gedit

ProcessManagement(contd...)
bgmakeaforegroundprocesstoruninbackground
Usage:type'ctrl+z'andthen'bg<jobid>'
fgtomakebackgroundprocessasforegroundprocess
Usage:fg[jobid]
jobsdisplaysthenamesandidsofbackgroundjobs
Usage:jobs

AdvancedCommands(contd...)
sedstreameditorforfilteringandtransformingtext
Usage:sed[OPTION][inputfile]...
eg.sed's/love/hate/g'loveletter.txt

awkpatternscanningandprocessinglanguage
eg.awkF:'{print$1}'sample_awk.txt

findsearchforfilesinadirectoryhierarchy
Usage:find[OPTION][path][pattern]
eg.findnamefile1.txt
locatefindorlocateafile
Usage:locate[OPTION]...FILE...
eg.locatefile1.txt

Vous aimerez peut-être aussi