UHCL Banner

Unix Lab FAQs

Table of Contents

General Questions (click topics to expand)

What is my username?

To find your username, click on the following link and enter your Student ID or Last Name or First Name

Search

Your username will be listed under the ROCKS(Unix) system. Unix usernames are case sensitive.

What is my password?

Email the System's Administrator for your password.

How do I access the account from outside the university?

The Unix server is ruby.rocks.uhcl.edu. You need to ssh to this server in order to access this account from outside UHCL. This server will not accept telnet connections.

How do I access the server if I don't have a ssh client?

You can download putty client which is a free ssh client.

How to Remove cache files from unix account using Putty?

How to Remove cache files from unix account using Mac/Apple?

How do I change my password?

At the command prompt, enter:

% passwd

The system will prompt you for the old password and then for the new password.

How do I print my files?

Go to the File tab and select the print option:

This is valid on both Ubuntu and Solaris 10 OS

What are the software available on Server?

What are the software available in D158(UNIX) Lab?

 Click here for more available softwares.

How do I start Netscape?

There are many ways of doing this:

If /usr/dt/bin is already added to your path, then at the command prompt enter:

% netscape

If /usr/dt/bin is not added to your path, then add it to your path and then at the command prompt enter:

%/usr/dt/bin/netscape

How do I get more information about a specific Unix command?

At the command prompt, enter:

% whatis name of the command

The system will return a brief decription of the command.

How do I get help regarding a specific command?

At the command prompt, enter:

% man name of the command

The system will return a detailed decription of the command. For example:

% man man

will give you the detailed description of the man command. To return to the prompt without reading the whole description, at the command prompt enter:

% <cntrl> c

How do I find the name of the operating system that my computer runs?

At the command prompt, enter:

% uname

The system will return the current operating system. To find the version of the operating system, at the coommand prompt enter:

% uname -v

Directories

How do I find my current directory?

At the command prompt, enter:

% pwd

The system will return the path to you.

How do I create a directory?

At the command prompt, enter:

% mkdir directory-name

How do I change my directory?

At the command prompt, enter:

% cd path of the directory

By path of the directory, we mean the location of the directory from the root.

% cd d

How do I return to the previous directory?

At the command prompt, enter:

% cd ..

How do I go to the root directory?

At the command prompt, enter:

% cd /

How do I return to my home directory?

At the command prompt, enter:

% cd

How do I empty a directory?

First go into the directory to be emptied. Then, at the command prompt, enter:

% rm *

The system will inform you if there is another directory present in this directory. If so, at the command prompt enter:

% rmdir *

How do I remove a directory?

At the command prompt, enter:

% rmdir name of the directory

How do I get a recursive directory listing?

At the command prompt, enter one of the following commands:

% ls -R

To read the output of the system one page at a time, pipe the command to more. That is, at the command prompt , enter:

% name of the command | more

Files

How do I create a file?

At the command prompt, enter:

% touch name of the file you would like to make

How do I rename a file?

At the command prompt, enter:

% mv [old file name] [new file name]

How do I copy a file?

At the command prompt, enter:

% cp [old file name] [new file name]

How do I erase a file?

At the command prompt, enter:

% rm file name

How do I list all the files (including directories) in my current directory?

At the command prompt, enter:

% ls

How do I list only those files that start with a . (dot)?

At the command prompt, enter:

% ls -a

This will list all files including the ones begining with a dot.

or

At the command prompt, enter:

% ls .*

This will list only the files beginning with a dot.

How do list all the files that have an underscore ( _ ) in the name?

At the command prompt, enter:

% ls *_*

How do I find the creation time of a file?

You can't - it isn't stored anywhere. Files have a last-modified time (shown by "ls -l"), a last-accessed time (shown by "ls -lu") and an inode change time (shown by "ls -lc"). The latter is often referred to as the "creation time" - even in some man pages - but that's wrong.

How do I remove a file whose name begins with a "-" ?

At the command prompt, enter:

% rm ./- filename

The Unix Path

How do I find out my PATH?

At the command prompt, enter:

%echo $PATH

How do I add a new path to the PATH variable?

Edit or create (if does not exist) .profile file in your home directory as follows:

% vi .profile

Add the following commands to the .profile file

PATH=$PATH: the name of the path that you wish to add
export PATH

Save .profile file as follows:

wq!

