Difference between revisions of "File Management"

From UCB Math Wiki
Jump to: navigation, search
Line 44: Line 44:
  
 
===Permissions===
 
===Permissions===
 +
 +
In order for other people to be able to access your files (in particular, webpages) you have to set the permissions on files and directories appropriately. Every file and folder has many permission variables, but the three that are most relevant are denoted R (read), W (write), and X (execute). By default you have all these permissions and no one else does so if you want to give other people these permissions you have to actually adjust the permissions.
 +
 +
A user who has R permission on a file may view the file and R permission on a directory allows you to see the contents. W permission allows the user to change the file, including replacing or deleting it. Only trusted users should be given this permission, and in general it is best to only give yourself this permission. The X permission allows a user to execute a file--this is relevant if you have some sort of web script or other mini-program that external users might want to use.
 +
 +
There are three classes of individuals who may read, write or execute a file; they are Owner (=you), Group (on the math server, this will usually be just you also), and Others. For each set of users, you decide which permissions to give. Each file or directory has a three digit permission code: the first digit corresponds to the permissions for owner, the second digit corresponds to group, and third digit to others.
 +
 +
In general, private files should have permissions set to 600 (owner has RW) or 700 (owner has RWX). Public files (such as those needed for your webpage) should be set to 744 in general, or 755 if they are an executable file. Private directories should have permissions set to 700, while public directories should all be set to 755.
 +
 +
To change the file/directory permissions, type <code>chmod &lt;file/directoryname&gt; &lt;3digitcode&gt;</code>

Revision as of 00:22, 26 September 2006

This page describes how to manage your files on the math department network, both remotely and locally. File uploading/downloading, directory creation, and setting permissions are among the topics covered belong.

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 the ones in 708) 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

SSH stands for Secure Shell. For those who have used Telnet before, it is practically the same program except that is has stronger 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 webbrowsers remotely through SSH (but be warned, it can be an extremely slow process!).

  • Windows: you need to download an SSH client. One option is Putty. Then use the SSH client to connect to login.math.berkeley.edu, 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> login.math.berkeley.edu 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).
  • Unix: you probably have SSH preinstalled as well. Just open a terminal window and type in the same thing Mac users do.


SFTP

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.

I do not know whether SFTP comes standard on Macs or Unix, but it may be worthwhile to install a program anyway since there are many free, well-written programs out there. A recommendation for Windows is WinSCP.

Navigation

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.
  • cd .. Go up one level in the heirarchy.
  • pwd Present working 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 settings files and other weird junk that usually you don't care about.

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> Exactly like copy, except it moves the file (so that the file no longer exists in the location it came from.
  • rm <filename> Removes (deletes) the file. Be VERY careful if you try to apply this command to a directory--many times the file server won't let you, but if it does and you type things in wrong, the results could be disastrous.

Permissions

In order for other people to be able to access your files (in particular, webpages) you have to set the permissions on files and directories appropriately. Every file and folder has many permission variables, but the three that are most relevant are denoted R (read), W (write), and X (execute). By default you have all these permissions and no one else does so if you want to give other people these permissions you have to actually adjust the permissions.

A user who has R permission on a file may view the file and R permission on a directory allows you to see the contents. W permission allows the user to change the file, including replacing or deleting it. Only trusted users should be given this permission, and in general it is best to only give yourself this permission. The X permission allows a user to execute a file--this is relevant if you have some sort of web script or other mini-program that external users might want to use.

There are three classes of individuals who may read, write or execute a file; they are Owner (=you), Group (on the math server, this will usually be just you also), and Others. For each set of users, you decide which permissions to give. Each file or directory has a three digit permission code: the first digit corresponds to the permissions for owner, the second digit corresponds to group, and third digit to others.

In general, private files should have permissions set to 600 (owner has RW) or 700 (owner has RWX). Public files (such as those needed for your webpage) should be set to 744 in general, or 755 if they are an executable file. Private directories should have permissions set to 700, while public directories should all be set to 755.

To change the file/directory permissions, type chmod <file/directoryname> <3digitcode>