TutorialGuru: Free Tutorials for your life
Search TutorialGuru:
Free TutorialEdit This Tutorial
Recently Viewed Tutorials

unix

This tutorial teaches the very basics of UNIX and shows how to navigate a unix system.

Tutorial

What is UNIX?

UNIX is a computer operating system.

UNIX is a general name for a number of operating system products including

  • AIX
  • DEC UNIX
  • HP-UX
  • LINUX
  • SOLARIS

The two most important components of the UNIX operating system are

  • Kernel
  • Shell

The Kernel instructs and controls the hardware components of the system.

The shell is the interface between the user and the rest of the operating system.

Changing your password

Your password can be changed by entering passwd at the command prompt. The command prompt differs between shell types but is most commonly shown as a $ symbol.

$ passwd

When you press the enter key the system will respond "Changing password for username". If you had a password already you would need to enter that then your new password otherwise you will just need to enter your new password.

Simple user commands

There are a few small commands that you can use to interrogate the system:

$ who

This will list the names of all the people currently logged into the unix box.

$whoami

This will list the name of the person logged into the terminal. (probably your username).

$tty

Tells you the number of the terminal you are on. (useful when collecting printouts)

$listusers

Lists all the users set up on the system.

$listusers - g students

The -g attribute lists all the users in a group called students

$listusers -l user1

Gives a full detailed listing about user1.

$clear

Clears the screen

$date

Displays the current date

$echo "message"

Displays a message on the screen

$banner "message"

Displays a large ascii banner on the screen

$ls

Lists all the files in the current directory.

Sending messages between terminals

Unix has a very simple messaging system between users.

User1 wants to write to User2.

User1 types $ write user2

user1 can then type any amount of text into the keyboard and it will appear on user2's terminal.

Whenuser1 has finished he can press ctrl and d on the keyboard to stop sending.

If you don't want to receive messages type $ mesg n.

If you want to turn messaging back on type $mesg y

If you aren't sure of the messaging setting type $mssg

Sending mail

More popular than messaging is the mail facility which enables user1 to send a message to user2 without interrupting what user2 is doing.

For user1 to send a mail message to user2 he types:

$mail user2

He can then type the message followed by CTRL + D to end.

To read the mail user2 just needs to type $mail

After typing $mail user2 will see the most recent message plus a ? command prompt.

The ? command prompt lets user2 know he is still in the mail facilitiy and he can type:

  • d - delete the message
  • p - redisplay the message
  • q - quit from mail
  • - read the next message
  • s filename - save the message to a file named filename
  • w filename - same as s
  • r - reply to the message
  • m username - forward the message to another user
  • ? - see a list of available commands

File Structure

UNIX has a folder structure in the same way windows does. In windows you will have a windows directory with system, system32 etc.

In UNIX you have a similar structure whereby you will have folders full of unix system files and folders for your own applications.

A Typical Folder structure is as follows:

/sbin - system programs folder

/etc - machine adminstration files

/dev - device files such as printer drivers

/home - a place where a user will store his/her work

/stand/unix - unix kernel

/usr - static files that can be shared by users

/usr/bin - all commands besides system admin commands

/var - varying files and directories

/tmp - temporary files

Navigation

As a user you will probably only be interested in the /home directory.

Imagine you are user1 your allocated directory on the unix box will probably be /home/user1.

You can then create directories such as images, work, programs.

Your folder structure will be

home/user1
home/user1/images
home/user1/work
home/user1/programs

If you are user1 you will probably be in the home/user1 folder when you first log in. To find out where you are type

$pwd

To navigate from the home/user1 directory into the images directory type:

$cd images

You can also navigate to the images directory using the full path:

$cd /home/user1/images

If you are in the images directory you can get to the work directory by typing:

$cd /home/user1/work

or

$cd ../work

The .. stands for one level up.

If you are in the user1 directory you can get a list of all the files in that directory by typing:

$ls

To get a list of all the files in all directories type

$ls -R

This stands for list recursive.

If you type:

$ls -a -R

You will get a list of all the files in all the directories including hidden files and finally

Creating directories

To create a directory type

$mkdir directoryname

Removing directories

To remove a directory type

$rmdir directoryname

To remove all directories and files within a directory use

$rmdir -r directoryname

Displaying the contents of a file

To display the contents of a file in a directory type

$cat filename

To display the contents of two files on the screen type

$cat filename1 filename2

If the file scrolls on the screen type the word more after it as follows:

$cat filename|more

Alternatively you can use the pg command

$pg filename

Copying files

To copy a file type

$cp filename1 filename2

This will create a copy of filename1 in a file called filename2.

If you wish to copy filename1 from the directory user1 into user1/work type

$cp filename1 user1/.

To copy a whole directory structure including files type

$cp -r images work/.

The above command would have copied everything from images including subdirectories into the work directory.

Moving files

You can move files by typing

$mv filename1 work

Summary

This has been a fleeting guide about navigating your way around UNIX and doesn't even scratch the surface.

by garynewelluk on Thursday, October 18, 2007

 

 

Information About This Tutorial
Tutorial Requestor: Anonymous
Request Created: 1/31/2006 1:28:19 AM
Request Description:  
2122
 
© 2005 That Network. All Rights Reserved. Part of That Network.
This page last updated 10/18/2007 10:02:48 AM .