Floppy Disk Access

How do I access a floppy disk?

On many Sun hardware platforms, it is impossible to automatically detect the presence of a floppy in the drive. Run the command

/bin/volcheck

to ask volume management to check the floppy drive for media.

After volume management detects the floppy, it will be automatically mounted in

/floppy/< name_of_media >

How do I access the floppy disk through the File Manager?

The filemanager also has a menu item

File> Check for Floppy

which in effect, runs the volcheck command.

How do I format a floppy on a UNIX machine?

When formatting floppies,

fdformat

command will not put a file system on the floppy, by default. Use the

fdformat -d

flag to put a DOSfile system on it, or run the newfs command

newfs /vol/dev/rdiskette0/unnamed_floppy

to put a ufs file system on it.

How do I know if the floppy is not recognized by the system?

First check is to see if volume management knows about it. The best way to check this is to look in /vol/dev/rdiskette0 and see if there is something there. If not, the volcheck command has not been run, or there is some hardware problem.

The vi Editor

How do I start the vi editor?

To start using vi, at the command prompt enter :

% vi filename

The filename can be the name of an existing file or the name of the file that you want to create.

How do I insert into the file?

For inserting press i and then start inserting.

How do I save a file?

To save the file and quit vi editor, first check that you are in command mode by pressing ESC and then enter:

:ZZ or :wq to both save and quit

or

:w to save file but not quit vi

or

:q! to quit

How do I exit without saving the changes?

To quit vi without saving the contents of the buffer to the file press the ESC key and then enter

:q! .

What is the typical command format inside the vi editor (that is, when editing a file with vi, what is the format of the command)?

ESC, [n] operator [m] object

How do I find and replace?

:s/<char to be searched>/<new char>

Useful commands that will come in useful when editing a file:

To move to:

Next line down : j
Start on next line down : +
Previous line : k
Start of previous line : -
Left one character : h
Right one character : l
Go to first character of current line : ^
Go to last character of current line : $

To delete:

Current word : dw
Previous word : db
Entire line : dd
To end of line : d$

To insert:

Insert text after the cursor : a
Insert text before the cursor : i
Append text at the end of the current line : A
Insert text at the start of the current line : I
Open a new line below the current line : o
Open a new line above the current line : O

Oracle and sqlplus

How do I get sqlplus to startup?

At the command prompt, enter:

% sqlplus

Why does my oracle password not work?

When entering your password, oracle needs to know which database it should connect to. The database that you use is known as the nas database. At the password prompt, enter:

% your-password@nas

Why does the sqlplus command not work?

Check the .login file in your c-shell. To do so, at the command prompt, enter:

% more . login

The ORACLE_BASE, ORACLE_HOME and the TWO_TASK environment variables need to be set to the following paths:

setenv ORACLE_BASE "/orasw/oracle"
setenv ORACLE_HOME "${ORACLE_BASE}/product/9.0.1/"
setenv TWO_TASK "nas"
setenv PATH "$PATH":${ORACLE_HOME}/bin

If the variables are not set, please edit the .login file and include the above 4 lines.Now you need to make sure that the changes go into effect. This can be accomplished by executing the following command:

% source .login

Now run the command SQLplus, and this should take care of it. If you STILL have a problem, copy a new .login file into your directory from /compilers/usrlib by entering the following command at the prompt:

% cp /compilers/usrlib/.login .

WARNING: You will lose all previous configurations made in the .login file.

Now source the .login file and it should work.

% source .login

C and C++ and Java Compilers:

How do I compile and create an executable file in C or C++?

If the source file is a C++ file, at the command prompt enter:

% g++ filename.cc –o filename

This will create the executable file named filename. If the source file is a C file,at the command prompt enter:

% g++ filename.c –o filename

When I try to compile with gcc or g++, why do I get a "gcc: command not found" or "g++: command not found" error message

This means that your PATH does not contain the directory that has gcc or g++ in it. /usr/local/bin is where the executables for gcc and g++ reside. You can either give the full path to gcc in the following manner:

% /usr/local/bin/gcc filename.cc –o filename

or add /usr/local/bin to your PATH

Why do I get a "Fatal Error : stdlib could not be found" when I execute a compiled and linked program?

Your environment needs to have the LD_liBRARY_PATH set, so that it can find all its libraries. The LD_liBRARY_PATH has to be set in the .login file, for your program to execute correctly in the c-shell. Edit the .login file in your home directory and add the following into it.

