advanced shell scripting and computer environment - lecture 4€¦ · scripting and computer...

42
Advanced Shell Advanced shell Scripting and Computer Environment - Lecture 4 Saurabh Barjatiya International Institute Of Information Technology, Hyderabad 28 July, 2011 Saurabh Barjatiya Advanced shell Scripting and Computer Environment - Lecture 4 IIIT Hyderabad

Upload: others

Post on 13-Oct-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Advanced shell Scripting and Computer Environment - Lecture 4€¦ · Scripting and Computer Environment - Lecture 4 Saurabh Barjatiya International Institute Of Information Technology,

Advanced Shell

Advanced shell

Scripting and Computer Environment - Lecture 4

Saurabh Barjatiya

International Institute Of Information Technology, Hyderabad

28 July, 2011

Saurabh Barjatiya Advanced shell Scripting and Computer Environment - Lecture 4 IIIT Hyderabad

Page 2: Advanced shell Scripting and Computer Environment - Lecture 4€¦ · Scripting and Computer Environment - Lecture 4 Saurabh Barjatiya International Institute Of Information Technology,

Advanced ShellWorking remotelyRedirection and ProcessesMiscellaneous

Contents

1 Advanced ShellWorking remotelyRedirection and ProcessesMiscellaneous

Saurabh Barjatiya Advanced shell Scripting and Computer Environment - Lecture 4 IIIT Hyderabad

Page 3: Advanced shell Scripting and Computer Environment - Lecture 4€¦ · Scripting and Computer Environment - Lecture 4 Saurabh Barjatiya International Institute Of Information Technology,

Advanced ShellWorking remotelyRedirection and ProcessesMiscellaneous

Working remotely

ssh

Saurabh Barjatiya Advanced shell Scripting and Computer Environment - Lecture 4 IIIT Hyderabad

Page 4: Advanced shell Scripting and Computer Environment - Lecture 4€¦ · Scripting and Computer Environment - Lecture 4 Saurabh Barjatiya International Institute Of Information Technology,

Advanced ShellWorking remotelyRedirection and ProcessesMiscellaneous

Working remotely

ssh

scp

Saurabh Barjatiya Advanced shell Scripting and Computer Environment - Lecture 4 IIIT Hyderabad

Page 5: Advanced shell Scripting and Computer Environment - Lecture 4€¦ · Scripting and Computer Environment - Lecture 4 Saurabh Barjatiya International Institute Of Information Technology,

Advanced ShellWorking remotelyRedirection and ProcessesMiscellaneous

Working remotely

ssh

scp

rsync

Saurabh Barjatiya Advanced shell Scripting and Computer Environment - Lecture 4 IIIT Hyderabad

Page 6: Advanced shell Scripting and Computer Environment - Lecture 4€¦ · Scripting and Computer Environment - Lecture 4 Saurabh Barjatiya International Institute Of Information Technology,

Advanced ShellWorking remotelyRedirection and ProcessesMiscellaneous

Working remotely

ssh

scp

rsync

passwd

Saurabh Barjatiya Advanced shell Scripting and Computer Environment - Lecture 4 IIIT Hyderabad

Page 7: Advanced shell Scripting and Computer Environment - Lecture 4€¦ · Scripting and Computer Environment - Lecture 4 Saurabh Barjatiya International Institute Of Information Technology,

Advanced ShellWorking remotelyRedirection and ProcessesMiscellaneous

Working remotely

ssh

scp

rsync

passwd

Winscp (Windows based)

Saurabh Barjatiya Advanced shell Scripting and Computer Environment - Lecture 4 IIIT Hyderabad

Page 8: Advanced shell Scripting and Computer Environment - Lecture 4€¦ · Scripting and Computer Environment - Lecture 4 Saurabh Barjatiya International Institute Of Information Technology,

Advanced ShellWorking remotelyRedirection and ProcessesMiscellaneous

Working remotely

ssh

scp

rsync

passwd

Winscp (Windows based)

Putty (Windows based)

Saurabh Barjatiya Advanced shell Scripting and Computer Environment - Lecture 4 IIIT Hyderabad

