dirs - Displays the Directory Stackpushd - Pushes a Directory onto the Stackpopd - Pops a Directory off the StackI have posted Homework 9 here.
As usual, it will be due next Sunday at 11:59 PM.
I have posted the answers to Quiz 6 here.
fg is used to bring a background job into the foregroundfgman ...info$ echo Here are the contents of my home directory ; ls ; echo Here are the contents of my home directory bin course_files it116 it244 mail submitted tmp code html it116_test it244_test public_html tests_taken xrchiv
$ ./bother.sh > /dev/null & ./bother.sh > /dev/null & ./bother.sh > /dev/null & jobs [1] 1794 [2] 1795 [3] 1796 [1] Running ./bother.sh > /dev/null & [2]- Running ./bother.sh > /dev/null & [3]+ Running ./bother.sh > /dev/null &
$ echo A man \ > A plan \ > A canal \ > Panama A man A plan A canal Panama
( cd ~/bar ; tar-xvf - )
dirs - Displays the Directory Stackdirs displays the current contents of the directory stackdirs displays the current directory
$pwd
~/it244/hw5
$ dirs
~/it244/hw5
pushd - Pushes a Directory onto the Stackpushd changes your current directory ...cd ...pushd
popd - Pops a Directory off the Stackpopd changes your directory to another directorypopd
$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
VARIABLE_NAME=VALUE
$ city=Boston $ echo $city Boston
$ hello="Hello there" $ echo $hello Hello there
export command
$ echo $foo
FOO
$ export foo=BLETCH
$ echo $foo
BLETCH
$ ./print_foo.sh
foo = BLETCH
env command, when used without an argument ...$ env TERM=xterm-color SHELL=/bin/bash SSH_CLIENT=66.92.76.9 53785 22 OLDPWD=/home/it244gh SSH_TTY=/dev/pts/8 USER=it244gh ...
Variable Value HOME The absolute pathname of your home directory PATH The list of directories the shell will search when looking for the executable file associated with a command you entered at the command line SHELL The absolute pathname of your default shell PS1 Your command line prompt - what you see after entering each command PS2 The secondary prompt - what you see if you continue a command to a second line
$ foo=FOO $ echo $foo FOO
$ ls bar.txt bar.txt $ echo $? 0 $ ls xxx ls: cannot access xxx: No such file or directory $ echo $? 2
$ cat print_positionals.sh #!/bin/bash # # Prints the value of the first four positional arguments echo echo 0: $0 echo 1: $1 echo 2: $2 echo 3: $3 $ ./print_positionals.sh foo bar bletch 0: ./print_positionals.sh 1: foo 2: bar 3: bletch
$ cat print_arg_numbers.sh #!/bin/bash # # Prints the number of arguments sent to this script echo echo This script received $# arguments $ ./print_arg_numbers.sh foo bar bletch This script received 3 arguments
$ team="Red Sox' echo $team Red Sox $ cheer='Go $team' $ echo $cheer Go $team
$ cheer="Go $team" $ echo $cheer Go Red Sox
$ foo=bar $ echo $foo bar $ foo3=\$foo $ echo $foo3 $foo
unset command
$ echo $foo
FOO
$ unset foo
$ echo $foo
$
$ echo $foo
FOO
$ foo=
$ echo $foo
$
export ...
$ export foo=FOO
readonly command
$ echo $foo FOO $ readonly foo $ foo=bar -bash: foo: readonly variable
declare command ...declare
Option Meaning a Declares a variable to be an array f Declares a variable to be a function name i Declares a variable to be an integer r Makes a variable read only x Makes a variable global
$ foo=bar $ echo $foo bar $ foo=bletch $ echo $foo bletch $ declare -r foo $ foo=bling -bash: foo: readonly variable
declare -rexport is a built-in too ...declare -xfork()exec()sleepinit ...systemdgettymingettyagettyagettylogin ...exec() is called ...ps -f displays a full listing of information about each process running ...$ ps -f UID PID PPID C STIME TTY TIME CMD it244gh 26374 26373 0 13:41 pts/5 00:00:00 -bash it244gh 27891 26374 0 13:57 pts/5 00:00:00 ps -f
sleep in the background ...ps -f, I would see
$ sleep 10 & ps -f [1] 27352 UID PID PPID C STIME TTY TIME CMD ghoffman 27292 27287 0 15:12 pts/1 00:00:00 -bash ghoffman 27352 27292 0 15:13 pts/1 00:00:00 sleep 10 ghoffman 27353 27292 0 15:13 pts/1 00:00:00 ps -f
sleep and ps -f ...pstree will display a tree of all currently running processespstree on
users3 I can see the process structure
systemd─┬─accounts-daemon─┬─{gdbus}
│ └─{gmain}
├─acpid
├─agetty
├─atd
├─automount───10*[{automount}]
├─bash
├─bother.sh───sleep
├─cron
├─cups-browsed─┬─{gdbus}
│ └─{gmain}
├─dbus-daemon
├─dhclient
├─irqbalance
├─2*[iscsid]
├─lvmetad
├─lxcfs───4*[{lxcfs}]
├─master─┬─pickup
│ └─qmgr
├─mdadm
├─ntpd
├─polkitd─┬─{gdbus}
│ └─{gmain}
├─rpc.statd
├─rpcbind
├─rsyslogd─┬─{in:imklog}
│ ├─{in:imuxsock}
│ └─{rs:main Q:Reg}
├─rwhod───rwhod
├─screen───bash
├─screen───bash───vim
├─snapd───7*[{snapd}]
├─sshd─┬─3*[sshd───sshd───bash───alpine]
│ ├─2*[sshd───sshd───bash]
│ ├─sshd───sshd───bash───pstree
│ └─sshd───sshd───bash───ssh
├─10*[systemd───(sd-pam)]
├─systemd-journal
├─systemd-logind
├─systemd-udevd
└─ypbind───2*[{ypbind}]
pstree with the -p option ...
systemd(1)─┬─accounts-daemon(2099)─┬─{gdbus}(2136)
│ └─{gmain}(2134)
├─acpid(2076)
├─agetty(2481)
├─atd(2103)
├─automount(42937)─┬─{automount}(42938)
│ ├─{automount}(42939)
│ ├─{automount}(42942)
│ ├─{automount}(42945)
│ ├─{automount}(42946)
│ ├─{automount}(42947)
│ ├─{automount}(42948)
│ ├─{automount}(42949)
│ ├─{automount}(42950)
│ └─{automount}(42951)
├─bash(27573)
├─bother.sh(16996)───sleep(47645)
├─cron(2087)
├─cups-browsed(40751)─┬─{gdbus}(40833)
│ └─{gmain}(40832)
├─dbus-daemon(2089)
├─dhclient(2246)
├─irqbalance(2465)
├─iscsid(2355)
├─iscsid(2356)
├─lvmetad(1199)
├─lxcfs(2101)─┬─{lxcfs}(2126)
│ ├─{lxcfs}(2127)
│ ├─{lxcfs}(3081)
│ └─{lxcfs}(29814)
├─master(21825)─┬─pickup(44495)
│ └─qmgr(31008)
├─mdadm(2148)
├─ntpd(2507)
├─polkitd(2164)─┬─{gdbus}(2180)
│ └─{gmain}(2178)
├─rpc.statd(2782)
├─rpcbind(2053)
├─rsyslogd(2071)─┬─{in:imklog}(2132)
│ ├─{in:imuxsock}(2131)
│ └─{rs:main Q:Reg}(2133)
├─rwhod(2449)───rwhod(2450)
├─screen(19504)───bash(19505)
├─screen(20288)───bash(20289)───vim(21881)
├─snapd(2056)─┬─{snapd}(2118)
│ ├─{snapd}(2119)
│ ├─{snapd}(2120)
│ ├─{snapd}(2121)
│ ├─{snapd}(2150)
│ ├─{snapd}(2151)
│ └─{snapd}(2152)
├─sshd(2341)─┬─sshd(3104)───sshd(3160)───bash(3161)───alpine(8255)
│ ├─sshd(4288)───sshd(4347)───bash(4348)───alpine(4354)
│ ├─sshd(15840)───sshd(15919)───bash(15926)
│ ├─sshd(40522)───sshd(40572)───bash(40588)
│ ├─sshd(41273)───sshd(41339)───bash(41346)───alpine(41362)
│ ├─sshd(46574)───sshd(46658)───bash(46665)───pstree(47648)
│ └─sshd(48106)───sshd(48199)───bash(48200)───ssh(48213)
├─systemd(2874)───(sd-pam)(2878)
├─systemd(10316)───(sd-pam)(10320)
├─systemd(15847)───(sd-pam)(15860)
├─systemd(48118)───(sd-pam)(48124)
├─systemd(46589)───(sd-pam)(46600)
├─systemd(41295)───(sd-pam)(41303)
├─systemd(27537)───(sd-pam)(27542)
├─systemd(17838)───(sd-pam)(17842)
├─systemd(14978)───(sd-pam)(14983)
├─systemd(20176)───(sd-pam)(20181)
├─systemd-journal(1164)
├─systemd-logind(2095)
├─systemd-udevd(1207)
└─ypbind(2476)─┬─{ypbind}(2477)
└─{ypbind}(2478)
pstreet