lecture 2: es 102 linux commands · logo-lecture 2: es 102 linux commands introduction to computing...
TRANSCRIPT
logo
-
Lecture 2: ES 102Linux Commands
Introduction to Computing
IIT Gandhinagar, India
Sep, 2013
Bireswar, Shivkumar (IIT Gandhinagar) Lecture 2 Sep 2013 1 / 12
logo
Directory Structure in Linux
/
bin dev ....... home .... etc sys var
root
iitgn es102 guest
Cprog Folder1 Desktop .... file1 ...
prog1.c Prog2.c
Home Folder
path /home/es102/Cprog/Prog2
Bireswar, Shivkumar (IIT Gandhinagar) Lecture 2 Sep 2013 2 / 12
logo
Directory Structure in Linux/
bin dev ....... home .... etc sys var
root
iitgn es102 guest
Cprog Folder1 Desktop .... file1 ...
prog1.c Prog2.c
Home Folder
path /home/es102/Cprog/Prog2
Path of directory Folder1 is /home/username/ES102/Folder1.
Parent directory: Directory that contains it.
Home directory: Each user has a directory with the same name aslogin id. This directory called home directory.
pwd print home directory.
mkdir create directory.
ls list directory and files.
Bireswar, Shivkumar (IIT Gandhinagar) Lecture 2 Sep 2013 3 / 12
logo
Directory Structure in Linux/
bin dev ....... home .... etc sys var
root
iitgn es102 guest
Cprog Folder1 Desktop .... file1 ...
prog1.c Prog2.c
Home Folder
path /home/es102/Cprog/Prog2
Path of directory Folder1 is /home/username/ES102/Folder1.
Parent directory: Directory that contains it.
Home directory: Each user has a directory with the same name aslogin id. This directory called home directory.
pwd print home directory.
mkdir create directory.
ls list directory and files.
Bireswar, Shivkumar (IIT Gandhinagar) Lecture 2 Sep 2013 3 / 12
logo
Directory Structure in Linux/
bin dev ....... home .... etc sys var
root
iitgn es102 guest
Cprog Folder1 Desktop .... file1 ...
prog1.c Prog2.c
Home Folder
path /home/es102/Cprog/Prog2
Path of directory Folder1 is /home/username/ES102/Folder1.
Parent directory: Directory that contains it.
Home directory: Each user has a directory with the same name aslogin id. This directory called home directory.
pwd print home directory.
mkdir create directory.
ls list directory and files.
Bireswar, Shivkumar (IIT Gandhinagar) Lecture 2 Sep 2013 3 / 12
logo
Directory Structure in Linux/
bin dev ....... home .... etc sys var
root
iitgn es102 guest
Cprog Folder1 Desktop .... file1 ...
prog1.c Prog2.c
Home Folder
path /home/es102/Cprog/Prog2
Path of directory Folder1 is /home/username/ES102/Folder1.
Parent directory: Directory that contains it.
Home directory: Each user has a directory with the same name aslogin id. This directory called home directory.
pwd print home directory.
mkdir create directory.
ls list directory and files.
Bireswar, Shivkumar (IIT Gandhinagar) Lecture 2 Sep 2013 3 / 12
logo
Directory Structure in Linux/
bin dev ....... home .... etc sys var
root
iitgn es102 guest
Cprog Folder1 Desktop .... file1 ...
prog1.c Prog2.c
Home Folder
path /home/es102/Cprog/Prog2
Path of directory Folder1 is /home/username/ES102/Folder1.
Parent directory: Directory that contains it.
Home directory: Each user has a directory with the same name aslogin id. This directory called home directory.
pwd print home directory.
mkdir create directory.
ls list directory and files.
Bireswar, Shivkumar (IIT Gandhinagar) Lecture 2 Sep 2013 3 / 12
logo
Directory Structure in Linux/
bin dev ....... home .... etc sys var
root
iitgn es102 guest
Cprog Folder1 Desktop .... file1 ...
prog1.c Prog2.c
Home Folder
path /home/es102/Cprog/Prog2
Path of directory Folder1 is /home/username/ES102/Folder1.
Parent directory: Directory that contains it.
Home directory: Each user has a directory with the same name aslogin id. This directory called home directory.
pwd print home directory.
mkdir create directory.
ls list directory and files.
Bireswar, Shivkumar (IIT Gandhinagar) Lecture 2 Sep 2013 3 / 12
logo
Directory Structure in Linux/
bin dev ....... home .... etc sys var
root
iitgn es102 guest
Cprog Folder1 Desktop .... file1 ...
prog1.c Prog2.c
Home Folder
path /home/es102/Cprog/Prog2
Path of directory Folder1 is /home/username/ES102/Folder1.
Parent directory: Directory that contains it.
Home directory: Each user has a directory with the same name aslogin id. This directory called home directory.
pwd print home directory.
mkdir create directory.
ls list directory and files.
Bireswar, Shivkumar (IIT Gandhinagar) Lecture 2 Sep 2013 3 / 12
logo
Navigation
Basic command cd path
Some shorthands:
1 special name for root directory /2 The shorthand for current directory .3 The shorthand for parent directory ..4 The shorthand for home directory ∼
Examples $cd $cd . $cd .. $ cd ../..
Bireswar, Shivkumar (IIT Gandhinagar) Lecture 2 Sep 2013 4 / 12
logo
Navigation
Basic command cd path
Some shorthands:
1 special name for root directory /2 The shorthand for current directory .3 The shorthand for parent directory ..4 The shorthand for home directory ∼
Examples $cd $cd . $cd .. $ cd ../..
Bireswar, Shivkumar (IIT Gandhinagar) Lecture 2 Sep 2013 4 / 12
logo
Navigation
Basic command cd path
Some shorthands:1 special name for root directory /
2 The shorthand for current directory .3 The shorthand for parent directory ..4 The shorthand for home directory ∼
Examples $cd $cd . $cd .. $ cd ../..
Bireswar, Shivkumar (IIT Gandhinagar) Lecture 2 Sep 2013 4 / 12
logo
Navigation
Basic command cd path
Some shorthands:1 special name for root directory /2 The shorthand for current directory .
3 The shorthand for parent directory ..4 The shorthand for home directory ∼
Examples $cd $cd . $cd .. $ cd ../..
Bireswar, Shivkumar (IIT Gandhinagar) Lecture 2 Sep 2013 4 / 12
logo
Navigation
Basic command cd path
Some shorthands:1 special name for root directory /2 The shorthand for current directory .3 The shorthand for parent directory ..
4 The shorthand for home directory ∼Examples $cd $cd . $cd .. $ cd ../..
Bireswar, Shivkumar (IIT Gandhinagar) Lecture 2 Sep 2013 4 / 12
logo
Navigation
Basic command cd path
Some shorthands:1 special name for root directory /2 The shorthand for current directory .3 The shorthand for parent directory ..4 The shorthand for home directory ∼
Examples $cd $cd . $cd .. $ cd ../..
Bireswar, Shivkumar (IIT Gandhinagar) Lecture 2 Sep 2013 4 / 12
logo
Navigation
Basic command cd path
Some shorthands:1 special name for root directory /2 The shorthand for current directory .3 The shorthand for parent directory ..4 The shorthand for home directory ∼
Examples $cd $cd . $cd .. $ cd ../..
Bireswar, Shivkumar (IIT Gandhinagar) Lecture 2 Sep 2013 4 / 12
logo
Copying and Moving
Basic command cp filePath destinationPath.
If destination is a directory cp creates a copy inside the directory.
If destination is a file name, cp creates a copy with that name.
Copying directory cp -r dirPath destinationPath.
Basic command mv sourcePath destinationPath.
Examples:cp Cprog/Prog2.c ../new.ccp Cprog/Prog2.c ../mv Cprog ../newFoldermv Cprog ../Folder2
Bireswar, Shivkumar (IIT Gandhinagar) Lecture 2 Sep 2013 5 / 12
logo
Copying and Moving
Basic command cp filePath destinationPath.
If destination is a directory cp creates a copy inside the directory.
If destination is a file name, cp creates a copy with that name.
Copying directory cp -r dirPath destinationPath.
Basic command mv sourcePath destinationPath.
Examples:cp Cprog/Prog2.c ../new.ccp Cprog/Prog2.c ../mv Cprog ../newFoldermv Cprog ../Folder2
Bireswar, Shivkumar (IIT Gandhinagar) Lecture 2 Sep 2013 5 / 12
logo
Copying and Moving
Basic command cp filePath destinationPath.
If destination is a directory cp creates a copy inside the directory.
If destination is a file name, cp creates a copy with that name.
Copying directory cp -r dirPath destinationPath.
Basic command mv sourcePath destinationPath.
Examples:cp Cprog/Prog2.c ../new.ccp Cprog/Prog2.c ../mv Cprog ../newFoldermv Cprog ../Folder2
Bireswar, Shivkumar (IIT Gandhinagar) Lecture 2 Sep 2013 5 / 12
logo
Copying and Moving
Basic command cp filePath destinationPath.
If destination is a directory cp creates a copy inside the directory.
If destination is a file name, cp creates a copy with that name.
Copying directory cp -r dirPath destinationPath.
Basic command mv sourcePath destinationPath.
Examples:cp Cprog/Prog2.c ../new.ccp Cprog/Prog2.c ../mv Cprog ../newFoldermv Cprog ../Folder2
Bireswar, Shivkumar (IIT Gandhinagar) Lecture 2 Sep 2013 5 / 12
logo
Copying and Moving
Basic command cp filePath destinationPath.
If destination is a directory cp creates a copy inside the directory.
If destination is a file name, cp creates a copy with that name.
Copying directory cp -r dirPath destinationPath.
Basic command mv sourcePath destinationPath.
Examples:cp Cprog/Prog2.c ../new.ccp Cprog/Prog2.c ../mv Cprog ../newFoldermv Cprog ../Folder2
Bireswar, Shivkumar (IIT Gandhinagar) Lecture 2 Sep 2013 5 / 12
logo
Copying and Moving
Basic command cp filePath destinationPath.
If destination is a directory cp creates a copy inside the directory.
If destination is a file name, cp creates a copy with that name.
Copying directory cp -r dirPath destinationPath.
Basic command mv sourcePath destinationPath.
Examples:cp Cprog/Prog2.c ../new.ccp Cprog/Prog2.c ../mv Cprog ../newFoldermv Cprog ../Folder2
Bireswar, Shivkumar (IIT Gandhinagar) Lecture 2 Sep 2013 5 / 12
logo
Some Other Commands
rm -iv path remove a file.
rm -riv path remove a directory.
locate name locate a file/directory with the name.
bc -l arbitrary precision calculator.
Some useful tricks in terminal:
1 Press Tab to autocomplete.2 Press Up arrow to get previous commands.3 Select to copy, middle click to paste.
Bireswar, Shivkumar (IIT Gandhinagar) Lecture 2 Sep 2013 6 / 12
logo
Some Other Commands
rm -iv path remove a file.
rm -riv path remove a directory.
locate name locate a file/directory with the name.
bc -l arbitrary precision calculator.
Some useful tricks in terminal:
1 Press Tab to autocomplete.2 Press Up arrow to get previous commands.3 Select to copy, middle click to paste.
Bireswar, Shivkumar (IIT Gandhinagar) Lecture 2 Sep 2013 6 / 12
logo
Some Other Commands
rm -iv path remove a file.
rm -riv path remove a directory.
locate name locate a file/directory with the name.
bc -l arbitrary precision calculator.
Some useful tricks in terminal:
1 Press Tab to autocomplete.2 Press Up arrow to get previous commands.3 Select to copy, middle click to paste.
Bireswar, Shivkumar (IIT Gandhinagar) Lecture 2 Sep 2013 6 / 12
logo
Some Other Commands
rm -iv path remove a file.
rm -riv path remove a directory.
locate name locate a file/directory with the name.
bc -l arbitrary precision calculator.
Some useful tricks in terminal:
1 Press Tab to autocomplete.2 Press Up arrow to get previous commands.3 Select to copy, middle click to paste.
Bireswar, Shivkumar (IIT Gandhinagar) Lecture 2 Sep 2013 6 / 12
logo
Some Other Commands
rm -iv path remove a file.
rm -riv path remove a directory.
locate name locate a file/directory with the name.
bc -l arbitrary precision calculator.
Some useful tricks in terminal:
1 Press Tab to autocomplete.2 Press Up arrow to get previous commands.3 Select to copy, middle click to paste.
Bireswar, Shivkumar (IIT Gandhinagar) Lecture 2 Sep 2013 6 / 12
logo
Some Other Commands
rm -iv path remove a file.
rm -riv path remove a directory.
locate name locate a file/directory with the name.
bc -l arbitrary precision calculator.
Some useful tricks in terminal:1 Press Tab to autocomplete.
2 Press Up arrow to get previous commands.3 Select to copy, middle click to paste.
Bireswar, Shivkumar (IIT Gandhinagar) Lecture 2 Sep 2013 6 / 12
logo
Some Other Commands
rm -iv path remove a file.
rm -riv path remove a directory.
locate name locate a file/directory with the name.
bc -l arbitrary precision calculator.
Some useful tricks in terminal:1 Press Tab to autocomplete.2 Press Up arrow to get previous commands.
3 Select to copy, middle click to paste.
Bireswar, Shivkumar (IIT Gandhinagar) Lecture 2 Sep 2013 6 / 12
logo
Some Other Commands
rm -iv path remove a file.
rm -riv path remove a directory.
locate name locate a file/directory with the name.
bc -l arbitrary precision calculator.
Some useful tricks in terminal:1 Press Tab to autocomplete.2 Press Up arrow to get previous commands.3 Select to copy, middle click to paste.
Bireswar, Shivkumar (IIT Gandhinagar) Lecture 2 Sep 2013 6 / 12
logo
How to know Everything?
man command: Manual.
Example: man ls
Bireswar, Shivkumar (IIT Gandhinagar) Lecture 2 Sep 2013 7 / 12
logo
How to know Everything?
man command: Manual.
Example: man ls
Bireswar, Shivkumar (IIT Gandhinagar) Lecture 2 Sep 2013 7 / 12
logo
How to know Everything?
man command: Manual.
Example: man ls
Bireswar, Shivkumar (IIT Gandhinagar) Lecture 2 Sep 2013 7 / 12
logo
The * Wildcard
Create empty files test, test123, newtest123, abc, abcfoo, xyzCommand to create file without using editor: touch filename
The star wildcard (*) matches with any string of character.
It also matches with the empty string.
Example ls test, ls *test, ls *test*, ls *abc*
Bireswar, Shivkumar (IIT Gandhinagar) Lecture 2 Sep 2013 8 / 12
logo
The * Wildcard
Create empty files test, test123, newtest123, abc, abcfoo, xyzCommand to create file without using editor: touch filename
The star wildcard (*) matches with any string of character.
It also matches with the empty string.
Example ls test, ls *test, ls *test*, ls *abc*
Bireswar, Shivkumar (IIT Gandhinagar) Lecture 2 Sep 2013 8 / 12
logo
The * Wildcard
Create empty files test, test123, newtest123, abc, abcfoo, xyzCommand to create file without using editor: touch filename
The star wildcard (*) matches with any string of character.
It also matches with the empty string.
Example ls test, ls *test, ls *test*, ls *abc*
Bireswar, Shivkumar (IIT Gandhinagar) Lecture 2 Sep 2013 8 / 12
logo
The * Wildcard
Create empty files test, test123, newtest123, abc, abcfoo, xyzCommand to create file without using editor: touch filename
The star wildcard (*) matches with any string of character.
It also matches with the empty string.
Example ls test, ls *test, ls *test*, ls *abc*
Bireswar, Shivkumar (IIT Gandhinagar) Lecture 2 Sep 2013 8 / 12
logo
Editors
Vim (or vi) : A command based, rich text editor.. Many people workwith it at lightning speed.
Emacs: A classic editor. Generations of linux geeks love this
gedit: Ubuntu default editor .. Easy to use text editor with thousandsof useful features.
Bireswar, Shivkumar (IIT Gandhinagar) Lecture 2 Sep 2013 9 / 12
logo
Finding a File
locate cannot find newly created files/directories.
Command find FromwhereToStart -name “filename” -print
Example find ∼ -name “test” -print, find ∼ -name “abc”
filename can be specified with the help of *
Example find /home/ -name “test*” -print, find ../ -name “*test*”-print
Bireswar, Shivkumar (IIT Gandhinagar) Lecture 2 Sep 2013 10 / 12
logo
Finding a File
locate cannot find newly created files/directories.
Command find FromwhereToStart -name “filename” -print
Example find ∼ -name “test” -print, find ∼ -name “abc”
filename can be specified with the help of *
Example find /home/ -name “test*” -print, find ../ -name “*test*”-print
Bireswar, Shivkumar (IIT Gandhinagar) Lecture 2 Sep 2013 10 / 12
logo
Finding a File
locate cannot find newly created files/directories.
Command find FromwhereToStart -name “filename” -print
Example find ∼ -name “test” -print, find ∼ -name “abc”
filename can be specified with the help of *
Example find /home/ -name “test*” -print, find ../ -name “*test*”-print
Bireswar, Shivkumar (IIT Gandhinagar) Lecture 2 Sep 2013 10 / 12
logo
Finding a File
locate cannot find newly created files/directories.
Command find FromwhereToStart -name “filename” -print
Example find ∼ -name “test” -print, find ∼ -name “abc”
filename can be specified with the help of *
Example find /home/ -name “test*” -print, find ../ -name “*test*”-print
Bireswar, Shivkumar (IIT Gandhinagar) Lecture 2 Sep 2013 10 / 12
logo
Finding a File
locate cannot find newly created files/directories.
Command find FromwhereToStart -name “filename” -print
Example find ∼ -name “test” -print, find ∼ -name “abc”
filename can be specified with the help of *
Example find /home/ -name “test*” -print, find ../ -name “*test*”-print
Bireswar, Shivkumar (IIT Gandhinagar) Lecture 2 Sep 2013 10 / 12
logo
Some more commands
Listing detailed information ls -la
Listing the running tasks top
Listing the running tasks top
To find time taken by a command/program time command
Bireswar, Shivkumar (IIT Gandhinagar) Lecture 2 Sep 2013 11 / 12
logo
Some more commands
Listing detailed information ls -la
Listing the running tasks top
Listing the running tasks top
To find time taken by a command/program time command
Bireswar, Shivkumar (IIT Gandhinagar) Lecture 2 Sep 2013 11 / 12
logo
Some more commands
Listing detailed information ls -la
Listing the running tasks top
Listing the running tasks top
To find time taken by a command/program time command
Bireswar, Shivkumar (IIT Gandhinagar) Lecture 2 Sep 2013 11 / 12
logo
Some more commands
Listing detailed information ls -la
Listing the running tasks top
Listing the running tasks top
To find time taken by a command/program time command
Bireswar, Shivkumar (IIT Gandhinagar) Lecture 2 Sep 2013 11 / 12
logo
Thousands of Free Applications
Open office or Libre office :Reading all document files ( Word,Excel,Powerpoint equivalent)
Hundreds of editors: Kile (Latex), Spyder (Python) etc..
Mathtools : octave (matlab), Scilab, geogebra,
Plotting: Gnuplot, Xmgrace, ..
Photo editing gimp , video editing , sound editing ..
Installing applications in Ubuntu: sudo apt-get install APPLICATIONNAME
Bireswar, Shivkumar (IIT Gandhinagar) Lecture 2 Sep 2013 12 / 12
logo
Thousands of Free Applications
Open office or Libre office :Reading all document files ( Word,Excel,Powerpoint equivalent)
Hundreds of editors: Kile (Latex), Spyder (Python) etc..
Mathtools : octave (matlab), Scilab, geogebra,
Plotting: Gnuplot, Xmgrace, ..
Photo editing gimp , video editing , sound editing ..
Installing applications in Ubuntu: sudo apt-get install APPLICATIONNAME
Bireswar, Shivkumar (IIT Gandhinagar) Lecture 2 Sep 2013 12 / 12
logo
Thousands of Free Applications
Open office or Libre office :Reading all document files ( Word,Excel,Powerpoint equivalent)
Hundreds of editors: Kile (Latex), Spyder (Python) etc..
Mathtools : octave (matlab), Scilab, geogebra,
Plotting: Gnuplot, Xmgrace, ..
Photo editing gimp , video editing , sound editing ..
Installing applications in Ubuntu: sudo apt-get install APPLICATIONNAME
Bireswar, Shivkumar (IIT Gandhinagar) Lecture 2 Sep 2013 12 / 12
logo
Thousands of Free Applications
Open office or Libre office :Reading all document files ( Word,Excel,Powerpoint equivalent)
Hundreds of editors: Kile (Latex), Spyder (Python) etc..
Mathtools : octave (matlab), Scilab, geogebra,
Plotting: Gnuplot, Xmgrace, ..
Photo editing gimp , video editing , sound editing ..
Installing applications in Ubuntu: sudo apt-get install APPLICATIONNAME
Bireswar, Shivkumar (IIT Gandhinagar) Lecture 2 Sep 2013 12 / 12
logo
Thousands of Free Applications
Open office or Libre office :Reading all document files ( Word,Excel,Powerpoint equivalent)
Hundreds of editors: Kile (Latex), Spyder (Python) etc..
Mathtools : octave (matlab), Scilab, geogebra,
Plotting: Gnuplot, Xmgrace, ..
Photo editing gimp , video editing , sound editing ..
Installing applications in Ubuntu: sudo apt-get install APPLICATIONNAME
Bireswar, Shivkumar (IIT Gandhinagar) Lecture 2 Sep 2013 12 / 12