Hills (Linux) Access and Use Information
Everyone who is registered in a computer science class
automatically gets an account on "hills",
which is a Linux server.
hills account info
Your hills account gives you
access to text file editing through
the "nano" program, and Java
compiling through the "javac" program,
plus other standard software. Hills may be accessed from any
computer that has Internet access, including the
computers in the ACRC. To access hills, use
any SSH or terminal emulation program, such as SSH Client or PuTTY from Windows. From a Mac or Linux computer, open a Terminal window and type ssh.
Your hills login name is the same as your CCSFmail account user name. To find this user
name, Login to Web4, go to the "Student Services & Financial Aid" tab,
and scroll down to the "Student CCSFmail" link near the bottom of the page. Then click on "CCSFmail info".
If you need help determining your login
name, ask an ACRC staff member. Your initial password for hills
is your birthday and first, last initials in mmmddyy.fl format, for example, if I, Craig Persiko, were born on January 3, 1980,
my password would be jan0380.cp These two initials are actually the first two characters of your login name. You will
be forced to change this password the first time you login,
using this password as your
"old password", and a new one of your choice for
future use. Even if you've logged onto hills before, you have to use this new password.
Ask the ACRC staff for help if you can't login.
To connect to hills, use a
terminal emulation program such as SSH Client or PuTTY.
From a Mac or Linux computer, you can open a terminal window and type:
ssh uname@hills.ccsf.edu
(Put your hills username in place of "uname" above.)
The ACRC has put some good Linux-related tips online
One common mistake with hills is when people use the mouse. On hills, we
are using Linux with a text-only interface,
so your mouse does nothing to interact with hills. When you're
using hills, forget about the mouse.
Another common mistake is that people don't know Linux is case-
sensitive. So file and program names must
always be in the correct (upper or lower) case.
When you log in to hills using your own username, you will
automatically be placed in your own directory on
hills. So you can save any files you wish in that directory or
any subdirectories you create. All the
files you create will be there for you next time you login.
Here is a list of basic commands you should know, all of which you type
at the main Linux (bash) prompt:
- ls
- list files in current directory. Use ll to list all files (including hidden ones)
- rm myfile
- remove (delete) the file specified (replace myfile
with your file's name)
- cp oldfile newfile
- copy file: above will make a new copy of oldfile,
calling it newfile
- mv oldfile newfile
- move file: above will change the name of oldfile to
newfile
- mkdir newdir
- make directory: above will make a new directory
called newdir
- cd newdir
- change directory: above will make newdir the new
working (current) directory
- cat myfile
- concatenate (display): above will print the contents
of myfile to the screen
- more myfile
- same as cat, except it shows only one page at a
time. Hit space to see next page, or "q" to
stop display.
- script myscript.txt
- create a script file called "myscript.txt" (use any name you wish, but please end it with .txt).
Script file will contain all future screen output. Don't forget to type "exit" to stop scripting!
- exit
- exit, or logout, from hills. Or if you're in the
midst of a saving your output to a script,
this will stop the scripting.
- Ctrl-C
- To terminate a program - if you need to stop a program and get back to your Linux prompt
(maybe your program is in an infinite loop or something) - type Ctrl-C (Control and 'c'
together). If you just close your terminal emulator without stopping your program or logging out,
the
program will continue to run indefinitely, and you won't be able to delete that program file!
- man xxx
- manual page: Linux online help: above will tell you
more about xxx. So to learn more about ls,
type "man ls"
- quota -v
- Used to find out how close you are to your quota and maximum limit of storage space on hills.
There are two main programs you'll use on hills: nano
for text file editing (including writing programs)
and javac to compile your java programs.
Following are some basic directions on how to use these programs:
nano(text editor)
To run nano to create a new file, simply type "nano" at the
Linux prompt. To use nano to edit an existing
file (or create a new one) type "nano filename" where filename
is replaced by whatever file you want to
edit. To save your file in nano, type Ctrl-o (for write Out),
and to exit, type Ctrl-x (it will prompt you
to save if you've made changes). The is a limited menu of
commands at the bottom of the nano screen, with
the control key represented by ^. To insert a file that you've
saved on hills into the document you're currently editing, type Ctrl-R.
javac (Java compiler)
Once you've used nano to write your Java program, use javac to
compile it. The filename for your program
must end in ".java" so that javac knows it is a java program.
If your program didn't compile
correctly, you'll get errors or warnings telling you what's
wrong. Otherwise, javac should have created
a class file for each of your classes, with the name of that
class followed by ".class". So if the file
"prog1.java" defines the class "prog1", then you compile the
program by typing: "javac prog1.java". If
you simply get another prompt, with no message, it compiled
successfully. The file "prog1.class" should
now be in your directory. To test your program, type "java
prog1" at the prompt. To compile and run
a java program on your computer, you follow the above directions,
starting from a command prompt.
Logging Out
When you are done using any computer system, you should always
log out. To log out of hills, type "exit"
at the command prompt. To log out of the Windows network, go to
the Start menu and select "Log Off".
Summary: Step-by-Step Instructions for Doing Homework with hills
You may use any text editor and any Java compiler to write and run your program; just make sure you turn in
a text file containing your source code and sample output. Here are some
step-by-step instructions for doing all this using CCSF resources that are available from anywhere:
- Sit at a computer that is connected to the Internet. If
personal account login is necessary, see "ACRC account info" above.
- Run a terminal emulation program such as SSH Client or PuTTY. (Or open a Terminal window if using Mac or Linux.)
- Connect and Login to hills.ccsf.edu
- Use a text editor to write your java program. For example, to create a program called "HelloWorld"
type the following at your Linux prompt: nano HelloWorld.java and then in the nano window type the
java code for your program, such as this one.
When you are
finished writing your program, save it and exit nano by typing Ctrl-X followed by Y, then Enter to
save.
- Compile your program using javac. Continuing with the HelloWorld example, type the following at your
Linux prompt: javac HelloWorld.java
If you just get another Linux prompt, then your program
compiled successfully. If you get any error messages, use nano to fix the problems in your java code and
compile again.
- Run your program using java. For this example that's: java HelloWorld (if that doesn't work,
try
./java HelloWorld
)
- Once your program works and you're ready to turn it in, it's time to save its source code and output
in a file. Start this by using "cat" to display your file on the screen: cat HelloWorld.java
- Run your program again: java HelloWorld
Make sure to show a variety of test-cases to
demonstrate your program's behavior (by running it as many times as necessary).
- You should turn in the entire program listed by your "cat" command, as well as all your sample output.
The easiest way to do this is by copying and pasting. So highlight and copy the program and output, and open a text editor on your computer (such as Notepad) then paste into a new document. Make sure your document contains the entire program and all its output. Save the document in a plain text file.
- Now use your web browser to access
https://ccsf.instructure.com and
log in to this course in Canvas. Click on the assignment you
want to turn in. Then click on the Submit Assignment button. Select the text file with your program and its output. Then click on Submit Assignment. On the right side of your screen it should now say Submission Turned In!
- Don't forget to log out! In your terminal emulator window, log out of your hills account by typing
exit. And
of course log out of Canvas by clicking Account (your face) on the top left, then clicking Logout.
More Information
For more information on many of these topics, see my Links page
at
http://fog.ccsf.edu/~cpersiko/links.html