Up to main menu         Back to File System         Next: File names and Wildcard symbols

Directory and File Manipulation

Inside your home directory, where you own files and therefore have the power to create, edit and delete files, you can use the following Unix commands to manipulate files and directories.

pwd
Tells you which directory you currently reside in.

cd
change directory. Used by itself, this command moves you into your home directory. Used with the name of a directory, it moves you there.

ls
list the contents of the current directory. Several of the command-line options for this command are particularly useful;

mv
``move'' -- change the name of a file. Give both the current name and the new name, like mv oldname newname

cp
copy a file. Give the name of the current file name and the name of the new file to be created; cp existingfile newfile. If there is already a file by that (new) name, it will be destroyed!

rm
remove a file. Use with care! rm filename.

mkdir
make a new directory; mkdir newdirname.

rmdir
delete an existing directory; rmdir olddirname. This won't work unless all the contents of the old directory have already been deleted.

chmod
change the permissions on a file/directory; e.g., who is allowed to view, edit, delete, execute, or reside in a file/directory. You can view the existing permissions of a file or directory by using ls -l filename.

The commands
   (1)		chmod 400 filename
   (2)		chmod 644 filename
   (3)		chmod 755 directoryname
are often used. (1) makes the file readable only by the file's owner, and not writeable (editable, removeable) by anyone. (2) makes the file readable and writeable by the file's owner, and merely readable by everyone else. (3) makes a directory open to everyone, but only writeable (adding/deleting files) by its owner. Each of the three digits is either 0 or the sum of the rwx permissions, where readable=4, writeable=2, executable/resideable=1. See the manual page for chmod.

Up to main menu         Back to File System         Next: File names and Wildcard symbols
Bruce.Fast@Colorado.EDU