1 Starting Up in Young 313
1 Starting Up in Young 313
1 Starting Up in Young 313
The following are the basic steps to get a Linux virtual machine up and running in Young313:
1. Open up the VMWare player; there should be a desktop icon corresponding to this program.
2. Should someone else have already started up a Linux virtual machine, you may well see a window
pop up saying something like “Restoring ...” with a status bar filling up. If this is the case, skip to
step 4 below.
3. Now that you have started VMWare player without seeing the “Restoring ...” window, you should
see a clickable item labeled “Fedora Core 10” on the right hand side of the window, about 1/2 way
down. Go ahead and click on this. You should then see the Linux O/S starting to boot in a virtual
machine window ... have patience, this can take a few minutes (you are booting a machine right
now, one that is both more powerful than Windows, but yet is being booted in a relatively slow
environment due to running in a virtual machine on top of windows [instead of actually “live” on the
computer itself]).
4. At this point, you should (eventually) see a login screen. If you see your name in the menu (meaning
you have already logged in previously on this specific machine), click your name; if you do not, click
on “other” and you will be prompted to enter your username (as provided to you by Dr. Blythe)
and press enter. At this point, you will prompted to enter your password (again, as provided by Dr.
Blythe).
5. If your login did not work, try to re-enter your username and password (as in step 4), making sure
you are typing them in correctly. If you are convinced that you are doing so, reboot the virtual
machine (not the physical Windows machine!) by selecting the power-off and restart option in the
virtual machines menu bar; this will (eventually) put you back at step 4.
• ls, which simply lists all of the files and directories (folders) in your current (working) directory. If
you specify the name of a directory (as an argument to this command, it will list the contents of the
named directory. Some examples:
– ls Pictures would list the contents of the subdirectory (sub-folder) named Pictures found in
your current directory (folder).
– ls / would list the contents of the root of the Linux filesystem.
– ls ~sblythe would list the contents of user sblythe’s home directory (assuming that you have
permission to look at such).
– ls ~idiot/Public would list the contents of the directory Public found in user idiot’s home
directory (assuming that you have permission to look at such).
– ls ~ would list the contents of your home directory, no matter what your current working
directory is.
– ls ~/public_html would list the contents of your public_html directory, no matter what your
current working directory is.
There are some useful extra options you can pass to ls in addition to the argument as discussed
above. Here are a few of them (there are many more options than these):
– -l (i.e. “dash” lowercase-L), which shows the “long” listing for each file/directory. This includes
information like the last time the file was modified, the size of the file, the type of the file
(directory or regular file), and other information.
– -a, which gets ls to show “hidden” files. In Unix, files that start with a period are said to be
hidden, and do not show up by default when using ls
• pwd, which prints the complete path of your current working directory (i.e. lists all of the folders/sub-
folders that would get you to where you are right now).
• cd, which changes directories (i.e. takes you to a different directory/folder). Without any arguments,
this will take you to back to your home directory. If you specify a directory name as an argument, you
will change into that directory (provided that you have such a subdirectory relative to your current
working directory). Examples would work equivalently as the above first set of ls examples, except
that you would not be looking at the contents of the directories, you would actually be making the
corresponding directory your current working directory. There are options to cd, but most are not
useful to beginners.
• xemacs, which is a basic editor with a GUI (graphical user interface). It is essentially menu-driven,
but it is not hard to learn the “hot keys” and become a power user with this editor. Typically, you
invoke this with the name of the file you would want to edit as an argument (although you can load
this with a menu option, too). For example:
xemacs project1.cpp
would edit the file named project1.cpp in your current working directory. If the file does not yet
exist, it would be created by this command. There is only one problem with the above invocation of
xemacs; namely that you would not get your command prompt back! This can be fixed by instead
running the command “in the background” as follows:
xemacs project1.cpp &
You will notice that you immediately get the command prompt back to type in another command,
and xemacs also runs simultaneously! This is especially convenient when programming, as it allows
you to compile and edit a program at the same time (as most IDE’s do).
• g++, which is the C++ compiler. I recommend the following invocation of this command:
g++ -o <run_me> -g -Wall -ansi -pedantic <source_code>
where:
– <run_me> should be replaced by the name of the executable file you wish to create. The -o
alerts the compiler to store its resulting executable (assuming there are no compiler errors) in
something other than the default executable name of a.out.
– -g is the option that allows your resulting executable to be run through a debugger program.
– -Wall is an option that tells the compiler to give you all possible warning about your code.
When you start out, this will be a pain in the neck ... but as you get more experience, the
warning messages you get will help to improve your code. Just as with Microsoft compilers,
warnings will not stop an executable program from being created.
– -ansi and -pedantic require that the source code strictly follow the ANSI C++ standards (note
that Microsoft compilers do not do so by default).
– <source-code> should be replaced by the name of the source code file you wish to compile.
Here’s a quick example:
g++ -o p1 -g -Wall -ansi -pedantic project1.cpp
Would compile the source code file named project1.cpp, generating an executable file named
p1 (assuming there were no compiler errors). You could then type ./p1 to run the program (or
./p1 www.cnn.com if you wanted to pass www.cnn.com to the code as a single command line argu-
ment).
• man, which gives access to Linux’s manual pages. For example, to get more information about the
g++ compiler, you could type:
man g++
and up comes the manual page for the C++ compiler. Pressing the space-bar will move you forward
one page (screen) in the manual page, pressing the ’b’ key will move you back one page, and pressing
’q’ will quit reading the manual page. You can even read the manual page about the manual page
program by typing man man (no joke!!!!)
This quick tutorial barely scratches the surface of what you can do. For example, debugging your code
by means other than cout statements would certainly be helpful - there are a few debuggers available,
including the gdb and ddd programs. Surfing the web is a great resource for such things!