Page 9: Advanced shell Scripting and Computer Environment - Lecture 4€¦ · Scripting and Computer Environment - Lecture 4 Saurabh Barjatiya International Institute Of Information Technology,

Advanced ShellWorking remotelyRedirection and ProcessesMiscellaneous

Working remotely

ssh

scp

rsync

passwd

Winscp (Windows based)

Putty (Windows based)

SSH Secure Shell client (Windows based)

Saurabh Barjatiya Advanced shell Scripting and Computer Environment - Lecture 4 IIIT Hyderabad

Page 10: Advanced shell Scripting and Computer Environment - Lecture 4€¦ · Scripting and Computer Environment - Lecture 4 Saurabh Barjatiya International Institute Of Information Technology,

Advanced ShellWorking remotelyRedirection and ProcessesMiscellaneous

Working remotely

ssh

scp

rsync

passwd

Winscp (Windows based)

Putty (Windows based)

SSH Secure Shell client (Windows based)

XManager (Windows based)

Saurabh Barjatiya Advanced shell Scripting and Computer Environment - Lecture 4 IIIT Hyderabad

Page 11: Advanced shell Scripting and Computer Environment - Lecture 4€¦ · Scripting and Computer Environment - Lecture 4 Saurabh Barjatiya International Institute Of Information Technology,

Advanced ShellWorking remotelyRedirection and ProcessesMiscellaneous

Redirection

> → Send output to file

Saurabh Barjatiya Advanced shell Scripting and Computer Environment - Lecture 4 IIIT Hyderabad

Page 12: Advanced shell Scripting and Computer Environment - Lecture 4€¦ · Scripting and Computer Environment - Lecture 4 Saurabh Barjatiya International Institute Of Information Technology,

Advanced ShellWorking remotelyRedirection and ProcessesMiscellaneous

Redirection

> → Send output to file

< → Take input from file

Saurabh Barjatiya Advanced shell Scripting and Computer Environment - Lecture 4 IIIT Hyderabad

Page 13: Advanced shell Scripting and Computer Environment - Lecture 4€¦ · Scripting and Computer Environment - Lecture 4 Saurabh Barjatiya International Institute Of Information Technology,

Advanced ShellWorking remotelyRedirection and ProcessesMiscellaneous

Redirection

> → Send output to file

< → Take input from file

2 > → Send error output to file

Saurabh Barjatiya Advanced shell Scripting and Computer Environment - Lecture 4 IIIT Hyderabad

Page 14: Advanced shell Scripting and Computer Environment - Lecture 4€¦ · Scripting and Computer Environment - Lecture 4 Saurabh Barjatiya International Institute Of Information Technology,

Advanced ShellWorking remotelyRedirection and ProcessesMiscellaneous

Redirection

> → Send output to file

< → Take input from file

2 > → Send error output to file

>> → Append output to file

Saurabh Barjatiya Advanced shell Scripting and Computer Environment - Lecture 4 IIIT Hyderabad

Page 15: Advanced shell Scripting and Computer Environment - Lecture 4€¦ · Scripting and Computer Environment - Lecture 4 Saurabh Barjatiya International Institute Of Information Technology,

Advanced ShellWorking remotelyRedirection and ProcessesMiscellaneous

Redirection

> → Send output to file

< → Take input from file

2 > → Send error output to file

>> → Append output to file

| → Send output to program as input

Saurabh Barjatiya Advanced shell Scripting and Computer Environment - Lecture 4 IIIT Hyderabad

Page 16: Advanced shell Scripting and Computer Environment - Lecture 4€¦ · Scripting and Computer Environment - Lecture 4 Saurabh Barjatiya International Institute Of Information Technology,

Advanced ShellWorking remotelyRedirection and ProcessesMiscellaneous

Redirection

> → Send output to file

< → Take input from file

2 > → Send error output to file

>> → Append output to file

| → Send output to program as input

‘ ‘ → Use command output as argument

Saurabh Barjatiya Advanced shell Scripting and Computer Environment - Lecture 4 IIIT Hyderabad

Page 17: Advanced shell Scripting and Computer Environment - Lecture 4€¦ · Scripting and Computer Environment - Lecture 4 Saurabh Barjatiya International Institute Of Information Technology,

