SlideShare ist ein Scribd-Unternehmen logo
1 von 60
Downloaden Sie, um offline zu lesen
bashin theory and in practice
19.06.2013
03.07.2013 @pvb265 #imolug
Agenda
General Info
Underwater
Overview
Syntax
Examples
19.06.2013
03.07.2013 @pvb265 #imolug
Agenda
General Info
Underwater
Overview
Syntax
Examples
19.06.2013
03.07.2013 @pvb265 #imolug
19.06
03.07
Agenda
General Info
Underwater
Overview
Syntax
Examples
19.06.2013
03.07.2013 @pvb265 #imolug
19.06
03.07
bash
bourne again shell
GNU project
textual shell
19.06.2013
03.07.2013 @pvb265 #imolug
interface of an O. S.
to access Kernel services
19.06.2013
03.07.2013 @pvb265 #imolug
shell
bash
. resources control
. process execution
19.06.2013
03.07.2013 @pvb265 #imolug
o.s.
shellbash
. process manager
. memory manager
. scheduler/event manager
. file manager
19.06.2013
03.07.2013 @pvb265 #imolug
o.s.
shellbash
. process wrapper
. scheduler controll
19.06.2013
03.07.2013 @pvb265 #imolug
kernel
o.s.shellbash
19.06.2013
03.07.2013 @pvb265 #imolug
kernel
o.s.
shell
bash
19.06.2013
03.07.2013 @pvb265 #imolug
kernel
o.s.
shell
bash
Desktop PC, Parallel Systems, Distribuited Systems,
Clustered Systems, Real-time Systems, Embedded Systems
19.06.2013
03.07.2013 @pvb265 #imolug
kernel
o.s.
shell
bash
Desktop PC, Parallel Systems, Distribuited Systems,
Clustered Systems, Real-time Systems, Embedded Systems
Monolithic, MicroKernel,
Hybryd kernel, exoKernel
19.06.2013
03.07.2013 @pvb265 #imolug
kernel
o.s.
shell
bash
Desktop PC, Parallel Systems, Distribuited Systems,
Clustered Systems, Real-time Systems, Embedded Systems
Monolithic, MicroKernel,
noKernel, Hybryd kernel, exoKernel
19.06.2013
03.07.2013 @pvb265 #imolug
kernel
o.s.
shell
bash
Desktop PC, Parallel Systems, Distribuited Systems,
Clustered Systems, Real-time Systems, Embedded Systems
Monolithic, MicroKernel,
Hybrid kernel, exoKernel
textual, GUI
19.06.2013
03.07.2013 @pvb265 #imolug
kernel
o.s.
shell
bash
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
19.06.2013
03.07.2013 @pvb265 #imolug
shell 1970: runcom (Multics) JCL (s/390)
1975-1978: Steve Bourne, at Bell Labs wrote sh
1978-1979: Bill Joy at BSD wrote csh
1981: tcsh is a fork of csh POSIX compliance
1983: David Korn wrote ksh
1989: Brian Fox wrote bash
1990: Paul Falstad wrote zsh
1997: bash 2.0
2004: bash 3.0
2011: bash 4.2 latest (now) stable
19.06.2013
03.07.2013 @pvb265 #imolug
bash
UnderWater
19.06.2013
03.07.2013 @pvb265 #imolug
bash Pick-Up a Mac OS X Box
UnderWater
Terminal Process
bash-3.2$ ps -ef|grep Terminal
ps -ef|grep Terminal
501 1636 211 0 1:55pm ?? 0:04.57 /Applications/Utilities/Terminal.app/Contents/MacOS/Terminal -psn_0_667811
19.06.2013
03.07.2013 @pvb265 #imolug
bash Pick-Up a Mac OS X Box
UnderWater
Terminal Process
bash-3.2$ ps -ef|grep Terminal
ps -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 1636
ps -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
19.06.2013
03.07.2013 @pvb265 #imolug
bash Pick-Up a Mac OS X Box
UnderWater
Terminal Process
bash-3.2$ ps -ef|grep Terminal
ps -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 1636
ps -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 1638
ps -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
19.06.2013
03.07.2013 @pvb265 #imolug
bash Pick-Up a Linux Box
UnderWater
[root@www ~]# ps -ef|grep sshd
root 3065 1 0 Feb05 ? 00:01:54 /usr/sbin/sshd
root 10442 3065 0 17:15 ? 00:00:00 sshd: root@pts/0
[root@www ~]# ps -ef| grep 10442
root 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
19.06.2013
03.07.2013 @pvb265 #imolug
bash Who said system to invoke bash
UnderWater
[root@www ~]# cat /etc/passwd|head -5
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
Linux Users Definitions
19.06.2013
03.07.2013 @pvb265 #imolug
bash Who said system to invoke bash
UnderWater
[root@www ~]# cat /etc/passwd|head -5
root :x :0 :0 :root :/root :/bin/bash
bin :x :1 :1 :bin :/bin :/sbin/nologin
daemon :x :2 :2 :daemon :/sbin :/sbin/nologin
adm :x :3 :4 :adm :/var/adm :/sbin/nologin
lp :x :4 :7 :lp :/var/spool/lpd :/sbin/nologin
Username Password UID GID Description Home Initialprogram
Linux Users Definitions
19.06.2013
03.07.2013 @pvb265 #imolug
bash Who said system to invoke bash
UnderWater
[root@www ~]# cat /etc/passwd|head -5
root :x :0 :0 :root :/root :/bin/bash
bin :x :1 :1 :bin :/bin :/sbin/nologin
daemon :x :2 :2 :daemon :/sbin :/sbin/nologin
adm :x :3 :4 :adm :/var/adm :/sbin/nologin
lp :x :4 :7 :lp :/var/spool/lpd :/sbin/nologin
Username Password UID GID Description Home Initialprogram
[root@www ~]# grep root /etc/shadow
Root: $1$LDqgrtQA$IXip/e.HuPhjSjLWXmrdj0 :15561 :0:99999:7:::
Username Password Lastchanged PasswordAging
Linux Users Definitions
19.06.2013
03.07.2013 @pvb265 #imolug
bash Who said system to invoke bash
UnderWater
[root@www ~]# cat /etc/passwd|head -5
root :x :0 :0 :root :/root :/bin/bash
bin :x :1 :1 :bin :/bin :/sbin/nologin
daemon :x :2 :2 :daemon :/sbin :/sbin/nologin
adm :x :3 :4 :adm :/var/adm :/sbin/nologin
lp :x :4 :7 :lp :/var/spool/lpd :/sbin/nologin
Username Password UID GID Description Home Initialprogram
[root@www ~]# grep root /etc/shadow
Root: $1$LDqgrtQA$IXip/e.HuPhjSjLWXmrdj0 :15561 :0:99999:7:::
Username Password Lastchanged PasswordAging
[root@www ~]# cat /etc/passwd|head -1
root:$1$LDqgrtQA$IXip/e.HuPhjSjLWXmrdj0:0:0:root:/root:/bin/bash
Linux Users Definitions
19.06.2013
03.07.2013 @pvb265 #imolug
bash Who said system to invoke bash
UnderWater
[root@www ~]# cat /etc/passwd|head -5
root :x :0 :0 :root :/root :/bin/bash
bin :x :1 :1 :bin :/bin :/sbin/nologin
daemon :x :2 :2 :daemon :/sbin :/sbin/nologin
adm :x :3 :4 :adm :/var/adm :/sbin/nologin
lp :x :4 :7 :lp :/var/spool/lpd :/sbin/nologin
Username Password UID GID Description Home Initialprogram
[root@www ~]# grep root /etc/shadow
Root: $1$LDqgrtQA$IXip/e.HuPhjSjLWXmrdj0 :15561 :0:99999:7:::
Username Password Lastchanged PasswordAging
[root@www ~]# cat /etc/passwd|head -1
root::0:0:root:/root:/bin/bash
Linux Users Definitions
19.06.2013
03.07.2013 @pvb265 #imolug
bash Who said system to invoke bash
UnderWater
[root@www ~]# cat /etc/passwd|head -5
root :x :0 :0 :root :/root :/bin/bash
bin :x :1 :1 :bin :/bin :/sbin/nologin
daemon :x :2 :2 :daemon :/sbin :/sbin/nologin
adm :x :3 :4 :adm :/var/adm :/sbin/nologin
lp :x :4 :7 :lp :/var/spool/lpd :/sbin/nologin
Username Password UID GID Description Home Initialprogram
Linux Users Definitions
19.06.2013
03.07.2013 @pvb265 #imolug
bash Who said system to invoke bash
UnderWater
[root@www ~]# cat /etc/passwd|head -5
root :x :0 :0 :root :/root :/bin/bash
bin :x :1 :1 :bin :/bin :/sbin/nologin
daemon :x :2 :2 :daemon :/sbin :/sbin/nologin
adm :x :3 :4 :adm :/var/adm :/sbin/nologin
lp :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
19.06.2013
03.07.2013 @pvb265 #imolug
bash Who said system to invoke bash
UnderWater
[root@www ~]# cat /etc/passwd|head -5
root :x :0 :0 :root :/root :/bin/bash
bin :x :1 :1 :bin :/bin :/sbin/nologin
daemon :x :2 :2 :daemon :/sbin :/sbin/nologin
adm :x :3 :4 :adm :/var/adm :/sbin/nologin
lp :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
19.06.2013
03.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?
19.06.2013
03.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?
19.06.2013
03.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?
19.06.2013
03.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
19.06.2013
03.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
fi
done
19.06.2013
03.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
fi
done
19.06.2013
03.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
19.06.2013
03.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
19.06.2013
03.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 definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
19.06.2013
03.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 definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
19.06.2013
03.07.2013 @pvb265 #imolug
bash
Overview
19.06.2013
03.07.2013 @pvb265 #imolug
bash POSIX 1003.1 standard (IEEE Std 1003.1)
pazh-ics not poh-six
Command Interpreter
Default 4 Linux and Mac OS X
Bourne Again Shell ( as rebird or another Bourne)
A superset of Bourne shell
Include history and directory stack from C shell
Relative New concepts in the recents versions:
. 3.0 regex like in perl
. 4.0 hash to implement awk
Overview
19.06.2013
03.07.2013 @pvb265 #imolug
bash Overview
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
19.06.2013
03.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
19.06.2013
03.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
19.06.2013
03.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
19.06.2013
03.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
19.06.2013
03.07.2013 @pvb265 #imolug
bash Overview
[root@www ~]# ls /root/.bash +TAB+TAB
.bash_history .bash_profile .bashrc
[root@www ~]# mkfs +TAB+TAB
mkfs 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
19.06.2013
03.07.2013 @pvb265 #imolug
bash Overview
export HISTFSIZE=10000
export HISTFILESIZE=10000
shopt -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
19.06.2013
03.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
19.06.2013
03.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
19.06.2013
03.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
19.06.2013
03.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
19.06.2013
03.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 ~
19.06.2013
03.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 -r
rbash
bash --restricted
19.06.2013
03.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 -r
rbash
bash --restricted
vi
:set shell=/bin/sh
:shell
~$ rbash
~$ cd /
rbash: cd: restricted
~$ bash
~$ cd /
/$
19.06.2013
03.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 -r
rbash
bash --restricted
vi
:set shell=/bin/sh
:shell
~$ rbash
~$ cd /
rbash: cd: restricted
~$ bash
~$ cd /
/$
rssh
19.06.2013
03.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 code
and builtins when a job exits with a non-zero
status 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...
19.06.2013
03.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
19.06.2013
03.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
AgendaGeneral Info
Underwater
Overview
Syntax
Scripting
Examples
19.06.2013
03.07.2013 @pvb265 #imolug
19.06
03.07

