A Quick Tour to CS UNIX Environment at HKUST

CS LAB UNIX Hosts

You can connect to a CS UNIX host by telnet to one of the csl2su#.cs.ust.hk where # is from 1 to 41.

Telnet

Basically, you can use any telnet program to establish the connection. But the cssystem recommends using SSH Secure Shell. All the PCs in the CS labs have SSH Secure Shell installed. To telnet to, for example csl2su5.cs.ust.hk using SSH Secure Shell, follow these steps:

  1. Run SSH Secure Shell.
  2. Left-click on the "connect" button (circled in the above figure) on the toolbar.
  3. Enter csl2su5.cs.ust.hk as the host name, and your unix ID as the user name.
  4. Enter your password when the program asks for it.
  5. You should log in sufficiently.
  6. To logout from UNIX, enter logout. You also need to click on the "disconnect" button, which is to the right of "connect".

Note: Microsoft Windows also comes with a (insecure) telnet program. You can enter telnet csl2su5.cs.ust.hk in the DOS prompt to establish a telnet session.

File Transfer

To transfer a file to your CS UNIX account, ftp to one of CS UNIX hosts mentioned in previous section. Similar to telnet, you can use any ftp program to establish the connection. But the cssystem recommends using SSH Secure File Transfer. All the PCs in the CS labs have SSH Secure File Transfer  installed. To ftp to, for example csl2su5.cs.ust.hk using SSH Secure File Transfer, follow these steps:

  1. Left-click on the "Connect" button (circled in the above figure) on the toolbar.
  2. Enter csl2su5.cs.ust.hk as the host name, and your unix ID as the user name.
  3. Enter your password when the program asks for it.
  4. You should log in sufficiently.

You can rename files, delete files, create/remove directories and change files access permissions (right-click and choose "properties").

Note: Microsoft Windows also comes with a (insecure) ftp program. You can enter ftp csl2su5.cs.ust.hk in the DOS prompt to establish a ftp session. This program requires knowledge of ftp commands.

Some Basic UNIX Commands

Directory

In DOS, you can list the files in a directory by using dir. The corresponding UNIX command is ls. To list in detail the files in a directory, enter ls -l.

Making and Removing Directory

To make an empty directory, use the command mkdir dir. The UNIX command rm can only be used to remove a file. To remove a directory, you must use rmdir.

Editing a Text File

There are several commands to edit a text file. The most user-friendly one is pico. It is easy to use.

Other popular editors are emacs and vi. They are more powerful but harder to use.

Showing a Text File

There are several commands to display the content of a text file:

cat Display the whole content without stop.
more Display the content page by page. 
less Similar to more, but has more functions (e.g. can move backward).

Example: more libsort.cpp

Man Page

Almost all UNIX commands come with a manual (a.k.a man page). To show the manual of a command, enter man cmd. For example, to show the manual of ls, enter man ls.

A manual is usually longer than one page. So people generally redirect the output of a man page to more (or less) by pipelining: man ls | more.

If you simply want to redirect the output of a man page to a text file, enter man ls > ls.txt.

This redirection technique can be applied to store the output of a program into a text file.

C++ Compiler

The c++ compiler in UNIX is called g++. To compile one source code file, for instance called hello.cpp, enter g++ hello.cpp. If there is no message then the compilation is success. (In UNIX environment, no message usually means okay.) The executable binary is called a.out. You can rename this file by the command mv. You can also specify the executable filename during the compilation. Suppose you want to name it as "hello". Then enter g++ hello.cpp -o hello.

References

The SSH programs can be downloaded from cssystem homepage.



Ken Lee
cswkl@cs.ust.hk
Last update: 2002.10.08