lsby itself lists files in the current directory. If you want to access files other than in the current directory, you have to use either a relative pathname or a full (absolute) pathname.
When you log in, your current directory is your home directory.
If you are in a CS course (and are not a CS major), your home directory will be:
This just means that your home directory is under the csXXX
directory, which is under the course directory, which is
under the home directory, which is under the
root directory, i.e.,
This, of course, is an example of a full pathname.
An example path would be:
which refers to a file called
prog1.cpp in the
directory hw1, under the directory
homework under whatever your current
directory is. Note the use of the slash (
to separate the pieces.
Typically you'd use a path to tell a command what file to operate on. For example,
ls -l homeworks/hw1/prog1.cpp
uses ls to list information
about the file
prog1.cpp. Since, in this case,
prog1.cpp is not in your current directory. you must give a
path with the file name.
Any example full path is:
which is the location of the
Any example relative path is:
which refers to a file in the subdirectory homeworks under your current directory.
ls -l homework
where the command name is ls
and the arguments are
"-l" (a special kind of argument
called a flag) and
in which case the flag
-l (minus ell, not one)
gives a longer set of information. Flags alter the default
behavior of commands. For example, the command ls, by default, just lists the names of
files. With the
-l flag, it gives you more
information about each file (or directory).
Flags normally start with a minus sign (
consist of a single letter, like l (i.e., ell) or a whole
word, as in -debug. For commands that take only single letter
flags, more than one flags can often, but not always, be
combined. For example, -l and -F could be typed as
some cases, flags will start with a plus sign (
instead. It is more typically for flags with pluses to be part of a
pair of flags, e.g.,
-a to turn some feature on and
+a to turn it off.
Because some flags turn features on/off, flags are sometimes called switches. In addition, they may be called options.
Types of files that are not text files are executables and word processor documents and are called binary files. When you try to view binary files with text file commands, they look like garbage. Again, a text file only differs from a binary file in that information is stored in it using the typical symbols that you'd see on a typewriter.
.cpp(and sometimes in
.h). These files cannot be run on the computer. In order to get an executable, which can be run, you must compile and link the source code.
lsto view files, these executables often have an asterisk (
*) after their names (though the
*is not part of the file's name).
To run an executable, you just type its name.
Compiling and linking are actually separate procedures, though often you'll use one program to both compile and link. Technically, compiling puts all the source code into an intermediate form and linking links all the intermediate pieces and special libraries into a single executable.
Often we'll use the term compiling for both compiling and linking.
We'll compile and link our C++ programs by using the g++ compiler or by using the make utility.
Our debugger is
&) at the end of a UNIX command, so that we get the prompt back right away.
If a program is not running in the background, we say it is in the foreground.
UNIX allows you to use the less than
<) character to make the program take input
from a file instead of the keyboard.
UNIX allows you to use the greater
>) character to send a program's output
to a file instead of to the screen.
UNIX allows you to use the pipe symbol (
send a program's output into another program.
Using the up and down arrow keys, you can scroll to a previous command, edit it (or leave it as is) and then press <RETURN> to perform it again.