Weitere ähnliche Inhalte

Was ist angesagt?

C: A Humbling Language
C: A Humbling LanguageC: A Humbling Language
C: A Humbling Languageguestaa63aa
 
Kernel Recipes 2019 - GNU poke, an extensible editor for structured binary data
Kernel Recipes 2019 - GNU poke, an extensible editor for structured binary dataKernel Recipes 2019 - GNU poke, an extensible editor for structured binary data
Kernel Recipes 2019 - GNU poke, an extensible editor for structured binary dataAnne Nicolas
 
Unix shell scripting basics
Unix shell scripting basicsUnix shell scripting basics
Unix shell scripting basicsManav Prasad
 
On UnQLite
On UnQLiteOn UnQLite
On UnQLitecharsbar
 
Crafting Beautiful CLI Applications in Ruby
Crafting Beautiful CLI Applications in RubyCrafting Beautiful CLI Applications in Ruby
Crafting Beautiful CLI Applications in RubyNikhil Mungel
 
Rush, a shell that will yield to you
Rush, a shell that will yield to youRush, a shell that will yield to you
Rush, a shell that will yield to youguestdd9d06
 
COSCUP 2016 - ROS + Gazebo機器人模擬器工作坊
COSCUP 2016 - ROS + Gazebo機器人模擬器工作坊COSCUP 2016 - ROS + Gazebo機器人模擬器工作坊
COSCUP 2016 - ROS + Gazebo機器人模擬器工作坊Po-Jen Lai
 
