Tutorial 1

In this tutorial, we are going to learn some basic commands of Unix. We have two Unix servers to login:

cs1.utdallas.edu

cs2.utdallas.edu

To login to any of these servers remotely, we can use any of the following two programs:

1. Xmanager

2. PuTTY

At first we will see briefly how to login with both of these software. Later we will move on choosing one.

Xmanager:

Xmanager is a group of programs. We will use Xbrowser program of the group to login to our server. To start Xbrowser, we have to go to start->Programs->Xmanager->Xbroswer like below:

From Xbrowser, select cs2 (cs2.utdallas.edu) as below and double-click on it:

If you see the following screen, select the ip starting with 129.110.97. Otherwise, skip this instruction.

You should be able to see the login prompt now:

Type your netid in the field:

Press enter. Then type the password associated with your netid:

If you see the following scree, you are in!

Open the console as the following picture shows:

Here you get the console window, where you can practice most of the commands you will learn today:

Type "exit" to exit the console. Then click on the small exit button on the menu bar:

Click OK to end the session.

So, that's the end of your Xbrowser session!!

PuTTY:

On your desktop, you will find an icon called SSH. Double-clicking on it starts PuTTY.

In the Host Name field, type cs2.utdallas.edu and then click open:

You will have a PuTTY security alert window, click yes on it:

In the login prompt, type your netid:

In the password prompt, type the password associated with netid:

If you logged in successfully, you should be able to view the following welcome screen:

Congratulations! You have logged in successfully. To logout, type "logout" and press enter:

So, there ends your PuTTY session.

Some useful commands:

The commands we will see in this tutorial are:

date
pwd

mkdir

cd

ls

cat
cp
mv
rm
rmdir
 

1. date:

To view the current system date and time, type the single command "date". The result should be similar to following:

{cs2:~} date
Wed Aug 30 18:04:36 CDT 2006
 

To view only the month, use the format "+%m":

{cs2:~} date +%m
09
 

To view the month name, use "+%h":

{cs2:~} date +%h
Sep
 

They can be combined into one command:

{cs2:~} date +"%h %m"
Sep 08
 

While using multiple format specifiers, they must be enclosed within quotes and a single + must prefix them. To get other formats, here is a list:

d - The day of the month (1 to 31)

y - The last two digits of the year

H, M and S - The hour, minute and second respectively

D - The date in the format mm/dd/yy

T - The time in the format hh:mm:ss

2. Viewing the present working directory with pwd:

If we want to see in which directory we are now, we can use the pwd command:

{cs2:~} pwd
/net/core/export/home/cs/002/w/weiminma
{cs2:~}

3. Displaying list of filenames with ls:

To view the list of files we have, we can type "ls":

{cs2:~} ls
HW1 HW2 temp HW3 Bonus2 HW4 HW5
{cs2:~} ls -F
HW1/ HW2/ temp/ HW3/ Bonus2/ HW4/ HW5/

 

The option "-F" marks the directories with a trailing slash (/). Moreover, the option "-F" marks the executable files with a trailing asterisk (*), FIFOs with a trailing vertical bar (|), symbolic links with a triailing "at" sign (@).

4. Creating directory with mkdir:

To create a directory, we can use the command "mkdir" which takes the directory name as its only parameter:

{cs2:~} mkdir scripts
{cs2:~} ls -F
HW1/ HW2/ temp/ HW3/ Bonus2/ HW4/ HW5/ scripts/
 

Note that, "-F" follows the ls command. It marks directories with a trailing '/' to make it easier for users to identify.

5. Changing directory with cd:

To change the working directory we have to use the cd command. Suppose, we want to get into the newly created scripts directory. We have to type:

{cs2:~} cd scripts
{cs2:~/scripts} pwd
/net/core/export/home/cs/002/w/weiminma/scripts
 

6. Show enpty directories with ls:

To view the list of files we have, we can type "ls":

{cs2:~/scripts} ls

We can see that the directory is empty.
 

7. Create a file with redirection

Instead of displaying the date on the screen, we can redirect the output into a file:

{cs2:~/scripts} date > foo
 

">" is the redirection operator, which saves the output of the "date" command into a file called "foo", instead of displaying it on the screen.

To view the list of files we have, we can type "ls":

{cs2:~/scripts} ls

foo

8. Displaying file with cat:

The cat command displays the content of files. To view the file we just created, we can type:

{cs2:~/scripts} cat foo
Sun Aug 3 11:00:46 CDT 2008
 

9. Copying a file with cp:

cp command copies a source file to a destination location. It takes two parameters. First one is the source file name, and the second one is the destination file name. If we want to copy the file we just created with a new name "foo.sh", we have to type:

{cs2:~/scripts} cp foo foo.sh
{cs2:~/scripts} ls -F

foo foo.sh
 

10. Renaming a file with mv:

The mv command renames a file. It takes two parameters. The first parameter is the old filename and the second one is the new filename. To rename the file foo.sh to foo.shell, we have to type:

{cs2:~/scripts} mv foo.sh foo.shell
{cs2:~/scripts} ls
foo foo.shell

11. Removing both files with rm (one at a time):

The rm command removes a file. As the only parameter, it takes the filename. It asks the user whether to remove to file to prevent accidental removal. To remove the foo.shell file, we have to type:

{cs2:~/scripts} rm foo.shell
rm: remove foo.shell (yes/no)? y
{cs2:~/scripts} ls
foo

{cs2:~/scripts} rm foo
rm: remove foo (yes/no)? y
{cs2:~/scripts} ls

When prompted (yes/no), we can type 'y' to confirm or 'n' to abort.

12. Removing a directory with rmdir:

rmdir command is used to remove a directory. It takes the directory name as its only parameter. Suppose, we want to remove the directory scripts which we created few minutes ago. To do this, we have come out of the directory first. We can go to its parents directory by the command "cd ..":

{cs2:~/scripts} cd ..
{cs2:~} pwd
/net/core/export/home/cs/002/w/weiminma
 

Now, we can use the rmdir command to remove it:

{cs2:~} rmdir scripts
{cs2:~} ls scripts
scripts: No such file or directory

Note that, we can remove only empty directories in this way.

The tutorial ends here!