Professional Documents
Culture Documents
04 - Shell Commands1
04 - Shell Commands1
© Samantha Indika
• With in GUI : Gnome : Open a terminal
: KDE : Open a konsole
Application > Accessories > Terminal
Right-Click on Desktop > Open Terminal
• Without GUI
: minimize GUI shell
Ctrl + ALT + F1
: maximize GUI shell
Ctrl + ALT + F7
• What is command?
Command is executable file : GUI & TUI
Application > Accessories > Calculator
Help > About
Prepared by : Samantha Indika | MCT, ACS, CEH, CCNA, BCS
(Certificate), MCS (SL), MCITP, MCTS, MCSE + Security + Messaging,
MCSA + Security + Messaging, MCP 1
Cont.. Shell Commands
Application > Accessories > Text Editor
Help > About
© Samantha Indika
[user1@srv2~]$gcalctool
[user1@srv2~]$gedit
[user1@srv2~]$gcalctool Copy (R.C > Copy) & Paste (R.C. > Paste / Shift + Ins)
[user1@srv2~]$cal Calendar / Output is text
[user1@srv2~]$date
[user1@srv2~]$clear or Ctrl + L
© Samantha Indika
OS related OS related
commands commands
[/bin] [/sbin]
System
System
[/usr]
Common Admin
Linux Connectors
User
Commands [/bin] [/sbin]
Software Software
© Samantha Indika
• Create Folder name : .123
• Print working directory
[user1@srv2 ~]$pwd
/home/user1 Root
[Home]
[user1]
/home/user1
© Samantha Indika
Current
User
Logged Current
in Folder
Computer
Name
• List the content in the folder
[user1@srv2 ~]$ls
• All objects (hidden file/folder also)
[user1@srv2 ~]$ls Δ -a
• Manual of a command
[user1@srv2~]$man command
Browse : Up arrow, Down arrow, Left arrow, Right arrow
Quit :q
Julian Calendar
[user1@srv2~]$cal Δ -3 1…..7
[user1@srv2~]$cal Δ –y 8……15
16…..23
Prepared by : Samantha Indika | MCT, ACS, CEH, CCNA, BCS
(Certificate), MCS (SL), MCITP, MCTS, MCSE + Security + Messaging,
MCSA + Security + Messaging, MCP 5
Cont.. Shell Commands
• Go to “home” folder /
[test1] [test2]
© Samantha Indika
[test3]
[test4]
[test5]
[user1@srv2 ~]$tree
[user1@srv2 ~]$tree Δ –C : To view with colors
[user1@srv2 ~]$tree Δ –a : All objects
[user1@srv2 ~]$tree Δ –C Δ –a or tree Δ –a Δ –C
OR
[user1@srv2 ~]$tree Δ –Ca
[user1@srv2 ~]$tree Δ –d : directories only
• Create 2 files in home folder using GUI. Eg : file1 & file2
[user1@srv2 ~]$tree
[user1@srv2 ~]$tree Δ –C
Prepared by : Samantha Indika | MCT, ACS, CEH, CCNA, BCS
(Certificate), MCS (SL), MCITP, MCTS, MCSE + Security + Messaging,
MCSA + Security + Messaging, MCP 6
Cont.. Shell Commands
[user1@srv2 ~]$tree Δ –Cd
[user1@srv2 ~]$tree Δ -adC
© Samantha Indika
• To see a large output in part by part
Pipe Pager
mark
#ls Δ –l
© Samantha Indika
#ls Δ –lh
#ls Δ –alh
© Samantha Indika
1 / home / user1 / test2 / test3
[/home]
© Samantha Indika
• To go to your home folder
$cd
$pwd
$cd Δ test2/test3 << Relative path
$cd
$cd Δ test2/test4/test5
$ls Δ -a
$cd . .
$pwd
© Samantha Indika
• Go to root partition Symlink (Shortcut) - Light Blue
Executable files with Root Permission
- Red
$cd Δ / File - Black
$pwd Folder - Blue
$ls
$cd Δ /bin
$cd Δ /usr/share/backgrounds
$pwd
$cd Δ images
$pwd
$cd Δ . .
$pwd
$cd
$cd Δ -
© Samantha Indika
$pwd
• Go to Root
$cd Δ /
$pwd
$ls
$mkdir Δ fol1
© Samantha Indika
$ls
$mkdir Δ fol2 Δ fol3 Δ fol4 Δ fol5
$ls
$ls Δ test1
© Samantha Indika
$mkdir Δ redhat $mkdir –p Δ redhat/linux
$mkdir Δ redhat/centos $ls
$ls Δ redhat
$mkdir Δ “my Δ data Δ 2” Prepared by : Samantha Indika | MCT, ACS, CEH, CCNA, BCS
(Certificate), MCS (SL), MCITP, MCTS, MCSE + Security + Messaging,
OR MCSA + Security + Messaging, MCP 14
$mkdir Δ my \ data \ 2
Cont.. Shell Commands
• Create a folder call (“my Δ data Δ 2”)
• Ex: 2
© Samantha Indika
$mkdir Δ “my Δ data Δ 2”
OR
$mkdir Δ my \ data \ 2
$ls
$ls Δ – l (L)
$ls Δ – 1 (1/One)
• New file
Use a text editor to Create / Edit / Read files
$nano Δ file1
CENTOS
$nano Δ fol2/file1
© Samantha Indika
CENTOS
Ctrl + O
Press ENTER Key
Ctrl + X
$ls Δ fol2
$cat Δ fol2/file1
• New Symlinks
Create a new symlink in your home folder to
access /usr/share/backgrounds/images folder
$cd
Prepared by : Samantha Indika | MCT, ACS, CEH, CCNA, BCS
(Certificate), MCS (SL), MCITP, MCTS, MCSE + Security + Messaging,
MCSA + Security + Messaging, MCP 16
Cont.. Shell Commands
$ln Δ –s Δ /usr/share/backgrounds/images Δ link1
© Samantha Indika
Name
(Any Name)
$ls Δ -l
$cd Δ link1
$pwd
$pwd Δ -P
$cd
$ln Δ –s Δ /etc/fstab Δ link3
$ls Δ -l
Destination File Symlink
Location NamePrepared by : Samantha Indika | MCT, ACS, CEH, CCNA, BCS
(Certificate), MCS (SL), MCITP, MCTS, MCSE + Security + Messaging,
MCSA + Security + Messaging, MCP 17
Cont.. Shell Commands
$ln Δ –s Δ /etc/fstab Δ /tmp/link3
$ls Δ /tmp
$cat Δ /tmp/link3
© Samantha Indika
• Use the link to access the file
© Samantha Indika
$ls
$mv Δ CurrentObjectName Δ NewObjectName
© Samantha Indika
$mv Δ file1 Δ folder1 /
$ls Δ folder1
[/home] [/tmp]
Move Link1 in to Folder1
$mv Δ link1 Δ folder1
[/user1] file2
$ls Δ folder1
© Samantha Indika
$cp Δ file1 Δ folder1
$ls
$ls Δ folder1
© Samantha Indika
$rm Δ link1
$rm Δ file1 ? Y/N
$ls
-r = recursive