Advanced ShellWorking remotelyRedirection and ProcessesMiscellaneous

Redirection

> → Send output to file

< → Take input from file

2 > → Send error output to file

>> → Append output to file

| → Send output to program as input

‘ ‘ → Use command output as argument

tee → Print as well as send to file

Saurabh Barjatiya Advanced shell Scripting and Computer Environment - Lecture 4 IIIT Hyderabad

Page 18: Advanced shell Scripting and Computer Environment - Lecture 4€¦ · Scripting and Computer Environment - Lecture 4 Saurabh Barjatiya International Institute Of Information Technology,

Advanced ShellWorking remotelyRedirection and ProcessesMiscellaneous

Redirection

> → Send output to file

< → Take input from file

2 > → Send error output to file

>> → Append output to file

| → Send output to program as input

‘ ‘ → Use command output as argument

tee → Print as well as send to file

tail − f → Print file contents till Ctrl+C

Saurabh Barjatiya Advanced shell Scripting and Computer Environment - Lecture 4 IIIT Hyderabad

Page 19: Advanced shell Scripting and Computer Environment - Lecture 4€¦ · Scripting and Computer Environment - Lecture 4 Saurabh Barjatiya International Institute Of Information Technology,

Advanced ShellWorking remotelyRedirection and ProcessesMiscellaneous

Processes

Ctrl + Z

Saurabh Barjatiya Advanced shell Scripting and Computer Environment - Lecture 4 IIIT Hyderabad

Page 20: Advanced shell Scripting and Computer Environment - Lecture 4€¦ · Scripting and Computer Environment - Lecture 4 Saurabh Barjatiya International Institute Of Information Technology,

Advanced ShellWorking remotelyRedirection and ProcessesMiscellaneous

Processes

Ctrl + Z

fg

Saurabh Barjatiya Advanced shell Scripting and Computer Environment - Lecture 4 IIIT Hyderabad

Page 21: Advanced shell Scripting and Computer Environment - Lecture 4€¦ · Scripting and Computer Environment - Lecture 4 Saurabh Barjatiya International Institute Of Information Technology,

Advanced ShellWorking remotelyRedirection and ProcessesMiscellaneous

Processes

Ctrl + Z

fg

jobs

Saurabh Barjatiya Advanced shell Scripting and Computer Environment - Lecture 4 IIIT Hyderabad

Page 22: Advanced shell Scripting and Computer Environment - Lecture 4€¦ · Scripting and Computer Environment - Lecture 4 Saurabh Barjatiya International Institute Of Information Technology,

Advanced ShellWorking remotelyRedirection and ProcessesMiscellaneous

Processes

Ctrl + Z

fg

jobs

bg

Saurabh Barjatiya Advanced shell Scripting and Computer Environment - Lecture 4 IIIT Hyderabad

Page 23: Advanced shell Scripting and Computer Environment - Lecture 4€¦ · Scripting and Computer Environment - Lecture 4 Saurabh Barjatiya International Institute Of Information Technology,

Advanced ShellWorking remotelyRedirection and ProcessesMiscellaneous

Processes

Ctrl + Z

fg

jobs

bg

ps

Saurabh Barjatiya Advanced shell Scripting and Computer Environment - Lecture 4 IIIT Hyderabad

Page 24: Advanced shell Scripting and Computer Environment - Lecture 4€¦ · Scripting and Computer Environment - Lecture 4 Saurabh Barjatiya International Institute Of Information Technology,

Advanced ShellWorking remotelyRedirection and ProcessesMiscellaneous

Processes

Ctrl + Z

fg

jobs

bg

ps

&

Saurabh Barjatiya Advanced shell Scripting and Computer Environment - Lecture 4 IIIT Hyderabad

Page 25: Advanced shell Scripting and Computer Environment - Lecture 4€¦ · Scripting and Computer Environment - Lecture 4 Saurabh Barjatiya International Institute Of Information Technology,

Advanced ShellWorking remotelyRedirection and ProcessesMiscellaneous

Processes

Ctrl + Z

fg

jobs

bg

ps

&

;

Saurabh Barjatiya Advanced shell Scripting and Computer Environment - Lecture 4 IIIT Hyderabad

