Linux Tutorial
Linux Tutorial
KARUNYALINUXCLUB www.karunya.edu/linuxclub
Outline
1. 2. 3. 4. 5. 6. 7. 8.
OverviewofLinuxSystem
Kernel&Shell
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
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
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
3.Inyourhomedirectory,
4.Trytochangeyourpassword,
passwdusername (Typecurrentpasswordonce,then typenewpasswordtwice.Youdonthaveto changepasswordhere.Justapractice)
5.checkdiskspaceusage
df dfh
Relative&AbsolutePath
Relative&AbsolutePath
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
Pipe
Redirect,AppendandPipe
Commands
head tail
grep
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
Permission
Example) [cswug@hyperion001cswug]$lsl.bash_profile r:
rwrr1cswugcswug191Jan413:11.bash_profile
readable,w:writable,x:executable
Permission
Command
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
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
Linux system has a de facto standard way to install a software. configure, make & make install Typical software installation procedure as following.
1. 2. 3.
Download source code. Usually, it s archived with tar command and compressed with gzip command. configure command creates Makefile automatically which is used to compile the source. Program compilation is written in Makefile.
InstallSoftware
Commands
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
Programs & configuration files are text file. There are two popular text editors, vi and Emacs. Very powerful and useful.
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
TutorialofLinux
E N D