CSC148H/A48H -- Essential Linux commands


Linux basics

There are usually two ways to interact with a filesystem: using a GUI (Graphical User Interface) where you point and click, and using a command line where you type commands. In Linux, the command line is called an "xterm".

Unless otherwise specified all files and directories are assumed to be in the current directory. Use the following commands to navigate through the directory structure:

command effect
ls list contents of current directory
cd dirName go to directory "dirName"
cd .. go up to parent directory
cd go to home directory
rm llama delete file called "llama"
mv llama alpaca rename file or directory "llama" to "alpaca"
mv llama a1/ mv the file "llama" from the current directory to the subdirectory "a1".
mkdir eek make a new directory called "eek"
rmdir eek remove the directory called "eek"

Note: Linux is case sensitive, like Java. For example, Java and Linux know that hello, HELLO and hEllO are not the same.


Compiling, Running and Documenting Java Programs

Although you will likely have already compiled your code from within DrJava, you can also do it in Linux. Type

      javac Marf.java
    

at the prompt, where Marf.java is the java source file.

To run a Java program, type

      java Marf
    

Where Marf is the name of the class containing the program's main method. Note: Do not type the .class or .java extension.


Javadoc from the command line

You can run javadoc either by changing directories (with cd) or by specifying the absolute path to the source files. The following generates the documentation for all the .java files in the current directory:

      javadoc -private *.java
    

The -private flag generates documentation for the private members of your classes as well as public members. This is appropriate when generating documentation for other programmers who will maintain your code, and may be required for assignments.

Click for detailed documentation for JavaDoc. (This is not required reading.)