COMP2021 Lab1: Linux & UNIX Basics


Activating your CS Account (non-CS/CPEG/EE students only)

By clicking this link you can follow the steps to activate your CS account, which is different from your ITSC account. CS/CPEG/EE and other students who have taken a CS course recently will have already activated this account. Your CS login name is the same as your ITSC login name.

Logging in

At the login screen, simply enter your username and password following the instructions.

Accessing the Web

After logging in, use a browser to access the comp2021 web page at http://course.cse.ust.hk/comp2021/. You can open the browser by clicking the second shortcut Web Browser in the screen's lower-left corner. You can also open the browser in KMenu (first shortcut) >> Internet >> Firefox Web Browser or Konqueror. Besides seeing the course web page and lab web page, try to access the web page of your TA through the comp2021 web page. If you have problems opening firefox, please follow the instructions here to troubleshoot the problems.

Printing in the Lab

The current settings of the lab machines do not allow students to print with the printers in the lab. You are suggested to submit the print job to other CS labs.

Viewing the Lecture Notes

With the CS Lab2 machines, there is no Microsoft Office. However you can use OpenOffice (KMenu >> Office) to display the COMP2021 PowerPoint notes. You can simply open the notes by clicking the links in the course website, or open them locally using the OpenOffice presentation software via the fifth shortcut called "Presentation".

Try some editors

The common usage of editor is create a new file, edit, search, replace, copy and paste. You can download a file here. You can find tutorial for emacs and vim.

Familiarizing yourself with the Linux environment

The objective of Lab 1 is for you to try different Linux commands and know more about the Linux environment. The system used in CS Lab 2 is CentOS 5.6 (a RedHat variant) with the KDE windows manager. Besides using the consoles inside CS Lab 2, you can also access the machines remotely by SSH to hosts csl2wk01.cse.ust.hk to csl2wk40.cse.ust.hk.

Remember: Since the CS Lab 2 machines can be remotely accessed, please NEVER shut down the consoles by force!

Open a Linux command-line terminal by double-clicking on the Terminal shortcut on the desktop. You may also open it by KMenu >> System >> Terminal. Try to get familiar with the Linux commands with the following steps.

  1. Use the vi editor to create a file called lab1 in your home directory (just type vi lab1 in the terminal) with the following contents (you can use emacs if you prefer) :
    SOME SIMPLE UNIX/LINUX COMMANDS...
    ls - list the files in the current directory
    cat - concatenate and displays file contents
    rm - remove a file
    cp - copy source file to target file
    mv - move a file 
    man - display the reference manual pages by keyword
  2. Copy the file lab1 to a file called lab1a.
  3. Check: What files are now in your home directory?
  4. Show the contents of lab1 and lab1a on your screen using ONE single command.
  5. Try cal 2014 to show the calendar for the year 2014.
  6. Try date to show the current date and time.
  7. Try whoami to show who you are.
  8. Listing the contents of a file:
    Save some text of this web page to a file called webpage (using copy & paste, perhaps). Use the following commands to display the file. Use the man command to understand the difference between the four commands. (press q to quit man)

    Quiz

    1. What command lists the contents of webpage with a line number at the beginning of each line?
    2. What command lists the first 6 lines of webpage?
    3. What command lists the last 6 lines of webpage?
    4. What command lists the contents of webpage with the first 20 lines skipped?
  9. Log out. (under Menu in the lower-left corner of the screen)

Lab Answers

Please find the answers for lab 1: anslab1.txt.

Linux on Virtual Machine

You can find a video on how to install VMWare with Ubuntu on your Windows PC here.


Any inquiry please contact your TAs by email.