Assignment #1 - Working with Basic Unix Commands

Due: Friday June 8,2018 11:59:59PM

Objective

In this assignment you will be asked to show your ability to accomplish tasks with some basic Unix commands and to work with the Pico (or Nano) editor (or VI or Emacs if you choose).

Requirements

  • You will complete this homework assignment in a TEXT FILE. No other types of file submissions will be accepted. A .docx or .rtf file is NOT a text file.
  • You should complete this assignment by logging into shell.cs.fsu.edu or a machine of your choice. You'll submit your program from the machine: linprog@cs.fsu.edu. For questions 2-4, you will need to actually perform the commands on your CS account, and then copy your text from the SSH window into the document (a text file) that you will turn in. Each part of questions 2-4 should be performed with one command if stated. Note that you are expected to copy all relevant portions of text of your Unix session for each question into your file that you'll submit. This includes: the command prompt, the command(s) that you type to perform a task, and Any console output from those commands (the output from a directory listing, for example).
  • Make sure that you include ALL commands you used to do a task. This includes any commands you have to type to move to a specific directory. Make sure your pasted text makes it clear where you are or have moved to, if you get to a step that requires you to change your working directory. Failure to do so will lose points for that question.

  • Questions

    Question 1 (10 points) - Answer the following simple questions.
    a. Name 2 pieces of hardware in a computer and explain their importance/use.
    b. Assuming a file called testfile.txt already has been created in your current directory, how would you open and edit that file using 
       the pico (or nano) editor? (What's the exact command you'd type?)
    c. Write down the pico/nano command that will:
       1. Uncut selected text.
       2. Exit.
       3. Save the file.
       4. Cut selected text.
       5. Move forward one page.
    d. Name 2 commonly used shells in Unix, and also name the one that we use (by default) when we're logged into our Computer Science 
    accounts.
    
    
    Question 2 (10 points) - Manipulate directory structures (starting from your home directory)
    a. Perform a command that displays the absolute path of your home directory (your current location).
    b. Create a new directory inside your home directory and name it COP3353-hw1
    c. Navigate to the COP3353-hw1 directory.
    d. Create two new directories using one command inside of the COP3353-hw1 directory, and name them assign1 and assign2.
    e. Display the contents of your current working directory (the directory COP3353-hw1).
    f. Delete the directory assign2.
    g. Display the contents again of the directory COP3353-hw1, this time using the long listing format.
    
    
    Question 3 (10 points) - Manipulate files. Starting from the COP3353-hw1 directory you created in Q 2 
    a. Change your current working directory to assign1.
    b. Create a new directory (inside of the assign1 directory) called Files
    c. Create a new file (inside of the assign1 directory) called MyFile.txt using the touch command.
    d. Write a command to open the file MyFile.txt in a text editor of your choice, then do the following (I don't need to see the 
    commands/keystrokes for the rest of this question)
       Insert three lines into the file (which you'll display in part e).
       The first line should be a sentence that tells me your favorite musician/band.
       The second line should be a sentence that tells me your favorite food.
       The final line should tell me your favorite hobby.
       Then save your text file and exit out of the text editor.
    e. Write a command to display the contents of the file MyFile.txt to standard output (the screen).
    f. Copy the file MyFile.txt to directory Files and rename the copy to t_1.txt (There is a way to do this with one command - try to figure it out!)
    g. Change your working directory to Files.
    h. Make a copy of t_1.txt with the name t_2.txt (in the same directory).
    i. Display the contents of the directory Files using the long listing format.
    j. Delete the file t_1.txt in the directory Files.
    k. Display the contents of the directory Files.
    
    
    Question 4 (10 points) - Manipulate files using wildcards. Starting from the Files directory you created in Question 3
    a. Change your current working directory to COP3353-hw1. (Stay in this directory for the rest of the steps in question 4)
    b. Create a new directory called assign3 in your current working directory.
    c. Create 9 new files using ONE COMMAND (in directory COP3353-hw1) named as follows:
    	Test_1.txt
    	Test_2.txt
    	Test_1-1.txt
    	Test_2-1.txt
    	Test_1-2.xtxt
    	Test_2-2.xtxt
    	Test_1-1.bak
    	Test_2-2.bak
    	File_1.bat
    d. Display a listing of all the files in the current working directory.
    e. Display a listing of all the files in the current working directory ending in txt using one command. (NOTE: txt is not equal to .txt)
    f. Display a listing of all the files in the current working directory ending in t using one command.
    g. Copy all the files containing "t_1" to the directory assign3 using one command.
    h. Display a listing of the contents of the directory assign3, without navigating to the directory.
    
    
    
    Question 5 (10 points) - Filenames (relative, absolute) and their paths. Assume Bob is your home directory ( ~ ), and your 
    current working directory is dog.
    (Note you're no longer performing commands on your account for this question).
    
    
    
    (1pt ea) Write the absolute pathnames for:
    	a. Alice
    	b. Felix
    	c. etc
    	d. Tweety
    
    (1pt ea) Relative to where you are located (dog directory), write the cd command that would navigate you to the following 
    directories (relative pathname):
    	e. user
    	f. Carl
    	g. Garfield 
    
    (3pts) Write 3 different ways (using 3 different pathnames, one relative, one absolute, and one that uses ~ ) to navigate with cd 
    to:
    	h. Felix	
    

    Format of the Assignment:

    The submitted assignment document is expected to be in plain text format in a single file, named this way:
    assign1_lastname_firstname.txt where you substitute your own last name and first name in the filename, in the format above. For instance, my file would be assign1_vastola_melina.txt
    The assignment file should be formatted as follows:
    COP3353 - Summer 2018
    Assignment 1 Solution - Due Date Here
    Name: Your Name
    
    Question 1 (10 points):
    ----------------------------------------------------------------------------
    Your Solution
    
    Question 2 (10 points):
    ----------------------------------------------------------------------------
    Your solution 
    (etc) ...
    

    Submitting

    Make sure you are logged into linprog.cs.fsu.edu and the file you want to submit is stored in your current working directory.
    To submit, type the following command:
    ~vastola/usub/submit1 yourFilename
    where you substitute your filename above as the parameter. Example -- if my file is called assign1_vastola_melina.txt, I would type:
    ~vastola/usub/submit1 assign1_vastola_melina.txt
    This will run a script and a C++ program that copies your file into a submission directory. The program will also give you feedback at the end -- it will display the contents of the file you just submitted to standard output. This will allow you to check to make sure that what you submitted was correct.