Getting Started : Exercises

Exercise 1 : Connecting to linux.ox.ac.uk

  1. Launch a terminal session program (TELNET).
  2. Type linux.ox.ac.uk then press the <Return> key.
  3. You will be asked for your username at the login: prompt.
  4. If you have logged in successfully, you should see the linux.ox.ac.uk% prompt.

Exercise 2 : Simple Commands

  1. Find out the current date and time with the date and time commands. Date gives the current date and time while time gives the command execution time.
  2. Examine the current quota for your course username by typing quota

 

Exercise 3 : Accessing Help

  1. On linux.ox.ac.uk, there are two help systems, the man pages as described above and Help on using linux.ox.ac.uk which is an OUCS system. To access the Help on using linux.ox.ac.uk information, type help and press <Return>.
  2. Read the instructions at the bottom of the screen to see how to use the information system.
  3. Move around the options on the screen using the arrow keys. Various words will be highlighted as you move. Pressing <Return> when the item you want is highlighted will take you to the page of information on that topic.
  4. Browse through the headings available under General Help on Unix.

 

Exercise 4 : Changing your Password

  1. The password rules on linux.ox.ac.uk can be quite complicated. Details about them and how to change your password can be found by typing help (as above), then selecting Getting Started on linux.ox.ac.uk and Passwords. If you are already in Help, type M for the Main Menu and confirm that is where you want to go then select Getting Started on linux.ox.ac.uk.
  2. Read through the information given.
  3. When you have read it, quit from the help system by typing q and confirming that you wish to quit.
  4. To actually change your password type passwd and follow the instructions to change your password to one of your choice, remembering the rules and guidelines given in the help system. But only do this if you wish to change your password.

 

Exercise 5 : Using the Man Pages

  1. Look up the man page on the ls command. What does the ls option -x do?
  2. Find out what sub-commands are available while browsing the man pages by typing h
  3. When you have finished reading the information, type q to return to the linux.ox.ac.uk% prompt. Alternatively, browse to the end of the information, press any key and the linux.ox.ac.uk% prompt will reappear.
  4. Look up the page for mv then use man -k rename to list all the pages on the topic of renaming files and directories. Is mv one of the pages listed?
  5. Type man quota to find out about the quota command. Search for the next page containing the word group by typing /group then pressing <Return>.

 

Exercise 6 : Manipulating Files

  1. List all the files in your current (home) directory with ls.
  2. Try typing ls -l to see the difference. This will give more information on the files. How many directories do you have?
  3. List the files using ls -a to see the hidden files and finally with ls -la to see all information on all the files.
  4. List full details for everything beginning with v using the ls -l v* command.

 

Exercise 7 : Creating a File

  1. Create a file called intro using the pico editor by typing pico intro and type the following text into it:
    Two files in your main (home) directory are executed automatically on login. One, .cshrc, contains C-shell setup material, that is set commands to define various shell variables and alias commands to provide alternative names for commands. In fact, this file is executed whenever you begin a (new) C-shell, including at the start of a batch job.
  2. Save the file and leave pico with <Ctrl/x>. Confirm you want to save the file and press <Return> to accept the filename.

 

Exercise 8 : Displaying and Printing Files

  1. Display this file on the screen with the cat intro command.
  2. Use cat to display a file on the screen.
  3. Display the file again but this time use more to see it a page at a time.
  4. Print the file on the userarea lineprinter.

 

Exercise 9 : Copying, Renaming and Deleting Files

  1. Use cp afile text to copy the file called afile to text.
  2. Copy afile2 to text. text already exists and you do not want to overwrite it so type n, when asked to confirm your actions, to cancel the copy.
  3. Rename text as txt with the mv command.
  4. Now copy afile2 to text again. This time there is no file called text to be overwritten.
  5. Type rm t* to delete all files starting with t. Only confirm deletion of text.
  6. Rename txt as afileand delete text. You should now have all the same files as when you started! Check with ls.

 

Exercise 10 : Redirecting Input and Output

  1. List your home directory to the file dirlist with the ls > dirlist command. Use pico to check the contents of dirlist.
  2. The finger command can be used to obtain brief details about people who have usernames on a particular machine. Type finger chris | more to list the people called Chris a page at a time.

 

Exercise 11 : Working with Directories

  1. Create a subdirectory called coursestuff under your home directory with the mkdir command.
  2. Change directory to coursestuff and list its contents.
  3. Copy the some files to this directory. As they are in your home directory and you are currently in the coursestuff directory, you will need to use cp ~/***** .(full stop). The full stop means 'here'. That is, copy this file to the current directory and keep its name.
  4. Create another new directory under coursestuff called newfiles
  5. Change directory to newfiles and check the path with the pwd command.
  6. Type cd then pwd to move back to your home directory and check its path.
  7. From your home directory, move the a file from the coursestuff directory to the newfiles directory and rename it as first. The command will be:
    mv ~/coursestuff/***** ~/coursestuff/newfiles/first
  8. Type ls ~/coursestuff/newfiles to check.
  9. Now, change directory to coursestuff and copy another file to newfiles, renaming it as second. Type cp ******* newfiles/second. When moving or copying files the pathnames can often be simplified depending on which directory you start from.
  10. From the coursestuff directory, type rmdir newfiles to delete the directory. As it is not empty, you will not be able to.
  11. Change directory to newfiles, check its contents, which should be first and second, and delete them with rm *
  12. Use cd .. to go back down the directory structure to coursestuff and delete the newfiles directory. This time it will succeed.