Aludra Unix FAQ

Aludra Unix Basics

Disclaimer

Things change on our developer machines. If you notice anything wrong with these instructions, please let the TA know. Similarly, if you feel some topic is missing, let us know as well.

X-windows and FTP client

You can download the X-Windows software from the ISD software download site (note that the Windows 2000 version of X-Windows will work for Windows XP).  Follow the installation instructions from the ISD site (they are checked).  Also, download a FTP client of your choice.

To make sure you can connect to aludra.usc.edu using X-Windows, we will go over using the basic X-Windows commands below in Lab1, please pay attention to them because you will need to use them repeatedly throughout the class:

1.         Open X-Windows by going to the Start menu, clicking on Programs, and then selecting the X-Win32 icon.

2.         Open your Telnet window by going to the Start menu, clicking on Run, and then typing in telnet aludra.usc.edu.

3.         When the telnet window appears, type in your login information.

4.         Now that you are logged into Aludra UNIX server, in your Telnet window, you have to tell the UNIX server where to send your X-windows.

a.          You must find the IP address of your own computer by going to run, type command, and then ipconfig /all in the prompt window.

b.         In the Aludra Telnet window, type in setenv DISPLAY ip_address:0, where ip_address = the ip address you just found from ipconfig /all

c.          Then type in xterm.

d.         In a few seconds, a X-windows should pop up.

Getting around in UNIX

We will go through a short tutorial in class to make sure you can execute the basic commands in Unix (For our purposes, we will be using Emacs).  However, if you're not familiar with Unix/Linux and proficient in at least one Unix-based editor, PLEASE make sure you read up and familiarize yourself with Emacs by going to the below links since you'll be using it extensively in CSCI201.  YOU HAVE TO GET YOUR CODE RUNNING ON YOUR UNIX ACCOUNTS FOR PROPER GRADING.

http://www.xemacs.org

Emacs Basics

Starting up Emacs

1.         Start up Emacs by typing in emacs in the Telnet window

a.          The display in Emacs is divided into three regions. The top region is called the text window, which displays the document you plan on editing.

b.         At the bottom of the text window, there is a single mode line. The mode line gives information about the document and the Emacs session.

c.          The bottom line of the Emacs display is called the minibuffer, this holds the space for the commands that you give to Emacs by, and displays status information, the commands are discussed below.

2.         Modern emacs has a Windows-like interface with menus that you can control with the mouse.

3.         Experienced emacs users most often use keyboard commands.

a.          Many commands in emacs are started by typing the Control key followed by a letter, e.g.  c-s is incremental search.

b.         Emacs also uses [Control-X] to initial a command, e.g. c-x c-f will initiate the find-file command.

c.          You can also access commands by name using  [Escape-X] or [Alt-x]. These appear in the command line as M-x and then you type the command (using spc for name completion), e.g., Alt-x shell will open a shell in emacs.

4.         Most commands can be cancelled with Control-G.

5.         To exit Emacs and return to the UNIX shell, type [Control-X-Control-C].

a.          If you have made changes to the buffer since the last time you saved it to disk, Emacs will ask you if you want to save.

b.         Type y for yes, or n for no.

6.         Online Help: Emacs has an on-line help system that can be invoked by typing [Control-H].

a.          If you type the question mark (?), Emacs will present a list of help topics you can choose.

Working with Buffers in Emacs

Buffers are work spaces. You can have many buffers in an emacs session. When you open a file, it is put in a buffer.  When you save a file buffer the file is rewritten. Save often.

·             You can move from buffer to buffer by using the Buffers menu.

·             c-x b  Moves you to another buffer. If you don't type a name, it defaults to the last buffer.

·             c-x 2  Divides the window into 2 buffers. Very Useful.

·             c-x 1  Puts the buffer into a single window.

Working with Directories in Emacs (Using the Dired Command)

Entering Dired

 

 

Moving around in the Dired Buffer

 

 

Visiting Entries in Dired (VERY IMPORTANT)

 

 

Deleting Files with Dired

 

 

Operating on Files (notice the capitalized command letters)

 

 

Shell Commands in Dired (Only for experts)

 

o           If you use `*' in the shell command, then it runs just once, with the list of file names substituted for the `*'. The order of file names is the order of appearance in the Dired buffer.

o           If the command string doesn't contain `*', then it runs once for each file, with the file name added at the end.

o           % u    Rename each of the selected files to an upper case name (dired-upcase).

o           % l    Rename each of the selected files to a lower case name (dired-downcase).

o           % R from RET to RET, % C from RET to RET, % H from RET to RET, % S from RET to RET    These four commands rename, copy, make hard links and make soft links, in each case computing the new name by regular expression substitution from the name of the old file.

 

File Comparison with Dired using diff

                                                                      

 

Subdirectories in Dired

 

 

Moving Over Subdirectories

 

 

Updating the Dired Buffer

 

 

Dired and find

·             You can select a set of files for display in a Dired buffer more flexibly by using the find utility to choose the files.

Working with a File in Emacs

