UNIX COMMANDS (the bare necessities)

mkdir Make directory creates a new sub-directory. To use, type mkdir , where "name" may be up to 256 characters long, but the symbol '/' may not be used.
pwd Print Working Directory. Displays WHICH directory you are in (Shows the current directory location).
ls LiSt current directory contents Shows list of files in current directory in short format.
ls -lLong List of files Gives file names, as well as mode, owner, group, size, and creation date and time. If a sub-directory is given after the ls command, the files listed will be those in the given directory. Otherwise, files in the working directory are used. -C used with ls, shows file names in Columns.
-a    When used with ls , gives hidden files as well.
cd Change directory Type the name of the directory after the command (e.g., cd Mail to go the Mail sub-directory of your home directory). When used alone, it returns you to your home directory. Or use cd $HOME to get to your home directory
cp Copy files. Type the command followed by the old file and the new file names, in that order, such as cp oldfile newfile, and press Return.
mv Move files Type the command followed by the old file and the new file names, in that order, such as mv oldfile newfile, and press <Return>.
rm ReMove file Type the command followed by the file name, such as rm filename, and press <Return> Can be used with wildcard -- rm *.o would remove all files ending with .o extension (these are usually object files)
cat Concatenate files Without redirection, cat prints the file or files to standard output (terminal display). With redirection, files are concatenated to the specified location. For example, cat file1 file2 > file3 copies file1 and file2 into a new file, file3.
more Displays contents of file to screen 1 page at a time. Used instead of cat command so that entire file can be seen page by page on the screen. Example: more hello.cpp displays the contents of file hello.cpp to the screen 1 page at a time.
a2ps print file to fh110a printer print file to printer in fleck hall 110a Example: a2ps hello.cpp would print the file named hello.cpp to the printer in fh 110a.
r Repeat or RECALL command Used with a command to REPEAT last command. Example: r more Repeats the last more command you gave
history Gives a history of commands used Gives the last 20 commandsyou have typed at the terminal. Used in conjuction with ! command (recall) ! 123 means repeat the command 123 (you get the number of the command from history)
passwd Changes password on system System prompts for old password, then for new password then asks for a verification of new password. Passwords must have 6 or more characters, at least 1 must be a NON-LETTER. Passwords are CASE-SENSITIVE as are ALL unix commands.!
emacs A popular and very powerful text editor. Used to create files containing a program or any text. Example: emacs test1.cpp opens the emacs editor and you are now creating/editing a file called "test1.cpp". REMEMBER case sensitive file names. Example: emacs Test1.java opens the emacs editor to create or edit a file named "Test1.java" (a java program)
exit logout (exit or kill) of the terminal session. In X-Windows make sure you logout of the Windows session also on the toolbar under the "-" box.




Emacs Editor Common Commands

Note when in Emacs:
   C   -   means HOLD control key
   M   -   means HOLD the ALT key

C-xC-c Exit from editor
C-xC-s Save (output) file
C-xC-f Find file (opens it into emacs window)
C-x C-b List current open buffers
C-x k Kill buffer that is currently selected
C-x o Switch to other window
C-v Page Down 1 screen
M-v Page UP 1 screen
C-e Move cursor to END of LINE
C-a Move cursor to BEGINNING of LINE
C-d Delete character AT cursor
M- > Move to END OF WHOLE TEXT
M- < Move to BEGINNING of WHole TEXT
C-k Delete to end of current line (Cut)
C-y Paste (yank from buffer) last item Cut
C-g Kill current command, or STOP when stuck
C-x u Undo previous command (allows several in a row)
C-s Search for string in file (forward search)
C-r Search for string in file (reverse search)
C-h Get help on emacs commands
M-x insert-file Inserts a File into current location
M-x compile Runs compile command from within emacs
M-x shell Runs unix shell in current buffer window
M-x help-with-tutorial go through emacs tutorial (good idea!)
M-x replace-string prompts for old string, then new string and replaces old with new, all occurrences.

Summary of Commands to create/compile/execute a Java program

  1. Use the emacs text editor to create your program in a file, save the file as a java program, ie.
    Hello.java
  2. Compile your java program with this command:
        javac Hello.java
  3. Execute your compiled program (your .class file) on the java virtual machine (vm)
        java Hello

HOW TO COMPILE WITH GNU C++ COMPILER ON UNIX SYSTEM

The following is a list of commands to know to be able to use the gnu C++ compiler:
  1. g++ filename.cpp
    compiles, and links filename.cpp into executable a.out
    ==> a.out (note:filename is whatever name you give the program when it is created with the editor)
  2. g++ -c filename.cpp
    compiles ONLY filename.cpp into filename.o (object code)
    ==> filename.o
  3. g++ -o filename.out filename.cpp file1.o
    compiles filename.cpp, links file1.o and makes executable filename.out
    ==> filename.out
  4. g++ -o lab1 f1.cpp f2.o f3.o
    compiles f1.cpp, links with f2.o and f3.o and makes executable named lab1
  5. Execute the program whose default name is a.out:
    ./a.out
  6. To Execute a program with the name of filename.out:
    ./filename.out
  7. To Execute a program with the name of lab1:
    ./lab1