Unix Shell Scripting Basics
Unix Shell Scripting BasicsUnix Shell Scripting Basics
Unix Shell Scripting BasicsDr.Ravi
 
PHP-FIG: Past, Present and Future
PHP-FIG: Past, Present and FuturePHP-FIG: Past, Present and Future
PHP-FIG: Past, Present and FuturePhil Sturgeon
 
Unix Shell Scripting Basics
Unix Shell Scripting BasicsUnix Shell Scripting Basics
Unix Shell Scripting BasicsSudharsan S
 
Talk Unix Shell Script
Talk Unix Shell ScriptTalk Unix Shell Script
Talk Unix Shell ScriptDr.Ravi
 
Introduction to Bash Scripting, Zyxware Technologies, CSI Students Convention...
Introduction to Bash Scripting, Zyxware Technologies, CSI Students Convention...Introduction to Bash Scripting, Zyxware Technologies, CSI Students Convention...
Introduction to Bash Scripting, Zyxware Technologies, CSI Students Convention...Zyxware Technologies
 
Introducing Command Line Applications with Ruby
Introducing Command Line Applications with RubyIntroducing Command Line Applications with Ruby
Introducing Command Line Applications with RubyNikhil Mungel
 
Happy Go Programming
Happy Go ProgrammingHappy Go Programming
Happy Go ProgrammingLin Yo-An
 