Page 26: Advanced shell Scripting and Computer Environment - Lecture 4€¦ · Scripting and Computer Environment - Lecture 4 Saurabh Barjatiya International Institute Of Information Technology,

Advanced ShellWorking remotelyRedirection and ProcessesMiscellaneous

Processes

Ctrl + Z

fg

jobs

bg

ps

&

;

Ctrl + C

Saurabh Barjatiya Advanced shell Scripting and Computer Environment - Lecture 4 IIIT Hyderabad

Page 27: Advanced shell Scripting and Computer Environment - Lecture 4€¦ · Scripting and Computer Environment - Lecture 4 Saurabh Barjatiya International Institute Of Information Technology,

Advanced ShellWorking remotelyRedirection and ProcessesMiscellaneous

Processes

Ctrl + Z

fg

jobs

bg

ps

&

;

Ctrl + C

kill

Saurabh Barjatiya Advanced shell Scripting and Computer Environment - Lecture 4 IIIT Hyderabad

Page 28: Advanced shell Scripting and Computer Environment - Lecture 4€¦ · Scripting and Computer Environment - Lecture 4 Saurabh Barjatiya International Institute Of Information Technology,

Advanced ShellWorking remotelyRedirection and ProcessesMiscellaneous

Processes

Ctrl + Z

fg

jobs

bg

ps

&

;

Ctrl + C

kill

killall

Saurabh Barjatiya Advanced shell Scripting and Computer Environment - Lecture 4 IIIT Hyderabad

Page 29: Advanced shell Scripting and Computer Environment - Lecture 4€¦ · Scripting and Computer Environment - Lecture 4 Saurabh Barjatiya International Institute Of Information Technology,

Advanced ShellWorking remotelyRedirection and ProcessesMiscellaneous

Command line features

Shell wildcards ‘*’, ‘?’ and ‘[ ]’

Saurabh Barjatiya Advanced shell Scripting and Computer Environment - Lecture 4 IIIT Hyderabad

Page 30: Advanced shell Scripting and Computer Environment - Lecture 4€¦ · Scripting and Computer Environment - Lecture 4 Saurabh Barjatiya International Institute Of Information Technology,

Advanced ShellWorking remotelyRedirection and ProcessesMiscellaneous

Command line features

Shell wildcards ‘*’, ‘?’ and ‘[ ]’

!<command> → Run last command with same program name

Saurabh Barjatiya Advanced shell Scripting and Computer Environment - Lecture 4 IIIT Hyderabad

Page 31: Advanced shell Scripting and Computer Environment - Lecture 4€¦ · Scripting and Computer Environment - Lecture 4 Saurabh Barjatiya International Institute Of Information Technology,

Advanced ShellWorking remotelyRedirection and ProcessesMiscellaneous

Command line features

Shell wildcards ‘*’, ‘?’ and ‘[ ]’

!<command> → Run last command with same program name

echo $? → Return value of last command

Saurabh Barjatiya Advanced shell Scripting and Computer Environment - Lecture 4 IIIT Hyderabad

Page 32: Advanced shell Scripting and Computer Environment - Lecture 4€¦ · Scripting and Computer Environment - Lecture 4 Saurabh Barjatiya International Institute Of Information Technology,

Advanced ShellWorking remotelyRedirection and ProcessesMiscellaneous

Command line features

Shell wildcards ‘*’, ‘?’ and ‘[ ]’

!<command> → Run last command with same program name

echo $? → Return value of last command

Ctrl + R → Reverse incremental search

Saurabh Barjatiya Advanced shell Scripting and Computer Environment - Lecture 4 IIIT Hyderabad

Page 33: Advanced shell Scripting and Computer Environment - Lecture 4€¦ · Scripting and Computer Environment - Lecture 4 Saurabh Barjatiya International Institute Of Information Technology,

Advanced ShellWorking remotelyRedirection and ProcessesMiscellaneous

Command line features

Shell wildcards ‘*’, ‘?’ and ‘[ ]’

!<command> → Run last command with same program name

echo $? → Return value of last command

Ctrl + R → Reverse incremental search

history

Saurabh Barjatiya Advanced shell Scripting and Computer Environment - Lecture 4 IIIT Hyderabad