1.         To read a disk file into an Emacs buffer, type the command [Control-X-Control-F], then type the name of the file, and then [Return], and Emacs will load the file into a buffer, and display it in the text window.

2.         To save the contents of the buffer to a disk file, type [Control-X-Control-S].

3.         To write the contents of the buffer to a different file with the command [Control-X-Control-W], then type the name of the file, and then [Return].

4.         To create a new file, use [Control-X-Control-F], then type the name of the file, then [Return], and an empty document will appear in the text window.

5.         To use file name completion, type part of the name of the file you want, and press the [Spacebar] or [Tab] key to complete a file name. If Emacs displays a few or more potential matches, continue typing in more of the file's name, and keep pressing file completion key until you get the file you want.

Working with the text window in Emacs

1.         To insert text into a buffer, or the text window, move the cursor to where you want the text to appear and type.

2.         To Delete text just press delete or use one of the following:

a.          [Control-D] deletes forward one letter.

b.         [Control-K] deletes from the point to the end of the line.

c.          [Escape-D] deletes forward one word.

d.         [Escape-Delete] deletes backward one word.

3.         To select, move the cursor to where you want to begin the selection and type [Control-Spacebar], which sets the mark, and move the cursor to the other end of what you are trying to select.  This will select the whole section.

4.         To cut, type [Control-W].

5.         To paste, type [Control-Y], but only pastes the most recently-cut text.

6.         To paste in earlier cuts, type [Escape-Y], which cycles every time you type it, but you must first type [Control-Y] first for [Escape-Y] to work.

7.         To copy, type [Escape-W].

8.         To undo, type [Control-_] (Underscore).

Running a unix shell from within emacs

 

 

Help Commands

 

 

File Reading and Writing Commands

 

 

Cursor/Screen Movement Commands

  

 

Copy and Delete Commands

 

 

Search and Replace Commands [The most often used commands]

 

 

Window and Buffer Commands

 

 

Exiting Emacs, Fixing Mistakes and Other Important Stuff

 

Some common UNIX commands

  1. Working with Directories:
    1. ls: list files and directories
    2. ls –a: list all files and directories
    3. mkdir: make a directory
    4. cd directory: change to named directory
    5. cd: change to home-directory
    6. cd ~: change to home-directory
    7. cd ..: change to parent directory
    8. pwd: display the path of the current directory
  2. Copying a Directory: Very Useful

a.          cp -i -r existingDirectory  newDirectory
This does a recursive copy of all files and subdirectories.

b.         For example, after you unzip v1, you'll have an agentsV1 directory (or something like that). Then, before modifying anything you need to copy it to a directory whose name might be agentsV3:
cp -i -r agentsV1 agentsV3

c.          YOU SHOULD ALWAYS HAVE A RUNNING VERSION OF YOUR WORK. Every time you are going to modify something running, you should copy it as a backup.

  1. Working with Files:
    1. cp file1 file2: copy file1 and call it file2
    2. mv file1 file2: move or rename file1 to file2
    3. rm file: remove a file
    4. rmdir directory: remove a directory
    5. cat file: display a file
    6. more file: display a file a page at a time
    7. head file: display the first few lines of a file
    8. tail file: display the last few lines of a file
    9. grep 'keyword' file: search a file for keywords
    10. wc file: count number of lines/words/characters in file
  2. A Few More Complex UNIX commands:
    1. *: match any number of characters
    2. ?: match one character
    3. man command: read the online manual page for a command
    4. apropos keyword: match commands with keyword in their man pages

Preparing your Bash Shell

Shells are an important concept in Unix. There are many different shells out there so it's important to find one you're comfortable with. We use the Bourne-Again Shell (BASH) so that's what most of these instructions will be geared towards.

-             bash - to invoke the bash shell simply type bash. If you want Bash to be your default login shell type chsh in the command line and follow the instructions on changing your login shell. I only recommend this if you feel really comfortable messing around in Unix and with Bash.

-             You will be creating a .bashrc file with commands that will be executed when you enter a bash shell.

Setting up Java, ANT, and JUnit

Ant is a Java-based build tool that makes managing and building your Java projects MUCH easier. For more details on Ant, make sure you check out the Ant User's Manual. The Ant setup script calls the setup script for the Java 1.5.0_06 JDK so all we have to do is call the Ant setup script in our .bashrc file. Junit is a regression testing framework for Java programs. It is used for unit testing Java programs; you will be doing a lot of unit testing in class.

#export  JAVA_HOME=/usr/usc/jdk/1.5.0_06

export  JAVA_HOME=/usr/usc/jdk/default
export  PATH=/usr/usc/ant/default/bin:$PATH

export CLASSPATH=$CLASSPATH:/home/scf-22/csci201/junit3.8.1/junit.jar
ulimit -v 1840000

                                            

 

 

The University of Southern California does not screen or control the content on this website and thus does not guarantee the accuracy, integrity, or quality of such content. All content on this website is provided by and is the sole responsibility of the person from which such content originated, and such content does not necessarily reflect the opinions of the University administration or the Board of Trustees