- Open a text document named yourlastnameA3.txt in order to record your answers.
- If you are working in a Windows environment, download the communications program, putty.exe (372 KB). This program will allow us to login remotely to another system using the ssh protocol. It provides secure encrypted communications between two
hosts. If you are not running windows, you may use the sshcommand directly instead, but I do not recommend using sshfrom coLinux for this assignment.
- Each of you has been given an account on cs.berea.edu, which has IP address 65.166.71.15. Your account name on cs.berea.edu is modeled after Berea's email accountnames--your last name followed by the first letter of your first name. Thus, mine is pearcej. Please use the ssh command in putty to connect to cs.berea.edu and to login. Your initial password on your cs.berea.edu account is your social security number.
- Using the passwd command, please change your password on cs.berea.edu.
- We used the finger command last time on our solo computers. Now try the finger command by typing finger yourusername. Describe briefly in your text file what it does. Try the finger command alone by typing "finger". Use the who command to see who else is logged in. Next try finger again. In your text file, briefly compare and contrast finger and who and describe what you see.
- Next try who > yourusername.txt. Recall that the > character is the redirection of output. We performed this same command last time in our solo Linux environment. Use less to see the contents of this new file.
- Read man talk and use it with someone else in the class. Do you like this command? It is very early text messaging.
- Try the pwd command. Type ls -l so that you can see the longer version of your directory listing. Use the command cd .. to change the parent directory of your user account. Type ls -l again. Then use the command cd .. again to change the parent directory of this directory, placing you two directories above your account home. Type ls -l again. Then type cd ~. Briefly explain in your text file what happened at each directory change.
- Next read the man pages on the cp command so that you can figure out how to make a copy of your yourusername.txt file and place the copy in my /home/pearcej/A3 directory. Hint: files and directories in Unix-like systems are treated nearly identically. Once you complete this, you may be wondering why you have permission to write in my directory! To see why this is, we will need to explore file and directory permissions. When you finish this, go back to your main directory with cd ~.
- The permissions on files and directories have the following form: drwxrwxrwx. The first letter stands for the type of file, in this case "d" is for directory. The rest of the letters are the permissions on the file. They are read as follows in groups of three: permissions for the owner, permissions for the group, and permissions for everyone else. So in the case of drwxr-xr--, the owner has permissions of rwx, the group has permissions of r-x, and everyone else has permissions of r--. The letters r,w,x stand for Read, Write and Execute, respectively. Using the appropriate pathname, list (using the long format) the files and directories in home/pearce/A3 and in your directory. How are the permissions different? Could someone write in your home directory?
- If we want to know how to change the permissions on files and directories, we will use the chmod command. First make a new directory named "test" inside your account directory.
So note that the owner can read, write and execute (open) the directory, the members of the owners group can read, write and execute the directory, and everyone else can read and execute but not write to the directory. Now type chmod 777 test. Explain the result of what you have done.
To calculate the number "777" in the above example, think of the permissions in three groups, owner-group-everyone, and imagine their values in binary - so rwx would be 111 in binary. So then do the conversion (111)2 = 7. So as another example, if you want to the permissions of rwxr--r-x, you would use the command chmod 745 "directory name".
So play around with changing the permission on the directory "test," so that you can better understand file and directory permissions and how to change them. Change the permission of the homework directory back to 775 when you are done.
- Last time we used the screen command in order to multiplex sessions. In this assignment, we will try a different approach. Using putty (or ssh if you are not running windows), open a second connection to cs.berea.edu, and log into your account again. You should now have two sessions running!
Try finger again. Note that you can see both of your sessions running the bash shell. Describe what you believe the main techical differences are between using screen and opeing a second session with ssh. I am looking for a substantive answer here, so you may want to think carefully about the differences. Is there any difference in the RAM usage? What about CPU usage?
- Next, we are going to learn how to use the most basic Unix-Like mail program. Mail in Linux is similar to other mail systems such as Outlook, but is much faster. Type mail username < yourusername.txt. You may have guessed that the < character is a "redirection" of input. In out example, it basically makes mail take its input from the contents of the "yourusername.txt" file. Now type mail. This will get you into the mail program. It may take a few seconds for the mail to reach your inbox.
Type "1" to see the contents of the mail message, then type "q" to exit mail.
To write a mail message to someone, type mail user@host, where user is the user name and host is the host name of the computer that user has a mail account on. If you are sending messages to someone in the class, the host portion may be omitted. To send a message to your Outlook account, type mail firstname_lastname@berea.edu. Try it!
- First you type the subject, and then the body of the message. Note that to end the message, you type "." on a line by itself. For more information on mail type man mail at the command prompt. In your text file, write a paragraph on the how this most basic of mail programs in Unix-like system compares to Outlook.
- Try the date command. Note that this command gives you both the date and the time. Try time date. Try time mail username. In your text file explain what seems to be the purpose of the time command.
- If you have no unread mail, send yourself some more mail. Then in one of your windows enter the mail program and use control-z before you read your message. Linux will respond with "stopped mail" -- However, the mail program is still active, but it is running in the background. The number in brackets at the beginning of the line that says "stopped mail" is called the Job Number. Try ps -la again to see that the mail process is indeed still active. The control-z puts the process "in the background". What this means is that it is still active, but is not accepting input from the keyboard (which the mail program happens to need). Try typing jobs -l to see a list of the jobs you have put into the background. See how easy it is to have multiple jobs?
- The manual page on the fg command is not very helpful. Nevertheless, the fg command is explained on p 635 of your text. Try typing fg and explain in your text file what fg does. Next use control-z again to put the mail process back into the background again.
- Type mail again. Next type vi from inside of the mail program, but do not use it (i.e. Do not exit mail, and at the mail prompt, type vi return and nothing else.) This sequence of commands allows you to edit mail as you write it. However, we're not going to type any mail right now--instead, we're looking at processes. Before quitting vi or mail, type control-z to put your current process into the background. Now type ps -la. Note that the PID for one of your mail jobs and the PPID for the vi job are identical. Try typing jobs -l to see a list of the jobs you have put into the background. You should have multiple stopped jobs.
- Next try the pstree username command with your username. This gives you a graphical look at your own processes. Think about your knowledge of processes and how they come into existence. Then in your text file, explain what PID and PPID stand for and why is should not be surprising that these two should be identical.
- Type ps -la. In your text file, list all of the processes that your user ID has active now. Next we are going to start a process that will take a while for it to end.
At the command line prompt, type ls / -al --recursive > directory.txt. This will list all of the files on the computer and put the output into the file "directory.txt" in your home directory. Switch back to the other ssh window where you are logged into cs.berea.edu. Type top to see the active processes. Then type u and top will ask you which user. Answer with your username. Note what the status of the ls / -al --recursive process is, it should be either D or R. Wait until you have seen both the D and R status for the ls / -al --recursive process. Go to your text file and explain what is going on here and why the ls / -al --recursive process exhibits both the D and R status.
- Now type ps -la again and note the PID (process ID) for the ls / -al --recursive process. (If the process has ended, then go back to the window where you started it from and hit the up arrow and execute it again.) Now type kill 'PID' where 'PID' is the process ID for the ls / -al --recursive process. Type ps again and note that ls / -al --recursive is not listed. Go to the other ssh window and note that the process has been terminated.
- Locate your stopped mail process' PID. Try to kill this process. Explain what happens. Is this what you expected? Why do you suppose this happened?
- Now exit from all of your ssh sessions, making sure to use the fg command to go back to any stopped jobs and quit them. Then exit out of your final session.
Submit yourlastnameA3 in the usual way.