Professional Documents
Culture Documents
Basics
KARUNYALINUXCLUB
www.karunya.edu/linuxclub
Outline
1.
2.
3.
4.
5.
6.
7.
8.
OverviewofLinuxSystem
BasicCommands
Relative&AbsolutePath
Redirect,AppendandPipe
Permission
ProcessManagement
InstallSoftware
TextEditor
OverviewofLinuxSystem
Kernel&Shell
Linuxisoperatingsystem(OS).
Linuxsystemisdescribedaskernel&
shell.
KernelisamainprogramofLinux
system.Itcontrolshardwares,CPU,
memory,harddisk,networkcardetc.
Shellisaninterfacebetweenuserand
kernel.Shellinterpretsyourinputas
commandsandpassthemtokernel.
User
input
Shell
Kernel
LinuxOverview(cont.)
Multiuser&Multiprocess
Manypeoplecanuseonemachineatthesame
time.
File&Process
Data,directory,process,harddisketc(almost
everything)areexpressedasafile.
Processisanrunningprogramidentifiedbya
uniqueid(PID).
LinuxOverview(cont.)
DirectoryStructure
Filesareputinadirectory.
Alldirectoriesareinahierarchicalstructure(tree
structure).
Usercanputandremoveanydirectoriesonthe
tree.
Topdirectoryis/,whichiscalledslashorroot.
Usershavetheowndirectory.(homedirectory)
LinuxOverview(cont.)
DirectoryStructure
LinuxOverview(cont.)
ImportantDirectories
/binThiscontainsfilesthatareessentialforcorrect
operationofthesystem.Theseareavailablefor
usebyallusers.
/mntProvidesalocationformountingdevices,suchas
remotefilesystemsandremovablemedia
/homeThisiswhereuserhomedirectoriesarestored.
/var Thisdirectoryisusedtostorefileswhichchange
frequently,andmustbeavailabletobewrittento.
/etc Varioussystemconfigurationfilesarestoredhere.
LinuxOverview(cont.)
ImportantDirectories
/dev Thiscontainsvariousdevicesasfiles,e.g.hard
disk,CDROMdrive,etc.
/rootThisistheroot(administrator)user'shome
directory
/sbin Binarieswhichareonlyexpectedtobeusedby
thesuperuser.
/tmpTemporaryfiles.
/bootHasthebootableLinuxkernelandboot
loaderconfigurationfiles(GRUB)
/usrContainsuserdocumentation,games,graphical
files,libraries(lib),etc..
LinuxOverview(cont.)
NormaluserandSuperuser
InLinuxsystem,thereisonespecialuserforadministrator,
whichcandoanything.
Thisspecialuseriscalledrootorsuperuser.
CaseSensitivity
LinuxlikeUNIXiscasesensitive.
MYFILE.doc,Myfile.doc,mYfiLe.Docaredifferent.
OnlineManual
Linuxhaswellwrittenonlinemanuals.
BasicCommands
Howtoruncommands
WhenyoulogonLinuxmachine,youwillsee,
[cswug@hyperion001cswug]$
Onecommandconsistsofthreeparts,i.e.commandname,
options,arguments.
Example)
[cswug~]$commandnameoptionAoptionBargument1argument2
BasicCommands
Howtoruncommands
Betweencommandname,optionsandarguments,spaceis
necessary.
Opitionsalwaysstartwith
Example)
cd..
lsl.bashrc
mvfileAfileB
BasicCommands
Commands
ls
showfilesincurrentposition
cd
changedirectory
cp
copyfileordirectory
mv
movefileordirectory
rm
removefileordirectory
pwd
showcurrentposition
mkdir
createdirectory
rmdir
removedirectory
catdisplayfilecontents
less
displayfilecontentspagewise
man
displayonlinemanual
BasicCommands
Commands
su
switchuser
passwd
changepassword
useradd
createnewuseraccount
userdel
deleteuseraccount
mount
mountfilesystem
umount
unmountfilesystem
df
showdiskspaceusage
shutdown
rebootorturnoffmachine
PracticeBasicCommands
1.Typefollowingcommandin
yourdirectory.
ls
lsa
lsla
lsFa
2.Makeadirectory
mkdirlinux
pwd
cdlinux
pwd
cd
pwd
rmdirlinux
3.Inyourhomedirectory,
ls.bash_profile
cp.bash_profilesample.txt
lesssample.txt(note:toquitless,pressq)
rmsample.txt
4.Trytochangeyourpassword,
passwdusername
(Typecurrentpasswordonce,then
typenewpasswordtwice.Youdonthaveto
changepasswordhere.Justapractice)
5.checkdiskspaceusage
df
dfh
Relative&AbsolutePath
Pathmeansapositioninthedirectorytree.
Toexpressapath,youcanuserelativepath
orabsolutepath.
Inrelativepathexpression,thepathisnot
defineduniquely,dependsonyourcurrent
path.
Inabsolutepathexpression,thepathis
defineduniquely,doesnotdependonyour
currentpath.
Relative&AbsolutePath
Charactersusedin
relativepath
.currentdirectory
..parentdirectory
Example)
cd..
./a.out
Absolutepathstartswith/
Example)
cd/home/user01
/home/root/a.out
Relative&AbsolutePath
Userelativepath.
Inhomedirectory,type
pwd
cd.
pwd
cd..
pwd
cd..
pwd
cd
Useabsolutepath.
Inhomedirectory,type
pwd
cd/home/cswug
pwd
cd/home
pwd
cd/
pwd
cd/home/cswug
Redirect,AppendandPipe
Redirectandappend
Outputofcommandisdisplayedonscreen.
Using>,youcanredirecttheoutputfromscreentoafile.
Using>>youcanappendtheoutputtothebottomofthefile.
Pipe
Somecommandsrequireinputfromafileorothercommands.
Using|,youcanuseoutputfromothercommandasinputtothe
command.
Redirect,AppendandPipe
Commands
head
showfirstseverallinesandomitotherlines.
tail
showlastseverallinesandomit otherlines.
grep
showlinesmatchingapattern
Redirect,AppendandPipe
Inhomedirectory,type
ls.bash_profile
cp.bash_profilesample.txt
lesssample.txt
Useredirect.
head3sample.txt
head3sample.txt>redirect.txt
Useappend.
tail3sample.txt
tail3sample.txt>>redirect.txt
lessredirect.txt
Usepipe.
lessredirect.txt
grepPATHredirect.txt
tailredirect.txt|grepPATH
rmsample.txt
rmredirect.txt
Permission
Alloffilesanddirectorieshaveownerandpermission.
Therearethreetypesofpermission,readable,
writeableandexecutable.
Permissionsaregiventothreekindsofgroup.owner,
groupmemberandothers.
Example)
[cswug@hyperion001cswug]$lsl.bash_profile
rwrr1cswugcswug191Jan413:11.bash_profile
r:
readable,w:writable,x:executable
Permission
Command
chmod
changefilemode,addorremove
permission
chown
changeownerofthefile
Example)
chmoda+wfilename
addwritablepermissiontoallusers
chmodoxfilename
removeexecutablepermissionfromothers
Permission
Checkpermission
lsl.bash_profile
cp.bash_profilesample.txt
lslsample.txt
Removereadablepermissionfromall.
chmodarsample.txt
lslsample.txt
lesssample.txt
Addreadable&writablepremissionstofileowner.
chmodu+rwsample.txt
lslsample.txt
lesssample.txt
rmsample.txt
ProcessManagement
Processisaunitofrunningprogram.
Eachprocesshassomeinformations,likeprocessID,owner,
priority,etc.
ProcessManagement
Commands
kill
Sendsspecifiedsignaltospecified
process.Thisprocessisspecifiedby
processID.
killall
Stopaprogram.Theprogramis
specifiedbycommandname.
ps
Showprocessstatus
top
Showsystemusagestatistics
ProcessManagement
Checkyourprocess.
ps
psu
Checkprocessofallusers.
top(Toquittop,pressq)
pse
psef
Findyourprocess.
psef|grepcswug
InstallSoftware
InstallSoftware
Commands
gzip
gunzip
tar
configure
make
compress a file
uncompress a file
archive or expand files
create Makefile
compile & install software
InstallSoftware
Example)parallelprogramminglibraryinstallation
Executingcommandslinebyline:
tarxvfzmpich.tar.gz
cdmpich1.2.5.2
./configureprefix=/usr/localrsh=ssh
make
makeinstall
TextEditor
TextEditor
WritehelloworldprograminC(assumingGCCisinstalledon
yourLinuxsystem).
Typevihello.c[whereviiseditornameandhello.cisfilename]
PressIforinsertingandtypetehello.casfollows.
#include<stdio.h>
intmain(void){
printf(HelloWorld\n);
}
AfterfinishingtypingsavethefilebypressingESC
buttonandthentypingcolonfollowedbywqasfollows:
:wq[wtosaveandqtoquit]
Compile
gcchello.c
Run
./a.out
TextEditor
Weopenthevieditorforediting/writingafileusingvicommand
as:vifilename[wherefilenameisthenameofthefileused]
PressIforinserting(iefortypingintheeditor),ifany.
Aftertyping,pressESCfollowedby(eitherofthefollowing)
:q[toquitsimply]
:wq[tosaveandquit]
:q![toforcequitwithoutsaving]
TutorialofLinux
E
N
D