Log-in to the cs server.cs500dd@cs:/u1/class/cs500dd>where the d's are your digits. The command prompt means that the operating system is ready for you to enter another command. The part of the command prompt after the colon
/u1/class/cs500dd
is the pathname of your home directory.
Each account has associated with it a home directory for the owner's files and
sub-directories.
The Log-in sets your current directory to be
your home directory. Both pathname and
current directory are talked about below.
lsto see the files and sub-directories of the current directory. You should see:
Desktop/The slash at the end of the name indicates that Desktop is a directory (sub-directory) and is NOT a file.
Desktop
in a unix command, we can use its pathname, for example enter the command
ls /u1/class/cs500dd/DesktopThis will show the content of the
Desktop directoryDesktop is in
the current directory,
/u1/class/cs500dd,
we can enter the shorter command:
ls DesktopNote: Desktop is still a pathname, but it is a pathname relative to the current directory. Pathnames that start at the root directory with a
/,   are
called absolute pathnames.
pathname for your home directory:
/u1/class/cs500ddThe left-most slash stands for the root or top directory. The rest of the slashes are NOT directories; they just separate one directory name from the next. The path tells us that:
The pathnameu1is a sub-directory of the root directory,/
classis a sub-directory of directoryu1,
cs500ddis a sub-directory of directoryclass.
/u1/class/cs500dd
is the list of directories (path) from the root to cs500dd
where each item is a sub-directory of the directory before it.

cd to change the current directory.
Each of the four commands below changes the current directory.
Enter the firstcd / cd /u1 cd class cd
cd command.
It sets the current directory to be the root directory.
Now enter the ls command. It displays the content of
the current directory (root directory). One of the sub-directories
is u1, but there are lots of others:
bin,
boot,
etc,
var, and so on.
Enter the second cd command. It sets the current directory
to be /u1. Again enter the ls
command. It displays the content of /u1.
The third cd command
is different from the first two. The pathname class
does not start with a /, so it is a relative pathname,
relative to the current directory. Enter the third cd
command. Before it executes the
current directory is /u1. So the third command sets the
current directory to be the class sub-directory of
directory /u1. Enter the ls command to
see all of the class accounts.
Enter the fourth cd command. The syntax (pattern)
of all unix commands is:
cmdName arg1 arg2 ...
where the command name is followed by zero or more arguments separated
by spaces. A command argument is just something typed. This fourth
cd command has zero arguments. It sets the current
directory to be your home directory.
You can not get lost since this last cd takes you back home!
cd
We are going to make a program file named pgm1.c
We start our work by entering the command:
pico pgm1.c
This command starts the pico editor program
which will let you write or change file pgm1.c.pico
does not immediately finish. It waits until we tell it we are done
writing.
The upper part of the pico screen is where you type
in the file content. The lower two lines list several pico
commands you can use.
-----------------The two important pico commands------
The caret (^) in front of each command means hold down the ctrl (or control) key when typing the letter that follows.^O Write Out ^X Exit
^O: To SAVE your work
(Write Out) you hold down the ctrl key when you type the O key. When you
do this, pico responds with the line:
File name to Write: pgm1.cThe file name that appears is the name you typed in the when you started
pico.
Mostly you will just press enter to accept the name,
^X: To EXIT pico,
you hold down the ctrl
key and type the X key. If you do this after you have done the ^O
command, pico will return you to the unix command line.
But if you have not saved all that you have typed, pico
gives you the option of saving your recent changes before returning to
the unix command line.
In the pico window type:
#include<stdio.h>
int main() {
printf("Hello, World\n");
}
Once all of the above has been typed, type
the command ^O then press the enter key to save your work to
the file pgm1.c. Finally type ^X to exit
pico.
This will list out the content of the current directory. You should see:ls
Now let's check the content of our fileDesktop/ pgm1.c
pgm1.c
One way to do this is to use the pico command:
and then do ^X to exit pico. A quicker way is to enter the commandpico pgm1.c
The cat command displays the content of pgm1.c and is done immediately. There is NO NEED to exit with a ^X.cat pgm1.c
gcc pgm1.c
If you made no grammar errors when you wrote pgm1.c, then
NO complaints (error messages) will appear on the screen and the
command will MAKE a new file, a.out that contains
the machine language translation of pgm1.c. If there are
errors, use the command
pico pgm1.c
to look file pgm1.c and fix it. Compare to the code above. Save the
fixed code. Exit pico. Recompile.
Finally when pgm1.c compiles without error, You are ready to run
the program. Enter the command:
a.out
You should see
Hello, Worldon the screen.