logo

Using BGUnix

Most computer science classes use a system called bgunix. However, before using bgunix for computer science classwork, you need to execute the following command:

cs-config

This command will set up the environment for your use in computer science classes. After you execute this command and log in again, your command prompt will show your current default directory (where ~ signifies your login directory). The following are descriptions of some common Unix commands and features.

Command Description
cat Display the contents of a file on the screen
cd Return to the login directory
cd directory-name Change default directory to directory-name
clear Clear the terminal screen
cp source dest Copy file source to dest
[Control]-c Interrupt the execution of the current program
exit or [Control]-d Log off the system
lpq List files waiting to be printed
cslpr filename Send a file to the printer
ls Lists the files in the current directory
ls -l Lists the files in the current directory, with more info.
mkdir dir-name Create a subdirectory called dir-name
man command Display information about a unix command
more filename View a file one page at a time
mv old-name new-name Rename a file
passwd Change your password
photo log-file-name Save a session in a photo file
vi filename or
pico filename
Create or edit a file
pwd Display the current default directory
rm filename Delete (remove) a file
rmdir dirname Delete (remove) an empty directory
command < file Read standard input from a file
command > file Redirect standard output to a file
command > file 2>&1 Redirect standard output and errors to a file
alias m='more' Create an alias
unalias m Remove an alias
history List command history
!! Reexecute the previous command
[Press up-arrow key] Reexecute the previous command
!5 Reexecute the fifth command in the history list
!vi Reexecute the last command that started with vi
function fun {
   commands
}
export -f fun
Define a function
fun Execute a function
class -join cs123rl Join class cs123rl
dropclass cs123rl Remove yourself from class cs123rl
g++ prog.cpp Compile a C++ program
g++ -g prog.cpp Compile a C++ program for use with debugger
File/directory references Description
.bash_profile File containing commands executed when logging in
~ Represents home directory of current user
~jsmith Represents home directory of user jsmith
. (period)
~+
Represents current working directory
~- Represents previous working directory

Use the [Tab] key to complete a partially-typed filename.

Customizing your bgunix environment

You can customize your bgunix working environment by adding lines to the .bash_profile file found in your home directory. This is an invisible file, so you won't see it with the ls command unless you say "ls -a". However, you must be very careful when making changes to this file since errors in this file could prevent you from logging onto the system. Here are some sample lines you could add to this file:

export PS1="\u \w\$ " This command will show your username and the current directory in your command prompt. (There is a space after the 'u' and after the '$'.)
function ls {
   command ls -F $@
}
export -f ls
These four lines change the ls command so that the -F flag is always added. The -F flag adds / to the end of directory names and * to the end of executable filenames.

If you make changes to .bash_profile, be sure that you don't delete any lines that are already there.