setenv LD_liBRARY_PATH /compilers/SUNWspro/lib:/usr/local/lib:/usr/ openwin/lib

Now, source the .login file.

% source .login

Your account now points to the correct libraries that C and C++ requires.

Where can I go to find more information on GNU software?

The GNU Project Home page is located at:

www.fsf.org/home.htm

The GNU software documentation pages are located at:

http://www.delorie.com/gnu/docs

GNU links to Free Software Site Pages can be found at:

http://www.fsf.org/links.html#FreeSoftwareDocumentation

How do I compile and create an executable file in Java?

At the command prompt enter:

% javac filename.java -o filename

This will create the object file filename. Now execute the command

java -classpath .filename

This will execute the file named filename

When compiling a java program, why do I get Exception in thread "main" java.lang.NoClassDefFoundError:

You need to have the following variables set in your environment.

JAVA_HOME=/compilers/j2sdk1_3_1
J2EE_HOME=/usr/local/j2sdkee1.2.1
CLASSPATH=/faculty/abeyseke:/usr/local/j2sdkee1.2.1/lib/j2ee.jar:/compilers
/j2sdk1_3_1/lib/emailmessages.jar:/compilers/j2sdk1_3_1/lib/mm.mysql-2.0.4-bin.jar

Your also need to have the following included in your PATH variable:

/compilers/j2sdk1_3_1/bin:/usr/local/j2sdkee1.2.1/bin

When I try to create a thread from my C code, why does pthread_create return error # 68608 which corresponds to out of range?

When compiling the program, make sure that the -lpthread option is added to the gcc or g++ command. If this is omitted, the program still compiles successfully, but you will not be able to actually execute the program.

Web Applications

How do I get a web account?

A request has to be made, by the instructor to the systems adminstrator, on your behalf, in order for you to get web account. It should be required for a course that you are taking. If the request is approved, your instructor will be notified of your account information.

How do I view my web page?

Your web page is created on ruby.rocks.uhcl.edu. Your URL will be http://ruby.rocks.uhcl.edu/username

Where do I save my CGI applications in apache?

A directory will be created for the user at /usr/local/apache/cgi-bin , where all your CGI applicaitons can be stored. Please note that this is ONLY on the machined named Ruby, not on any machines in the lab.

Where do I put my files in TOMCAT?

A directory will be created for the user at /compilers/jakarta-tomcat-3.2.3/webapps, where all your TOMCAT files can be stored.

How do I view my TOMCAT files?

The TOMCAT installation on the system can be viewed at http://Ruby.rocks.uhcl.edu:8080. Your TOMCAT files can be stored at /compilers/jakarta-tomcat-3.2.3/webapps/username and can be viewed at http://Ruby.rocks.uhcl.edu:8080/username

Where do I put my classes files in TOMCAT?

A directory will be created for users at /compilers/jakarta-tomcat-3.2.3/classes/username to save their classes files.

Unix Shells and Scripts

What is my shell?

At the command prompt, enter:

% echo $shell

How do I {set an environment variable, change directory} inside a program or shell script and have that change affect my current shell?

In general, you can't, at least not without making special arrangements. When a child process is created, it inherits a copy of its parent's variables (and current directory). The child can change these values all it wants but the changes won't affect the parent shell, since the child is changing a copy of the original data.

Some special arrangements are possible. Your child process could write out the changed variables, if the parent was prepared to read the output and interpret it as commands to set its own variables.

Also, shells can arrange to run other shell scripts in the context of the current shell, rather than in a child process, so that changes will affect the original shell.

For instance, if you have a C shell script named "myscript":

cd /very/long/path
setenv PATH /something:/something-else

or the equivalent Bourne or Korn shell script

cd /very/long/path
PATH=/something:/something-else export PATH

and try to run "myscript" from your shell, your shell will fork and run the shell script in a subprocess. The subprocess is also running the shell; when it sees the "cd" command it changes *its* current directory, and when it sees the "setenv" command it changes *its* environment, but neither has any effect on the current directory of the shell at which you're typing (your login shell, let's say).

In order to get your login shell to execute the script (without forking) you have to use the "." command (for the Bourne or Korn shells) or the "source" command (for the C shell). I.e. you type

. myscript

