Bash in theory and in practice - part one
-
Upload
pvb265 -
Category
Technology
-
view
279 -
download
0
description
Transcript of Bash in theory and in practice - part one
![Page 1: Bash in theory and in practice - part one](https://reader033.fdocuments.net/reader033/viewer/2022052822/554f54c3b4c905b9508b4fd6/html5/thumbnails/1.jpg)
bashin theory and in practice
19.06.201303.07.2013 @pvb265 #imolug
![Page 2: Bash in theory and in practice - part one](https://reader033.fdocuments.net/reader033/viewer/2022052822/554f54c3b4c905b9508b4fd6/html5/thumbnails/2.jpg)
AgendaGeneral InfoUnderwaterOverviewSyntaxExamples
19.06.201303.07.2013 @pvb265 #imolug
![Page 3: Bash in theory and in practice - part one](https://reader033.fdocuments.net/reader033/viewer/2022052822/554f54c3b4c905b9508b4fd6/html5/thumbnails/3.jpg)
AgendaGeneral InfoUnderwaterOverviewSyntaxExamples
19.06.201303.07.2013 @pvb265 #imolug
19.06
03.07
![Page 4: Bash in theory and in practice - part one](https://reader033.fdocuments.net/reader033/viewer/2022052822/554f54c3b4c905b9508b4fd6/html5/thumbnails/4.jpg)
AgendaGeneral InfoUnderwaterOverviewSyntaxExamples
19.06.201303.07.2013 @pvb265 #imolug
19.06
03.07
![Page 5: Bash in theory and in practice - part one](https://reader033.fdocuments.net/reader033/viewer/2022052822/554f54c3b4c905b9508b4fd6/html5/thumbnails/5.jpg)
bashbourne again shellGNU projecttextual shell
19.06.201303.07.2013 @pvb265 #imolug
![Page 6: Bash in theory and in practice - part one](https://reader033.fdocuments.net/reader033/viewer/2022052822/554f54c3b4c905b9508b4fd6/html5/thumbnails/6.jpg)
interface of an O. S.to access Kernel services
19.06.201303.07.2013 @pvb265 #imolug
shellbash
![Page 7: Bash in theory and in practice - part one](https://reader033.fdocuments.net/reader033/viewer/2022052822/554f54c3b4c905b9508b4fd6/html5/thumbnails/7.jpg)
. resources control
. process execution
19.06.201303.07.2013 @pvb265 #imolug
o.s.shellbash
![Page 8: Bash in theory and in practice - part one](https://reader033.fdocuments.net/reader033/viewer/2022052822/554f54c3b4c905b9508b4fd6/html5/thumbnails/8.jpg)
. process manager
. memory manager
. scheduler/event manager
. file manager
19.06.201303.07.2013 @pvb265 #imolug
o.s.shellbash
![Page 9: Bash in theory and in practice - part one](https://reader033.fdocuments.net/reader033/viewer/2022052822/554f54c3b4c905b9508b4fd6/html5/thumbnails/9.jpg)
. process wrapper
. scheduler controll
19.06.201303.07.2013 @pvb265 #imolug
kernelo.s.shellbash
![Page 10: Bash in theory and in practice - part one](https://reader033.fdocuments.net/reader033/viewer/2022052822/554f54c3b4c905b9508b4fd6/html5/thumbnails/10.jpg)
19.06.201303.07.2013 @pvb265 #imolug
kernelo.s.
shellbash
![Page 11: Bash in theory and in practice - part one](https://reader033.fdocuments.net/reader033/viewer/2022052822/554f54c3b4c905b9508b4fd6/html5/thumbnails/11.jpg)
19.06.201303.07.2013 @pvb265 #imolug
kernelo.s.
shellbash
Desktop PC, Parallel Systems, Distribuited Systems, Clustered Systems, Real-time Systems, Embedded Systems
![Page 12: Bash in theory and in practice - part one](https://reader033.fdocuments.net/reader033/viewer/2022052822/554f54c3b4c905b9508b4fd6/html5/thumbnails/12.jpg)
19.06.201303.07.2013 @pvb265 #imolug
kernelo.s.
shellbash
Desktop PC, Parallel Systems, Distribuited Systems, Clustered Systems, Real-time Systems, Embedded Systems
Monolithic, MicroKernel, Hybryd kernel, exoKernel
![Page 13: Bash in theory and in practice - part one](https://reader033.fdocuments.net/reader033/viewer/2022052822/554f54c3b4c905b9508b4fd6/html5/thumbnails/13.jpg)
19.06.201303.07.2013 @pvb265 #imolug
kernelo.s.
shellbash
Desktop PC, Parallel Systems, Distribuited Systems, Clustered Systems, Real-time Systems, Embedded Systems
Monolithic, MicroKernel, noKernel, Hybryd kernel, exoKernel
![Page 14: Bash in theory and in practice - part one](https://reader033.fdocuments.net/reader033/viewer/2022052822/554f54c3b4c905b9508b4fd6/html5/thumbnails/14.jpg)
19.06.201303.07.2013 @pvb265 #imolug
kernelo.s.
shellbash
Desktop PC, Parallel Systems, Distribuited Systems, Clustered Systems, Real-time Systems, Embedded Systems
Monolithic, MicroKernel, Hybrid kernel, exoKernel
textual, GUI
![Page 15: Bash in theory and in practice - part one](https://reader033.fdocuments.net/reader033/viewer/2022052822/554f54c3b4c905b9508b4fd6/html5/thumbnails/15.jpg)
19.06.201303.07.2013 @pvb265 #imolug
kernelo.s.
shellbash
Desktop PC, Parallel Systems, Distribuited Systems, Clustered Systems, Real-time Systems, Embedded Systems
Monolithic, MicroKernel, Hybrid kernel, exoKernel
textual, GUI
sh, csh, ksh, bash, tcsh, zsh
![Page 16: Bash in theory and in practice - part one](https://reader033.fdocuments.net/reader033/viewer/2022052822/554f54c3b4c905b9508b4fd6/html5/thumbnails/16.jpg)
19.06.201303.07.2013 @pvb265 #imolug
shell 1970: runcom (Multics) JCL (s/390)
1975-1978: Steve Bourne, at Bell Labs wrote sh1978-1979: Bill Joy at BSD wrote csh
1981: tcsh is a fork of csh POSIX compliance1983: David Korn wrote ksh
1989: Brian Fox wrote bash1990: Paul Falstad wrote zsh1997: bash 2.02004: bash 3.02011: bash 4.2 latest (now) stable
![Page 17: Bash in theory and in practice - part one](https://reader033.fdocuments.net/reader033/viewer/2022052822/554f54c3b4c905b9508b4fd6/html5/thumbnails/17.jpg)
19.06.201303.07.2013 @pvb265 #imolug
bash
UnderWater
![Page 18: Bash in theory and in practice - part one](https://reader033.fdocuments.net/reader033/viewer/2022052822/554f54c3b4c905b9508b4fd6/html5/thumbnails/18.jpg)
19.06.201303.07.2013 @pvb265 #imolug
bash Pick-Up a Mac OS X Box
UnderWaterTerminal Processbash-3.2$ ps -ef|grep Terminalps -ef|grep Terminal 501 1636 211 0 1:55pm ?? 0:04.57 /Applications/Utilities/Terminal.app/Contents/MacOS/Terminal -psn_0_667811
![Page 19: Bash in theory and in practice - part one](https://reader033.fdocuments.net/reader033/viewer/2022052822/554f54c3b4c905b9508b4fd6/html5/thumbnails/19.jpg)
19.06.201303.07.2013 @pvb265 #imolug
bash Pick-Up a Mac OS X Box
UnderWaterTerminal Processbash-3.2$ ps -ef|grep Terminalps -ef|grep Terminal 501 1636 211 0 1:55pm ?? 0:04.57 /Applications/Utilities/Terminal.app/Contents/MacOS/Terminal -psn_0_667811
bash-3.2$ ps -ef| grep 1636ps -ef| grep 1636 501 1636 211 0 1:55pm ?? 0:05.87 /Applications/Utilities/Terminal.app/Contents/MacOS/Terminal -psn_0_667811 0 1638 1636 0 1:55pm ttys000 0:00.03 login -pfql valeriobalbi /bin/bash -c exec -la bash /bin/bash
Login Process
![Page 20: Bash in theory and in practice - part one](https://reader033.fdocuments.net/reader033/viewer/2022052822/554f54c3b4c905b9508b4fd6/html5/thumbnails/20.jpg)
19.06.201303.07.2013 @pvb265 #imolug
bash Pick-Up a Mac OS X Box
UnderWaterTerminal Processbash-3.2$ ps -ef|grep Terminalps -ef|grep Terminal 501 1636 211 0 1:55pm ?? 0:04.57 /Applications/Utilities/Terminal.app/Contents/MacOS/Terminal -psn_0_667811
bash-3.2$ ps -ef| grep 1636ps -ef| grep 1636 501 1636 211 0 1:55pm ?? 0:05.87 /Applications/Utilities/Terminal.app/Contents/MacOS/Terminal -psn_0_667811 0 1638 1636 0 1:55pm ttys000 0:00.03 login -pfql valeriobalbi /bin/bash -c exec -la bash /bin/bash
bash-3.2$ ps -ef| grep 1638ps -ef| grep 1638 0 1638 1636 0 1:55pm ttys000 0:00.03 login -pfql valeriobalbi /bin/bash -c exec -la bash /bin/bash 501 1639 1638 0 1:55pm ttys000 0:00.11 -bash
Login Process
Shell Invocation
![Page 21: Bash in theory and in practice - part one](https://reader033.fdocuments.net/reader033/viewer/2022052822/554f54c3b4c905b9508b4fd6/html5/thumbnails/21.jpg)
19.06.201303.07.2013 @pvb265 #imolug
bash Pick-Up a Linux Box
UnderWater
[root@www ~]# ps -ef|grep sshdroot 3065 1 0 Feb05 ? 00:01:54 /usr/sbin/sshdroot 10442 3065 0 17:15 ? 00:00:00 sshd: root@pts/0
[root@www ~]# ps -ef| grep 10442root 10442 3065 0 17:15 ? 00:00:00 sshd: root@pts/0 root 10464 10442 0 17:15 pts/0 00:00:00 -bash
SSH Process and Login
Shell Invocation
![Page 22: Bash in theory and in practice - part one](https://reader033.fdocuments.net/reader033/viewer/2022052822/554f54c3b4c905b9508b4fd6/html5/thumbnails/22.jpg)
19.06.201303.07.2013 @pvb265 #imolug
bash Who said system to invoke bash
UnderWater
[root@www ~]# cat /etc/passwd|head -5root:x:0:0:root:/root:/bin/bashbin:x:1:1:bin:/bin:/sbin/nologindaemon:x:2:2:daemon:/sbin:/sbin/nologinadm:x:3:4:adm:/var/adm:/sbin/nologinlp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
Linux Users Definitions
![Page 23: Bash in theory and in practice - part one](https://reader033.fdocuments.net/reader033/viewer/2022052822/554f54c3b4c905b9508b4fd6/html5/thumbnails/23.jpg)
19.06.201303.07.2013 @pvb265 #imolug
bash Who said system to invoke bash
UnderWater
[root@www ~]# cat /etc/passwd|head -5root :x :0 :0 :root :/root :/bin/bashbin :x :1 :1 :bin :/bin :/sbin/nologindaemon :x :2 :2 :daemon :/sbin :/sbin/nologinadm :x :3 :4 :adm :/var/adm :/sbin/nologinlp :x :4 :7 :lp :/var/spool/lpd :/sbin/nologin
Username Password UID GID Description Home Initialprogram
Linux Users Definitions
![Page 24: Bash in theory and in practice - part one](https://reader033.fdocuments.net/reader033/viewer/2022052822/554f54c3b4c905b9508b4fd6/html5/thumbnails/24.jpg)
19.06.201303.07.2013 @pvb265 #imolug
bash Who said system to invoke bash
UnderWater
[root@www ~]# cat /etc/passwd|head -5root :x :0 :0 :root :/root :/bin/bashbin :x :1 :1 :bin :/bin :/sbin/nologindaemon :x :2 :2 :daemon :/sbin :/sbin/nologinadm :x :3 :4 :adm :/var/adm :/sbin/nologinlp :x :4 :7 :lp :/var/spool/lpd :/sbin/nologin
Username Password UID GID Description Home Initialprogram
[root@www ~]# grep root /etc/shadowRoot: $1$LDqgrtQA$IXip/e.HuPhjSjLWXmrdj0 :15561 :0:99999:7:::
Username Password Lastchanged PasswordAging
Linux Users Definitions
![Page 25: Bash in theory and in practice - part one](https://reader033.fdocuments.net/reader033/viewer/2022052822/554f54c3b4c905b9508b4fd6/html5/thumbnails/25.jpg)
19.06.201303.07.2013 @pvb265 #imolug
bash Who said system to invoke bash
UnderWater
[root@www ~]# cat /etc/passwd|head -5root :x :0 :0 :root :/root :/bin/bashbin :x :1 :1 :bin :/bin :/sbin/nologindaemon :x :2 :2 :daemon :/sbin :/sbin/nologinadm :x :3 :4 :adm :/var/adm :/sbin/nologinlp :x :4 :7 :lp :/var/spool/lpd :/sbin/nologin
Username Password UID GID Description Home Initialprogram
[root@www ~]# grep root /etc/shadowRoot: $1$LDqgrtQA$IXip/e.HuPhjSjLWXmrdj0 :15561 :0:99999:7:::
Username Password Lastchanged PasswordAging
[root@www ~]# cat /etc/passwd|head -1root:$1$LDqgrtQA$IXip/e.HuPhjSjLWXmrdj0:0:0:root:/root:/bin/bash
Linux Users Definitions
![Page 26: Bash in theory and in practice - part one](https://reader033.fdocuments.net/reader033/viewer/2022052822/554f54c3b4c905b9508b4fd6/html5/thumbnails/26.jpg)
19.06.201303.07.2013 @pvb265 #imolug
bash Who said system to invoke bash
UnderWater
[root@www ~]# cat /etc/passwd|head -5root :x :0 :0 :root :/root :/bin/bashbin :x :1 :1 :bin :/bin :/sbin/nologindaemon :x :2 :2 :daemon :/sbin :/sbin/nologinadm :x :3 :4 :adm :/var/adm :/sbin/nologinlp :x :4 :7 :lp :/var/spool/lpd :/sbin/nologin
Username Password UID GID Description Home Initialprogram
[root@www ~]# grep root /etc/shadowRoot: $1$LDqgrtQA$IXip/e.HuPhjSjLWXmrdj0 :15561 :0:99999:7:::
Username Password Lastchanged PasswordAging
[root@www ~]# cat /etc/passwd|head -1root::0:0:root:/root:/bin/bash
Linux Users Definitions
![Page 27: Bash in theory and in practice - part one](https://reader033.fdocuments.net/reader033/viewer/2022052822/554f54c3b4c905b9508b4fd6/html5/thumbnails/27.jpg)
19.06.201303.07.2013 @pvb265 #imolug
bash Who said system to invoke bash
UnderWater
[root@www ~]# cat /etc/passwd|head -5root :x :0 :0 :root :/root :/bin/bashbin :x :1 :1 :bin :/bin :/sbin/nologindaemon :x :2 :2 :daemon :/sbin :/sbin/nologinadm :x :3 :4 :adm :/var/adm :/sbin/nologinlp :x :4 :7 :lp :/var/spool/lpd :/sbin/nologin
Username Password UID GID Description Home Initialprogram
Linux Users Definitions
![Page 28: Bash in theory and in practice - part one](https://reader033.fdocuments.net/reader033/viewer/2022052822/554f54c3b4c905b9508b4fd6/html5/thumbnails/28.jpg)
19.06.201303.07.2013 @pvb265 #imolug
bash Who said system to invoke bash
UnderWater
[root@www ~]# cat /etc/passwd|head -5root :x :0 :0 :root :/root :/bin/bashbin :x :1 :1 :bin :/bin :/sbin/nologindaemon :x :2 :2 :daemon :/sbin :/sbin/nologinadm :x :3 :4 :adm :/var/adm :/sbin/nologinlp :x :4 :7 :lp :/var/spool/lpd :/sbin/nologin
Username Password UID GID Description Home Initialprogram
[root@www ~]# ls -l /etc/shells-rw-r--r-- 1 root root 60 15 feb 2012 /etc/shells
Linux Users Definitions
![Page 29: Bash in theory and in practice - part one](https://reader033.fdocuments.net/reader033/viewer/2022052822/554f54c3b4c905b9508b4fd6/html5/thumbnails/29.jpg)
19.06.201303.07.2013 @pvb265 #imolug
bash Who said system to invoke bash
UnderWater
[root@www ~]# cat /etc/passwd|head -5root :x :0 :0 :root :/root :/bin/bashbin :x :1 :1 :bin :/bin :/sbin/nologindaemon :x :2 :2 :daemon :/sbin :/sbin/nologinadm :x :3 :4 :adm :/var/adm :/sbin/nologinlp :x :4 :7 :lp :/var/spool/lpd :/sbin/nologin
Username Password UID GID Description Home Initialprogram
[root@www ~]# ls -l /etc/shells-rw-r--r-- 1 root root 60 15 feb 2012 /etc/shells
[root@www ~]# cat /etc/shells/bin/sh/bin/bash/sbin/nologin/bin/tcsh/bin/csh/bin/ksh
Linux Users Definitions
![Page 30: Bash in theory and in practice - part one](https://reader033.fdocuments.net/reader033/viewer/2022052822/554f54c3b4c905b9508b4fd6/html5/thumbnails/30.jpg)
19.06.201303.07.2013 @pvb265 #imolug
bash the way to suit your bash
UnderWater
[root@www ~]# ls -l /etc/profile-rw-r--r-- 1 root root 1029 21 set 2009 /etc/profile[root@www ~]# ls -l /root/.bash_profile-rw-r--r-- 1 root root 191 6 gen 2007 /root/.bash_profile
what after login?
![Page 31: Bash in theory and in practice - part one](https://reader033.fdocuments.net/reader033/viewer/2022052822/554f54c3b4c905b9508b4fd6/html5/thumbnails/31.jpg)
19.06.201303.07.2013 @pvb265 #imolug
bash the way to suit your bash
UnderWater
[root@www ~]# ls -l /etc/profile-rw-r--r-- 1 root root 1029 21 set 2009 /etc/profile[root@www ~]# ls -l /root/.bash_profile-rw-r--r-- 1 root root 191 6 gen 2007 /root/.bash_profile
[root@www ~]# ls -l /etc/profile.d/totale 104-rwxr-xr-x 1 root root 766 21 lug 2011 colorls.csh-rwxr-xr-x 1 root root 727 21 lug 2011 colorls.sh-rwxr-xr-x 1 root root 3015 19 ago 2011 lang.csh-rwxr-xr-x 1 root root 3466 19 ago 2011 lang.sh…
what after login?
![Page 32: Bash in theory and in practice - part one](https://reader033.fdocuments.net/reader033/viewer/2022052822/554f54c3b4c905b9508b4fd6/html5/thumbnails/32.jpg)
19.06.201303.07.2013 @pvb265 #imolug
bash the way to suit your bash
UnderWater
[root@www ~]# ls -l /etc/profile-rw-r--r-- 1 root root 1029 21 set 2009 /etc/profile[root@www ~]# ls -l /root/.bash_profile-rw-r--r-- 1 root root 191 6 gen 2007 /root/.bash_profile
[root@www ~]# ls -l /etc/profile.d/totale 104-rwxr-xr-x 1 root root 766 21 lug 2011 colorls.csh-rwxr-xr-x 1 root root 727 21 lug 2011 colorls.sh-rwxr-xr-x 1 root root 3015 19 ago 2011 lang.csh-rwxr-xr-x 1 root root 3466 19 ago 2011 lang.sh…
[root@www ~]# ls -l /root/.bashrc-rw-r--r-- 1 root root 176 6 gen 2007 /root/.bashrc
[root@www ~]# ls -l /etc/bashrc-rw-r--r-- 1 root root 1708 21 set 2009 /etc/bashrc
what after login?
![Page 33: Bash in theory and in practice - part one](https://reader033.fdocuments.net/reader033/viewer/2022052822/554f54c3b4c905b9508b4fd6/html5/thumbnails/33.jpg)
19.06.201303.07.2013 @pvb265 #imolug
bash the way to suit your bash
UnderWater
[root@www ~]# ls -l /etc/profile-rw-r--r-- 1 root root 1029 21 set 2009 /etc/profile[root@www ~]# ls -l /root/.bash_profile-rw-r--r-- 1 root root 191 6 gen 2007 /root/.bash_profile
[root@www ~]# ls -l /etc/profile.d/totale 104-rwxr-xr-x 1 root root 766 21 lug 2011 colorls.csh-rwxr-xr-x 1 root root 727 21 lug 2011 colorls.sh-rwxr-xr-x 1 root root 3015 19 ago 2011 lang.csh-rwxr-xr-x 1 root root 3466 19 ago 2011 lang.sh…
[root@www ~]# ls -l /root/.bashrc-rw-r--r-- 1 root root 176 6 gen 2007 /root/.bashrc
[root@www ~]# ls -l /etc/bashrc-rw-r--r-- 1 root root 1708 21 set 2009 /etc/bashrc
what after login?1
2
4
3
5
![Page 34: Bash in theory and in practice - part one](https://reader033.fdocuments.net/reader033/viewer/2022052822/554f54c3b4c905b9508b4fd6/html5/thumbnails/34.jpg)
19.06.201303.07.2013 @pvb265 #imolug
bash the way to suit your bash
UnderWater
[root@www ~]# ls -l /etc/profile-rw-r--r-- 1 root root 1029 21 set 2009 /etc/profile[root@www ~]# ls -l /root/.bash_profile-rw-r--r-- 1 root root 191 6 gen 2007 /root/.bash_profile
[root@www ~]# ls -l /etc/profile.d/totale 104-rwxr-xr-x 1 root root 766 21 lug 2011 colorls.csh-rwxr-xr-x 1 root root 727 21 lug 2011 colorls.sh-rwxr-xr-x 1 root root 3015 19 ago 2011 lang.csh-rwxr-xr-x 1 root root 3466 19 ago 2011 lang.sh…
[root@www ~]# ls -l /root/.bashrc-rw-r--r-- 1 root root 176 6 gen 2007 /root/.bashrc
[root@www ~]# ls -l /etc/bashrc-rw-r--r-- 1 root root 1708 21 set 2009 /etc/bashrc
what after login?1
2
4
3
5
for i in /etc/profile.d/*.sh ; do if [ -r "$i" ]; then if [ "$PS1" ]; then . $i else . $i >/dev/null 2>&1 fi fidone
![Page 35: Bash in theory and in practice - part one](https://reader033.fdocuments.net/reader033/viewer/2022052822/554f54c3b4c905b9508b4fd6/html5/thumbnails/35.jpg)
19.06.201303.07.2013 @pvb265 #imolug
bash the way to suit your bash
UnderWater
[root@www ~]# ls -l /etc/profile-rw-r--r-- 1 root root 1029 21 set 2009 /etc/profile[root@www ~]# ls -l /root/.bash_profile-rw-r--r-- 1 root root 191 6 gen 2007 /root/.bash_profile
[root@www ~]# ls -l /etc/profile.d/totale 104-rwxr-xr-x 1 root root 766 21 lug 2011 colorls.csh-rwxr-xr-x 1 root root 727 21 lug 2011 colorls.sh-rwxr-xr-x 1 root root 3015 19 ago 2011 lang.csh-rwxr-xr-x 1 root root 3466 19 ago 2011 lang.sh…
[root@www ~]# ls -l /root/.bashrc-rw-r--r-- 1 root root 176 6 gen 2007 /root/.bashrc
[root@www ~]# ls -l /etc/bashrc-rw-r--r-- 1 root root 1708 21 set 2009 /etc/bashrc
what after login?1
2
4
3
5
for i in /etc/profile.d/*.sh ; do if [ -r "$i" ]; then if [ "$PS1" ]; then . $i else . $i >/dev/null 2>&1 fi fidone
![Page 36: Bash in theory and in practice - part one](https://reader033.fdocuments.net/reader033/viewer/2022052822/554f54c3b4c905b9508b4fd6/html5/thumbnails/36.jpg)
19.06.201303.07.2013 @pvb265 #imolug
bash the way to suit your bash
UnderWater
[root@www ~]# ls -l /etc/profile-rw-r--r-- 1 root root 1029 21 set 2009 /etc/profile[root@www ~]# ls -l /root/.bash_profile-rw-r--r-- 1 root root 191 6 gen 2007 /root/.bash_profile
[root@www ~]# ls -l /etc/profile.d/totale 104-rwxr-xr-x 1 root root 766 21 lug 2011 colorls.csh-rwxr-xr-x 1 root root 727 21 lug 2011 colorls.sh-rwxr-xr-x 1 root root 3015 19 ago 2011 lang.csh-rwxr-xr-x 1 root root 3466 19 ago 2011 lang.sh…
[root@www ~]# ls -l /root/.bashrc-rw-r--r-- 1 root root 176 6 gen 2007 /root/.bashrc
[root@www ~]# ls -l /etc/bashrc-rw-r--r-- 1 root root 1708 21 set 2009 /etc/bashrc
what after login?1
2
4
3
5
if [ -f ~/.bashrc ]; then. ~/.bashrc
fi
![Page 37: Bash in theory and in practice - part one](https://reader033.fdocuments.net/reader033/viewer/2022052822/554f54c3b4c905b9508b4fd6/html5/thumbnails/37.jpg)
19.06.201303.07.2013 @pvb265 #imolug
bash the way to suit your bash
UnderWater
[root@www ~]# ls -l /etc/profile-rw-r--r-- 1 root root 1029 21 set 2009 /etc/profile[root@www ~]# ls -l /root/.bash_profile-rw-r--r-- 1 root root 191 6 gen 2007 /root/.bash_profile
[root@www ~]# ls -l /etc/profile.d/totale 104-rwxr-xr-x 1 root root 766 21 lug 2011 colorls.csh-rwxr-xr-x 1 root root 727 21 lug 2011 colorls.sh-rwxr-xr-x 1 root root 3015 19 ago 2011 lang.csh-rwxr-xr-x 1 root root 3466 19 ago 2011 lang.sh…
[root@www ~]# ls -l /root/.bashrc-rw-r--r-- 1 root root 176 6 gen 2007 /root/.bashrc
[root@www ~]# ls -l /etc/bashrc-rw-r--r-- 1 root root 1708 21 set 2009 /etc/bashrc
what after login?1
2
4
3
5
if [ -f ~/.bashrc ]; then. ~/.bashrc
fi
![Page 38: Bash in theory and in practice - part one](https://reader033.fdocuments.net/reader033/viewer/2022052822/554f54c3b4c905b9508b4fd6/html5/thumbnails/38.jpg)
19.06.201303.07.2013 @pvb265 #imolug
bash the way to suit your bash
UnderWater
[root@www ~]# ls -l /etc/profile-rw-r--r-- 1 root root 1029 21 set 2009 /etc/profile[root@www ~]# ls -l /root/.bash_profile-rw-r--r-- 1 root root 191 6 gen 2007 /root/.bash_profile
[root@www ~]# ls -l /etc/profile.d/totale 104-rwxr-xr-x 1 root root 766 21 lug 2011 colorls.csh-rwxr-xr-x 1 root root 727 21 lug 2011 colorls.sh-rwxr-xr-x 1 root root 3015 19 ago 2011 lang.csh-rwxr-xr-x 1 root root 3466 19 ago 2011 lang.sh…
[root@www ~]# ls -l /root/.bashrc-rw-r--r-- 1 root root 176 6 gen 2007 /root/.bashrc
[root@www ~]# ls -l /etc/bashrc-rw-r--r-- 1 root root 1708 21 set 2009 /etc/bashrc
what after login?1
2
4
3
5
# Source global definitionsif [ -f /etc/bashrc ]; then
. /etc/bashrcfi
![Page 39: Bash in theory and in practice - part one](https://reader033.fdocuments.net/reader033/viewer/2022052822/554f54c3b4c905b9508b4fd6/html5/thumbnails/39.jpg)
19.06.201303.07.2013 @pvb265 #imolug
bash the way to suit your bash
UnderWater
[root@www ~]# ls -l /etc/profile-rw-r--r-- 1 root root 1029 21 set 2009 /etc/profile[root@www ~]# ls -l /root/.bash_profile-rw-r--r-- 1 root root 191 6 gen 2007 /root/.bash_profile
[root@www ~]# ls -l /etc/profile.d/totale 104-rwxr-xr-x 1 root root 766 21 lug 2011 colorls.csh-rwxr-xr-x 1 root root 727 21 lug 2011 colorls.sh-rwxr-xr-x 1 root root 3015 19 ago 2011 lang.csh-rwxr-xr-x 1 root root 3466 19 ago 2011 lang.sh…
[root@www ~]# ls -l /root/.bashrc-rw-r--r-- 1 root root 176 6 gen 2007 /root/.bashrc
[root@www ~]# ls -l /etc/bashrc-rw-r--r-- 1 root root 1708 21 set 2009 /etc/bashrc
what after login?1
2
4
3
5
# Source global definitionsif [ -f /etc/bashrc ]; then
. /etc/bashrcfi
![Page 40: Bash in theory and in practice - part one](https://reader033.fdocuments.net/reader033/viewer/2022052822/554f54c3b4c905b9508b4fd6/html5/thumbnails/40.jpg)
19.06.201303.07.2013 @pvb265 #imolug
bash
Overview
![Page 41: Bash in theory and in practice - part one](https://reader033.fdocuments.net/reader033/viewer/2022052822/554f54c3b4c905b9508b4fd6/html5/thumbnails/41.jpg)
19.06.201303.07.2013 @pvb265 #imolug
bash POSIX 1003.1 standard (IEEE Std 1003.1)pazh-ics not poh-six
Command InterpreterDefault 4 Linux and Mac OS XBourne Again Shell ( as rebird or another Bourne)
A superset of Bourne shellInclude history and directory stack from C shellRelative New concepts in the recents versions: . 3.0 regex like in perl . 4.0 hash to implement awk
Overview
![Page 42: Bash in theory and in practice - part one](https://reader033.fdocuments.net/reader033/viewer/2022052822/554f54c3b4c905b9508b4fd6/html5/thumbnails/42.jpg)
19.06.201303.07.2013 @pvb265 #imolug
bash OverviewFunction Implemented:
Command line editing Command line completion Unlimited size command history Prompt control Bash startup files The Directory Stack The Restricted Shell Bash POSIX Mode Bash conditional expressions
![Page 43: Bash in theory and in practice - part one](https://reader033.fdocuments.net/reader033/viewer/2022052822/554f54c3b4c905b9508b4fd6/html5/thumbnails/43.jpg)
19.06.201303.07.2013 @pvb265 #imolug
bash Overview
[root@www ~]#set -o vi
Esc-k Esc-j
Function Implemented:
Command line editing Command line completion Unlimited size command history Prompt control Bash startup files The Directory Stack The Restricted Shell Bash POSIX Mode Bash conditional expressions
![Page 44: Bash in theory and in practice - part one](https://reader033.fdocuments.net/reader033/viewer/2022052822/554f54c3b4c905b9508b4fd6/html5/thumbnails/44.jpg)
19.06.201303.07.2013 @pvb265 #imolug
bash Overview
[root@www ~]#set -o vi
Esc-k Esc-j
beginning-of-line (C-a)end-of-line (C-e)forward-char (C-f)backward-char (C-b)forward-word (M-f)backward-word (M-b)clear-screen (C-l)
Function Implemented:
Command line editing Command line completion Unlimited size command history Prompt control Bash startup files The Directory Stack The Restricted Shell Bash POSIX Mode Bash conditional expressions
![Page 45: Bash in theory and in practice - part one](https://reader033.fdocuments.net/reader033/viewer/2022052822/554f54c3b4c905b9508b4fd6/html5/thumbnails/45.jpg)
19.06.201303.07.2013 @pvb265 #imolug
bash Overview
[root@www ~]# ls /root/.bash
Function Implemented:
Command line editing Command line completion Unlimited size command history Prompt control Bash startup files The Directory Stack The Restricted Shell Bash POSIX Mode Bash conditional expressions
![Page 46: Bash in theory and in practice - part one](https://reader033.fdocuments.net/reader033/viewer/2022052822/554f54c3b4c905b9508b4fd6/html5/thumbnails/46.jpg)
19.06.201303.07.2013 @pvb265 #imolug
bash Overview
[root@www ~]# ls /root/.bash +TAB+TAB.bash_history .bash_profile .bashrc
Function Implemented:
Command line editing Command line completion Unlimited size command history Prompt control Bash startup files The Directory Stack The Restricted Shell Bash POSIX Mode Bash conditional expressions
![Page 47: Bash in theory and in practice - part one](https://reader033.fdocuments.net/reader033/viewer/2022052822/554f54c3b4c905b9508b4fd6/html5/thumbnails/47.jpg)
19.06.201303.07.2013 @pvb265 #imolug
bash Overview
[root@www ~]# ls /root/.bash +TAB+TAB.bash_history .bash_profile .bashrc
[root@www ~]# mkfs +TAB+TABmkfs mkfs.ext2 mkfs.ext3 mkfs.vfat
Function Implemented:
Command line editing Command line completion Unlimited size command history Prompt control Bash startup files The Directory Stack The Restricted Shell Bash POSIX Mode Bash conditional expressions
![Page 48: Bash in theory and in practice - part one](https://reader033.fdocuments.net/reader033/viewer/2022052822/554f54c3b4c905b9508b4fd6/html5/thumbnails/48.jpg)
19.06.201303.07.2013 @pvb265 #imolug
bash Overview
export HISTFSIZE=10000
export HISTFILESIZE=10000shopt -s histappend
Function Implemented:
Command line editing Command line completion Unlimited size command history Prompt control Bash startup files The Directory Stack The Restricted Shell Bash POSIX Mode Bash conditional expressions
![Page 49: Bash in theory and in practice - part one](https://reader033.fdocuments.net/reader033/viewer/2022052822/554f54c3b4c905b9508b4fd6/html5/thumbnails/49.jpg)
19.06.201303.07.2013 @pvb265 #imolug
bash Overview
$PS1 - primary prompt string, default \s-\v\$ .$PS2 - secondary, default is >$PS3 - prompt for the select command$PS4 - during an execution trace. default is +
Function Implemented:
Command line editing Command line completion Unlimited size command history Prompt control Bash startup files The Directory Stack The Restricted Shell Bash POSIX Mode Bash conditional expressions
![Page 50: Bash in theory and in practice - part one](https://reader033.fdocuments.net/reader033/viewer/2022052822/554f54c3b4c905b9508b4fd6/html5/thumbnails/50.jpg)
19.06.201303.07.2013 @pvb265 #imolug
bash Overview
$PS1 - primary prompt string, default \s-\v\$ .$PS2 - secondary, default is >$PS3 - prompt for the select command$PS4 - during an execution trace. default is +
\d : date "Tue May 26" \h : hostname up to the first '.' \t : current time HH:MM:SS \u : username of the current user \w : current working directory \$ : if UID is 0, a #, otherwise a $
Function Implemented:
Command line editing Command line completion Unlimited size command history Prompt control Bash startup files The Directory Stack The Restricted Shell Bash POSIX Mode Bash conditional expressions
![Page 51: Bash in theory and in practice - part one](https://reader033.fdocuments.net/reader033/viewer/2022052822/554f54c3b4c905b9508b4fd6/html5/thumbnails/51.jpg)
19.06.201303.07.2013 @pvb265 #imolug
bash Function Implemented:
Command line editing Command line completion Unlimited size command history Prompt control Bash startup files The Directory Stack The Restricted Shell Bash POSIX Mode Bash conditional expressions
Overview
/etc/profile/etc/profile.d/*
/root/.bash_profile/root/.bashrc/etc/bashrc
![Page 52: Bash in theory and in practice - part one](https://reader033.fdocuments.net/reader033/viewer/2022052822/554f54c3b4c905b9508b4fd6/html5/thumbnails/52.jpg)
19.06.201303.07.2013 @pvb265 #imolug
bash Function Implemented:
Command line editing Command line completion Unlimited size command history Prompt control Bash startup files The Directory Stack The Restricted Shell Bash POSIX Mode Bash conditional expressions
Overview
/etc/profile/etc/profile.d/*
/root/.bash_profile/root/.bashrc/etc/bashrc
![Page 53: Bash in theory and in practice - part one](https://reader033.fdocuments.net/reader033/viewer/2022052822/554f54c3b4c905b9508b4fd6/html5/thumbnails/53.jpg)
19.06.201303.07.2013 @pvb265 #imolug
bash Function Implemented:
Command line editing Command line completion Unlimited size command history Prompt control Bash startup files The Directory Stack The Restricted Shell Bash POSIX Mode Bash conditional expressions
Overview
[root@www ~]# dirs~[root@www ~]# pushd /etc/etc ~[root@www etc]# pushd /tmp/tmp /etc ~[root@www tmp]# popd/etc ~[root@www etc]# dirs/etc ~
![Page 54: Bash in theory and in practice - part one](https://reader033.fdocuments.net/reader033/viewer/2022052822/554f54c3b4c905b9508b4fd6/html5/thumbnails/54.jpg)
19.06.201303.07.2013 @pvb265 #imolug
bash Function Implemented:
Command line editing Command line completion Unlimited size command history Prompt control Bash startup files The Directory Stack The Restricted Shell Bash POSIX Mode Bash conditional expressions
Overview
bash -rrbashbash --restricted
![Page 55: Bash in theory and in practice - part one](https://reader033.fdocuments.net/reader033/viewer/2022052822/554f54c3b4c905b9508b4fd6/html5/thumbnails/55.jpg)
19.06.201303.07.2013 @pvb265 #imolug
bash Function Implemented:
Command line editing Command line completion Unlimited size command history Prompt control Bash startup files The Directory Stack The Restricted Shell Bash POSIX Mode Bash conditional expressions
Overview
bash -rrbashbash --restricted
vi:set shell=/bin/sh:shell
~$ rbash~$ cd /rbash: cd: restricted~$ bash~$ cd //$
![Page 56: Bash in theory and in practice - part one](https://reader033.fdocuments.net/reader033/viewer/2022052822/554f54c3b4c905b9508b4fd6/html5/thumbnails/56.jpg)
19.06.201303.07.2013 @pvb265 #imolug
bash Function Implemented:
Command line editing Command line completion Unlimited size command history Prompt control Bash startup files The Directory Stack The Restricted Shell Bash POSIX Mode Bash conditional expressions
Overview
bash -rrbashbash --restricted
vi:set shell=/bin/sh:shell
~$ rbash~$ cd /rbash: cd: restricted~$ bash~$ cd //$
rssh
![Page 57: Bash in theory and in practice - part one](https://reader033.fdocuments.net/reader033/viewer/2022052822/554f54c3b4c905b9508b4fd6/html5/thumbnails/57.jpg)
19.06.201303.07.2013 @pvb265 #imolug
bash Function Implemented:
Command line editing Command line completion Unlimited size command history Prompt control Bash startup files The Directory Stack The Restricted Shell Bash POSIX Mode Bash conditional expressions
Overview
- When a command in the hash table no longer exists, Bash will re-search $PATH to find the new location. This is also available with ‘shopt -s checkhash’.
- The message printed by the job control codeand builtins when a job exits with a non-zerostatus is ‘Done(status)’.
- The message printed by the job control code and builtins when a job is stopped is ‘Stopped(signame)’, where signame is, for example, SIGTSTP.
And other 42...
![Page 58: Bash in theory and in practice - part one](https://reader033.fdocuments.net/reader033/viewer/2022052822/554f54c3b4c905b9508b4fd6/html5/thumbnails/58.jpg)
19.06.201303.07.2013 @pvb265 #imolug
bash Function Implemented:
Command line editing Command line completion Unlimited size command history Prompt control Bash startup files The Directory Stack The Restricted Shell Bash POSIX Mode Bash conditional expressions
Overview
to test $file
[ -e filepath ] true if file exists. [ -x filepath ] true if file exists and exec. [ -d filepath ] true if dir exists. [ expr1 -a expr2 ] and condition [ expr1 -o expr2 ] or condition
![Page 59: Bash in theory and in practice - part one](https://reader033.fdocuments.net/reader033/viewer/2022052822/554f54c3b4c905b9508b4fd6/html5/thumbnails/59.jpg)
19.06.201303.07.2013 @pvb265 #imolug
bash Function Implemented:
Command line editing Command line completion Unlimited size command history Prompt control Bash startup files The Directory Stack The Restricted Shell Bash POSIX Mode Bash conditional expressions
Overview
to test $file
[ -e filepath ] true if file exists. [ -x filepath ] true if file exists and exec. [ -d filepath ] true if dir exists. [ expr1 -a expr2 ] and condition [ expr1 -o expr2 ] or condition
for arithmetics [ $VAR1 OP $VAR2 ] true if file exists. OP := -gt -eq -ne -lt -ge -le
![Page 60: Bash in theory and in practice - part one](https://reader033.fdocuments.net/reader033/viewer/2022052822/554f54c3b4c905b9508b4fd6/html5/thumbnails/60.jpg)
AgendaGeneral InfoUnderwaterOverview
SyntaxScriptingExamples
19.06.201303.07.2013 @pvb265 #imolug
19.06
03.07