What's New!

Chat with

How to Defend
Your Computer 

The Guides
to (mostly) 
Harmless Hacking

Happy Hacker 
Digests (old stuff) 

Hacker Links 


Meet the 
Happy Hacksters 

Help for 



It Sucks 
to Be Me!

How to Commit
Computer Crime (not)! 

What Is a 
Hacker, Anyhow? 

Have a 
Great Life! 

News from the 
Hacker War Front

The Bash Shell,continued...

The Bash Prompt

    This is the equivalent to using the DOS PROMPT command or the tcsh set prompt= command. In bash, the variable that stores what your prompt is to display is $PS1.

   To change this you simply need to do something basic like:

export PS1="this is my computer: "

    And next time you look, your prompt will read:

this is my computer:

    This prompt will wait for you to enter a command. You will notice that this is now set. Press ENTER, type "ls", it stays. Great! But that is a little boring.

    What you want it to do is display your user name and/or the current directory you are in so that you don't have to use pwd (the command to show your directory) constantly.  Bash allows you to use switches (as seen when we did an echo $PS1 earlier) to display lots of useful info. Here is a list of the main ones:

   \d    date (format: ddd mmm dd - eg: Sat Mar 12)
   \h    display your computers hostname
   \n    newline
   \s    shell name (ie: bash)
   \t    time (24 hour format: hh:mm:ss - eg: 16:22:08)
   \u    current user
   \w    working directory (this changes on the fly to the directory
that you change to).
   \$    display $ character
   \\    display \ character

    There are others, but these will be the most useful to you. Play around and see what others you can find.

More bash shell programming --->> 

Carolyn's most
popular book,
in 4th edition now!
For advanced
hacker studies,
read Carolyn's
Google Groups
Subscribe to Happy Hacker
Visit this group


Return to the index of Guides to (mostly) Harmless Hacking!

 © 2013 Happy Hacker All rights reserved.