CIS 90 - Lesson 3
Lesson Module Checklist • Slides • WB
• Flash cards • Properties • Page numbers • 1st minute quiz • Web Calendar summary • Web book pages • Commands
• Lab tested • MSDNAA accounts made • VMware AA accounts made • CIS Lab schedule published • Census done • cis90-students alias in /etc/aliases + newaliases command
• Welcome ready for mailing • Historical events ready for mailing
• 9V backup battery for microphone • Backup slides, CCC info, handouts on flash drive 1 CIS 90 - Lesson 3
Instructor: Rich Simms Dial-in: 888-450-4821 Passcode: 761867 Aaron Andrew B. Andrew C. Arthur Brian Cory
Daniel David G. Dave L. David P. Debbie Edtson Fidel Humberto Hunter Imara
Ismael Jessica Joseph Juliana Lucie Marc Marty Matt Michael Rochelle
Shawn Tabitha Taylor Tyler Will Zachary Zsolt
Email me ([email protected]) a relatively current photo of your face for 3 points extra credit CIS 90 - Lesson 3 Introductions and Credits
Jim Griffin • Created this Linux course • Created Opus and the CIS VLab • Jim’s site: http://cabrillo.edu/~jgriffin/
Rich Simms • HP Alumnus • Started teaching this course in 2008 when Jim went on sabbatical • Rich’s site: http://simms-teach.com
And thanks to: • John Govsky for many teaching best practices: e.g. the First Minute quizzes, the online forum, and the point grading system (http://teacherjohn.com/) 3 CIS 90 - Lesson 3
[ ] Preload White Board with cis*lesson??*-WB
[ ] Connect session to Teleconference
Session now connected to teleconference
[ ] Is recording on?
Red dot means recording
[ ] Use teleconferencing, not mic 4 Should be greyed out CIS 90 - Lesson 3
[ ] Video (webcam) optional [ ] layout and share apps
[ ] Share Foxit, Putty, and Chrome
foxit for slides chrome
vSphere Client putty
5 CIS 90 - Lesson 3
[ ] Video (webcam) optional [ ] Follow moderator [ ] Double-click on postages stamps
6 CIS 90 - Lesson 3
Universal Fix for CCC Confer:
1) Shrink (500 MB) and delete Java cache 2) Uninstall and reinstall latest Java runtime
Control Panel (small icons) General Tab > Settings… 500MB cache size Delete these
Google Java download
7 CIS 90 - Lesson 3 First Minute Quiz Please answer these questions in the order shown:
1. What is the command to print the manual page for a command?
2. How do you show your path?
3. Name four directories where one can find commands?
email answers to: [email protected]
(answers must be emailed within the first few minutes of class for credit)
8 CIS 90 - Lesson 3 Electronic Mail
Objectives Agenda • Learn how to use the UNIX • Quiz communication tools write and mail. • Questions from last week • Overview on end-to-end email. • Mini review
• Housekeeping
• Write • Basic Mail • More on Mail • End-to-end email • Other MUAs, MTAs, DA and AAs • Wrap up
9 CIS 90 - Lesson 3
Class Activity
If you haven’t already, log into Opus
10 CIS 90 - Lesson 3
Questions
11 CIS 90 - Lesson 3 Questions
How this course works?
Previous lessons
Previous labs?
他問一個問題,五分鐘是個傻子,他不問一個問題仍然是一個 Chinese 傻瓜永遠。 Proverb He who asks a question is a fool for five minutes; he who does not ask a question remains a fool forever.
12 CIS 90 - Lesson 3
Lab 1 Results (xx times answered incorrectly)
1 X "1) What is your shell prompt on Doc?" 0 "2) What is your shell prompt on Opus?" 0 "3) What is your shell prompt on your assigned Arwen system?" 0 "4) What distro has been installed on Catalina?" 1 X "5) Log into Catalina and Thabiti as cis90. Are your uid numbers the same on both?" 9 XXXXXXXXX "6) Which shell program are your running on your Arwen system?" 2 XX "7) On Catalina, which remote system did Juliet log in from?" 2 XX "8) On Doc, what is the output from the hostname command?" 2 XX "9) Log in twice into Opus. Does exiting one session exit you from the other session?" 3 XXX "10) Log in twice into your Arwen. What is the output of the tty command in each session?" 5 XXXXX "11) Stay logged twice into your Arwen. How are your two sessions distinguished in the who output?" 1 X "12) What is the name of the kernel running on Doc?" 11 XXXXXXXXXXX "13) Log into the system named Thabiti, is Linux or UNIX installed?" 14 XXXXXXXXXXXXXX "14) Log in as cis90 to the system whose name is the answer to Q7. What shell is running?" 17 XXXXXXXXXXXXXXXXX "15) What does the tty command output on your Arwen's tty5 virtual console?"
7 XXXXXXX *** NO SUBMITTAL ***
14 CIS 90 - Lesson 3
6) Which shell program are your running on your Arwen system?
Use the ps command to print your processes
This list shows two processes. The first is the bash shell and the second is the ps command
The answer is: bash
16 CIS 90 - Lesson 3
11) Stay logged twice into your Arwen. How are your two sessions distinguished in the who output?"
The answer is: They are distinguished by the terminal device used, e.g. pts/0 vs pts/1 17 CIS 90 - Lesson 3
13) Log into the system named Thabiti, is Linux or UNIX installed?
Use uname to show the name of the kernel, google the name of the kernel if it's not Linux
The answer is: UNIX 18 CIS 90 - Lesson 3
7) On Catalina, which remote system did Juliet log in from?
14) Log in as cis90 to the system whose name is the answer to Q7. What shell is running?
On Catalina use who to see that Juliet logged in from Razia. Log into Razia and use the ps command to see the name of the shell
The answer is: sh
Many shell programs have been written for UNIX/Linux. sh was the original shell written by Stephen Bourne at ATT, the csh ("C shell") was written by Bill Joy at UC Berkeley, the bash ("Bourne"-Again Shell) was written by Brian Fox for the GNU project. We will use bash in CIS 90. 19 CIS 90 - Lesson 3
15) What does the tty command output on your Arwen's tty5 virtual console?
1) Log into VLab
2) Open a console for your Arwen 3) Change to Virtual terminal tty5
The answer is: /dev/tty5 20 CIS 90 - Lesson 3
For those who didn't submit Lab 1
If you would like some help getting started, come see us in the CIS Lab.
Leandro and Geoffrey are both CIS 90 Alumni. Michael teaches the Linux System Administration class (CIS 191). 21 CIS 90 - Lesson 3
Housekeeping
22 CIS 90 - Lesson 3
Lab 2 due tonight
• Use history -a before using submit.
If you neglect to do this the history snapshot you send me to grade will not have the latest commands you issued.
• Submit as many times as you wish up to 11:59PM
• You can optionally use the verify command to see what you submitted for grading.
To grade, I will check your history to see if you used all the commands asked for in Lab 2 as well as your answers to the three questions.
23 CIS 90 - Lesson 3
Lord of the Rings Code Names http://simms-teach.com/cis90grades.php
Your grade code names are now available. Send me your survey to get your code name.
24 CIS 90 - Lesson 3 Review your graded lab work ls cat lab01.graded
Use the ls command to list the files in your home directory
Use the cat command to show your graded work
25 CIS 90 - Lesson 3
Review the correct answers for a lab
cat /home/cis90/answers/lab01
The answers to quizzes, tests and labs will be posted to the /home/cis90/answers directory after the due date has passed. 26 CIS 90 - Lesson 3
Review the correct answers for a quiz
cat /home/cis90/answers/quiz01
The answers to quizzes, tests and labs will be posted to the /home/cis90/answers directory after the due date has passed. 27 CIS 90 - Lesson 3
Extra Credit
Note the caps on extra credit.
28 CIS 90 - Lesson 3
Extra Credit Howtos
If you have a strong interest in a topic write a Howto on it to share what you've learned and earn some extra credit at the same time 29 CIS 90 - Lesson 3
Software for CIS students
How to obtain Microsoft and VMware software for academic use
30 CIS 90 - Lesson 3 MSDN for CIS Students
Accounts for students enrolled in CIS 90 have been created using your WebAdvisor email addresses.
Link is on website Resources page in Tools and Software section
Happy downloading!
31 CIS 90 - Lesson 3 VMware Software for CIS Students
Accounts for students enrolled in CIS 90 have been created using your WebAdvisor email addresses.
Link is on website Resources page in Tools and Software section
Happy downloading!
32 CIS 90 - Lesson 3
• Don't forget to register on the forum
• Next week is the 1st five post deadline! (worth 20 points)
• Only your posts in the CIS 90 forum will earn points
• Make sure your username is your full first and last name, separated by a space, so you get credit for your posts
• Be nice and stay on topic with your posts!
Email the instructor for username changes or login issues
33 CIS 90 - Lesson 3
Subtle Stuff
34 CIS 90 - Lesson 3
Putty to: [email protected] Opus (a RHEL server) vs oslab.cis.cabrillo.edu
If you specify the username in Putty you won't be prompted for it, just the password.
If you specify only the hostname in Putty you get prompted for both username and password.
Tip: Use the Putty “Saved Sessions” for your Opus connection. Then you don’t have to type in the username, hostname and port number each time you connect to Opus. 36 CIS 90 - Lesson 3
ssh thabiti vs ssh cis90@thabiti
Opus (a RHEL server)
Benji is logged in as simben90 on Opus uses ssh command to log into Thabiti
Benji is logged in as simben90 on Opus uses ssh command to log into Thabiti
If you don't specify the username on the ssh command it will use the username you are currently logged in as. This account may not exist on the remote system! 37 CIS 90 - Lesson 3 type and man caveats
Usually, to find the location of a command on your path, use the type command:
/home/cis90/simben $ type hostname hostname is /bin/hostname
The hostname program file is in the /bin directory
38 CIS 90 - Lesson 3 type and man caveats
Usually, to find the manual page for a command, use the man command:
/home/cis90/simben $ man hostname
39 CIS 90 - Lesson 3 Command Review
However, sometimes you may get something different than expected with the type and man commands
40 CIS 90 - Lesson 3 type and man caveats
Note, using type on ls, /home/cis90/simmsben $ type ls without the -a option, will not ls is aliased to `ls --color=tty‘ display the location of the ls program file on the path!
/home/cis90/simmsben $ type -a ls ls is aliased to `ls --color=tty' To see the location on ls is /bin/ls the path use the -a option The ls program file resides in the /bin directory
The ls command is aliased, use the -a option on the type command to find where the command resides on the path
41 CIS 90 - Lesson 3 type and man caveats
/home/cis90/simben $ type history The history command is history is a shell builtin built into the shell and does not have its own program file /home/cis90/simben $ man history
The history command does not have its own man page either!
… but it is included in the man page for bash builtins
42 CIS 90 - Lesson 3
Mini Review
43 CIS 90 - Lesson 3
Expectation Check Commands you should understand and be comfortable using
Lesson/Lab 1 Lesson/Lab 2 Files & Files & Directories Commands Directories Commands
cal /etc/issue apropos /bin clear /etc/*-release banner /usr/bin date bash /sbin exit bc /usr/sbin history cat /etc/passwd hostname cd /etc/shadow id echo ps env ssh file uname finger tty info who file who am i ls passwd set type man whatis If you have any questions on these commands, ask your instructor or post a question on the forum! 44 CIS 90 - Lesson 3
Expectation Check Skills you should be comfortable performing
• Navigating the course website: simms-teach.com • Entering the CCC Confer Virtual Classroom • Reviewing Lesson video archives • Downloading and searching lessons PDFs • Checking your current grade status • Checking when assignments are due • Checking when quizzes and tests will be held • Checking your graded labs against correct answers
• Logging into Opus from home or school using SSH • Logging into Arwen or other VMs from Opus using SSH • Using Arwen's graphical desktop via VLab • Changing Virtual (TTY) Terminals on Arwen
• Parsing any shell command • Getting documentation on any command • Identify the four key components of the UNIX/Linux architecture • Identify the six steps the shell does for every command • Temporarily change your shell prompt • Set and show values of shell variables
If you have any questions on these skills, ask your instructor or post a question on the forum! 45 CIS 90 - Lesson 3 Key components of the Linux/UNIX architecture
Users interact with the shell to run commands
Shell
Commands such as ls, cal, System Web servers, file servers, Applications date, tty, id, who, etc. Commands word processors, etc.
Kernel
The kernel manages processes, memory, file system, and the network stack and interacts with all the hardware components 46 CIS 90 - Lesson 3 Environment Variables Names and Values
Use $ for the “value” of a variable
Analogy: Each variable is a named location. The contents of any location is the “value” of that variable.
$ echo $LOGNAME simmsben
$ echo HOME HOME
$ echo $HOME /home/cis90/simmsben
$ echo $SHELL /bin/bash
$ echo $HOSTNAME opus.cabrillo.edu 48 CIS 90 - Lesson 3 Variable Names and Values Analogy: knobs and settings
Users can create their own variables, lets make a new one called FAN
$ echo $FAN HI
FAN $ FAN=HI $ echo $FAN HI $ echo "The fan is set to: " $FAN The fan is set to: HI $ FAN=LO $ echo "The fan is set to: " $FAN The fan is set to: LO
49 CIS 90 - Lesson 3
Shell review
51 CIS 90 - Lesson 3
The Shell
• Allows users to interact with the computer via a “command line”.
• Prompts for a command, parses the command, finds the right program and Shell gets that program executed.
• Is called a “shell” because it hides the OS System underlying operating system. Applications Commands • Multiple shell programs are available: sh (Bourne shell), bash ("bourne- again" shell), csh (C shell), ksh (Korn shell). Kernel • The shell is a user interface and a programming language (scripts).
• GNOME and KDE desktops could be called graphical shells
52 CIS 90 - Lesson 3
OS The six steps of the Shell
1) Prompt
Shell 2) Parse 3) Search System Applications Commands 4) Execute
Kernel 5) Nap 6) Repeat
53 CIS 90 - Lesson 3 Command Syntax Shell prints this to prompt user to enter a command Shell parses this command line
Prompt Command Options Arguments Redirection
Options modify the Examples behavior of the command /home/cis90/simben $ Arguments are what the /home/cis90/simben $ ls command works upon /home/cis90/simben $ ls -l Redirection is /home/cis90/simben $ ls -l -t covered later in /home/cis90/simben $ ls -li Poems/ the course /home/cis90/simben $ ls -a Poems/ bin/ /home/cis90/simben $ ls -d Poems/ bin/ > mylist
Spaces (blanks) are used to separate the command, options and arguments. Additional blanks are ignored. 54 CIS 90 - Lesson 3 Life of the Shell
Example:
/home/cis90/simben $ ls -lt proposal1 proposal2 -rw-r--r--. 1 simben90 cis90 1074 Aug 26 2003 proposal1 -rw-r--r--. 1 simben90 cis90 2175 Jul 20 2001 proposal2 /home/cis90/simben $
Shell Steps Lets take a deep dive into how a command 1) Prompt 2) Parse gets executed. 3) Search 4) Execute 5) Nap Note it is always a team effort by both 6) Repeat the shell and the command.
55 CIS 90 - Lesson 3
Shell Steps Life of the Shell 1) Prompt 2) Parse 3) Search 4) Execute 5) Nap 1) Prompt user for a command 6) Repeat
The shell begins by outputting the prompt Example: (which is based on the PS1 variable)
/home/cis90/simben $ ls -lt proposal1 proposal2
Then you type the command
FYI, you can mimic outputting the prompt yourself with these commands:
/home/cis90/simben $ echo $PS1 to show value of PS1 variable
$PWD $ echo the output of the /home/cis90/simben $ echo $PWD $ previous command /home/cis90/simben $ was output by the echo command above /home/cis90/simben $ echo my prompt is: $PWD $ my prompt is: /home/cis90/simben $ 56 CIS 90 - Lesson 3
Shell Steps Life of the Shell 1) Prompt 2) Parse 3) Search 4) Execute 5) Nap 2) Parse command user typed 6) Repeat
Example: The shell uses the command syntax rules to break down the ls -lt proposal1 proposal2 command line into options, arguments and redirection.
• Command = ls Parsing includes expanding variables and properly any • 2 Options = l, t handling metacharacters. • 2 Arguments = proposal1, proposal2 • Redirection = NA
The shell doesn't actually distinguish between options and arguments. To the shell it is just another argument comprised of a string of text separated by blanks. We will distinguish between options and arguments to better understand command syntax and how it controls what commands do. 57 CIS 90 - Lesson 3
Shell Steps Life of the Shell 1) Prompt 2) Parse 3) Search 4) Execute 5) Nap 3) Search for program on the path 6) Repeat ls -lt proposal1 proposal2
Use this command to see the path directories (separated by :’s) on your path /home/cis90/simben $ echo $PATH /usr/lib/qt-3.3/bin:/usr/local/bin:/bin:/usr/bin: /usr/local/sbin:/usr/sbin:/sbin: /home/cis90/simben/../bin:/home/cis90/simben/bin:.
The shell will search each directory in order for an ls command /usr/lib/qt-3.3/bin no /usr/local/bin no /bin YES! - it was found in the /bin directory /usr/bin /usr/local/sbin /usr/sbin Try mimicking what the shell does to search for ls: /sbin /home/cis90/simben $ ls /usr/lib/qt-3.3/bin/ls ls: cannot access /usr/lib/qt-3.3/bin/ls: No /home/cis90/simben/../bin such file or directory /home/cis90/simben/bin . /home/cis90/simben $ ls /usr/local/bin/ls ls: cannot access /usr/local/bin/ls: No such file or directory
/home/cis90/simben $ ls /bin/ls /bin/ls 58 CIS 90 - Lesson 3
Shell Steps Life of the Shell 1) Prompt 2) Parse 3) Search 4) Execute 5) Nap 4) Execute the command 6) Repeat
ls -lt proposal1 proposal2 Invokes the kernel to load the program into memory (which becomes a process), passes along any parsed options & expanded arguments, hooks up any redirection requests then goes to sleep till the new process has finished Options: -lt Args: proposal1, proposal 2
1 0 ls 2
file information Read file type, permissions, owner, size, links, etc. information from the kernel
59 CIS 90 - Lesson 3
Shell Steps Life of the Shell 1) Prompt 2) Parse 3) Search 4) Execute 5) Nap 5) Nap while the command 6) Repeat (process) runs to completion
(The shell, itself a loaded process, goes into the sleep state and waits till the command process is finished)
/home/cis90/simben $ ls -lt proposal1 proposal2 -rw-r--r--. 1 simben90 cis90 1074 Aug 26 2003 proposal1 -rw-r--r--. 1 simben90 cis90 2175 Jul 20 2001 proposal2
60 CIS 90 - Lesson 3
Shell Steps Life of the Shell 1) Prompt 2) Parse 3) Search 4) Execute 5) Nap 6) And do it all over 6) Repeat again … go to step 1
61 CIS 90 - Lesson 3
Activity
/home/cis90/simben $ weather=rain /home/cis90/simben $ country=Spain /home/cis90/simben $ location="the plain" /home/cis90/simben $ echo The $weather in $country stays mainly in $location The rain in Spain stays mainly in the plain /home/cis90/simben $
When echo is loaded into memory and starts to run:
1) How many arguments does it receive from the bash shell?
2) Does echo see "$weather" or "rain" as one of the arguments it receives?
62 CIS 90 - Lesson 3 Inputs to commands
review
63 CIS 90 - Lesson 3
Program Inputs to commands (a file on the hard drive) console screen stdout (default)
Command line (parsed by shell): Options: … Commands can Args: … get input from: Command line Keyboard 1 Operating System 0 2
console keyboard read write (default) Operating System console screen Information available only from (default) Keyboard stdin the OS. E.g. files, directories, Additional data date & time, process info, user stderr command needs info, tty info etc. from user. E.g. passwords, math expressions, … 64 CIS 90 - Lesson 3
echo gets input from the command line /home/cis90/simben $ echo I am $LOGNAME I am simben90 stdout The echo command gets its input from the command line.
Note: echo never saw the Options: NA $LOGNAME" typed by the user. Args: I, am, simben90 bash expanded this before passing it to the echo command 1 0 echo 2
stdin stderr
stdin and stderr were never used for this command 65 CIS 90 - Lesson 3
This ls command got input from the OS /home/cis90/simmsben $ ls Poems/ ant Blake nursery Shakespeare twister Yeats stdout
In this example, the ls Options: NA command gets input from the Args: Poems/ ant Blake command line and the nursery operating system Shakespeare 1 twister 0 ls Yeats 2
read directory contents ant Blake nursery Shakespeare twister stdin Yeats (This file information stderr comes from the kernel)
stdin and stderr were never used for this command 66 CIS 90 - Lesson 3 This bc command gets input from the keyboard [rsimms@nosmo ~]$ bc
In this example, the bc Options: NA command gets input only from 4 the keyboard Args: NA
1 0 bc 2
2+2 stdin stderr
stderr was never used for this command 67 CIS 90 - Lesson 3 Practice Test Questions
68 CIS 90 - Lesson 3 Practice Test Questions
What is simben90's uid (user ID) on Opus?
Benji's uid is 1001
/home/cis90/simben $ id simben90 uid=1001(simben90) gid=190(cis90) groups=190(cis90),100(users) /home/cis90/simben $
69 CIS 90 - Lesson 3 Practice Test Questions
What is simben90's uid (user ID) on Opus?
Benji's uid is 1001
/home/cis90/simben $ id simben90 uid=1001(simben90) gid=190(cis90) groups=190(cis90),100(users) /home/cis90/simben $
70 CIS 90 - Lesson 3 Practice Test Questions
What day of the week was Sept 11, 2001?
It was a Tuesday
/home/cis90/simben $ cal 9 2001 September 2001 Su Mo Tu We Th Fr Sa 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 /home/cis90/simben $
71 CIS 90 - Lesson 3 Practice Test Questions
What day of the week was Sept 11, 2001?
It was a Tuesday
/home/cis90/simben $ cal 9 2001 September 2001 Su Mo Tu We Th Fr Sa 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 /home/cis90/simben $
72 CIS 90 - Lesson 3 Practice Test Questions
Where (what directory) does the program file for the ps command reside?
/home/cis90/simben $ type ps ps is /bin/ps
It's in the /bin directory
73 CIS 90 - Lesson 3 Practice Test Questions
Where (what directory) does the program file for the ps command reside?
/home/cis90/simben $ type ps ps is /bin/ps
It's in the /bin directory
74 CIS 90 - Lesson 3 Practice Test Questions
Parse the following command line. What is the command? How many options and how many arguments are there? What are the options and arguments? ls -l /boot/grub/
Command: ls
One option: -l (for long listing)
One argument: /boot/grub (the file named grub in the /boot directory)
75 CIS 90 - Lesson 3 Practice Test Questions
Parse the following command line. What is the command? How many options and how many arguments are there? What are the options and arguments? ls -l /boot/grub/
Command: ls
One option: -l (for long listing)
One argument: /boot/grub
76 CIS 90 - Lesson 3 Practice Test Questions
Parse the following command line. What is the command? How many options and how many arguments are there? What are the options and arguments? echo "1 2 3" four 5 six
Command: echo
No options
4 arguments: • "1 2 3" • four • 5 • six
77 CIS 90 - Lesson 3 Practice Test Questions
Parse the following command line. What is the command? How many options and how many arguments are there? What are the options and arguments? echo "1 2 3" four 5 six
Command: echo
No options
4 arguments: • "1 2 3" • four • 5 • six
78 CIS 90 - Lesson 3 Practice Test Questions
Which program gave you this error message?
/home/cis90/simben $ uname-x -bash: uname-x: command not found /home/cis90/simben $ It was the bash program. bash is the shell we are using and it could not find a command named typo on the path
79 CIS 90 - Lesson 3 Practice Test Questions
Which program gave you this error message?
/home/cis90/simben $ uname-x -bash: uname-x: command not found /home/cis90/simben $
It was the bash program. bash is the shell we are using and it could not find a command named typo on the path
80 CIS 90 - Lesson 3 Practice Test Questions
Which program gave you this error message?
/home/cis90/simben $ uname -x uname: invalid option -- 'x' Try `uname --help' for more information. /home/cis90/simben $ It was the uname program. The uname program was loaded into memory. It started to handle its options and discovered an unknown option. It printed the error message and aborted.
81 CIS 90 - Lesson 3 Practice Test Questions
Which program gave you this error message?
/home/cis90/simben $ uname -x uname: invalid option -- 'x' Try `uname --help' for more information. /home/cis90/simben $
It was the uname program. The uname program was loaded into memory. It started to handle its options and discovered an unknown option. It printed the error message and aborted.
82 CIS 90 - Lesson 3 Practice Test Questions
What terminal device are you using?
Use the tty command to find out:
/home/cis90ol/simmsben $ tty /dev/pts/2 /home/cis90ol/simmsben $
83 CIS 90 - Lesson 3 Practice Test Questions
What terminal device are you using?
Use the tty command to find out:
/home/cis90/simben $ tty /dev/pts/0 /home/cis90/simben $
84 CIS 90 - Lesson 3 Practice Test Questions
What type of terminal are you using?
Use the echo $TERM command to find out:
/home/cis90/simben $ echo $TERM xterm This user’s terminal type is xterm
85 CIS 90 - Lesson 3 Practice Test Questions
What type of terminal are you using?
Use the echo $TERM command to find out:
/home/cis90/simben $ echo $TERM xterm This user’s terminal type is xterm
86 CIS 90 - Lesson 3 Practice Test Questions
What directories make up your path?
Use echo $PATH to find out:
/home/cis90/simben $ echo $PATH /usr/lib/qt-3.3/bin:/usr/local/bin:/bin:/usr/bin: /usr/local/sbin:/usr/sbin:/sbin:/home/cis90/simben/../bin: /home/cis90/simben/bin:.
/usr/lib/qt-3.3/bin /usr/local/bin /bin /usr/bin /usr/local/sbin There are 10 directories specified on /usr/sbin this user’s path /sbin /home/cis90/simben/../bin /home/cis90/simben/bin .
87 CIS 90 - Lesson 3 Practice Test Questions
What directories make up your path?
Use echo $PATH to find out:
/home/cis90/simben $ echo $PATH /usr/lib/qt-3.3/bin:/usr/local/bin:/bin:/usr/bin: /usr/local/sbin:/usr/sbin:/sbin:/home/cis90/simben/../bin: /home/cis90/simben/bin:.
/usr/lib/qt-3.3/bin /usr/local/bin /bin /usr/bin /usr/local/sbin There are 10 directories specified on /usr/sbin this user’s path /sbin /home/cis90/simben/../bin /home/cis90/simben/bin .
88 CIS 90 - Lesson 3 Practice Test Questions
Are the yum, useradd, and yell commands on your path?
/home/cis90/simben $ type yum Yes, on path yum is /usr/bin/yum
/home/cis90/simben $ type useradd Yes, on path useradd is hashed (/usr/sbin/useradd)
/home/cis90/simben $ type yell No, not on path -bash: type: yell: not found /home/cis90/simben $
Note: “is hashed” means bash has previously searched the path and run this command. The location of the command has been saved in the hash table to speed up subsequent searches.
89 CIS 90 - Lesson 3 Practice Test Questions
Are the yum, useradd, and yell commands on your path?
/home/cis90/simben $ type yum Yes, on path yum is /usr/bin/yum
/home/cis90/simben $ type useradd Yes, on path useradd is hashed (/usr/sbin/useradd)
/home/cis90/simben $ type yell No, not on path -bash: type: yell: not found /home/cis90/simben $
Note: “is hashed” means bash has previously searched the path and run this command. The location of the command has been saved in the hash table to speed up subsequent searches.
90 CIS 90 - Lesson 3 Practice Test Questions
Knowing the steps the shell performs, which of the two processes shown below is “taking a nap”? Shell’s steps /home/cis90/simben $ ps 1) Prompt PID TTY TIME CMD 2) Parse 21559 pts/0 00:00:00 bash 3) Search 22012 pts/0 00:00:00 ps 4) Execute 5) Nap 6) Repeat bash (the shell) is sleeping while the ps command runs
/home/cis90/simben $ ps -l F S UID PID PPID C PRI NI ADDR SZ WCHAN TTY TIME CMD 0 S 1001 21559 21558 0 80 0 - 1275 - pts/0 00:00:00 bash 0 R 1001 22013 21559 0 80 0 - 1213 - pts/0 00:00:00 ps
Status column, R=running, S=sleeping
91 CIS 90 - Lesson 3 Practice Test Questions
Knowing the steps the shell performs, which of the two processes shown below is “taking a nap”? Shell’s steps /home/cis90/simben $ ps 1) Prompt PID TTY TIME CMD 2) Parse 21559 pts/0 00:00:00 bash 3) Search 22012 pts/0 00:00:00 ps 4) Execute 5) Nap 6) Repeat bash (the shell) is sleeping while the ps command runs
/home/cis90/simben $ ps -l F S UID PID PPID C PRI NI ADDR SZ WCHAN TTY TIME CMD 0 S 1001 21559 21558 0 80 0 - 1275 - pts/0 00:00:00 bash 0 R 1001 22013 21559 0 80 0 - 1213 - pts/0 00:00:00 ps
Status column, R=running, S=sleeping
92 CIS 90 - Lesson 3 Practice Test Questions
What is the name of the environment variable that defines your shell prompt?
It’s PS1
/home/cis90/simben $ echo $PS1 $PWD $
/home/cis90/simben $ echo "The PWD variable =" $PWD The PWD variable = /home/cis90/simben /home/cis90/simben $
Both PS1 and PS2 are environment variables
93 CIS 90 - Lesson 3 Practice Test Questions
What is the name of the environment variable that defines your shell prompt?
It’s PS1
/home/cis90/simben $ echo $PS1 $PWD $
/home/cis90/simben $ echo "The PWD variable =" $PWD The PWD variable = /home/cis90/simben /home/cis90/simben $
Both PS1 and PS2 are environment variables
94 CIS 90 - Lesson 3 Practice Test Questions
How do your change the shell prompt to "Enter next command: " ?
Set PS1 to new value using “=“ sign
/home/cis90/simben $PS1="Enter next command: " Enter next command:
95 CIS 90 - Lesson 3 Practice Test Questions
How do your change the shell prompt to "Enter next command: " ?
Set PS1 to new value using “=“ sign
/home/cis90/simben $ /home/cis90/simben $ PS1="Enter next command: " Enter next command: Enter next command: echo $PWD /home/cis90/simben Enter next command: echo $PS1 Enter next command: Enter next command:
96 CIS 90 - Lesson 3 Practice Test Questions
How do you restore the original shell prompt so it displays the current directory followed by a $ and a blank?
To restore the original prompt use:
Enter next command: PS1='$PWD $ ' /home/cis90/simben $
97 CIS 90 - Lesson 3 Practice Test Questions
How do your change the shell prompt to "Enter next command: " then change it back again?
To restore the original prompt use:
Enter next command: PS1='$PWD $ ' /home/cis90/simben $
98 CIS 90 - Lesson 3
More commands for your toolbox
99 CIS 90 - Lesson 3
Introducing some new commands for this lesson
write “chat” with another user by writing to their terminal mesg enable/disable writes to your terminal mail send and read email
100 CIS 90 - Lesson 3
Write Command
101 CIS 90 - Lesson 3
Use the write command to chat with another user
102 CIS 90 - Lesson 3 write command send a message to another user
write username [ttyname]
• Use ttyname only if there are multiple logins by the target username • The receiver gets: Message from yourname@yourhost on yourtty at hh:mm … • Each line you type gets sent to the other user’s terminal • To end sending messages type Ctrl-D (Hold down Ctrl and tap D key) • The receiver will see an EOF (end of file) at the end • If the receiver wants to reply then they must use the write command as well • Use mesg n (to block incoming messages) • Use mesg y (to allow incoming messages)
103 CIS 90 - Lesson 3 write command send a message to another user
/home/cis90/simben $ type write write is /usr/bin/write
/home/cis90/simben $ file /usr/bin/write /usr/bin/write: setgid ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.18, stripped
Using Lesson 2 commands you can see that the write command resides in the /usr/bin directory and it is a binary executable
104 CIS 90 - Lesson 3 write command send a message to another user
/home/cis90/simben $ man write
Use the man command to review how the write command works.
105 CIS 90 - Lesson 3 write command simben90 writes to milhom90
Benji, uses the who command to see the current users logged into Opus. He sees his friend Homer is logged in twice. /home/cis90/simben $ who srelau98 pts/0 2012-09-11 06:36 (anice-34-27-241-136.wanadoo.fr) simben90 pts/1 2012-09-11 06:47 (42-15-94-107.dsl.com) alvdes98 pts/2 2012-09-11 07:49 (c-25-14-136-111.comcast.net) milhom90 pts/3 2012-09-11 08:03 (42-15-94-107.dsl.com) milhom90 pts/4 2012-09-11 08:09 (42-15-94-107.dsl.com)
Homer, ever curious, uses the tty /home/cis90/milhom $ tty command to see what terminal device /dev/pts/4 he is using /home/cis90/milhom $
106 CIS 90 - Lesson 3 write command simben90 writes to milhom90
1) Benji enters this /home/cis90/simben $ write milhom90 write: milhom90 is logged in more than once; writing to pts/4
/home/cis90/milhom $ Message from [email protected] on pts/1 at 09:52 ...
2) Homer sees this written to his terminal
107 CIS 90 - Lesson 3 write command simben90 writes to milhom90
/home/cis90/simben $ write milhom90 write: milhom90 is logged in more than once; writing to pts/4 What do you think of the new CentOS distro?
1) Benji enters this
/home/cis90/milhom $ Message from [email protected] on pts/1 at 09:52 ... What do you think of the new CentOS distro?
2) Homer sees this written to his terminal
108 CIS 90 - Lesson 3 write command simben90 writes to milhom90
/home/cis90/milhom $ Message from [email protected] on pts/1 at 09:52 ... What do you think of the new CentOS distro? write simben90
1) Homer enters this
/home/cis90/simben $ write milhom90 write: milhom90 is logged in more than once; writing to pts/4 What do you think of the new CentOS distro?
Message from [email protected] on pts/4 at 09:55 ...
2) and Benji sees this written to his terminal 109 CIS 90 - Lesson 3 write command simben90 writes to milhom90
/home/cis90/milhom $ Message from [email protected] on pts/1 at 09:52 ... What do you think of the new CentOS distro? write simben90 What's with the periods on the long listing permissions?
1) Homer enters this
/home/cis90/simben $ write milhom90 write: milhom90 is logged in more than once; writing to pts/4 What do you think of the new CentOS distro?
Message from [email protected] on pts/4 at 09:55 ... What's with the periods on the long listing permissions?
2) and Benji sees this written to his terminal 110 CIS 90 - Lesson 3 write command simben90 writes to milhom90
/home/cis90/simben $ write milhom90 write: milhom90 is logged in more than once; writing to pts/4 What do you think of the new CentOS distro?
Message from [email protected] on pts/4 at 09:55 ... What's with the periods on the long listing permissions? I think it's SELinux
1) Benji enters this
/home/cis90/milhom $ Message from [email protected] on pts/1 at 09:52 ... What do you think of the new CentOS distro? write simben90 What's with the periods on the long listing permissions? I think it's SELinux
2) Homer sees this written to his terminal 111 CIS 90 - Lesson 3 write command simben90 writes to milhom90
/home/cis90/milhom $ Message from [email protected] on pts/1 at 09:52 ... What do you think of the new CentOS distro? write simben90 What's with the periods on the long listing permissions? I think it's SELinux Talk to you later, I'm going to bark a little and take a nap
1) Homer enters this
/home/cis90/simben $ write milhom90 write: milhom90 is logged in more than once; writing to pts/4 What do you think of the new CentOS distro?
Message from [email protected] on pts/4 at 09:55 ... What's with the periods on the long listing permissions? I think it's SELinux Talk to you later, I'm going to bark a little and take a nap
2) and Benji sees this written to his terminal 112 CIS 90 - Lesson 3 write command simben90 writes to milhom90
/home/cis90/milhom $ Message from [email protected] on pts/1 at 09:52 ... What do you think of the new CentOS distro? write simben90 What's with the periods on the long listing permissions? I think it's SELinux Talk to you later, I'm going to bark a little and take a nap Ctrl-D 1) Homer issues a Ctrl-D (holds down Ctrl /home/cis90/milhom $ key, then taps D key)
/home/cis90/simben $ write milhom90 write: milhom90 is logged in more than once; writing to pts/4 What do you think of the new CentOS distro?
Message from [email protected] on pts/4 at 09:55 ... What's with the periods on the long listing permissions? I think it's SELinux Talk to you later, I'm going to bark a little and take a nap EOF 2) and Benji sees this written to his terminal 113 CIS 90 - Lesson 3 write command simben90 writes to milhom90
/home/cis90/simben $ write milhom90 write: milhom90 is logged in more than once; writing to pts/4 What do you think of the new CentOS distro?
Message from [email protected] on pts/4 at 09:55 ... What's with the periods on the long listing permissions? I think it's SELinux Talk to you later, I'm going to bark a little and take a nap EOF bye 1) Benji enters this
/home/cis90/milhom $ Message from [email protected] on pts/1 at 09:52 ... What do you think of the new CentOS distro? write simben90 What's with the periods on the long listing permissions? I think it's SELinux Talk to you later, I'm going to bark a little and take a nap /home/cis90/milhom $ bye 2) Homer sees this written to his terminal 114 CIS 90 - Lesson 3 write command simben90 writes to milhom90
/home/cis90/simben $ write milhom90 write: milhom90 is logged in more than once; writing to pts/4 What do you think of the new CentOS distro?
Message from [email protected] on pts/4 at 09:55 ... What's with the periods on the long listing permissions? I think it's SELinux Talk to you later, I'm going to bark a little and take a nap EOF bye 1) Benji issues a Ctrl-D (holds down Ctrl Ctrl-D key, then taps D key) /home/cis90/simben $
/home/cis90/milhom $ Message from [email protected] on pts/1 at 09:52 ... What do you think of the new CentOS distro? write simben90 What's with the periods on the long listing permissions? I think it's SELinux Talk to you later, I'm going to bark a little and take a nap /home/cis90/milhom $ bye EOF 2) and Homer sees this written to his terminal 115 CIS 90 - Lesson 3 mesg command mesg y enables and mesg n disables writes to your terminal
/home/cis90/milhom $ mesg n
1) Homer disables writes to his terminal so he can take his nap
/home/cis90/simben $ write milhom90 write: milhom90 has messages disabled
2) Benji discovers that Homer is no longer accepting messages
116 CIS 90 - Lesson 3 who command The -T option shows who is writeable
The -T option shows users messages status /home/cis90/simben $ who -T srelau98 + pts/0 2012-09-11 06:36 (anice-34-27-241-136.wanadoo.fr) simben90 + pts/1 2012-09-11 06:47 (42-15-94-107.dsl.com) alvdes98 + pts/2 2012-09-11 07:49 (c-25-14-136-111.comcast.net) milhom90 - pts/3 2012-09-11 08:03 (42-15-94-107.dsl.com) milhom90 - pts/4 2012-09-11 08:09 (42-15-94-107.dsl.com)
+ indicate writes to this user are enabled and - indicates writes to this user are blocked
We will learn about file /home/cis90/simben $ ls -l /dev/pts* wildcards and permissions total 0 later. crw--w----. 1 srelau98 tty 136, 0 Sep 11 08:15 0 crw--w----. 1 simben90 tty 136, 1 Sep 11 08:25 1 This is a just a preview crw--w----. 1 alvdes98 tty 136, 2 Sep 11 08:25 2 showing that write crw------. 1 milhom90 tty 136, 3 Sep 11 08:19 3 permission is removed from crw------. 1 milhom90 tty 136, 4 Sep 11 08:19 4 /dev/pts/3 and /dev/pts/4 c------. 1 root root 5, 2 Jul 30 21:25 ptmx for the tty group. 117 CIS 90 - Lesson 3
Class Exercise write and mesg
• Students, please login to Opus using your own accounts
• Rich, run the pairs script to pair up all the CIS 90 students.
• Students, use the write command to "chat" with your pair mate. e.g. write username
• Students, ask your pair mate for their real name and where they are right now.
• End the chat session with Ctrl-D
Note to Rich: Run the pairs script in your cis90/misc/uhist directory 118 CIS 90 - Lesson 3
Sending Mail
119 CIS 90 - Lesson 3 UNIX mail Sending messages mail recipient1 recipient2 … recipientn
The mail command can be used to send an email to one or more recipients.
Each argument designates a recipient specified by a username (in /etc/passwd), a normal email address, or an alias (in /etc/aliases).
Examples: mail rsimms username as argument mail simben90 halluc90 rawjes90 multiple usernames as arguments mail [email protected] brimar90 regular email address and username as arguments mail $LOGNAME your username, specified using a variable, as argument
an alias (used as a distribution list) mail cis90-students for all CIS 90 students 120 CIS 90 - Lesson 3 UNIX mail Sending messages
Using Lesson 2 commands we can observe /home/cis90/simben $ type mail that the mail program is on the path and in mail is /bin/mail the /bin directory.
/home/cis90/simben $ file /bin/mail It is a “symbolic link” (we learn about these /bin/mail: symbolic link to `mailx' later) to the mailx program.
/home/cis90/simben $ type mailx The mailx program files is also in the /bin mailx is /bin/mailx directory.
/home/cis90/simben $ file /bin/mailx /bin/mailx: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.18, stripped The mailx program is a binary executable.
121 CIS 90 - Lesson 3 UNIX mail Sending messages
Homer Rich As an example, Benji sends an email to (milhom90) ([email protected]) Homer (a user on Opus) and Rich (using his Yahoo email address)
/home/cis90/simben $ mail milhom90 [email protected] Subject: Where is the old bone I can't find my old bone. Let me know if you see it. Thanks, Benji Benji (simben90) . EOT /home/cis90/simben $
Use Ctrl-D or a single period to Recipients can be Opus users (just specify their end the message (End Of Text) username) or regular email addresses.
122 CIS 90 - Lesson 3
Class Exercise UNIX mail
• Login to Opus
• Send me a message
/home/cis90/simben $ mail rsimms Subject: Hello This mail program is pretty crazy! . /home/cis90/simben $
123 CIS 90 - Lesson 3
Notes to Rich
[ ] - Send out Welcome letter Use script in /cis90/misc/uhist directory cp list-full list mail-welcome
[ ] - Test cis90-students alias
124 CIS 90 - Lesson 3
Reading Mail
125 CIS 90 - Lesson 3 UNIX mail Sending messages
To read mail, enter the mail command with no arguments. The mail command has its own mini-shell with its own set of mail oriented commands.
126 CIS 90 - Lesson 3 UNIX Mail Reading messages Homer (milhom90)
Homer notices he has received /home/cis90/milhom $ new mail and runs the mail The N You have new mail in /var/spool/mail/milhom90 command to see what has arrived signifies a new /home/cis90/milhom $ mail message Heirloom Mail version 12.4 7/29/08. Type ? for help. "/var/spool/mail/milhom90": 1 message 1 new >N 1 Benji Simms Tue Sep 11 12:59 22/830 "Where is the old bone" & 1 He types 1 to read message 1 Message 1: From [email protected] Tue Sep 11 12:59:27 2012 The & is Return-Path:
I can't find my old bone. Let me know if you see it. Thanks, Benji
127 CIS 90 - Lesson 3 UNIX mail Reading messages sent from UNIX mail Rich ([email protected])
Rich reads the email from Benji using Yahoo mail (a mail user agent)
128 CIS 90 - Lesson 3
Class Exercise UNIX mail
• Read your own mail by typing the mail command by itself
• Use the p command followed by the number of the message to print a message. p 1 p 2 Or just type the number of the message.
• Use the q command to exit
Tip: You can just hit the Enter key by itself to read the next unread message.
129 CIS 90 - Lesson 3
Replying to Mail
130 CIS 90 - Lesson 3 UNIX Mail Replying to messages
Homer (milhom90)
< continued from above >
I can't find my old bone. Let me know if you see it. After reading the message Thanks, from Benji, Homer replies Benji with the mail r command (for reply to all). & r 1 To: [email protected] [email protected] [email protected] Subject: Re: Where is the old bone
Benji Simms
> I can't find my old bone. Let me know if you see it. > Thanks, > Benji I think its under the sink - Homer . EOT &
131 CIS 90 - Lesson 3 UNIX Mail Benji gets the reply from Homer
You have mail in /var/spool/mail/simben90 /home/cis90/simben $ mail Heirloom Mail version 12.4 7/29/08. Type ? for help. "/var/spool/mail/simben90": 1 message 1 unread Benji >U 1 Homer Miller Tue Sep 11 13:35 30/1096 "Re: Where is the old bone" (simben90) & 1 Message 1: From [email protected] Tue Sep 11 13:35:30 2012 Return-Path:
Benji Simms
& 132 CIS 90 - Lesson 3
Rich UNIX Mail ([email protected])
Since Homer replied to all, Rich also gets a copy
133 CIS 90 - Lesson 3
Saving Mail to a Folder
135 CIS 90 - Lesson 3 UNIX Mail Saving messages
Benji checks for new mail /home/cis90/simben $ mail Heirloom Mail version 12.4 7/29/08. Type ? for help. "/var/spool/mail/simben90": 1 message 1 new >N 1 Homer Miller Tue Sep 11 21:04 21/830 "Salsa" & 1 Prints the first (and only) message Message 1: From [email protected] Tue Sep 11 21:04:16 2012 Return-Path:
Don't forget, salsa class tonight at the Palomar - Homer
& s 1 archives Saves this message to a folder named “archives” "archives" [New file] 23/851 & q
136 CIS 90 - Lesson 3
Browsing a Mail Folder
137 CIS 90 - Lesson 3 UNIX mail Browse mail folders using the -f option
use the f option to specify a mail file
/home/cis90/simben $ mail -f archives Heirloom Mail version 12.4 7/29/08. Type ? for help. "archives": 5 messages 4 new 1 Homer Miller Tue Sep 11 21:04 22/841 "Salsa" >N 2 Homer Miller Tue Sep 11 21:25 20/790 "Hola" N 3 Rich Simms Tue Sep 11 21:58 20/752 "Treasure" 4 Rich Simms Tue Sep 11 22:01 21/798 "Lab Hours on Monday" N 5 Rich Simms Tue Sep 11 22:01 20/796 "Where were you last summer?" &
Opening a mail folder named archives which has some saved messages
138 CIS 90 - Lesson 3
Forwarding Mail
139 CIS 90 - Lesson 3 mail commands Forwarding a message with ~m
This is how you forward message 5
Tip: Use this to send the event you get from the instructor to others for Lab 3
140 CIS 90 - Lesson 3 mail commands Alternate ways to forward a message
There is an easier way to forward a message with the latest version of mailx!
I wonder who will be the first person to find out how its done and post the solution to the forum?
141 CIS 90 - Lesson 3
Mail Documentation
142 CIS 90 - Lesson 3 man page for mail
/home/cis90/milhom $ man mail
In the bash shell, use the man command for extensive documentation on mail 143 CIS 90 - Lesson 3 Mail ? command
& ? mail commands type
A
Use the ? command to see a short list of common mail commands 144 CIS 90 - Lesson 3
Listing messages (headers)
145 CIS 90 - Lesson 3 mail h (headers) command e.g. list my current folder)
Use the h command to show messages the current folder 146 CIS 90 - Lesson 3 mail h (headers) command e.g. list my current folder)
N = New message, a U = Unread message
message numbers
& is mail prompt for next command
> points to the current message (last one printed)
147 CIS 90 - Lesson 3
Deleting Messages
148 CIS 90 - Lesson 3 mail commands (d)elete and (u)ndelete
Messages can be deleted (and undeleted)
149 CIS 90 - Lesson 3
Mail files
150 CIS 90 - Lesson 3 UNIX mail The dead.letter mail file
/home/cis90/simben $ mail bogus Subject: Dead stuff I doubt you will get this because you don't exist! . EOT You have mail in /var/spool/mail/simben90 /home/cis90/simben $ /home/cis90/simben/dead.letter... Saved message in /home/cis90/simben/dead.letter
/home/cis90/simben $ mail -f dead.letter Heirloom Mail version 12.4 7/29/08. Type ? for help. "dead.letter": 1 message > 1 To bogus Tue Sep 17 10:04 18/562 "Dead s" & d 1 & q "dead.letter" complete /home/cis90/simben $
Undeliverable mail is placed in your dead.letter file. You can cat this file or open it with the mail command
151 CIS 90 - Lesson 3 UNIX mail The mail folders are ascii text files
/home/cis90/simben $ ls archives empty Lab2.1 Miscellaneous proposal2 text.err bigfile Hidden letter mission proposal3 text.fxd bin lab01.graded log Poems small_town timecal dead.letter Lab2.0 mbox proposal1 spellk what_am_i
/home/cis90/simben $ ls /var/mail/simben90 /var/mail/simben90
1 & 4: User's can create there own mail folder files, giving them any name they like, such as archives and mbox
/home/cis90/simben $ file archives dead.letter mbox /var/spool/mail/simben90 1) archives: ASCII mail text 2) dead.letter: ASCII mail text Mail files are text files that you 3) mbox: ASCII mail text can cat or open with mail -f 4) /var/spool/mail/simben90: ASCII mail text
2) All undeliverable 3) All incoming new messages are initially messages go into a user's placed in the /var/mail/
Mail files are ASCII text files. You can cat them out or open with the mail command.
/home/cis90/simben $ cat archives From [email protected] Mon Sep 16 18:52:53 2013 Return-Path:
------Original Message ------Original Message ------From: Rich Simms
You got it ... forward it on! - Rich You got it ... forward it on! - Rich & q /home/cis90/simben $ "archives" complete /home/cis90/simben $ 153 CIS 90 - Lesson 3
Class Exercise UNIX mail
• Send yourself several test messages with different subjects: mail $LOGNAME mail $LOGNAME • Now read your mail mail • Use the h command to list the message headers • Read all your messages using p command • Use the d command to delete one of the messages • Use the s command to save one message to a folder named archives • Use q to quit mail • Read the mail in your archives with mail -f archives • Use q to quit mail
154 CIS 90 - Lesson 3 end-to-end email
155 CIS 90 - Lesson 3
end-to-end email
Optional
open and read message compose and send message 156 CIS 90 - Lesson 3
end-to-end email DA Delivery Agent
MTA MTA Mail Mail Transport Transport Message Agent Agent Store
AA Access Agent
MUA MUA Mail Mail User User Agent Agent
open and read message compose and send message 157 CIS 90 - Lesson 3
end-to-end email: example Implementation DA procmail
SMTP Simple MTA Mail MTA sendmail Transport Protocol sendmail SMTP Simple Message Mail Store Transport Protocol /var/spool/mail/rsimms
MUA MUA /bin/mail /bin/mail
open, read and save messages compose and send message to folders uhistory archives 158 CIS 90 - Lesson 3
end-to-end email: example Implementation DA procmail
SMTP Simple MTA Mail MTA sendmail Transport Protocol sendmail SMTP Message Simple Store Mail Transport Protocol AA
POP MUA Post Office /bin/mail Protocol
MUA Yahoo Mail compose and send message open and read message 159 CIS 90 - Lesson 3
end-to-end email: configuring your MUA (Mail User Agent)
DA Delivery SMTP Agent Simple MTA SMTP MTA Mail Mail Simple Mail Transport Mail Transport Protocol Transport Transport Agent Agent Protocol Message Example MUA: Windows Mail (on Vista) Store
AA This is why you get Access asked for the SMTP Agent server and the POP3/IMAP server POP when you set up Post email on your PC. Office Protocol Your MUA needs to know this to send and receive messages. 160 CIS 90 - Lesson 3 Other MUAs MTAs, DAs, AAs
161 CIS 90 - Lesson 3
end-to-end email some of the many players
MTA sendmail, Exim, Microsoft Exchange, Postfix
DA /bin/mail, procmail, smrsh
AA imapd, spop
MUA /bin/mail, pine, elm, Outlook, gmail, Evolution, Yahoo Mail
162 CIS 90 - Lesson 3
Lab 3
163 CIS 90 - Lesson 3
Notes to Rich
[ ] - Send out UNIX historical events for Lab 3 use mail-lab03 script in /cis90/misc/uhist directory
164 CIS 90 - Lesson 3
Lab 3 - Start early and check your Opus email every day!
You will receive another mail message from me that describes a UNIX historical event for a particular year from 1968 to 2003. Save this message to a mail file called uhistory.
The objective of this lab is to exchange and collect all the individual events that were sent to each student using UNIX mail.
Start by sending an email to your other classmates with your event and ask them ask them to send you their events. Each time you get UNIX event that you haven't already saved, save it to your uhistory mail file. See how many dates you can accumulate. Can you get all 18?
Rules: • Do this lab on Opus using /bin/mail (the mail command). • When someone asks you for the date that you received, you must send it to them with the subject being the year of the event, e.g. 1972. The email message must contain the complete text of the event for that year. • Each email saved in uhistory must be for a single event/year.
If you receive an email that is missing the event or does not have the year as the subject, reply to the sender and ask them to resend a corrected version.
When you get all the UNIX event messages saved in your uhistory mailbox you should have up to 18 messages, each with a different date for the Subject field. Delete any duplicate dates you may have.
Lab 3 (and all future labs) must be done on Opus 165 CIS 90 - Lesson 3
Tips for Lab 3
Start this lab early in the week and check your mail daily to collect all messages
• Use the s command in mail to save a message to your uhistory file
• use mail -f uhistory to review your collection
• Use the d command in mail to delete duplicates in your uhistory file
Watch for more tips on the forum
166 CIS 90 - Lesson 3
Wrap up
167 CIS 90 - Lesson 3
New commands: mail - UNIX mail type
A
New Files and Directories: /var/mail - Message store for mail /var/mail/username - Incoming mailbox for username 168 CIS 90 - Lesson 3
Next Class
Assignment: Check Calendar Page on web site to see what is due next week.
Quiz questions for next class:
• What command can you use to "chat" with another user?
• How do you forward a message with /bin/mail?
• What is the dead.letter folder?
169 CIS 90 - Lesson 3
Backup
170 CIS 90 - Lesson 3
stdout
1 0 2
stdin stderr