Unix File Management
IITS has published an Info Note on the subject. Read on to see Dana's explanation.
File permissions (and their fancier cousins the access control lists) determine who can see/write to/execute your files on Alcor. If you do a detailed listing of your files (ls -l) you will notice that each line looks something like this:
drwx--x--x 25 webdoc webdoc 8192 Jul 23 09:32 Mail/
drwx------ 2 webdoc webdoc 8192 Jul 15 10:21 News/
-rw------- 1 webdoc webdoc 69668 Jul 23 11:41 letter
-rw------- 1 webdoc webdoc 6290 Jul 22 15:06 report
The -rw------- tells you about the permissions on the file. It works something like this: There are 10 places for the letters. The first one is a special one. If the letter 'd' appears it means that it is not a regular file but a directory. If it pertains to a file it will almost always be just a dash. The next three apply to you, the user, the middle three apply to the group, and the last three apply to everyone else on Alcor.
The first position of each group of three is r for read, the second one is w for write, and the third one is x for execute. A dash means that the permission (read, write, or execute) is not granted to the relevant group or user, whereas the presence of the letter means that the permission is granted. For example:
-rw------- means that the owner can read and write to the file but not
execute it, and nobody else can do anything.
-rwx------ means that the owner can read, write, and execute the
file, but nobody else can do anything.
-rw-r--r-- means that the owner can read and write to the file, the
group can read the file, and everyone on Alcor
can also read the file.
-rwxr-xr-x means that the owner can read, write, and execute, and the
group and everyone else on Alcor can read and execute
but not write the file.
-rwxrwxrwx means that everyone on Alcor (including of course the
file's owner and group) can read it, execute
it, and write to it. You want to avoid this since anyone
could destroy that file by overwriting it with garbage,
or an empty file.
In general you should be the only one with write permission on the files you own. The rest is for you to decide. (Do you want the rest of the users to see that particular file?) By default all of your files are -rw------- so that only you can see them and write to them.
For your web page all the files should be -rw-r--r-- and any directories should be drwxr-xr-x so that the rest of the world can view your creation.
To set these permissions you can use one of two methods.
The first method uses "symbolic" file modes. If you want to make the file executable for yourself only type chmod +x file. If you want the file to be readable by everyone say chmod a+r file. Basically the usage is chmod [who]+/-[permission] file_name where who is either you the user (u), the group (g), the world (o), or all three (a), + is to add a permission and - is to remove it, and r, w, and x stand for read, write and execute respectively.
The other method uses a number to represent the desired permissions. To use this method, you must look at the permission in three parts: rwx rwx rwx. Consider the permission turned on to be a 1 and off to be a 0. So what you have is three 3-digit numbers next to each other. Now think of them as binary numbers so that rwxrwxrwx becomes 111 111 111 and rw-r-r becomes 110 100 100 etc. Now convert the individual numbers to octal, so rwxrwxrwx = 111 111 111 = 777 and rw-r--r-- = 110100100 = 644 etc. All you have to do now is chmod ### (e.g. "chmod 644") and voila!
The numerical mode commands you'll need most often are:
To chmod all files in a directory you can use * as the wild card. If you need to recurse through subdirectories use chmod -R. This will however not follow symbolic links so it won't work on your www directory, unless you first cd into it first and then chmod.
Note: a directory cannot be traversed, and files in it accessed, unless it has its execute bit on for the appropriate user or group, so beware of using "chmod -R 644", which will make your directories unusable.
If you need to recursively add read permissions to all files and directories under a certain point, it's best to use the symbolic approach, and the X permission setting, (execute only if the file is a directory or already has execute permission for some user), as in
chmod -R a+rX,og-w /public$HOME
The above would make all files in your public directory (where
your web pages live) readable, and all directories under your public
directory executable (usable), to all users on the system, while at the
same time ensuring that none of these files and directories
are writable to any user other than the owner (you).
Back to the question list
The DOS batch file's Unix equivalent is the shell script. A shell script is a file of shell commands. At the top of the file, you should have
#!/bin/shor
#!/bin/csh(or some other shell's name), to tell Alcor which shell to use to interpret the file.
You also must make sure that the file is executable, by setting its file permissions appropriately. See file permissions for detailed info, but the short answer is "chmod 700 filename", so you can execute "filename", or "chmod 755 filename", so everyone can execute it.
A shell programming intro
is available on our
UNIXHelp site.
Back to the question list
begin 600 some_file_name.uue
M(#0U-R`@,#(O,34@("`@("`@("`@("`@("`@("`@(%)E.B!424X@:&]W('1O
M('5S93\\/'-?:V]B97)`86QC;W(N8V]N8V]R9&EA+F-A(`H@-#4X("`P,B\Q
M-2`@("`@("`@("`@("`@("`@("`@4F4Z(%5N:7@@1FEL97,N+G!L96%S92!H
(Note that every line starts with the letter M.)
The file is a "core dump", caused by a program crashing, and
dumping the
contents of its memory to disk so you can analyze what happened. Since
you're unlikely to want to do that, just delete the file when you see it.
Back to the question list
You can't.
The best you can do is try to prevent the situation by
aliasing
rm to rm -i.
(On Alcor this is already done by default on new accounts,
so you don't have to worry about it
unless you have removed the command to source the system aliases from
your .cshrc file.)
When rm is invoked with the -i option it will request confirmation
before deleting any file.
Back to the question list
You cannot get them back but you can copy the original ones. (If you've made
any changes to them they will be lost but at least your account will be usable).
We provide information on
how to find and copy the standard system dotfiles.
Back to the question list
An excellent explanation of common file formats and how to
deal with them both under Windows and MacOS
is available.
Back to the question list
|
Copyright, © 2003,
Concordia University,
(IITS).
|
|
|