cd Firstyear |
|
| Used to move into a subdirectory. This moves you down one level from your current directory to the subdirectory Firstyear. | |
| cd ../ | |
| Used to move up one level of the directory tree: Every directory contains a hidden directory .. (dot dot slash) that is a shorthand name for this directory's parent directory. |
|
| cd ../directoryname | |
|
|
This command moves you up one level in the directory tree and then moves you into the subdirectory Secondyear. |
| cd /fullpath | |
|
|
To move to a directory using a full pathname, type the entire server path including a preceeding slash. |
| cd | |
| Simply typing cd will take you to your home directory on the server | |
| groups username | |
| Every user is a member of one or more groups. To find out which groups you belong to use the command: groupsTo find out which groups another user belongs to use this command. | |
| ls | |
| Lists the filenames of the files in the current directory. | |
| ls filename | |
| Lists a specific file. | |
| ls directoryname | |
| Lists the filenames of the files in a specific directory on the server. | |
| ls -l directoryname | |
| Gives a long listing of the files in the current directory. This is useful for setting permissions on files (see below). | |
| rm filename | |
| Deletes a specific file. | |
| mkdir directoryname | |
| Creates a new directory. | |
| rmdir directoryname | |
| Deletes the specified directory. The directory however must be empty. | |
| pwd | |
| Displays the full path of the currect directory. | |
| mv oldfilename newfilename | |
| Renames a file | |
| mv filename directoryname | |
| Moves a file to another directory. | |
| cp filename directoryname | |
| Puts a copy of the file in another directory. | |
|
|
|
| Permissions and Groups | |
| Every file on the server has an owner and a group associated with it. This allows the owner of the file to set permissions for a group of people who may be working with that file. | |
| To display the access permissions of a file or directory
use the the command: ls -l in a directory |
|
| chmod mode filename | |
| Your files and directories are owned by the group (or one of the groups) that you belong to. This is known as their "group ownership". You can change the group ownership of a file or directory by using this command. | |
To list the group ownership of your files:
ls -gl
with the command:
chgrp group_name file/directory_name
You must be a member of the group to which you are changing ownership to.
This displays a one line summary for each file or directory.
For example:
-rwxr-xr-x 1 erpl08 staff 3649 Feb 22 15:51 my.html
This first item -rwxr-xr-x represents the access permissions on this file. The following items represent the number of links to it;
the username of the person owning it; the name of the group which owns it; its size; the time and date it was last changed, and finally, its name.
To display the permissions on a single file:
ls -l file1
-rw-r--r-- 2 unixjohn doc 3287 Apr 8 12:10 file1
This displays the following information about the file file1.
-rw-r--r-- (access permissions)
2 (number of links to this file)
unixjohn (owner)
doc (group ownership)
3287 (size in bytes)
Apr 8 12:10 (date and time last modified)
To display the permissions on the contents of a directory:
ls -l prototype
This displays the same information as in the example above for each file and directory in the directory prototype.
To display the permissions on each file and directory in your current
directory:
ls -l
-rw------- 1 erpl08 iss 4307 Jun 17 10:00 FAQ.xdh
drwx------ 2 erpl08 iss 1024 Jun 17 10:00 SCCS
-rw------- 1 erpl08 iss 15119 Jun 17 10:00 commands.xdh
-rw------- 1 erpl08 iss 266 Jun 17 10:00 concepts.xdh
This displays the following information about every file and directory.
d (this is a directory)
rwx------ (access permissions)
2 (number of links to this file)
erpl08 (owner)
iss (group ownership)
1024 (size in bytes)
Jun 17 10:00 (date and time last modified)
Examples:
ls -l file1
-rw------- 2 unixjohn 3287 Apr 8 12:10 file1
The owner of the file has read and write permission.
ls -l file2
-rw-r--r-- 2 unixjohn 3287 Apr 8 12:11 file2
The owner has read and write permission. Everyone else - the group and all other users - can read the file.
ls -l myprog
-rwx--x--x 2 unixjohn 3287 Apr 8 12:10 myprog
The user has read, write and execute permission. Everyone else -the group and all others- can execute the file.
...
drwxr-x--- 2 erpl08 1024 Jun 17 10:00 SCCS
This is a directory. The user has red, write and execute permission. The group has read and execute permission on the directory. Nobody else can get access to it.
To change the access permissions for a file or directory use the command
chmod mode filename
chmod mode directory_name
The "mode" consists of three parts: who the permissions apply to, how the permissions are set and which permissions to set.
This is given as one of:
+ add the specified permission
- subtract the specified permission
= assign the specified permission, ignoring whatever may have been set
before.
Examples:
To give members of your group permission to read a file:
chmod g+r file2
This gives the group permission to read the file "file2".
To give read permission to everyone for a particular type of file:
chmod a+r *.pub
This gives everyone permission to read all files with the extension .pub.
To give the group write and execute permission:
chmod g+wx $HOME/SCCS
This gives all members of the group permission to place files in the directory SCCS in your home directory. They can also list (ls) the contents of this directory.
There is a shorthand way of setting permissions by using octal numbers. Read permission is given the value 4, write permission the value 2 and execute permission 1.
r w x
4 2 1
These values are added together for any one user category:
1 = execute only
2 = write only
3 = write and execute (1+2)
4 = read only
5 = read and execute (4+1)
6 = read and write (4+2)
7 = read and write and execute (4+2+1)
So access permissions can be expressed as three digits. For example:
user
group
others
chmod 640 file1
rw-
r--
---
chmod 754 file1
rwx
r-x
r--
chmod 664 file1
rw-
rw-
r--