File Management

From UCB Math Wiki
Jump to: navigation, search

This page describes how to manage your files on the math department network, both remotely and locally.

Connecting to the Network

In order to manage your account, you first have to connect to the network. If you are in Evans, you can log onto one of the departmental computers (such as thin clients in 744 and public printer rooms) and instantly be on your math department account. Note that the only computers allowed to be physically connected to the network are the departmental ones. Therefore, if you want to connect from another computer, such as your laptop or home computer, you need to connect remotely. There are two kinds of programs that can connect your computer remotely, SSH and SFTP.


SSH stands for Secure Shell. For those who have used Telnet before, it is practically the same program except that is has encryption to securely transfer data. The department server no longer accepts connection requests from Telnet clients, so you have to use SSH if you want to connect.

SSH basically is a program that mimics the Terminal windows found on our department's computers. It is useful for editing files, changing file permissions and running basic programs like text editors or Pine email program. With a more elaborate setup, you can actually run programs such as web browsers remotely through SSH (but be warned, it can be a slow process!).

  • Windows: you need to download an SSH client. One option is Putty. Then use the SSH client to connect to, using your usual departmental username and password.
  • Mac: you already have SSH installed with your operating system. Just go to Utilities and click on Terminal. In the terminal window, type: ssh -l <username> The -l <username> part indicates to SSH that you want to log in with that specific username; if you don't include this text, then SSH will automatically use the account name on your computer (which probably won't be your departmental username).
  • Linux/Unix: you probably have SSH preinstalled as well. Just open a terminal window and type in the same thing Mac users do.

Professor Vojta has the following reference.


SFTP stands for Secure File Transfer Protocol, which is a secure version of FTP. As with Telnet, the department server no longer accepts connection requests from FTP, in order to increase network security.

As the name suggests, this program is primarily used to transfer files between the computer you are on and your account on the department network. Many SFTP clients have a graphical interface which make downloading and uploading very easy, and most also have an easy way of changing file and directory permissions.

If you have a command-line ssh program on your Mac or Unix computer, you probably have sftp as well. A recommendation for Windows is WinSCP.

Using the Macintosh Finder

There are several protocols that will allow you to access and manipulate files on our Unix network via the Macintosh finder. Probably the easiest to use is Netatalk, which unfortunately is not very robustly supported and may be turned off at some point in the future. It already presents various problems: it can be very slow, and sometimes will fail to copy files in either direction for mysterious reasons. At present you can use it from any Macintosh computer, either in your office or from home or another location. After this is done, connecting is easy: just select "Connect to server" in the "Go" menu of the Finder. This will bring up the "Connect to Server" dialog box. Enter "afp://". You should then be greeted with another dialog box asking for your password — your standard Unix password should work. Once the connection goes through, a second dialog will appear, asking you to select a volume to mount. Choose the one with your Unix user name. At this point your Unix home directory should appear as a volume on your Macintosh. Be sure to unmount the volume when you are finished with it.

Using Unix commands

Once you've logged into your account, either on one of the department's computers or using SSH, you will be presented with a Unix command line.


Every file and directory has a path; if you think of the directories as a tree, then the path is just the path in the tree through all the subdirectories you need to get to that directory or file. For example, your account's home directory is /home/u2/grad/<username>

  • cd <pathname> Change directory to the one given in <pathname>. This command has a very fine distinction between absolute paths and relative paths. If the pathname does not begin with / then it signifies that you are talking about subdirectories of the current one. If it does begin with / then you are specifying the path from the root of the directory tree.

Tip: Use Tab to complete file or directory names.

  • cd .. Go up one level in the hierarchy.
  • cd With no argument, this command returns you to your home directory.
  • pwd Print current directory. This is really useful if you've forgotten what directory you're in.
  • ls Lists the files and subdirectories of the present directory.
  • ls -a Lists all the files and subdirectories in the present directory. This includes files which begin with a ., which are usually hidden: mostly settings files and other weird junk that usually you don't care about.
  • ls -l Lists files and subdirectories with other information about them, including permissions.

Create, Move and Destroy

The file server tends to treat directories very differently from files, so if you're going to do some major changes to you account heirarchy it's probably better to use a graphical SFTP program than trying to do this all in a terminal or SSH.

  • mkdir <name> Makes a new directory with the given name.
  • cp <filename> <pathname> Creates a copy of file <filename> in the directory given by <pathname>. The same caveat regarding pathnames applies as with cd. This assumes that the file is in the current directory. If you'd like to move a file in a different directory, you have to put the file's path instead of <filename>.
  • mv <filename> <pathname> Moves a file to a different location. By specifying a filename at the end of the second path, you can also rename the file.
  • rm <filename> Removes (deletes) the file. Be careful because unlike moving a file to the trash, once you've typed the rm command there's no way to get the file back. For directories, you have to use:
  • rmdir <directoryname> Removes a directory. You can only remove a directory if it is empty.


Unix has different levels of permissions associated to files which control what you and other people can do. Somewhat confusingly, these are set using a 3 digit number, but the ls -l command displays them using a sequence of letters and dashes. There are many variations, but most of the time the following guidelines work:

  • For things you want other people to see (such as web pages): use 644 (rw-r--r-- in ls -l) for files and 755 (rwxr-xr-x) for directories.
  • For things which you don't what other people to read: use 600 (rw-------) for files and 700 (rwx------) for directories.

The command for setting the permissions on a file is chmod, for example: chmod 644 index.html. For more details, read on.

There are three different permissions and three different classes of users to which these permissions can be assigned. The permissions are read (r), write (w), and execute (x). For files, read and write mean the obvious things. The execute permission gives the ability to run the file as a program. For directories, the interpretations are slightly different: the read permission is the ability to see the list of files in the directory, the write permission allows you to create, move, and delete files in the directory, and the execute permission is necessary to do anything with files in the directory or its subdirectories other than see the list of files in the directory itself. Note that the ability to delete a file depends on having write permission to the directory it's contained in, and not anything with the file itself.

The three classes of users which may be given each of these three permissions: owner (i.e. you), group, and others. By default on the math servers, files you create will belong to the grad group, which includes all graduate students. Each of these three classes is assigned some subset of the permissions above. The three-digit code is formed by having one digit for each class (in the order: owner, group, others), and the binary expansion of the digit represents the permissions (read = 4, write = 2, execute = 1). For example, 644 gives read and write permission to the owner and read permission to the group and others.