INTRODUCTION TO UNIX
As an operating system, Unix is similar in some
ways to DOS, but it is much more capable and complex. Our Unix systems at Smith provide
a number of applications that are full-featured but simple to use. This document
describes those features and lists commonly used commands.
Note: You can get
more help by typing the following at the system prompt:
man command_name (or man
man for help
on help!)
Unlike many other operating
systems, Unix is case-sensitive. That means that typing SSMITH as
your username is NOT the same as typing ssmith. We recommend using all lower
case letters for filenames and commands unless otherwise specified.
Note: For information about creating web pages and
posting them on the Sophia server, see: Posting
pages on the Sophia server
Getting started
Directory management
File management
Printing on the Unix system
Getting Started
Although a Unix computer is a physical machine, you don't have to sit
down in front of it to use it. Most people at Smith connect to our Unix computers
via personal computers in on-campus labs, offices, and student rooms, or from off-campus.
Once you have logged on to the Smith system, you can connect to the Unix host of
your choice.
To log in to your Unix account:
- Use SSH Secure Shell software to connect your personal computer to a Unix server
on the Smith network.
Note: If you don't already have Secure Shell on your computer, you can download it from the Smith software page.
- When prompted for a host, enter: hostname.smith.edu
Example: sophia.smith.edu
- When prompted for a password, enter your password for that Unix computer.
To change your password:
- Log on to the Unix system with your current password.
- At the system prompt, type passwd. It must be in lower case!
- Type your current password. Press Enter.
- Type your new password. Press Enter.
- Type it again for verification. Use the new password next time you log in.
Directory Management
In the Unix system you perform most functions by typing commands. You
enter these comands at the system prompt. The system prompt lists the current directory
and the host name in brackets ([]) and always
ends with the $ symbol.
For example, when you
log in, you are at the root directory of your account and the prompt is: [<username>@sophia
~]$
If you move into your public_html directory, the prompt would become: [<username>@sophia
public_html~]$ and so on.
You can create directory names longer than 8 characters. Use the
underscore character (_) instead of a space for compound directory names. Remember,
Unix is case sensitive, so directoryname is not
the same as Directoryname or DirectoryName.
To create a new directory:
Move into the directory in which you wish to create a subdirectory.
Type: mkdir directoryname.
This creates a subdirectory of the current directory, or a "child" of
the "parent" directory. Creating the directory does not move you into
that subdirectory, it only creates it.
To change directories:
- At the [<username>@sophia ~]$ prompt,
where <username> is your username, type cd directoryname.
For example, cd public_html would
move you into your Web pages directory.
- To move up a directory level, type cd ..
The prompt will change to reflect which directory you are in.
To return to the root directory:
Type the change directory command without a directory name specified.
That is, cd. This will return you to home base and you may move to another directory
from here, if you choose.
To delete (or remove) a directory:
At the system prompt, type: rmdir directoryname.
In order to delete a directory, it must be empty and you must be
in the parent directory. To delete files within a directory in order to empty it,
see File Management.
To change permissions (for files or directories):
There are 3 kinds of permissions for 3 kinds of access. 'Owner',
which is you, 'Group' which is largely unnecessary (and so this documentation will
largely ignore it), and 'Other(public)' for 'Read', which is looking at a file,
'Write', which is changing, adding, or removing files, and 'eXecute' which is running
files (like scripts) or getting into directories. In order to get into a directory,
you must be able to 'eXecute' it.
In order to see what these permissions look like, when you have
used SSH to get into sophia, and you're at the [<username>@sophia
~]$ prompt (where <username> is your username), you can type ls
-laF (ls for list, - to add specifications to the list: l for long, a for
all, F to show types of files. (see File Management for a list
of helpful commands.)
You'll get a list something like this:
drwx--x--x 3 user staff 4096 Apr 10 15:21 ./
drwxr-xr-x 350 root root 8192 Apr 6 14:03 ../
-rw------- 1 user staff 3587 Apr 18 16:46 .bash_history
-rwx------ 1 user staff 304 Apr 6 14:03 .bash_logout*
-rwx------ 1 user staff 191 Apr 6 14:03 .bash_profile*
-rwx------ 1 user staff 124 Apr 6 14:03 .bashrc*
-rw------- 1 user staff 157 Apr 7 10:46 dead.letter
-rw-r--r-- 1 user staff 0 Apr 6 14:03 .forward
-rw------- 1 user staff 22869 Apr 17 15:59 mbox
drwxr-xr-x 3 user staff 4096 Apr 10 09:50 public_html/
In your home directory (./), the owner (which is you), will have all the permissions: rwx - Read, Write, eXecute. Other (other people) will have only x, because you want them to be able to get into the directory to see and get into public_html (which is the folder for your website), but you don't want them looking at anything else.
Looking at the letters on the left:
d is for directory. The first 3 characters after that owner (your) permissions, the next 3 for group, and the last 3 for Other (...everyone else).
So if you look at this line:
drwx--x--x 3 user staff 4096 Apr 10 15:21 ./
you can see it is a directory, that owner (you) have Read, Write, and eXecute permissions. Group and Other (public) have only eXecute, meaning they can move into that folder, but not see, change or delete it.
If you look at this line:
drwxr-xr-x 3 user staff 4096 Apr 10 09:50 public_html/
you're looking at the area on Sophia that holds your webpages. Again, it is a directory, and again, the owner (you) has rwx, but this time, Group and Other have r-x, meaning they have Read (so they can see your pages), they DO NOT have Write (so they can't change them), and they have eXecute (so they can get into the directory.)
Other information listed there is your username, the size of the file, the date the file was created, and then the actual name of the file. If there is a / after the name, it means it is a directory (just a repetition of the d in the beginning).
To change permissions, you will use the chmod command.
Look at this line:
-rw------- 1 user staff 22869 Apr 17 15:59 mbox
‘mbox’ is your mailbox on sophia. Say you wanted other people to read that, you would type chmod o+r mbox which basically means Change Mode (for) Other: add Read (to) mbox.
If you typed ls -laF again, you would see:
-rw----r-- 1 user staff 22869 Apr 17 15:59 mbox
If it suddenly occurred to you that letting others read your mail would be a bad thing, you would type chmod o-r mbox which basically means Change Mode (for) Other: remove Read (from) mbox.
File Management
Knowing how to manage your files in an important part of using Unix.
Because there are no on-screen displays, it is important to know the commands in
order to keep your files organized.
To examine files in a directory:
| ls | Displays a list of the files in the current directory. |
| ls -l | Displays a list of files with information about their security and size. |
| ls -lt | Displays a list of files, with full information, sorted by date of last modification instead of alphabetically. |
| ls -laF | Displays a list of all files, with full information, sorted alphabetically and with end-line indicators about what type of file they are. |
To move and copy files:
| mv file newfile | Renames file as newfile. |
| mv file directory | Moves file into a specific directory. |
| cp file newfile | Copies file as newfile; does not change file. |
| cp file directory | Makes a copy of file and moves it into a directory; leaves original where it is. |
Note: If the move or copy commands are about to write over
an existing file, the system will prompt you to confirm the command.
Other commands:
rm filename Deletes (removes)
files
Note that you can use the wildcard character * to
operate on groups of files.
For example, rm *.txt would
delete all files with the extension *.txt in the current directory.
Be careful
when using the wildcard character, so that you don't inadvertently alter more files
than you intend. For example, rm * would delete
all the files in the current directory!
Printing on the Unix System
Printing is no longer available from Sophia.
Back to top >














