.bashrc details

  • Bash configuration file: .bashrc
  • If the .bashrc file does not source, add " . ./.bashrc " to a .profile
  • Prompt - establish descriptive prompt: PS1 = ...
  • History - establish a clear and unique history file: HISTFILE = ...
  • Editor - define your editor: EDITOR=/usr/bin/vi
  • Set options - "set -o vi"
  • Path - append system path variable: PATH=$PATH:/home/luser/bin
  • Alias commands - alias ll="/usr/bin/ls -al" ; alias rm="/usr/bin/rm -i"
  • Liberal use of comments (#) - add notes, dates, reminders

a simple .bashrc

export PS1="
------------------------------------------------
$(whoami)@`hostname` [\$PWD]
------------------------------------------------
--> "
EDITOR=/usr/bin/vi; export EDITOR ; VISUAL=/usr/bin/vi; export VISUAL
export HISTFILE="/home/luser/.History/`/bin/date '+%d%b%y_%H%M'.hstry.txt`" set -o vi	 
PATH="$PATH:/home/luser/bin:/usr/sbin:/sbin"
alias ll="/bin/ls -Al"
alias mv="/bin/mv -i"		 
alias cp="/bin/cp -i"	 
alias rm="rm -i"

the prompt - PS1

export PS1="
------------------------------------------------
$(whoami)@`hostname` [\$PWD]
------------------------------------------------
--> "
  • Note the space above the line for clarity in the shell
  • Identify the active user in the shell, important for sysadmins
  • Identify the current host system, important for sysadmins
  • Identify the present working directory, important for sysadmins
  • Note the "-->" allows plenty of room for the next command

the history file, written to .History

export HISTFILE="/home/luser/.History/`/usr/bin/date '+%d%b%y_%H%M'.hstry.txt`" 
  • Create the ".History" directory in the home directory for the user
  • Using %H and %M allows a unique file based on hour and minute
  • One could also use the PID, %S for seconds, or other unique values
  • Check the working path for the date command
  • Be very careful with the quotes and ticks
  • The accent or tick is used to execute the date command within the quotes
  • The single quotes contain the formatting details of the date command
  • The entire variable is encapsulated within double quotes

the editor

EDITOR=/usr/bin/vi; export EDITOR ; export VISUAL=/usr/bin/vi

Note that more than one variable may be defined per line, separated by a ";"
You can export the variable as you declare it, or later.

Bash will invoke an editor on the current command line, and 
execute the result as shell commands.  Bash attempts to invoke 
$VISUAL, $EDITOR, and emacs as the editor, in that order. 
(from "man bash | col -b  | grep -C 5 VISUAL" )

   A sysadmin should only use vi, it is always on all UNIX and Linux systems 
   Other editors such as emacs, nano, and pico may not be installed or work
   The use of vi at the command line provides for rapid command editing

the set options

set -o vi       #  allows the use of the vi editor on the command line

The set command can be executed at the command line or in the .bashrc

--> set -o ( taken from a SuSE system, shown with ";" for clarity )
allexport off; braceexpand on; emacs off; errexit off; errtrace off;
functrace off; hashall on; histexpand on; history on; ignoreeof off;
interactive-comments on; keyword off; monitor on; noclobber off; noexec off;
noglob off; nolog off; notify off; nounset off; onecmd off; physical off; 
pipefail off; posix off; privileged off; verbose off; vi on; xtrace off;

the PATH

PATH="$PATH:/home/USER/bin:/usr/sbin:/sbin"

--> env | grep PATH
MANPATH=/usr/local/man:/usr/share/man
XNLSPATH=/usr/share/X11/nls
PATH=/home/john/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/X11R6/bin:
/usr/games:/bin:/sbin/:/usr/sbin:/etc:/usr/local/sbin:.
ALSA_CONFIG_PATH=/etc/alsa-pulse.conf

SECURITY NOTE:   The root user should never have the "." in their path 

aliases

alias ll="/bin/ls -Al"
alias mv="/bin/mv -i"   # recommended for safety, there are no undo's in Linux
alias cp="/bin/cp -i"     # recommended for safety, there are no undo's in Linux
alias rm="rm -i"           # recommended for safety, there are no undo's in Linux
alias mroe=more        # just in case you type too fast... add others like this

To unalias a command:
  • /usr/bin/rm files-to-delete
  • \rm files-to-delete
  • unalias rm

set your price...

...even free...
Video Series: Linux Sys Admin Course - O'Reilly
http://shop.oreilly.com/product/0636920050209.do
Study Guide for LPIC-2 Certification Exams
search for:
on the internet, or:
JohnMeister.com-fotos
LinuxMeister.net-Linux
BibleTech.net-
Bible overview


Wagoneers

FULL SIZE JEEPS

JeepMeister.com
"Jeep is America's
only real sports car."
-Enzo Ferrari


MeisterTech.net
Diesels +

One Page Overview

Intro to Linux
AMSOIL product guide,
or, AMSOIL web, or 1-800-956-5695,
use customer #283461

Amsoil dealer since 1983
purchase AMSOIL
at Midway Auto on SR9 in Snohomish,
or at Northland Diesel in Bellingham, WA


SJ - 1962-1991

XJ - 1984-2001

WJ - 1999-2004

KJ - 2002-2007

WK - 2005-2010

Find the recommended
AMSOIL synthetics
for your Jeep

CJ-10A - 1984-1986

Jeepsters

MJ - 1984-1992

Willys - 1946-1965

Other Jeeps (FC)