Instructions for Managing UNIX Files and Directories

The central servers (e.g., copland.udel.edu, strauss.udel.edu, mahler.udel.edu, etc.) run on the UNIX operating system. On these servers, you store information in computer files. You can create directories and subdirectories to organize these files.

The commands listed below will help you create, manage, and organize your files.

Note: Follow these guidelines when using any UNIX commmand:

  • Commands are case-sensitive—you must type them using uppercase and/or lowercase letters where appropriate.
  • Commands must be typed at the UNIX prompt—usually indicated by the name of the computer followed by the percent (%) sign (e.g., copland.udel.edu%).
  • Press ENTER key after you type a command.

UNIX commands to manage files

How do I get a list of my files?

To display a list of files in the directory in which you are working, type one of the following commands:

Command Action
ls Displays a list of files and subdirectories in the directory in which you are working.
ls -a Displays a more complete list containing those files that begin with a "." (dot). For example, the ".login" file.
ls -F Displays files and directories so that directories are marked with a trailing slash ("/") and executable files are marked with a trailing asterisk ("*").
ls -la Displays all files and directories in long format, giving details about each file and directory.
ls -t Displays files and directories by the time they were modified rather than alphabetically.
ls -r Displays a list of files and subdirectories in your current directory as well as on all of its subdirectories.

How do I see the sizes of my files?

To see the sizes of files in the directory in which you are currently working, at the UNIX prompt, type:

ls -l | more

You will only be able to see one screen of information at a time. Press the SPACEBAR to advance to the next screen. The information on your computer screen should look similar to the following:

screen of file information

On the far right is the file name (e.g., file1), just before that is the date (e.g., "Feb 11 16:29") which displays the date and time rather than the date and year because it is less than 6 months old, and just before that is the size of the file in characters or bytes (e.g., "109").

In the far left column, if a row has a d at the beginning, it is a directory. To see the size of the files in that directory, you have to change into that directory. (See the section on managing directories for instructions about how to change to a different directory.)


How do I see all of my files, even those beginning with a "."?

To see all files in the directory in which you are currently working, at the UNIX prompt, type:

ls -la | more

You will only be able to see one screen of information at a time. Press the SPACEBAR to advance to the next screen. The information on your computer screen should look similar to the following:

directory listing


How do I delete files from my account?

To delete a file from your account, at the UNIX prompt, type:

rm filename

replacing filename with the name of the file you want to remove.

To be prompted for confirmation before you remove a file, at the UNIX prompt, type:

rm -i filename

replacing filename with the name of the file you want to remove.


What are core files?

You may have a file named core in your home directory. This file is the result of an aborted process and can be deleted.

To find out if you have such a file, at the UNIX prompt, type:

ls core

If you see the word "core" repeated, you have the file.

To delete the file, at the UNIX prompt, type:

rm core


How do I display the contents of a file?

To display the contents of a file, one screen at a time, at the UNIX prompt, type:

more filename

replacing filename with the name of the file. To see the next screen of text, press the SPACEBAR. To quit, press the Q key. To display a list of commands, press the H key.

To display the contents of a file without pausing between screens, at the UNIX prompt, type:

cat filename

replacing filename with the name of the file.


How do I make copies of a file?

To copy the contents of one file into another file, at the UNIX prompt, type:

cp oldfilename newfilename

replacing oldfilename with the name of the original file and newfilename with the name of the new file. You will now have two copies of the same file.


How do I rename a file?

To rename (move) a file, at the UNIX prompt, type:

mv oldfilename newfilename

replacing oldfilename with the name of the original file and newfilename with the name of the new file. You will now have one copy of the original file—listed under the new name.

Top

UNIX commands to manage directories

How do I create a directory?

To organize your files on the central UNIX server, you can create directories and subdirectories.

To create (make) a directory, at the UNIX prompt, type:

mkdir newdirectoryname

replacing newdirectoryname with the name of the new directory.


How do I change to a different directory?

To change to a different directory, at the UNIX prompt, type:

cd directoryname

replacing directoryname with the name of the directory to which you want to change.

To return to your home directory, at the UNIX prompt, type:

cd


How do I identify the name of the directory in which I am working?

To identify the name of the directory in which you are currently working, at the UNIX prompt, type:

pwd


How do I change to my home directory?

To return to your home directory, at the UNIX prompt, type:

cd


How do I remove a directory?

To remove (delete) a directory, at the UNIX prompt, type:

rmdir directoryname

replacing directoryname with the name of the directory you want to remove. Note: Normally, all files must be removed from the directory before the directory can be deleted.

To remove a directory without removing all of the files first, at the UNIX prompt, type:

rm -ir directoryname

replacing directoryname with the name of the directory you want to remove. You will see a system message asking whether you want to remove each file in the directory. This system message prevents you from deleting files unintentionally.

Top

Search IT Help

My UD Search for forms & applications.