DevChatt 2010 - *nix Cmd Line Kung Foo
DevChatt 2010 - *nix Cmd Line Kung FooDevChatt 2010 - *nix Cmd Line Kung Foo
DevChatt 2010 - *nix Cmd Line Kung Foobrian_dailey
 
Talk Unix Shell Script 1
Talk Unix Shell Script 1Talk Unix Shell Script 1
Talk Unix Shell Script 1Dr.Ravi
 
Airlover 20030324 1
Airlover 20030324 1Airlover 20030324 1
Airlover 20030324 1Dr.Ravi
 
Unix And C
Unix And CUnix And C
Unix And CDr.Ravi
 

Was ist angesagt? (20)

C: A Humbling Language
C: A Humbling LanguageC: A Humbling Language
C: A Humbling Language
 
Kernel Recipes 2019 - GNU poke, an extensible editor for structured binary data
Kernel Recipes 2019 - GNU poke, an extensible editor for structured binary dataKernel Recipes 2019 - GNU poke, an extensible editor for structured binary data
Kernel Recipes 2019 - GNU poke, an extensible editor for structured binary data
 
Unix shell scripting basics
Unix shell scripting basicsUnix shell scripting basics
Unix shell scripting basics
 
Shell scripting
Shell scriptingShell scripting
Shell scripting
 
On UnQLite
On UnQLiteOn UnQLite
On UnQLite
 
Crafting Beautiful CLI Applications in Ruby
Crafting Beautiful CLI Applications in RubyCrafting Beautiful CLI Applications in Ruby
Crafting Beautiful CLI Applications in Ruby
 
Rush, a shell that will yield to you
Rush, a shell that will yield to youRush, a shell that will yield to you
Rush, a shell that will yield to you
 
COSCUP 2016 - ROS + Gazebo機器人模擬器工作坊
COSCUP 2016 - ROS + Gazebo機器人模擬器工作坊COSCUP 2016 - ROS + Gazebo機器人模擬器工作坊
COSCUP 2016 - ROS + Gazebo機器人模擬器工作坊
 
Unix Shell Scripting Basics
Unix Shell Scripting BasicsUnix Shell Scripting Basics
Unix Shell Scripting Basics
 
PHP-FIG: Past, Present and Future
PHP-FIG: Past, Present and FuturePHP-FIG: Past, Present and Future
PHP-FIG: Past, Present and Future
 
Git::Hooks
Git::HooksGit::Hooks
Git::Hooks
 
Unix Shell Scripting Basics
Unix Shell Scripting BasicsUnix Shell Scripting Basics
Unix Shell Scripting Basics
 
Talk Unix Shell Script
Talk Unix Shell ScriptTalk Unix Shell Script
Talk Unix Shell Script
 
Introduction to Bash Scripting, Zyxware Technologies, CSI Students Convention...
Introduction to Bash Scripting, Zyxware Technologies, CSI Students Convention...Introduction to Bash Scripting, Zyxware Technologies, CSI Students Convention...
Introduction to Bash Scripting, Zyxware Technologies, CSI Students Convention...
 
Introducing Command Line Applications with Ruby
Introducing Command Line Applications with RubyIntroducing Command Line Applications with Ruby
Introducing Command Line Applications with Ruby
 
Happy Go Programming
Happy Go ProgrammingHappy Go Programming
Happy Go Programming
 
DevChatt 2010 - *nix Cmd Line Kung Foo
DevChatt 2010 - *nix Cmd Line Kung FooDevChatt 2010 - *nix Cmd Line Kung Foo
DevChatt 2010 - *nix Cmd Line Kung Foo
 
Talk Unix Shell Script 1
Talk Unix Shell Script 1Talk Unix Shell Script 1
Talk Unix Shell Script 1
 
Airlover 20030324 1
Airlover 20030324 1Airlover 20030324 1
Airlover 20030324 1
 
Unix And C
Unix And CUnix And C
Unix And C
 

Ähnlich wie Bash in theory and in practice - part one

Globus toolkit4installationguide
Globus toolkit4installationguideGlobus toolkit4installationguide
Globus toolkit4installationguideAdarsh Patil
 
