VU Math: Intro to Our Computer Systems

Simple File Manipulation:
cd, ls, rm, cp, mv, mkdir, etc.

including how to upload or download files using Netscape or Explorer


Directories and files

Computer files on our machines are arranged in directories and subdirectories which form a tree structure. Your files are shared between the several machines, so you will see and be able to work on the same files from either machine. The very top directory is called the root directory. A file can be completely specified by a path name which indicates how to get to the file from the root directory. For example, /usr/users/mne/a.tex specifies the file a.tex in the directory mne which is a subdirectory of users which is a subdirectory of usr which is a subdirectory of the root directory. Notice how slashes are used to separate the parts of a path name. The root directory itself is just referred to as /.


The current directory

Most of the time it is not necessary to type a complete path name. At all times you have a current directory, and files in that directory can just be referred to by their actual name. For example, if your current directory is /usr/users/mne, the file /usr/users/mne/a.tex could be referred to as just a.tex. To change your current directory use the cd command. For example,
atlas 4 %   cd courses
would change your current directory to the courses subdirectory of where you are now. And
atlas 5 %   cd /usr/users/abc/pascal
would change your current directory to /usr/users/abc/pascal.


Special directories

So that users can keep their files separate, each user has a home directory. When a user logs in, this is his or her current directory. On our machines users' home directories are of the form /usr/users/username, so that, for example, jqsmith would have home directory /usr/users/jqsmith. You can refer to your home directory using the special abbreviation ~. So, for example, ~/a.tex always means the file a.tex in your home directory, no matter what your current directory is. One easy way to get there is by using the "current directory" command with no arguments -- i.e., typing
atlas 6 %   cd
After you typed that, your new current directory would be your home directory.

Another special directory abbreviation is .. which stands for the parent of your current directory. For example, if your current directory was /usr/users/abc/pascal and you typed

atlas 7 %   cd ..
your new current directory would be /usr/users/abc.


Looking at files

To get a list of the files in your current directory, type
atlas 8 %   ls
You can also type
atlas 9 %   ls -l
to get more detailed information such as file length, time of last modification, and so on.

To actually see the contents of a file, use the cat command or the more command. For example,

atlas 10 %   cat a.tex
prints the file a.tex from your current directory on your screen. If instead you type
atlas 11 %   more a.tex
then you get the file printed on your screen again, but at the end of each page the computer types something like
--More--(21%)
and politely waits for you to hit the space bar before printing the next page. The more program has many other features; read the manuals.


Moving files around

To copy a file, use the cp command. For example, to copy a.tex to a.tex.old, type
atlas 12 %   cp a.tex a.tex.old
To rename a file, use the mv command. Thus,
atlas 13 %   mv a.tex.old b.tex
would rename a.tex.old to b.tex. Any previously existing b.tex would be wiped out. (However, if oldfiles is the name of a subdirectory, then mv a.tex.old oldfiles would move a.tex.old into that subdirectory; no files would be deleted. Similarly, mv a.tex.old .. would move mv a.tex.old oldfiles into the parent of the current directory.)

To delete a file, use the rm command. For example,

atlas 14 %   rm a.tex b1.tex letters/alice
deletes the files a.tex and b1.tex from the current directory and the file alice from the letters subdirectory of the current directory. The rm command (and many other commands) accepts wildcards: for example, a * stands for just about anything, so that
atlas 15 %   rm a* b1.tex
would remove all files beginning with a, and also b1.tex, from the current directory. The rm command should only be used VERY CAREFULLY -- Unix does not have an "undelete" command; once a file is gone, it is gone for good.

An unusual situation: Sometimes you may accidentally create a file whose filename is pathological -- e.g., a file whose name begins with a hyphen. Such a file cannot be accessed by ordinary file commands, including mv. To deal with it, you should rename it to a more conventional filename by typing

mv - name newname
where "name" is the old name of the file and "newname" is some new filename which doesn't include a hyphen. The first hyphen tells mv that anything following it should be interpreted as a filename, not as a command switch.


Using subdirectories

