Homework 1 - Due before class February 3rd, 2021

This semester we will be doing several projects on a instructional linux system dedicated specifically to this class. If you have used unix or linux before then some of this material will be new. Some of it may not be. Please note that both the professor and TA for the course will have access to your files on this machine (and if you mess up the file permissions other students may as well). We will use this for helping you and accessing your code for testing, setup, or grading. Do not leave confidential or personal files on the class machine! Please note as well that the class machine is not backed up. Students must keep copies of their files elsewhere to preserve against loss.

For this assignment, you are to use your account on the ia-class.georgetown.edu machine. The account has been created for you with your netid. The default password will be emailed to you - please use a VERY SECURE password on this machine - the default password will be ok for this. You will have to use ssh to reach ia-class. A free ssh client (for Windows) is available at this link, or Windows 10 has its own built in client.

Mac OS X already has a ssh client available through the terminal application. It is also available from the command line of most linux systems.

You will quickly notice that unix, or in this case linux, has a command line interface. You will have to type commands you want executed. This is good and bad. You have more control over what happens, but you have a lot to learn. I have been using unix and linux for about 20 years now, and keep learning things.

First Off

First, you need to know that you can get what passes for help for any command on a linux system by typing:
man <command>
where <command> is the command you want information about. The man pages are not always useful in a tutorial sense, but they will explain the variety of options available for each command.

To see what man can tell you about itself try: man man

Reference information

A number of good tutorials exist that will teach you all you need to know about unix, and more. The Internet is also your friend.
Tutorials and Guides
Intro to unix
Introduction to Unix and Shell Programming

Unix in a Nutshell

Intro to System Administration (more in-depth)
The Linux System Administrator's Guide

You should also look in the Practical Unix text, as it has very useful relevant information.

Use the class text, man pages and the tutorials referenced above (other on-line sources are fine too, but ask me before you talk to others about the assignment) to figure out how to do the following things on a unix system.

Each question below has an answer that can be provided as a single command or file path. What you will be turning in (see below) is the single command or path that provides an answer. You will not turn in any output!

File System Manipulation

Commands to learn:

ls, rm, mkdir, rmdir, cd, pwd, ln, chmod, umask

1) How do you find out what directory you are working in?

2) What one command could you use to list every file on the entire system, showing their owner, location, and access time?

3) How do you list hidden files, i.e., file names that begin with '.' that are normally not shown?

4) How do you print a list of all files just within the subdirectories of the current directory? You should not list files in the subdirectories of the subdirectories or below, just the single directory below.

5) Where can you store files temporarily that are too large to fit within your account?

6) How would you create a special file named "~/fred" that, when opened, actually opened the /etc/passwd file?

7) What command would you use to delete a directory named test, assuming it contained other files and directories and you wanted them to be deleted as well?

8) What command would you use to make a file readable by anyone on the system?

9) What command would you use to make a file readable only by you (assuming it was your file)

10) Assuming you had root access, what command would you use to make a file execute as root when run?

11) What command would you use to make the default permissions for all the files you create be such that only you could read, write, or execute them?

12) What command would you execute that would make a program in your directory readable and executable by anyone on the system and when it executed it ran with your permissions?

Finding and examining files

Commands to learn:

which, whereis, file, strings, more (or less)

13) How would you find the path to the ping command?

14) Assume you found a file named /tmp/hacker-leftover. What command could you use to find out what type of file this was?

15) If the /tmp/hacker-leftover file was a binary executable, what command could you use to extract any readable information from the file without running it?

Commands to learn:

grep, find, locate

16) What command would you use to determine what files in a particular directory contained the string "d00d"?

17) What command would you use to determine what files in a particular directory contained either of the strings "d00d" or "hax0r3d"?

18) What command would you use to determine what files in a particular directory contained a string similar to "owned", except in some varying letter case (e.g. OwnEd)?

19) What command would you use to find all the files on a system that had been accessed within the last week?

20) What command would you use to find all the files on a system that were SUID root?

21) What command would you use to quickly find all the files on a system that had the work "tape" in their name?

22) What command would you use to file all files on a system that had a name ending in .txt that contained the string "qbert"?

Process Management and Information

Commands to learn:

top, ps, nice, nohup, kill, signal

23) What command can you use to show all the processes that you are running?

24) What is the process ID of the shell you are currently using?

25) What command can you use to show all the processes that are running on the system?

26) What command can you use to see the top few most active processes on a system?

27) How could you cause a command to run with a lower priority than it otherwise would?

28) What command can you use to send signals to running processes?

29) What signal would you send to a process on ia-class to suspend a process?

Coding

We will be developing a small amount of code on this machine over the course of the semester. In order to prepare for that, you will write and compile a very small program. You have probably done this in 051, so it should not take long. There are many editors available for coding. If you do not have a favorite, an easy one to learn to use is called nano. Once logged onto ia-class, type:

nano prog1.cc

This bring up your editor and allow you to enter program code.

You should create a program that, when run, does nothing but print out your name and netid. Compile it, fixing any errors, and run it to make sure it works. Should you encounter errors you can't work out, email me or refer to one of the TAs. Output should look like this:

Clay Shields clay

The basic structure of the program you will need is below. All you need to do is add the line that does the correct output.

#include<iostream> using namespace std; int main() { // This is a comment, code replaces this line return 0; }

Some links to help you, if you need them:

What to turn in:

For the first part, all you need to include is the appropriate list of commands. Please format them in the following manner: a pound sign, the question number, and then on the next line, the command. For example, if question zero were "How do you determine the hostname of the system you are on?", the answer would be:

#0
hostname

Create a single file that is formatted as described above. It can be PDF or text. You will then upload it to Canvas so that it can be graded.

Please note: DO NOT include the output of the commands, just the command that generates the appropriate output.

For the program, create a directory named "prog1" in your account and leave the source and executable there. We will log in and verify that it works correctly.