CS155: Introduction to Unix                

Spring 2018                

HW 1                

CS155 HW1: Making a file using Unix commands                


In this assignment you will create a plain text file called hw1 (that’s h-w-one, not h-w-ell). Note that the name is small letters, also known as lower case.                 


Create a file                

Create a single file, hw1, as your homework. You will use redirection (> and >>), as discussed in lecture, to create and append to the file.                 

Do the appropriate command for each of these items in the order shown, and add the output of each command to the homework file hw1. You should have 5 lines in your file when done with these items.                 

  1. The absolute path of your home directory (it will start with a /).
  2. The contents of the file hw1_file in the pub/hw1Files directory in cs155’s home directory (2 lines)
  3. The output of the program hw1_prog in the pub/hw1Files directory in cs155’s home directory (2 lines)

Add the command you would type for each of these items to the homework file hw1 in the order shown, not the output of the command. In some cases you will also need to execute the command to complete the remainder of these items. You should have 13 lines in your file after your complete these items. The answers for these items must each be a single Unix command. Semicolons (;) and pipes (|) are not allowed.                 

  1. The command to make a new directory and name it Rey (not rey), while your CWD (Current Working Directory) is your home directory.
  2. The command to list the contents of the directory you just made, while your CWD is your home directory.
    Note: the file that you turn in should not contain a list of files—it should contain the command.
  3. The command to change your CWD to the directory you created above (be sure to change into that directory to finish the rest of this assignment.).
  4. The command to make a file named names in the current directory, which contains a list of all the filenames (of any type) in the bin directory of the cs155 home directory.
    Note: Write out the command to achieve this—it should take only one command.
    Another note: it is not acceptable to simply look at the directory, and then create an echo command that echoes what you saw. Your command must work, no matter what the contents of the bin directory might be.
  5. The command to copy the file you just made (called names) to a file named my-names in your home directory without changing your CWD.
  6. The command to go back to your own home directory. (Change your CWD to your home directory)
  7. The command to delete the Rey directory, that you created, including any and all files inside the directory, while your CWD is your home directory.
  8. The command to copy all of the files in the pub/hw1Files directory in cs155’s home directory to your home directory with a single command.

Your final file should have exactly and only 13 lines.                 


Useful information                

% echo "cat *.html"
cat *.html
% echo cd ~ >bad
% echo "cd ~" >good
% cat bad
cd /s/bach/a/class/cs155
% cat good
cd ~
cp hw1 hw1.save1
cp hw1 hw1.save2
cp hw1 hw1.save3


Submit your file                

Use this command to submit your file. This works when you are are in the CSB 120 Linux Lab or working remotely with a machine in the lab from your Windows or Mac system.                 

    ~cs155/bin/checkin HW1 hw1

Modified: 2018-01-21T13:09                 

User: Guest                 

Edit History Source
Apply to CSU | Contact CSU | Disclaimer | Equal Opportunity
Colorado State University, Fort Collins, CO 80523 USA
© 2015 Colorado State University
CS Building