Configuring Your Shell

Your Default Shell

The shell that you enter by default when you log in is set by your system administrator. To change your own default shell, the command you need is:

chsh

followed by specifying:

/bin/bash
or
/bin/sh

Your Prompt

Root’s default prompt is:

[root@fedora root]#

Other users’ prompts are like:

[glenn@fedora glenn]$

 

The Prompt

These prompts actually are configured in the environment variable PS1:

echo $PS1

Which gets you:

[\u@\h \W]$

(On some systems you may get a “variable not set” message.)

 

\u is for User

What this means is:

\u = username

\h = hostname

\W = working (current) directory (short listing)

 

Changing your own profile

Let’s say you’d rather see the full path of your current working directory in the prompt.

You could change the value of PS1:

export PS1=”[\u@\h \w]$”
# in bash

PS1=”[\u@\h \w]$”
export PS1
# in Bourne

set PS1=”[\u@\h \w]>”
# in csh

But this will only last for your current session.

 

A Permanent Change

If you want a change to your prompt to be permanent, you’ll need to change your ~/.bashrc file.

Open this file in vi. If there is a PS1 variable declared, change it. Otherwise, add this line to the end of the file:

PS1=“[\u@\h \w]$”;

export PS1;

 

Changing Everyone’s Prompt

If you are root, you can make this new prompt the default for all users by adding the PS1 variable declaration to the /etc/bashrc file:

vi /etc/bashrc

In vi add:

PS1=“[\u@\h \w]$”;

export PS1;

(Note use of weak quotes to preserve spaces.)

 

Keyboard Mappings

One annoying thing that can happen when you log into a Linux/Unix server through a remote terminal. The most common problem is the Backspace key, which can print characters you never intended on the screen.

There are (at least) two ways to address this:

Modify your ssh or putty settings

In ssh, pull down the Edit menu and select Options. You’ll see this screen:

Depending on your situation, you may want to check Backspace sends Delete, or Delete sends Backspace. Click OK and your settings are immediately applied.

If you use the wonderful putty, click the Keyboard link on the left to see this page:

Again, the options to experiment with are the Backspace key options.

 

Modify your shell settings on the Linux/Unix server

Typically you’d do this in ~/.bashrc or your .profile file. You need a line like:

stty erase ^h

or

stty erase control-vBackspace-key

Once you’ve made the change, you can either log out and log back in, or “source” your profile file into your current environment. Assuming you set this in .bashrc, the command would be:

. ./.bashrc

Note that there is a space between the first dot and the second dot. That’s because the first dot is “shorthand” for the command source.

 

Mapping Resources

Anne Baretta’s Consistent BackSpace and Delete Configuration at http://www.ibb.net/~anne/keyboard.html