Webmail | Campus Compass | Events | FSP Lookup | Infoboard

Sunday, November 22, 2009 10:53 AM

Inside Tufts University Information Technology
GO >
this site tufts.edu people
   

Emerald Guide - UNIX

Overview | Upgrade FAQ | Account Rules | Space | Software | Access | UNIX | Web Hosting

UNIX

UNIX is the name of the operating system that runs on Emerald and many other computers on campus. The operating system is the software that is used to communicate with the hardware of the computer. It's analogous to Windows or Mac X (operating system) on an computer (hardware). After you login to your account, you will see a prompt that looks something like this:

Emerald:~>

The prompt reflects your current directory (or your "home" directory - '~' ) when you first log in. As you change directories, the prompt will mirror the directory changes. This prompt tells you that Emerald is ready for you to type in a command, like ls to see a listing of the files in your directories.


Common UNIX commands


cd change directory
cp copy files or directories
logout command to exit
lpr print command
ls list files and directories
ls -a list all files, including hidden files
mesg control whether or not you receive messages via talk or writing
mkdir create (make) a directory
more display a text file screen by screen
mv rename (move) a file
passwd change password
pico simple full-screen text editor
quota displays your account's disk quota and usage
rm delete (remove) files from a directory
telnet allows users to login to one Internet computer from another
tail views the end or bottom text of a long text file


Listing Files in a Directory

The ls command is a request to the system to list the contents of a directory. If no directory is specified on the ls command line, the list of files displayed will be of your current directory.

There are a number of options available to use with the ls command that will display more detailed information about the files in the directory. The example below illustrates this point.

With the command:

ls -al

the displayed information will be similar to the following:

drwxr-xr-x 1 juser 240 Jan 4 15:22 people.old
drwxr-xr-x 1 juser 32 Feb 12 20:31 people

The -a (all) option asks that all files be listed and the -l (long) option asks for a detailed listing. Without it, only the names of the files and directories are shown.

In the above example, the first column shows the protections on each file, the second column indicates the type of file (1 for file, 2 for directory, etc.), the third column shows the owner of the file, the fourth column shows the size of the file, the fifth through seventh columns show the date and time the file was last revised, and the last column shows the name of the file or directory.

If the directory listing takes more than a screen, use the command

ls -al | more

This sends the output of the ls command to the more command, which displays things one screen at a time.


Viewing Files

If you wish to look at a long file, you can use the more command. This command will display the file you specify on the screen, one screen at a time. There will be a prompt at the bottom of each screen directing you to press the spacebar to see the next screen. It will also tell you what percentage of the file you have already seen.

To look at the file named longfile, you could type more longfile. After you view each screen, simply press the spacebar to see the next screen. To scroll forward one line at a time, press . To stop viewing before the whole file has been shown, press ctrl-c.

To search for a pattern, such as mary had a little in the file longfile during the more session, press the / key, type the pattern, and press .

You can also try less, which lets you scroll backwards.


Creating Directories

The mkdir command creates (makes) directories. Let's suppose that you want to organize your files into two subdirectories, named courses and fun. To do this, you could enter the following commands:

mkdir courses  
mkdir fun

This creates two directories beneath your current directory (not necessarily your root directory). In this way, you can have multiple levels of directories.

To delete the fun directory and all of its files, type rm fun .


Changing The Current (working) Directory

To change the current directory (also reffered to as the working directory), use the cd (change) command plus the pathname of the new default directory.

To change the working directory to /tmp, type cd /tmp . To back up one level in the directory structure, type cd .. To get back to your root or home directory type cd.


Moving Files Between Directories

The principal function of the mv command is to move a file from one place in the file system to another. The file name in the destination directory does not have to be the same as it was in the original directory. Obviously, a move differs from a copy operation in that the original of the file disappears.

For example, to move a file named file1 from your current directory to the bio110 subdirectory with the same filename, type mv file1 bio110/file1 .

If you are working in the ~/courses directory, and want to move the file to your home directory and change the name, type mv file1 ~/newfilename .


Renaming Files

As seen earlier, the mv command moves files around in the filesystem. In the process of moving a file or a directory, mv can also rename the file. The process of renaming a file is a side effect of the move function.


Copying Files

To copy a file into another file, use the cp command.

Example:

To copy the contents of the file read.me into read.this

type
cp read.me read.this .

Both read.me and read.this will now exist and their contents will be identical.


Removing Files

The rm command deletes (removes) files from a directory.

For example, to remove the file read.this, type rm read.this .

Caution: Use the rm command with extreme caution! Once a file is deleted, it is very difficult to get it back. Unless it has been in your account long enough to have been saved during a regularly scheduled system backup, you will not be able to retrieve it at all. If the file has been saved as part of a regular system backup and is an extremely important file, contact the IT Support Center at ext. 73376 to discuss retrieval.


Managing Your Disk Space

The quota command shows your current disk space usage. Every time you login to Emerald, your disk usage is displayed. Your allocation limit is 5000 blocks. At the soft limit (4000 blocks) you will receive a warning message. Your current usage is displayed under the column titled blocks. You may issue the quota command at the UNIX prompt at any time.


Printing Files

To make your file look nice and be easy to read when printed, you can use the pr command.

The output of pr is separated into pages and normally each page has a five-line header at the top and a five-line trailer at the foot. The trailer at the foot of the page consists of blank lines. In the header, one of the lines forms a title consisting of the date the file was last modified, the file name, and a page number.

Font Size
Printer-friendly version

Profile

What's New in UIT?

What's New in UIT?

 Interested in learning more about UIT's current projects, IT plans, and staff initiatives? Visit us at UIT Update.


Read More >>

 

Tufts Home | Inside Tufts | Site Map | Site Feedback | Contact University Information Technology
© 2009 Trustees of Tufts College. All rights reserved.

Tufts University