To create a subdirectory, use the mkdir command. For example, if the current directory is /usr/users/abc then
atlas 16 %   mkdir programs
creates a directory /usr/users/abc/programs. To delete a subdirectory use rmdir:
atlas 17 %   rmdir programs
removes the subdirectory programs of the current directory. The subdirectory must be empty (no files or subdirectories of its own) for this to work.


Control-letter shortcuts

Unless you've altered your .login and .cshrc files, you should find that these commands work:

Your .login and .cshrc files

The command "ls" will not show all of your files. Some files have names beginning with a period; those files are hidden and will not be revealed by the "ls" command. You can see them with the "ls -a" command.

Most of the hidden files can be manipulated like any other file. For instance, if you type emacs .login you can edit your ".login" file. However, most of the hidden files are hidden for a good reason: If you alter them in the wrong way, you can really mess things up thoroughly. The ".login" and ".cshrc" files are used during the login procedure; if you mess them up, you may become unable to log in. Thus, these files should not be altered by beginners, except perhaps in ways that are carefully specified by more advanced users.

Here is one alteration that I like; you might like it too: Somewhere in your ".login" or ".cshrc" file, add the line

alias cd 'chdir \!* && set prompt="`dirs`>"'
Then, at the end of your ".login" file, add this line:
cd
(Be sure to type these lines exactly!) After you make these changes and log out and log in again, your prompt will consist of your current directory (with your home directory replaced by a tilde), followed by a greater-than sign.

By the way, the lines in your .login and .cshrc files that begin with a # (pound sign) are comment lines, ignored by Unix. If you mess up your .login and .cshrc files badly, you can copy the "plain" versions again from the directory /usr/skel. That is, log in and then give these commands:

cd
cp /usr/skel/.login .
cp /usr/skel/.cshrc .
Of course, if you mess the files up so badly that you can't log in, then you'll need to ask one of the superusers for help. Don't do that while they're out of town.


Using Netscape or Explorer to transfer files

You can use Netscape or Explorer to transfer files in both directions between your personal computer and your account on Atlas. I think it's the easiest method for transferring files -- easier than "ftp" or "fetch" or other file transfer programs. (One reason I prefer it is that I like to keep to a minimum the number of different programs that I need to familiarize myself with. I need Netscape for other purposes, so I may as well use it for ftp too.)

I'll describe the procedure first for Netscape. Run Netscape on your personal computer. Tell Netscape to go to this URL:

ftp://username@atlas.math.vanderbilt.edu/usr/users/username/
where both occurrences of "username" are replaced by your username. That's right, this URL doesn't begin with the usual "http" -- it begins with "ftp" instead. You'll be prompted for your password, and then the browser will go to a display that is like a web page, but consists of a list of all the files in your Atlas account's main directory. (Then bookmark the URL -- it's hard to type, and you may want to use it often!) Clicking on the name of a subdirectory will take you to that subdirectory, etc.

Microsoft Internet Explorer does not support password prompting, but you can follow a similar procedure if you include your password in your URL. Tell the browser to go to this URL:

ftp://username:password@atlas.math.vanderbilt.edu/usr/users/username/
where both occurrences of "username" are replaced by your username, and "password" is replaced by your password. Caution: Microsoft points out that this is not a secure means of logging in, and recommends that a separate FTP program be used instead. However, I don't think security is a big worry in our department -- we don't really have anything that hackers are likely to want to steal or destroy -- so I think you're probably not running any significant risks by using this login method for a few minutes.

After you have an ftp directory showing, you can download or upload files as follows:

To download a file from Atlas to your personal computer, just shift-click on the filename -- i.e., hold down the shift key, and click on the filename. You'll be prompted with some basic questions: Where in your personal computer's directory structure do you want to copy the file? What filename do you want the file to have? etc.

To upload a file from your personal computer to your Atlas account, open up a directory listing of the files on your personal computer. Then use the mouse to "drag" the desired filename from the personal computer directory listing into the Netscape ftp listing. Netscape will ask you whether you want to upload the file.

Note: Although this technique may be easier than using a separate program for FTP, it is also slower, and it has the further disadvantage that for downloads you can only specify one file at a time. For large uploads or downloads, you may prefer to use the separate FTP program.


A VU Math web page, updated 5 Sept 99 by webmaster@math.vanderbilt.edu.