Objectives:
1) Learn about compiling, linking, creating executable and running program
2) Get more experience about process, fork, getpid, and getppid
3) Learn to create makefile and use make utility, which are used in software development
4) Learn to modify PATH shell variable to search a new directory
5) Learn to use ftp to do file transfer between two systems
6) Learn to use whereis and which commands
7) Learn to use networking commands (utilities) such as ftp, rwho, finger, mailx, mount, and ping
8) Learn to create a backup and restore using cpio and find commands with pipe or tar command
Make Utility – Commands: make, pwd, mkdir, cd, ls, touch, cat, PATH
1) Create the directory hw4q1make under your login directory.
2) Copy one of your working C programs in homework #2 or homework #3 Q1 or Q2 program into hw4q1make directory. If you do not have a working program, then create a simple and small/trivial program, like the “Hello World” that you see in a programming book to do this homework.
3) Change working directory to hw4q1make.
4) Exit from script, if it enabled.
5) Using vi editor, create the makefile to produce that will produce an executable file for the C programs in the directory. In the makefile, there should be a target to create the object module ( .o file ) with compile only command ( cc –c ) and another target to generate the final executable file by linking the object module.
6) Enable script to start capturing output for the steps below.
7) Display the current working directory to ensure it is hw4q1make directory
8) Display the attributes of the files in the directory
9) Display the content of makefile
10)Build the executable by issuing make command.
11) Display the attributes of files in the directory
12) Modify the PATH shell variable to search hw4q1make directory for command as shown below (type it on the command line and do not modify .profile):
PATH=$PATH:/usr/home/your login name/hw4q1make
13) Change working directory to another directory
14) Issue current working directory
15) Run the program by typing just the executable program filename. Supply argument to the program (command), if necessary.
16) Change working directory to hw4q1make
17) Issue make command again
18) Issue touch command on the C source program file to change the modification date to current time
19) Issue the make command again. Observe that the C program gets compiled; object file and the executable files are recreated since the dependent C program file has been modified by the touch command.
ftp – ftp commands
You should try to do this question from your PC (laptop). Run cmd command to start the DOS command interface window on your laptop by clicking on Start, then run and then typing cmd and pressing Enter.
Issue ftp command from DOS window with UNIX server IP address to start the client ftp, establish a session (connection) with the server and login to the server. Issue appropriate ftp commands to perform the following tasks.
1) Issue help or ? command to get the list of ftp commands.
2) Issue stat ftp command and make sure the transfer mode is ASCII. If current mode is BINARY, issue ASCII command to change mode to ASCII.
3) Issue ls (lst) ftp command
4) Using get (or recv) ftp command, get a file from your login directory into your PC local directory. Give name to the file to be stored on the PC different from the file on the server.
5) Create a directory called ftptest under your login directory using mkdir command
6) Change the working directory to ftptest using cd (or cwd) command
7) Issue pwd ftp command.
8) Using put (or send) ftp command, send the file you have received in Step (3) above to the ftptest directory.
9) Issue ls (lst) ftp command.
10) Delete the file in the ftptest directory using delete ftp command.
11) Issue ls (lst) ftp command.
12) Issue cd (or cwd) ftp command to change working directory to your login directory.
13) Delete the ftptest directory using rmdir ftp command.
14) Issue ls (lst) ftp command.
15) Issue quit ftp command to logout from the ftp session.
To exit from DOS window, type exit command after copying and pasting the output.
NOTE: If you are unable to login to the server from your ftp session on the PC, then login to the server using PuTTY. Start the script. Then, issue ftp command and perform the above steps. After issuing the quit ftp command, stop the script command and save the output.
Networking commands – mailx, finger, rwho, ps, grep, ping, mount, netstat, cat
1) Send mail to yourself using mailx command
2) Read the mail you sent to yourself
3) Issue finger command with your login name. Finger will work for local and remote users.
4) Issue rwho command. The rwho command will display users logged on remote systems and local systems, if rwhod daemon is running and system is configured to send the info over the network.
5) Issue ps –e command and pipe the output to grep command with rwhod as the search pattern/string.
6) Look at the output of the grep command. With echo command, answer whether the rwhod daemon is running on the UNIX server.
7) The ping command can be used to check the network working condition between two systems. You may have to find the path name of the ping command file using which or whereis command and then type the full/absolute path name of the ping command. Issue ping command with UNIX server IP address as argument. If the command does not stop after displaying five packets transfer and receive information, terminate the command using ctrl-c. Otherwise, the command may never stop.
8) The mount command without arguments will display the list of mounted local and network file systems on the UNIX system. Find the path name of the mount command file using which or whereis command and then by typing the full/absolute path name of the mount command to display the list of mounted file systems.
9) Identify the file that has the list of file systems to be mounted when the UNIX system boots. Hint: This file is located in the /etc directory and the filename ends with tab. Change to the /etc directory and then issue ls command to display filename ending with tab ONLY. Display the content of the appropriate file containing the list of file systems to be mounted.
10) The file named hosts in the /etc directory contains names of computers (hosts) and their corresponding IP addresses. The first name in the list is called the official name and the remaining names are called aliases. Display the content of the hosts file.
11) Look at the content of the hosts file displayed above, and then using echo command, answer what is the name of the UNIX server at FSU that you are using.
12) The netstat command displays information about your network. To test this command, start the DOS command line interface on your PC by running cmd command like you did before. (1) Issue netstat command. (2) Issue help ( ? ) when you are in netstate to see the various options it supports. (3) Identify the option to display the routing table and then issue netstat with that option to display the routing table. Copy and paste the output of netstat session from the DOS window into your file to be submitted. To exit from DOS window, type exit command after copying and pasting the output.
Backup and Restore Using cpio and find Commands.
1) Make your login directory as your working directory
2) Using the find command and the cpio command, create a backup file called backup containing all the files in your login directory. To do backup, pipe the standard output of the find command to the cpio command and redirect the cpio standard output to the file named, backup like find . | cpio options > backup. Use appropriate options in the place of options in the cpio command to do backup. Must use verbose option in addition to other required options so that the list of files being backed will be displayed on the monitor. Make sure you use relative path in the find command to generate the list of files with relative path.
3) Display the attributes of the backup file
4) Create the directory restore under your login directory
5) Copy the backup file from your login directory to the restore directory
6) Change working directory to restore
7) Issue pwd command
8) Display the attributes of the files in the restore directory
9) Restore the files from the backup file into the restore directory. Redirect input using < operator from backup file to the cpio command. Must use verbose option in addition to other required options so that the list of files being restored will be displayed on the monitor.
10) Display the attributes of the files restored files in the restore directory.