to the Bourne or Korn shells, or

source myscript

to the C shell.

If all you are trying to do is change directory or set an environment variable, it will probably be simpler to use a C shell alias or Bourne/Korn shell function. See the "how do I get the current directory into my prompt" section of this article for some examples.

How do I ring the terminal bell during a shell script?

The answer depends on your Unix version (or rather on the kind of "echo" program that is available on your machine). A BSD-like "echo" uses the "-n" option for suppressing the final newline and does not understand the octal \nnn notation. Thus the command is:

% echo -n '^G'

where ^G means a _literal_ BEL-character (you can produce this in emacs using "Ctrl-Q Ctrl-G" and in vi using "Ctrl-V Ctrl-G")

A SysV-like "echo" understands the \nnn notation and uses \c to suppress the final newline, so the answer is:

echo '\007\c'

How do I read characters from the terminal in a shell script?

In sh, use read. It is most common to use a loop like:

while read line
do
...
done

Unfortunately csh has no way of distinguishing between a blank line and an end-of-file.

If you're using sh and want to read a *single* character from the terminal, you can try something like:

echo -n "Enter a character: "
stty cbreak # or stty raw readchar=`dd
if=/dev/tty bs=1 count=1 2>/dev/null`
stty -cbreak echo "

How can I get setuid shell scripts to work?

Let us first assume you are on a UNIX variant (e.g. 4.3BSD or SunOS) that knows about so-called `executable shell scripts'. Such a script must start with a line like:

#!/bin/sh

The script is called `executable' because just like a real (binary) executable it starts with a so-called `magic number' indicating the type of the executable. In our case this number is `#!' and the OS takes the rest of the first line as the interpreter for the script, possibly followed by 1 initial option like:

#!/bin/sed -f

Suppose this script is called `foo' and is found in /bin, then if you type:

foo arg1 arg2 arg3

the OS will rearrange things as though you had typed:

/bin/sed -f /bin/foo arg1 arg2 arg3

There is one difference though: if the setuid permission bit for `foo' is set, it will be honored in the first form of the command; if you really type the second form, the OS will honor the permission bits of /bin/sed, which is not setuid, of course.

How to convert perl scripts to use /usr/local/bin for the Sun Systems?

How do I find the last argument in a Bourne shell script?

If you are sure the number of arguments is at most 9, you can use:

eval last=\${$#}

In POSIX-compatible shells it works for ANY number of arguments. The following works always too:

for last
do
:
done

This can be generalized as follows:

for i
do
third_last=$second_last
second_last=$last
last=$i
done

Now suppose you want to REMOVE the last argument from the list, or REVERSE the argument list, or ACCESS the N-th argument directly, whatever N may be. Here is a basis of how to do it, using only built-in shell constructs, without creating subprocesses:

t0= u0= rest='1 2 3 4 5 6 7 8 9' argv=

for h in '' $rest
do
for t in "$t0" $rest
do
for u in $u0 $rest
do
case $# in
0)
break 3
esac
eval argv$h$t$u=\$1
argv="$argv \"\$argv$h$t$u\"" # (1)
shift
done
u0=0
done
t0=0
done

# now restore the arguments

eval set x "$argv" # (2)
shift

This example works for the first 999 arguments. Enough? Take a good look at the lines marked (1) and (2) and convince yourself that the original arguments are restored indeed, no matter what funny characters they contain!

To find the N-th argument now you can use this:

eval argN=\$argv$N

To reverse the arguments the line marked (1) must be changed to:

argv="\"\$argv$h$t$u\" $argv"

If you allow subprocesses as well, possibly executing nonbuilt-in commands, the `argvN' variables can be set up more easily:

N=1

for i
do
eval argv$N=\$i
N=`expr $N + 1`
done

To reverse the arguments there is still a simpler method, that even does not create subprocesses. This approach can also be taken if you want to delete e.g. the last argument, but in that case you cannot refer directly to the N-th argument any more, because the `argvN' variables are set up in reverse order:

argv=

for i
do
eval argv$#=\$i
argv="\"\$argv$#\" $argv"
shift
done

eval set x "$argv"
shift

How do I add CLISP to my path?

Common LISP(CLISP) is installed on the server. The following is the path for CLISP to be added to PATH variable

/opt/csw/bin

Note : Please refer The Unix Path for more details on how to add PATH variable.