CIS 15 UNIX ASSIGNMANT
Some of the Unix exercises have been borrowed from Prof. Scott Dexter.
To answer the following questions you will have to read the Unix shells and shell scripts chapters from the Unix tutorial posted on my web page.
1. On this UNIX system (i.e. the Atrium network), all users' home directories are stored in subdirectories of the root that have names of the form usersx or usersxx. (For example, Professor Dexter's account is stored in /users3/sdexter).
a. Use one command to create a file called rootdir in your home directory, which contains a listing of all files and subdirectories in the root directory.
b. Apply a filter to rootdir to get a list of all "users" subdirectories. Redirect the output of this filter to a file called userlist (if this is done correctly, this file should contain a list of all usernames).
2. The UNIX system you are using contains a subdirectory of the root directory called etc. Determine the absolute pathname of this directory. This directory contains a number of configuration files for the system, including group, device.tab, and courses.
a. In your home directory, create a file called etcstuff, which consists of the contents of these three files placed one after the other (group first and courses last). Use ONE command to do this. (Hint: use the man command to learn more about the cat command). You will need to use pathnames to distinguish between the etc directory and your home directory.
b. Use the man command to learn about the wc command. Create a file called etcstufftop, which contains just the first 23 lines of etcstuff. Create another file called etcstuffbot, which contains the rest of etcstuff.
c. Create a subdirectory of your home directory called tempdir.
d. Get a "long" listing of all files and subdirectories in your home directory. Redirect the output of this listing to a file called homelist.
e. Move homelist into tempdir (you may want to use the man command to learn a little more about the mv command). Get a "long" listing of all files and subdirectories in tempdir. Redirect the output of this listing to a file called tempdir.
3. Write a C program me.c, which produces the following output: Your last name on a line by itself, your student ID# on a line by itself, A carriage return ('\r') on a line by itself. Note that "on a line by itself" means that there should be no spaces etc. on the line, except for a newline character ('\n') at the end.
4. Write a script called today which displays the date in mm/dd/yy format:
a. Use the man command to learn about formatting options for the date command. In particular, understand the +%d and +%D options.
b. Use vi or pico to create a file called today which contains your script.
c. Test your script by first using the chmod command to make your script executable, then execute your script by typing today at the prompt.
5. Write a script called cgo that compiles and executes C programs. Specifically, the command $ cgo hw1 (for example) should compile the source file hw1.c and produce an executable file called hw1. It should then execute hw1.
6. Write script that will:
a. clear the screen ( you will have to find a command that will do this ).
b. display a banner that will say “welcome”.
c. change the command prompt to “$ my home directory>”.
d. check if you have new mail.
This script should be executed when you login to the system, hint look into the .profile file