Developer's Daily Unix by Example
  main | java | perl | unix | dev directory | web log
Unix Articles


A sample .profile file for Korn shell and Bash users


This article presents a sample .profile file that can be used by Unix Korn shell and Bash users.

The intent of this brief article is to show some of the things that are possible with the Korn and Bash shells.  Please feel free to use this .profile at your own site, and modify it as desired!

Brief discussion

Listing 1 shows our sample .profile file for Korn shell and Bash users.  For Korn shell and Bash users, the .profile is the shell startup file, just like autoexec.bat is the startup file for DOS users.

#  A sample .profile file for Korn shell and Bash users  #
#  Courtesy of Developer's Daily                         #
#                               # 


set -o vi           # enable the ability to recall previous commands with 
PS1='$PWD> '        # set the prompt to display the current directory

#  a few Korn/Bash shell aliases  #

alias lc="ls -C"
alias lm="ls -al | more"
alias dirs="ls -al | grep '^d'"     # show the dir's in the current dir
alias h=history                     # show the history of commands issued

alias nu="who|wc -l"                # nu - number of users
alias np="ps -ef|wc -l"             # np - number of processes running
alias p="ps -ef"

# mimick a few DOS commands with these aliases:

alias cd..="cd ../.."
alias cd...="cd ../../.."
alias dir="ls -al"
alias edit=vi
alias help=man
alias path="echo $PATH"

Listing 1:    profile - a sample .profile file for Korn shell and Bash users.

Download the .profile file

If you'd like to download the .profile into a separate window instead of cutting-and-pasting the text from Listing 1, click here, and the text will be displayed in the next window.  Then just select File|Save As... from your browser to save the .profile to your local filesystem.

What's related

copyright 1998-2009,, all rights reserved., an alvin alexander production.