Aliases: Customizing Your Unix Experience: .Profile

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

Customizing your Unix experience: .

profile
If you open a terminal window (called a shell in Unix) and type ls a, youll notice a bunch
of files that begin with a period, such as .bash_history. These dot files are hidden to the
usual ls command because we dont usually need to see them, but occasionally they come in
handy.
The file .profile is a good one to get to know. This hidden file is read every time you open a
shell in Unix and you can put in commands to define the experience you want when you
interact with a shell.
Aliases
You can put aliases into your .profile file, which customize commands. For example, the
following aliases redefine various options with the ls command:
alias ls='ls -F'
alias la='ls -a'
alias ll='ls -l'
The first of these tells the system to redefine the ls command itself, so that when you type ls
you get a display that gives visual cues for directory names and executable files, for example
(try it). The second one defines a new command la as a shorthand for ls a, which lists all
your files including hidden files. The third one defines a new command ll that gives long
listings of each file.
Another useful thing some new users like to do is to put in safety options, so they dont
inadvertently do some damage. For example, the rm temp.txt command deletes the file
temp.txt with no questions asked, and this cannot be undone. If you use the alias
alias rm=rm i
the shell will ask you to verify that you really want to do that. With this alias in your .profile,
if you mistakenly type rm * you wont immediately lose all your files.
If you spend a lot of time working remotely and need to run programs on meitner, you could
login to Meitner by typing
ssh simth@meitner.phy.ilstu.edu
every time. Or, if youre lazy like most programmers, you can just alias it:
alias mei='ssh smith@meitner.phy.ilstu.edu'
so now all you need to do is type mei and youre there.
Search path

Unix has the notion of a search path when it looks for commands that you issue. For example,
If you create a source code file and compile it, the default name of the executable file is
a.out. If you type a.out youd expect your program to run. If the shell responds with a
command not found message, it probably means you didnt tell it where to look. You can
either give the full path name for the file, add the current directory to a list that Unix keeps of
places to search. Heres how: put the following line in your .profile file:
PATH=$PATH:.
which tells the shell to add the current directory (.) to its search path. Then the shell will
always look in whatever you current working directory is for commands. If you need some
visual feedback that it worked, type
echo $PATH
which will spit back your current search path, for example,
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:.
where the last directory in the list (separated by colons) is the . directory, as expected.
Other commands
If you use software that always invokes certain programs or subsystems, you may want to put
those commands in your .profile. For example, if youre going to run programs using the
Xgrid grid computing subsystem, you might need something like
XGRID_CONTROLLER_HOSTNAME=yyyyyyyyyyy
XGRID_CONTROLLER_PASSWORD='xxxxxxxxxxxx'
export XGRID_CONTROLLER_HOSTNAME XGRID_CONTROLLER_PASSWORD

Typically these kinds of things are specialized and you wont need them in most physics
courses, but if you get into computational research, specific needs will probably come up.
Summary
Only a few sample examples have been given here. If you use them all, your .profile file will
look like this:

alias ls='ls -F'


alias la='ls -a'
alias ll='ls -l'
alias rm=rm i
alias mei='ssh smith@meitner.phy.ilstu.edu'
PATH=$PATH:.
XGRID_CONTROLLER_HOSTNAME=yyyyyyyyyyy
XGRID_CONTROLLER_PASSWORD='xxxxxxxxxxxx'
export XGRID_CONTROLLER_HOSTNAME XGRID_CONTROLLER_PASSWORD
alias log=exit
alias psq='ps -aj | egrep -v "tcsh|ps|bash"'
alias e='emacs'
alias 112='cd Documents/phy112'
alias xlist='xgrid -job list'
where Ive thrown in a few others for good measure. Hopefully, this brief writeup will whet
your appetite for more. You can learn more about customization online or by asking Dr.
Bogue.

You might also like