env - Show All Global Variablesread commanddirs - Displays the Directory Stackpushd - Pushes a Directory onto the Stackpopd - Pops a Directory off the StackAre there any questions before I begin?
I have posted Homework 9 here.
As usual, it will be due next Sunday at 11:59 PM.
ls -l foo{21,25,29}
fg is used to bring a background job into the foregroundfgman and info./bother.sh > /dev/null &
./bother.sh & > /dev/null
$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
VARIABLE_NAME=VALUE
$ username=ghoffman $ echo $username ghoffman
$ username = ghoffman
username: command not found
$ name=Glenn Hoffman
Hoffman: command not found
$ name=Glenn\ Hoffman $ echo $name Glenn Hoffman
$ team=Boston\ Red Sox
Command 'Sox' not found
$ team='Boston Red Sox' $ echo $team Boston Red Sox
$ team="Boston Red Sox" $ echo $team Boston Red Sox
$ name='Glenn Hoffman' $ echo $name Glenn Hoffman
$ bash ghoffman@itserver6:~$ ps PID TTY TIME CMD 29566 pts/16 00:00:00 bash 29792 pts/16 00:00:00 bash 29796 pts/16 00:00:00 ps ghoffman@itserver6:~$ echo $name $
export commandexport on a variable you have already created
$ export name $ cat print_name.sh #! /bin/bash # prints the value of the variable called name echo name: $name $ ./print_name.sh name = Glenn Hoffman
export when you are defining the variable
$ export name="Glenn Hoffman"
export when defining a variable ...ex_no=18
export lncd=/courses/it244/f24/ghoffman
PATH=$PATH:/home/ghoffman/bin/shell
| Variable | Value |
|---|---|
| HOME | The absolute pathname of your home directory |
| PATH | The list of directories the shell must search to find the executable file to run a command |
| SHELL | The absolute pathname of your default shell |
| PWD | The absolute pathname off your current directory |
| 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 |
lncd=/courses/it244/f24/ghoffman
export lncd=/courses/it244/f24/ghoffman export s1cd=/courses/it116/f24/ghoffman export s2cd=/courses/it117/f24/ghoffman
env - Show All Global Variablesenv 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 ...
read commandread commandread is used to set the value of a local variable using the following format
read VARIABLE_NAME
readread with the -p option it will print a
prompt
read -p PROMPT VARIABLE_NAME
#! /bin/bash read -p "Please enter a value: " value echo $value
$ ./read_2.sh
Please enter a value: hi there
hi there
$ 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
( echo Class Notes 19; echo ; cat 19_class_notes_it244.html ) | less
lesspushdpopddirs - 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 just like cdpushd
popd - Pops a Directory off the Stackpopd changes your directory to another directorypopd
$ 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 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 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
1010101010 1010100101 1010101010 ...
MOV AL, 61h ; Load AL with 97 decimal (61 hex)
forkpid = fork()
fork causes the kernel to create a new process
fork we have two identical processpid = fork()
sleep ...execexec replaces the Bash code in process memory ...
init ...systemdgettymingettyagettyagettyssh...login to verify the passwordlogin is located in the /bin directoryexec() ...ps -f displays a full listing for each of the user's running processes
$ 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$ 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
is my login shell
pstree will display a tree of all currently running processespstree on
pe15 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 optionpstree will show each process along with its process ID
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)
pstree