Page 34: Advanced shell Scripting and Computer Environment - Lecture 4€¦ · Scripting and Computer Environment - Lecture 4 Saurabh Barjatiya International Institute Of Information Technology,

Advanced ShellWorking remotelyRedirection and ProcessesMiscellaneous

Environment variables

set

Saurabh Barjatiya Advanced shell Scripting and Computer Environment - Lecture 4 IIIT Hyderabad

Page 35: Advanced shell Scripting and Computer Environment - Lecture 4€¦ · Scripting and Computer Environment - Lecture 4 Saurabh Barjatiya International Institute Of Information Technology,

Advanced ShellWorking remotelyRedirection and ProcessesMiscellaneous

Environment variables

set

export

Saurabh Barjatiya Advanced shell Scripting and Computer Environment - Lecture 4 IIIT Hyderabad

Page 36: Advanced shell Scripting and Computer Environment - Lecture 4€¦ · Scripting and Computer Environment - Lecture 4 Saurabh Barjatiya International Institute Of Information Technology,

Advanced ShellWorking remotelyRedirection and ProcessesMiscellaneous

Environment variables

set

export

echo

Saurabh Barjatiya Advanced shell Scripting and Computer Environment - Lecture 4 IIIT Hyderabad

Page 37: Advanced shell Scripting and Computer Environment - Lecture 4€¦ · Scripting and Computer Environment - Lecture 4 Saurabh Barjatiya International Institute Of Information Technology,

Advanced ShellWorking remotelyRedirection and ProcessesMiscellaneous

Environment variables

set

export

echo

alias

Saurabh Barjatiya Advanced shell Scripting and Computer Environment - Lecture 4 IIIT Hyderabad

Page 38: Advanced shell Scripting and Computer Environment - Lecture 4€¦ · Scripting and Computer Environment - Lecture 4 Saurabh Barjatiya International Institute Of Information Technology,

Advanced ShellWorking remotelyRedirection and ProcessesMiscellaneous

Environment variables

set

export

echo

alias

unalias

Saurabh Barjatiya Advanced shell Scripting and Computer Environment - Lecture 4 IIIT Hyderabad

Page 39: Advanced shell Scripting and Computer Environment - Lecture 4€¦ · Scripting and Computer Environment - Lecture 4 Saurabh Barjatiya International Institute Of Information Technology,

Advanced ShellWorking remotelyRedirection and ProcessesMiscellaneous

Environment variables

set

export

echo

alias

unalias

Important variables

PATH

Saurabh Barjatiya Advanced shell Scripting and Computer Environment - Lecture 4 IIIT Hyderabad

Page 40: Advanced shell Scripting and Computer Environment - Lecture 4€¦ · Scripting and Computer Environment - Lecture 4 Saurabh Barjatiya International Institute Of Information Technology,

Advanced ShellWorking remotelyRedirection and ProcessesMiscellaneous

Environment variables

set

export

echo

alias

unalias

Important variables

PATH

PWD

Saurabh Barjatiya Advanced shell Scripting and Computer Environment - Lecture 4 IIIT Hyderabad

Page 41: Advanced shell Scripting and Computer Environment - Lecture 4€¦ · Scripting and Computer Environment - Lecture 4 Saurabh Barjatiya International Institute Of Information Technology,

Advanced ShellWorking remotelyRedirection and ProcessesMiscellaneous

Environment variables

set

export

echo

alias

unalias

Important variables

PATH

PWD

HISTTIMEFORMAT=’%y %m %d %T ’

Saurabh Barjatiya Advanced shell Scripting and Computer Environment - Lecture 4 IIIT Hyderabad

Page 42: Advanced shell Scripting and Computer Environment - Lecture 4€¦ · Scripting and Computer Environment - Lecture 4 Saurabh Barjatiya International Institute Of Information Technology,

Advanced ShellWorking remotelyRedirection and ProcessesMiscellaneous

Environment variables

set

export

echo

alias

unalias

Important variables

PATH

PWD

HISTTIMEFORMAT=’%y %m %d %T ’

PS1

Saurabh Barjatiya Advanced shell Scripting and Computer Environment - Lecture 4 IIIT Hyderabad