CS253: Software Development with C++

Spring 2020

Commands

The Linux Command Line                

Description                

Part 1 — Paths                

  1. Use the cd command to go to info’s home directory.
  2. What command will tell you where you are? Do it.
  3. Use cd to go to the bin directory under cs253’s home directory.
  4. What command will tell you where you are? Do it.
  5. Use cd to go back to your home directory.

You are copy & pasting all your commands into another file, to show the TA, right? It would be a shame to do all this and not have anything to show to the TA.                 

Part 2 — Viewing Files                

  1. Use cat to view ~info/printers.
  2. Use cat to view ~cs253/pub/hamlet.txt. Did you get all that?
  3. Use more to view ~cs253/pub/hamlet.txt. Use q to exit more.
  4. Use head to view the beginning of ~cs253/pub/hamlet.txt.
  5. Use tail to view the end of ~cs253/pub/hamlet.txt.

Part 3 — Listing files, making files & directories                

A few file commands:

  1. Go to your home directory.
  2. Copy the file dwarfs from ~cs253/pub to your home directory.
  3. Rename it to seven.
  4. Make a new directory called Zulu.
  5. Move seven to that new directory.
  6. Generate a long listing of seven.
  7. Get rid of that new directory.

Part 4 — Commands                

  1. Copy the file dwarfs from ~cs253/pub to your home directory.
  2. How many lines are in dwarfs? Use a command do do the counting. Do not just cat the file and count it yourself.
  3. Use your favorite editor to alter the names of some of the dwarfs in your copy of dwarfs.
  4. Use diff to show the changes you’ve made.
  5. Use grep to find the dwarfs whose names contain a “u”.

Part 5 — Redirection                

  1. Run the date command, sending the output to the file now.
  2. Use cat to add the file ~cs253/pub/dwarfs to the end of now.
  3. Use grep to show the three words in ~cs253/pub/common-words.txt that contain “xy”, and then send that output to sort() to put them in alphabetical order.

Part 6 — Filename Patterns                

  1. Change your current directory to ~cs253/pub.
  2. List all the files whose names contain a dot.
  3. Copy all the files with eleven-letter names to your home directory. Do not do the counting yourself. This is a job for a computer. Imagine a directory with hundreds of files in it.

Part 7 — File Permissions                

    
% ls -l ~cs253/pub/dwarfs
-rw-r--r-- 1 cs253 class 45 Aug 28  2022 /s/bach/a/class/cs253/pub/dwarfs
  1. From your current location, copy the dwarfs file to your home directory.
  2. Go to your home directory.
  3. In your home directory, execute chmod ug=rw dwarfs to give yourself (the user) and others in your group (other students) read & write access to this file.
  4. Verify those permissions using ls.

Part 8 — Credit                

Show your work to the TA for credit.