DCEU 18: Tips and Tricks of the Docker Captains
DCEU 18: Tips and Tricks of the Docker CaptainsDCEU 18: Tips and Tricks of the Docker Captains
DCEU 18: Tips and Tricks of the Docker CaptainsDocker, Inc.
 
Sage 2 19_v5_busby
Sage 2 19_v5_busbySage 2 19_v5_busby
Sage 2 19_v5_busbyBen Busby
 
Using Nix and Docker as automated deployment solutions
Using Nix and Docker as automated deployment solutionsUsing Nix and Docker as automated deployment solutions
Using Nix and Docker as automated deployment solutionsSander van der Burg
 
SBA Security Meetup: I want to break free - The attacker inside a Container
SBA Security Meetup: I want to break free - The attacker inside a ContainerSBA Security Meetup: I want to break free - The attacker inside a Container
SBA Security Meetup: I want to break free - The attacker inside a ContainerSBA Research
 
ERP System Implementation Kubernetes Cluster with Sticky Sessions
ERP System Implementation Kubernetes Cluster with Sticky Sessions ERP System Implementation Kubernetes Cluster with Sticky Sessions
ERP System Implementation Kubernetes Cluster with Sticky Sessions Chanaka Lasantha
 
Scalable Deployment Architectures with TYPO3 Surf, Git and Jenkins
Scalable Deployment Architectures with TYPO3 Surf, Git and JenkinsScalable Deployment Architectures with TYPO3 Surf, Git and Jenkins
Scalable Deployment Architectures with TYPO3 Surf, Git and Jenkinsmhelmich
 
GTFO: Git Theory For OpenSource
GTFO: Git Theory For OpenSourceGTFO: Git Theory For OpenSource
GTFO: Git Theory For OpenSourceForest Mars
 
2012 coscup - Build your PHP application on Heroku
2012 coscup - Build your PHP application on Heroku2012 coscup - Build your PHP application on Heroku
2012 coscup - Build your PHP application on Herokuronnywang_tw
 
Princeton Wintersession: Software Quality Assurance Tooling
Princeton Wintersession: Software Quality Assurance ToolingPrinceton Wintersession: Software Quality Assurance Tooling
Princeton Wintersession: Software Quality Assurance ToolingHenry Schreiner
 
zebra & openconfigd Introduction
zebra & openconfigd Introductionzebra & openconfigd Introduction
zebra & openconfigd IntroductionKentaro Ebisawa
 
Docker command
Docker commandDocker command
Docker commandEric Ahn
 
Goの標準的な開発の流れ
Goの標準的な開発の流れGoの標準的な開発の流れ
Goの標準的な開発の流れRyuji Iwata
 
Package a PyApp as a Flatpak Package: An HTTP Server for Example @ PyCon APAC...
Package a PyApp as a Flatpak Package: An HTTP Server for Example @ PyCon APAC...Package a PyApp as a Flatpak Package: An HTTP Server for Example @ PyCon APAC...
Package a PyApp as a Flatpak Package: An HTTP Server for Example @ PyCon APAC...Jian-Hong Pan
 
Optimizing Spring Boot apps for Docker
Optimizing Spring Boot apps for DockerOptimizing Spring Boot apps for Docker
Optimizing Spring Boot apps for DockerGraham Charters
 
Linux Common Command
Linux Common CommandLinux Common Command
Linux Common CommandJeff Yang
 
Bash is not a second zone citizen programming language
Bash is not a second zone citizen programming languageBash is not a second zone citizen programming language
Bash is not a second zone citizen programming languageRené Ribaud
 

Ähnlich wie Bash in theory and in practice - part one (20)

Globus toolkit4installationguide
Globus toolkit4installationguideGlobus toolkit4installationguide
Globus toolkit4installationguide
 
DCEU 18: Tips and Tricks of the Docker Captains
DCEU 18: Tips and Tricks of the Docker CaptainsDCEU 18: Tips and Tricks of the Docker Captains
DCEU 18: Tips and Tricks of the Docker Captains
 
Sage 2 19_v5_busby
Sage 2 19_v5_busbySage 2 19_v5_busby
Sage 2 19_v5_busby
 
Using Nix and Docker as automated deployment solutions
Using Nix and Docker as automated deployment solutionsUsing Nix and Docker as automated deployment solutions
Using Nix and Docker as automated deployment solutions
 
SBA Security Meetup: I want to break free - The attacker inside a Container
SBA Security Meetup: I want to break free - The attacker inside a ContainerSBA Security Meetup: I want to break free - The attacker inside a Container
SBA Security Meetup: I want to break free - The attacker inside a Container
 
Lab manual
Lab manualLab manual
Lab manual
 
PHP selber bauen
PHP selber bauenPHP selber bauen
PHP selber bauen
 
