SC14-Handbook

BASIC UNIX COMMAND LINE EXERCISES

Test 1 :

  1. Go into the subdirectory called "unix". Verify all exercises by doing "ls"
  2. Copy the file "foo.txt" into "foo.txt.copy".
  3. Rename the file "foo.txt.copy" to "foo2".
  4. Move the file "foo2" into the "data" subdirectory.
  5. Create a new subdirectory called "new" in the unix directory.
  6. Move the file "foo2" in the "data" directory into the "new" directory.
  7. Move the file "foo2" in the "new" directory back into the "unix" directory and change the name to "foo.old".
  8. Delete the file "foo.old".
  9. Remove the "new" subdirectory.

Test 2 :

  1. Display the file "verylong.seq" on the screen using "cat" command.
  2. Same as 2a but use the "more" program instead.
  3. Test to walk upwards and downwards in the file using the "more" program.
  4. Search for the word "Length" using the "more" and the "less" program, compare the results.

Test 3 :

  1. Change the protection of your own file "foo.txt" so that anyone may read it.

Test 4 :

  1. Make a copy of the file "edit.me" and edit it using the "pico" editor.
  2. Make another copy of "edit.me" and call it "edit.txt"

Test 5 :

  1. Change the password to your account.

Test 6 :

  1. Use the man pages to find answers to the following:

    What is the option to "ls" to list all files? Try it in your home directory. Which files do you see now that you don't see with "ls" alone?

  2. What is the option to "ls" to list all files in all subdirectories. Try it.

  3. What is the command to count lines, words and characters in a file?

  4. How do you make this command display only the number of lines?

Test 7 :

  1. Use the "ls" command and list all files that contains "seq" in the filename.
  2. Copy all files in the "unix" directory into the "text" subdirectory.
  3. Make a list of your files into a file.
  4. Copy the content of all files that contain "seq" in their filename, into a file called "tot.txt".
  5. Write a single command that shows how many files you have in your current working directory.

Test 8 :

  1. Display the first 5 lines of the file "verylong.seq" on the screen.
  2. Do a case insensitive search for the string "length" in all files.
  3. Compare the files "1.txt", "2.txt" and "3.txt". Which one is different from the others?
  4. Put the first 7 and last 7 lines of the file "verylong.seq" into a file called "first-and-last".

Test 9 :

  1. List the names of all files in your whole account that end with "seq" in their filename.
  2. List all files created or changed during the last 24 hours.

Test 10 :

  1. Find out who is logged on using "w", "who" and "finger".
  2. Find out which processes that are running using "top".
  3. Get more information about one account using "finger accountname" where accountname is the name of the account. What does "No plan" mean?

Test 11 :

  1. Look at the file "test.ps" using the "more" command. What does it look like?
  2. Locate the same file using your browser, and click on its name. What does it look like now?

[Click here for answers][1]