Next: File Permissions
Up: Shell Basics
Previous: File Structure
  Contents
  Index
For all the commands below, you can execute them simply by typing them
at your prompt. Note that many commands require an argument; that is,
if you were creating a new directory, you would have to give the
mkdir command the name of the new directory you wished to make.
- pwd: gives your present working directory. It is useful
for remembering where you are. If you issued this command when you
first log in, it should return a path like the one shown in Section
I.3.1.
- ls: lists the files in your current working directory.
You can give it options to show file permissions, the last time a
file was modified, and other details. The syntax to do this is
ls -l. Note that your home directory will contain many
files that start with a period (called ``dot-files''). Most of
these files are special configuration files. Occasionally you may
want to modify them. You can only list these files by giving
ls the -a option.
- cd: change directory. Give this command followed by
either a relative or absolute path. Say you have a Mail/
subdirectory off of your home directory and you wish to go to it.
Here are two commands that do exactly the same thing:
joeblow@laser% cd Mail/
joeblow@laser% cd /home/reu/joeblow/Mail/
In the first example you used a relative path while in the second
you gave the full (or absolute) path to the directory. Note that
you can return to the previous directory by using:
joeblow@laser% cd ..
Another note: typing cd by itself will always return you to
your home directory.
- mkdir: make a subdirectory. Invoke with the name of the
subdirectory you wish to create. To create the subdirectory
``temp'' from your current working directory, simply type
joeblow@laser% mkdir temp
Note that you could have also included the trailing slash on the
directory (that is, ``temp/'').
- rm: remove a file. Invoke with the name of the file you
wish to delete. Use this command with caution - once you delete a
file, it is usually irretrievable.
- cp: copy a file. For example to copy file1 to a new file
called file2
joeblow@laser% cp file1 file2
- mv: move a file. Can also be used to rename a file.
Here are two examples:
joeblow@laser% mv file1 Mail/
joeblow@laser% mv file1 myfile
In the first example we have moved a file to the subdirectory called
``Mail''. In the second example we have renamed file1 to myfile.
A couple of final caveats about files and commands. Unix is
case-sensitive. Almost all Unix commands are lower-case. Another
suggestion - be careful when using non-alphanumeric characters.
* and ? are used as wild-card characters for instance.
Avoid spaces in Unix file names. Instead consider using the
underscore character (like my_first_try). Finally, be
careful when you copy or move files. Unix will allow you to easily
overwrite files with the same names. In the example for cp
above, if you already had a file named file2, it would be lost when
you copied file1 to file2. You can have Unix warn you about
overwriting files if you use the -i option when using cp
or mv. This will put you into an interactive mode where you
will be prompted if you are about to overwrite a file.
Next: File Permissions
Up: Shell Basics
Previous: File Structure
  Contents
  Index
Mohammad Ahmed
2003-07-23