ERP System Implementation Kubernetes Cluster with Sticky Sessions
ERP System Implementation Kubernetes Cluster with Sticky Sessions ERP System Implementation Kubernetes Cluster with Sticky Sessions
ERP System Implementation Kubernetes Cluster with Sticky Sessions
 
Scalable Deployment Architectures with TYPO3 Surf, Git and Jenkins
Scalable Deployment Architectures with TYPO3 Surf, Git and JenkinsScalable Deployment Architectures with TYPO3 Surf, Git and Jenkins
Scalable Deployment Architectures with TYPO3 Surf, Git and Jenkins
 
GTFO: Git Theory For OpenSource
GTFO: Git Theory For OpenSourceGTFO: Git Theory For OpenSource
GTFO: Git Theory For OpenSource
 
2012 coscup - Build your PHP application on Heroku
2012 coscup - Build your PHP application on Heroku2012 coscup - Build your PHP application on Heroku
2012 coscup - Build your PHP application on Heroku
 
Princeton Wintersession: Software Quality Assurance Tooling
Princeton Wintersession: Software Quality Assurance ToolingPrinceton Wintersession: Software Quality Assurance Tooling
Princeton Wintersession: Software Quality Assurance Tooling
 
zebra & openconfigd Introduction
zebra & openconfigd Introductionzebra & openconfigd Introduction
zebra & openconfigd Introduction
 
Docker command
Docker commandDocker command
Docker command
 
Goの標準的な開発の流れ
Goの標準的な開発の流れGoの標準的な開発の流れ
Goの標準的な開発の流れ
 
Package a PyApp as a Flatpak Package: An HTTP Server for Example @ PyCon APAC...
Package a PyApp as a Flatpak Package: An HTTP Server for Example @ PyCon APAC...Package a PyApp as a Flatpak Package: An HTTP Server for Example @ PyCon APAC...
Package a PyApp as a Flatpak Package: An HTTP Server for Example @ PyCon APAC...
 
Optimizing Spring Boot apps for Docker
Optimizing Spring Boot apps for DockerOptimizing Spring Boot apps for Docker
Optimizing Spring Boot apps for Docker
 
Linux Common Command
Linux Common CommandLinux Common Command
Linux Common Command
 
Cadence flow
Cadence flowCadence flow
Cadence flow
 
Bash is not a second zone citizen programming language
Bash is not a second zone citizen programming languageBash is not a second zone citizen programming language
Bash is not a second zone citizen programming language
 

Kürzlich hochgeladen

How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 

Kürzlich hochgeladen (20)

How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 

