SlackwareThis Forum is for the discussion of Slackware Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
# .bashrc
# sourced by BASH everytime it start
## These should be set by /etc/profile
## But sometime, bash missed them. So here is the push
export PATH="/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin:/opt/bin:/usr/X11/bin:/usr/local/games:/usr/games"
# Set various environment variables
for SH in /etc/profile.d/*.sh; do
. $SH
done
#use custom keymap
xmodmap ~/.Xmodmap
## Set fancy colors
eval `dircolors -b`
## Set this for your first choice
#export BROWSER=seamonkey
export BROWSER=firefox
#export BROWSER=opera
#export EXPLORER=konqueror
#export NETWORK_EXPLORER=konqueror
#export AUDIO_PLAYER=xmms
#export VIDEO_PLAYER=gxine
export DISPLAY=$DISPLAY
# This line was appended by KDE
# Make sure our customised gtkrc file is loaded.
export GTK2_RC_FILES=$HOME/.gtkrc-2.0
export USER=vl70
# update the time
ntpdate 0.pool.ntp.org
hwclock --systohc
PS1='[\d [ ]-\t[ ]\u@\h:\w]$'
alias h='history | less'
alias p='pwd'
alias n='netstat -tulpn'
alias d='df -h'
alias w='which $1'
alias wh='whereis $1'
alias p='pkgtool'
alias f1='file $1'
alias l='ls -l'
alias lp='leafpad .bashrc'
alias a='alias'
alias bl='blkid'
alias f="find $1 -iname S2"
alias p1='ps -ef | grep -v grep | grep daemon'
alias w="wget $1"
alias p='ps aux'
hwclock should already be handled by /etc/rc.d/rc.S
I'd put any ntpdate stuff in /etc/rc.d/rc.local, myself.
I have no idea why you have the line
Code:
export USER=vl70
in that .bashrc file.
When you say "root .bashrc file", do you mean root's .bashrc file?
Anyway, this is my normal login user's .bashrc:
Code:
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# setup environment for any login
export TEMP=/tmp/${USER}
export TMP=${TEMP}
mkdir -p ${TEMP}
# setup environment for interactive logins
if [ "$PS1" ] ; then
# source environment settings
if [ -d ~/etc/env.d ] ; then
for f in $(find ~/etc/env.d -type f); do
. $f
done
fi
fi
I drop various files with export or function definitions in ~/etc/env.d, like so...
Code:
~$ cat etc/env.d/qemu
# Qemu can use SDL sound instead of the default OSS
export QEMU_AUDIO_DRV=spice
# Whereas SDL can play through alsa:
#export SDL_AUDIODRIVER=alsa
# .bashrc
...
alias p='pwd'
alias p='pkgtool'
...
Who has much better Please!
Hmmm - I guess your 'pwd' is kinda being 'overwritten' ...
Personally, I don't see the need for such a lot of shortcuts, but hey, there's no accounting for taste ...
Mine, more or less (certainly less), goes like this:
Code:
export PS1="\h:\w \$ "
alias lf='ls -Fax'
alias l='ls -al'
alias cp='cp -p'
alias scp='scp -p'
alias md='sudo mkdir -p -m 0777'
alias sshfs='sudo sshfs -o allow_other'
alias grepit='egrep -v "^\s*(#|$)"'
alias burn='sudo cdrecord -v driveropts=burnfree dev=/dev/sr0 -dao -eject -data'
## I have problem with my usb-mouse :-( (acer aspire one)
alias mouse-reset='sudo rmmod uhci_hcd && sudo modprobe uhci_hcd'
ooops - forgot you asked for root's .bashrc - if you remove the sudo's (and change the PS1), its the same
You can use bash functions pretty much like alias; the one advantage is that a function takes parameters but alias doesn't.
For example, I use the following commands to manage the ssh keys for my users in a libvirt based multi-server lab. All those commands tab-complete in bash (including the ones starting with "_").
Code:
~$ cat etc/env.d/libvirt
# -*- mode: sh -*-
function _lab () {
ssh lab${1}adm@${2}
}
function _lab1 () {
_lab ${1} 10.0.0.10
}
function _lab2 () {
_lab ${1} 10.0.10.10
}
function _lab3 () {
_lab ${1} 10.0.1.10
}
function _lab4 () {
_lab ${1} 10.0.11.10
}
function lab1 () {
_lab1 app
}
function lab2 () {
_lab2 app
}
function lab3 () {
_lab3 app
}
function lab4 () {
_lab4 app
}
function syslab1 () {
_lab1 sys
}
function syslab2 () {
_lab2 sys
}
function syslab3 () {
_lab3 sys
}
function syslab4 () {
_lab4 sys
}
function dblab1 () {
_lab1 db
}
function dblab2 () {
_lab2 db
}
function dblab3 () {
_lab3 db
}
function dblab4 () {
_lab4 db
}
function appb2labs () {
scp ${1} labappadm@10.0.0.10:/var/app/extract
scp ${1} labappadm@10.0.10.10:/var/app/extract
}
function load2lab1 () {
scp ${1} labappadm@10.0.0.10:/var/app/loads
}
function load2lab2 () {
scp ${1} labappadm@10.0.10.10:/var/app/loads
}
function load2lab () {
load2lab1 ${1}
load2lab2 ${1}
}
function _rekey () {
for i in "labappadm" "labsysadm" "labdbadm"; do
for j in $*; do
ssh-copy-id ${i}@${j}
done
done
}
function rekey2 () {
_rekey 10.0.10.10 10.0.11.10
}
function rekey1 () {
_rekey 10.0.0.10 10.0.1.10
}
function _unkey () {
for j in $*; do
ssh-keygen -R ${j}
done
}
function unkey1 () {
_unkey 10.0.0.10 10.0.1.10
}
function unkey2 () {
_unkey 10.0.10.10 10.0.11.10
}
sample .bash_profile;
~$ cat .bash_profile
#-----------------cut-----------------
# .bash_profile
#08-30-06 12:21
# Source .bashrc
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
#-----------------cut end--------------
Code:
cat .bashrc
#-----------------cut-------------------
#.bashrc
#08-30-06 12:20
# Add bin to path
export PATH="$PATH:$HOME/bin"
# Dynamic resizing
shopt -s checkwinsize
#
#save bash history so as to share
shopt -s histappend
PROMPT_COMMAND='history -a'
# Custom prompt
#PS1='\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
#08-29-06 11:40 gws
if [ `id -un` = root ]; then
PS1='\[\033[1;31m\]\h:\w\$\[\033[0m\] '
else
PS1='\[\033[1;32m\]\h:\w\$\[\033[0m\] '
fi
#
# Add color
eval `dircolors -b`
#Terminus is a very nice Unicode font for the Linux console
#02-02-12 gws
#from dugan's site http://duganchen.ca/writings/slackware/fonts/
#04-30-12 11:41 removed
#
#if [ $TERM = "linux" ]; then
# setfont ter-v16n
#fi
# User defined aliases
alias cls='clear'
alias clls='clear; ls'
alias ll='ls -l'
alias lsa='ls -A'
alias lsg='ls | grep'
alias lsp='ls -1 /var/log/packages/ > package-list'
alias na='nano'
alias web='links -g -download-dir ~/ www.google.com'
#08-29-06 11:50
#To clean up and cover your tracks once you log off
#Depending on your version of BASH, you might have to use
# the other form of this command
trap "rm -f ~$LOGNAME/.bash_history" 0
#The older KSH-style form
#trap 0 rm -f ~$LOGNAME/.bash_history
#-----------------cut end--------------
I let them modify to suit their needs.
Hope this helps!
Have fun & enjoy!
# .bashrc
...
alias p='pwd'
alias p='pkgtool'
...
Who has much better Please!
Hmmm - I guess your 'pwd' is kinda being 'overwritten' ...
Also his pkgtool since there's another alias for p further down for ps aux.
Quote:
Originally Posted by perbh
alias h='history | less' alias p='pwd'
alias n='netstat -tulpn'
alias d='df -h'
alias w='which $1'
alias wh='whereis $1' alias p='pkgtool'
alias f1='file $1'
alias l='ls -l'
alias lp='leafpad .bashrc'
alias a='alias'
alias bl='blkid'
alias f="find $1 -iname S2"
alias p1='ps -ef | grep -v grep | grep daemon'
alias w="wget $1" alias p='ps aux'
Anyway, all I really do is remove the root checks for setting the $PATH variable to include all the root locations too (so all users get the same $PATH root would). I compromise my security by setting up sudo with no passwords and all commands for my user (I did this long before Ubuntu came to be so it had nothing to do with their weird implementation of sudo, and I've taken into account the security implications and decided I'd rather go for simplicity than security), and I don't like typing full paths. Plus, you can't ssh in to my network from the internet and I'm the only person who uses a linux CLI on the network, so I'm not too worried about someone getting in and screwing things up.
As already noted by others, in my root .bashrc I always color the prompt red - red prompt=root on any machine.
This thread is specifically about the root .bashrc, and we all know that nobody would allow root login via SSH...
But in my non-root .bashrc's (/etc/skel/.bashrc) I detect remote logins and color the prompt so that if I see a colored prompt I always know I am remote.
Code:
#Make prompt colored when logged in remote
export NON_LOCAL_LOGIN=`env | grep SSH`
if [ "$NON_LOCAL_LOGIN" != "" ]; then
PS1="\033[33m[\u@\h:\w]#\033[0m "
fi;
I spend most of my days in Tmux'd sessions, often with more than 20 windows open, many of those in remote sessions, so this has been a very important "feature" for me.
I have used different colors for different machines at times for better recognition, but colored prompt=remote in any context.
Hm. I set different background for root, there is nothing special in .bashrc. Actually I think root's shell should not contain any fancy coloring, aliases or prompt just direct and fast access to the bare system.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.