Bash in theory and in practice - part one

  • 1. bashin theory and in practice 19.06.2013 03.07.2013 @pvb265 #imolug
  • 5. bash bourne again shell GNU project textual shell 19.06.2013 03.07.2013 @pvb265 #imolug
  • 6. interface of an O. S. to access Kernel services 19.06.2013 03.07.2013 @pvb265 #imolug shell bash
  • 7. . resources control . process execution 19.06.2013 03.07.2013 @pvb265 #imolug o.s. shellbash
  • 8. . process manager . memory manager . scheduler/event manager . file manager 19.06.2013 03.07.2013 @pvb265 #imolug o.s. shellbash
  • 9. . process wrapper . scheduler controll 19.06.2013 03.07.2013 @pvb265 #imolug kernel o.s.shellbash
  • 11. 19.06.2013 03.07.2013 @pvb265 #imolug kernel o.s. shell bash Desktop PC, Parallel Systems, Distribuited Systems, Clustered Systems, Real-time Systems, Embedded Systems
  • 12. 19.06.2013 03.07.2013 @pvb265 #imolug kernel o.s. shell bash Desktop PC, Parallel Systems, Distribuited Systems, Clustered Systems, Real-time Systems, Embedded Systems Monolithic, MicroKernel, Hybryd kernel, exoKernel
  • 13. 19.06.2013 03.07.2013 @pvb265 #imolug kernel o.s. shell bash Desktop PC, Parallel Systems, Distribuited Systems, Clustered Systems, Real-time Systems, Embedded Systems Monolithic, MicroKernel, noKernel, Hybryd kernel, exoKernel
  • 14. 19.06.2013 03.07.2013 @pvb265 #imolug kernel o.s. shell bash Desktop PC, Parallel Systems, Distribuited Systems, Clustered Systems, Real-time Systems, Embedded Systems Monolithic, MicroKernel, Hybrid kernel, exoKernel textual, GUI
  • 15. 19.06.2013 03.07.2013 @pvb265 #imolug kernel o.s. shell bash 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
  • 16. 19.06.2013 03.07.2013 @pvb265 #imolug shell 1970: runcom (Multics) JCL (s/390) 1975-1978: Steve Bourne, at Bell Labs wrote sh 1978-1979: Bill Joy at BSD wrote csh 1981: tcsh is a fork of csh POSIX compliance 1983: David Korn wrote ksh 1989: Brian Fox wrote bash 1990: Paul Falstad wrote zsh 1997: bash 2.0 2004: bash 3.0 2011: bash 4.2 latest (now) stable
  • 18. 19.06.2013 03.07.2013 @pvb265 #imolug bash Pick-Up a Mac OS X Box UnderWater Terminal Process bash-3.2$ ps -ef|grep Terminal ps -ef|grep Terminal 501 1636 211 0 1:55pm ?? 0:04.57 /Applications/Utilities/Terminal.app/Contents/MacOS/Terminal -psn_0_667811
  • 19. 19.06.2013 03.07.2013 @pvb265 #imolug bash Pick-Up a Mac OS X Box UnderWater Terminal Process bash-3.2$ ps -ef|grep Terminal ps -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 1636 ps -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
  • 20. 19.06.2013 03.07.2013 @pvb265 #imolug bash Pick-Up a Mac OS X Box UnderWater Terminal Process bash-3.2$ ps -ef|grep Terminal ps -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 1636 ps -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 1638 ps -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
  • 21. 19.06.2013 03.07.2013 @pvb265 #imolug bash Pick-Up a Linux Box UnderWater [root@www ~]# ps -ef|grep sshd root 3065 1 0 Feb05 ? 00:01:54 /usr/sbin/sshd root 10442 3065 0 17:15 ? 00:00:00 sshd: root@pts/0 [root@www ~]# ps -ef| grep 10442 root 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
  • 22. 19.06.2013 03.07.2013 @pvb265 #imolug bash Who said system to invoke bash UnderWater [root@www ~]# cat /etc/passwd|head -5 root:x:0:0:root:/root:/bin/bash bin:x:1:1:bin:/bin:/sbin/nologin daemon:x:2:2:daemon:/sbin:/sbin/nologin adm:x:3:4:adm:/var/adm:/sbin/nologin lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin Linux Users Definitions
  • 23. 19.06.2013 03.07.2013 @pvb265 #imolug bash Who said system to invoke bash UnderWater [root@www ~]# cat /etc/passwd|head -5 root :x :0 :0 :root :/root :/bin/bash bin :x :1 :1 :bin :/bin :/sbin/nologin daemon :x :2 :2 :daemon :/sbin :/sbin/nologin adm :x :3 :4 :adm :/var/adm :/sbin/nologin lp :x :4 :7 :lp :/var/spool/lpd :/sbin/nologin Username Password UID GID Description Home Initialprogram Linux Users Definitions
  • 24. 19.06.2013 03.07.2013 @pvb265 #imolug bash Who said system to invoke bash UnderWater [root@www ~]# cat /etc/passwd|head -5 root :x :0 :0 :root :/root :/bin/bash bin :x :1 :1 :bin :/bin :/sbin/nologin daemon :x :2 :2 :daemon :/sbin :/sbin/nologin adm :x :3 :4 :adm :/var/adm :/sbin/nologin lp :x :4 :7 :lp :/var/spool/lpd :/sbin/nologin Username Password UID GID Description Home Initialprogram [root@www ~]# grep root /etc/shadow Root: $1$LDqgrtQA$IXip/e.HuPhjSjLWXmrdj0 :15561 :0:99999:7::: Username Password Lastchanged PasswordAging Linux Users Definitions
  • 25. 19.06.2013 03.07.2013 @pvb265 #imolug bash Who said system to invoke bash UnderWater [root@www ~]# cat /etc/passwd|head -5 root :x :0 :0 :root :/root :/bin/bash bin :x :1 :1 :bin :/bin :/sbin/nologin daemon :x :2 :2 :daemon :/sbin :/sbin/nologin adm :x :3 :4 :adm :/var/adm :/sbin/nologin lp :x :4 :7 :lp :/var/spool/lpd :/sbin/nologin Username Password UID GID Description Home Initialprogram [root@www ~]# grep root /etc/shadow Root: $1$LDqgrtQA$IXip/e.HuPhjSjLWXmrdj0 :15561 :0:99999:7::: Username Password Lastchanged PasswordAging [root@www ~]# cat /etc/passwd|head -1 root:$1$LDqgrtQA$IXip/e.HuPhjSjLWXmrdj0:0:0:root:/root:/bin/bash Linux Users Definitions
  • 26. 19.06.2013 03.07.2013 @pvb265 #imolug bash Who said system to invoke bash UnderWater [root@www ~]# cat /etc/passwd|head -5 root :x :0 :0 :root :/root :/bin/bash bin :x :1 :1 :bin :/bin :/sbin/nologin daemon :x :2 :2 :daemon :/sbin :/sbin/nologin adm :x :3 :4 :adm :/var/adm :/sbin/nologin lp :x :4 :7 :lp :/var/spool/lpd :/sbin/nologin Username Password UID GID Description Home Initialprogram [root@www ~]# grep root /etc/shadow Root: $1$LDqgrtQA$IXip/e.HuPhjSjLWXmrdj0 :15561 :0:99999:7::: Username Password Lastchanged PasswordAging [root@www ~]# cat /etc/passwd|head -1 root::0:0:root:/root:/bin/bash Linux Users Definitions
  • 27. 19.06.2013 03.07.2013 @pvb265 #imolug bash Who said system to invoke bash UnderWater [root@www ~]# cat /etc/passwd|head -5 root :x :0 :0 :root :/root :/bin/bash bin :x :1 :1 :bin :/bin :/sbin/nologin daemon :x :2 :2 :daemon :/sbin :/sbin/nologin adm :x :3 :4 :adm :/var/adm :/sbin/nologin lp :x :4 :7 :lp :/var/spool/lpd :/sbin/nologin Username Password UID GID Description Home Initialprogram Linux Users Definitions
  • 28. 19.06.2013 03.07.2013 @pvb265 #imolug bash Who said system to invoke bash UnderWater [root@www ~]# cat /etc/passwd|head -5 root :x :0 :0 :root :/root :/bin/bash bin :x :1 :1 :bin :/bin :/sbin/nologin daemon :x :2 :2 :daemon :/sbin :/sbin/nologin adm :x :3 :4 :adm :/var/adm :/sbin/nologin lp :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
  • 29. 19.06.2013 03.07.2013 @pvb265 #imolug bash Who said system to invoke bash UnderWater [root@www ~]# cat /etc/passwd|head -5 root :x :0 :0 :root :/root :/bin/bash bin :x :1 :1 :bin :/bin :/sbin/nologin daemon :x :2 :2 :daemon :/sbin :/sbin/nologin adm :x :3 :4 :adm :/var/adm :/sbin/nologin lp :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
  • 30. 19.06.2013 03.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?
  • 31. 19.06.2013 03.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?
  • 32. 19.06.2013 03.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?
  • 33. 19.06.2013 03.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
  • 34. 19.06.2013 03.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 fi done
  • 35. 19.06.2013 03.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 fi done
  • 36. 19.06.2013 03.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
  • 37. 19.06.2013 03.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
  • 38. 19.06.2013 03.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 definitions if [ -f /etc/bashrc ]; then . /etc/bashrc fi
  • 39. 19.06.2013 03.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 definitions if [ -f /etc/bashrc ]; then . /etc/bashrc fi
  • 41. 19.06.2013 03.07.2013 @pvb265 #imolug bash POSIX 1003.1 standard (IEEE Std 1003.1) pazh-ics not poh-six Command Interpreter Default 4 Linux and Mac OS X Bourne Again Shell ( as rebird or another Bourne) A superset of Bourne shell Include history and directory stack from C shell Relative New concepts in the recents versions: . 3.0 regex like in perl . 4.0 hash to implement awk Overview
  • 42. 19.06.2013 03.07.2013 @pvb265 #imolug bash Overview 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
  • 43. 19.06.2013 03.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
  • 44. 19.06.2013 03.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
  • 45. 19.06.2013 03.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
  • 46. 19.06.2013 03.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
  • 47. 19.06.2013 03.07.2013 @pvb265 #imolug bash Overview [root@www ~]# ls /root/.bash +TAB+TAB .bash_history .bash_profile .bashrc [root@www ~]# mkfs +TAB+TAB mkfs 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
  • 48. 19.06.2013 03.07.2013 @pvb265 #imolug bash Overview export HISTFSIZE=10000 export HISTFILESIZE=10000 shopt -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
  • 49. 19.06.2013 03.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
  • 50. 19.06.2013 03.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
  • 51. 19.06.2013 03.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
  • 52. 19.06.2013 03.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
  • 53. 19.06.2013 03.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 ~
  • 54. 19.06.2013 03.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 -r rbash bash --restricted
  • 55. 19.06.2013 03.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 -r rbash bash --restricted vi :set shell=/bin/sh :shell ~$ rbash ~$ cd / rbash: cd: restricted ~$ bash ~$ cd / /$
  • 56. 19.06.2013 03.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 -r rbash bash --restricted vi :set shell=/bin/sh :shell ~$ rbash ~$ cd / rbash: cd: restricted ~$ bash ~$ cd / /$ rssh
  • 57. 19.06.2013 03.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 code and builtins when a job exits with a non-zero status 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...
  • 58. 19.06.2013 03.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
  • 59. 19.06.2013 03.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