LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 09-01-2014, 12:24 PM   #1
Gary Baker
Member
 
Registered: Mar 2007
Location: Whitsett,NC
Distribution: Slackware 14.1 and MINT 17.1
Posts: 105

Rep: Reputation: 3
Wink Please post your edited root .bashrc file


# .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'


Who has much better Please!
 
Old 09-01-2014, 12:42 PM   #2
Richard Cranium
Senior Member
 
Registered: Apr 2009
Location: McKinney, Texas
Distribution: Slackware64 15.0
Posts: 3,858

Rep: Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225
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
Works For Me But Maybe Not For Anyone Else (TM).
 
1 members found this post helpful.
Old 09-01-2014, 12:49 PM   #3
perbh
Member
 
Registered: May 2008
Location: Republic of Texas
Posts: 393

Rep: Reputation: 81
Quote:
Originally Posted by Gary Baker View Post
# .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

Last edited by perbh; 09-01-2014 at 12:54 PM.
 
1 members found this post helpful.
Old 09-01-2014, 12:58 PM   #4
Richard Cranium
Senior Member
 
Registered: Apr 2009
Location: McKinney, Texas
Distribution: Slackware64 15.0
Posts: 3,858

Rep: Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225
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
}
 
3 members found this post helpful.
Old 09-01-2014, 03:12 PM   #5
GazL
LQ Veteran
 
Registered: May 2008
Posts: 6,897

Rep: Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019
~/.bash_profile:
Code:
case $- in
*i* )  # Interactive shell
       if [ -f ~/.bashrc ]; then
          source ~/.bashrc
       fi
       ;;
esac
~/.bashrc:
Code:
[ -f /etc/bashrc ] && source /etc/bashrc

########################################################################
/etc/bashrc:
Code:
# /etc/bashrc
#
# bashrc common to all users - must be sourced from users $HOME/.bashrc

########################################################################
# bash PS1 prompt:

bold_on="$(tput bold)" || bold_on=""
attr_off="$(tput sgr0)" || attr_off=""
PS1="\[${bold_on}\]\u@\h:\w\\$ \[${attr_off}\]"
unset bold_on attr_off 

########################################################################
# Keep track of terminal size (helpful for tiling window-managers):

shopt -s checkwinsize

########################################################################
# Set up colour 'ls'

# Set LS_COLORS:
for file in "$HOME/.dir_colors" "/etc/DIR_COLORS" ""
do
  [ -r "$file" ] && break
done
eval $( dircolors -b "$file" ) 
unset file 

alias ls="/bin/ls --color=auto --group-directories-first"

########################################################################
# Convenience aliases and functions:

alias df='df -a -x none -x fusectl -x fuse.gvfsd-fuse -x proc -x sysfs'

alias nicesh='chrt -i 0 ionice -c 3 bash'

function qf()  # Quick find
{
    find "$HOME" /srv/local -xdev -readable -path "*${1}*" 2>/dev/null
}

########################################################################
I've also completely reworked /etc/profile and a few other shell related files,
but that's another story.
 
2 members found this post helpful.
Old 09-01-2014, 03:42 PM   #6
brianL
LQ 5k Club
 
Registered: Jan 2006
Location: Oldham, Lancs, England
Distribution: Slackware64 15; SlackwareARM-current (aarch64); Debian 12
Posts: 8,298
Blog Entries: 61

Rep: Reputation: Disabled
I haven't bothered creating an /etc/bashrc, but here's my ~/.bashrc:
Code:
[ -z "$PS1" ] && return
export HISTFILE="$HOME/.bash_history"    
export HISTSIZE=${HISTSIZE:-"1000"}      
export HISTFILESIZE=${HISTSIZE:-"2000"}  
export HISTCONTROL=ignoredups
shopt -s checkwinsize
shopt -s histappend
set -o noclobber
[ -x /usr/bin/lesspipe ] && eval "$(lesspipe)"
man() {
    env LESS_TERMCAP_mb=$'\E[01;31m' \
    LESS_TERMCAP_md=$'\E[01;38;5;74m' \
    LESS_TERMCAP_me=$'\E[0m' \
    LESS_TERMCAP_se=$'\E[0m' \
    LESS_TERMCAP_so=$'\E[38;5;246m' \
    LESS_TERMCAP_ue=$'\E[0m' \
    LESS_TERMCAP_us=$'\E[04;38;5;146m' \
    man "$@"
}
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
alias du='du -h'
alias df='df -h'
alias ls='ls -a --color'
And my ~/.bash_profile:
Code:
if [ -f ~/.bashrc ]; then
   source ~/.bashrc
fi
 
1 members found this post helpful.
Old 09-01-2014, 08:36 PM   #7
onebuck
Moderator
 
Registered: Jan 2005
Location: Central Florida 20 minutes from Disney World
Distribution: SlackwareŽ
Posts: 13,925
Blog Entries: 44

Rep: Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159
Thumbs up Member Response

Hi,

Quote:
I like to provide my users with this;
Code:
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!

 
1 members found this post helpful.
Old 09-01-2014, 09:21 PM   #8
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Ubuntu MATE, Mageia, and whatever VMs I happen to be playing with
Posts: 19,323
Blog Entries: 28

Rep: Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142
Mine is very simple. I edited the prompt to remind me that I am su-ed to root.

Code:
PS1="\[\033[1;31m\]\u\[\033[0m\]:\w/ $ "
 
1 members found this post helpful.
Old 09-02-2014, 10:39 AM   #9
schmatzler
Member
 
Registered: Jan 2011
Location: Germany
Distribution: Slackware64 -current + Multilib
Posts: 411

Rep: Reputation: 181Reputation: 181
Code:
export PS1="\[\e[00;33m\]\u\[\e[0m\]\[\e[00;37m\]@\[\e[0m\]\[\e[00;36m\][\w]:\[\e[0m\]\[\e[00;37m\] \[\e[0m\]"
Looks like this:

schmatzler@[~/Desktop]:
 
1 members found this post helpful.
Old 09-02-2014, 11:55 AM   #10
onebuck
Moderator
 
Registered: Jan 2005
Location: Central Florida 20 minutes from Disney World
Distribution: SlackwareŽ
Posts: 13,925
Blog Entries: 44

Rep: Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159
Member Response

Hi,

I like to keep my root & user by;
Code:
# 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\] '  # as buck1:~# 
else PS1='\[\033[1;32m\]\h:\w\$\[\033[0m\] '                                 # as buck1:~$ 
fi  # 
I 'KISS' therefore easier to note root & normal user unique via color signification of # & $.
 
2 members found this post helpful.
Old 09-02-2014, 02:52 PM   #11
bassmadrigal
LQ Guru
 
Registered: Nov 2003
Location: West Jordan, UT, USA
Distribution: Slackware
Posts: 8,792

Rep: Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656
Quote:
Originally Posted by perbh View Post
Quote:
Originally Posted by Gary Baker View Post
# .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 View Post
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.
 
1 members found this post helpful.
Old 09-02-2014, 03:16 PM   #12
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=15, FreeBSD_12{.0|.1}
Posts: 6,263
Blog Entries: 24

Rep: Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194
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.

Last edited by astrogeek; 09-02-2014 at 03:19 PM.
 
2 members found this post helpful.
Old 09-02-2014, 08:52 PM   #13
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Ubuntu MATE, Mageia, and whatever VMs I happen to be playing with
Posts: 19,323
Blog Entries: 28

Rep: Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142
schmatzler, looks like this on my system:

Code:
root:/home/[username]/ $
It serves its purpose.
 
Old 09-03-2014, 05:16 AM   #14
phi11ip
Member
 
Registered: Jul 2007
Location: Nottingham, UK
Distribution: Slackware64-current
Posts: 93

Rep: Reputation: 23
Quote:
Originally Posted by frankbell View Post
schmatzler, looks like this on my system:

Code:
root:/home/[username]/ $
It serves its purpose.
But for me it's very confusing as a root prompt should end with a '#' not a '$'. I reckon your PS1 variable should be:
Code:
PS1="\[\033[1;31m\]\u\[\033[0m\]:\w/ \\$ "
 
Old 09-03-2014, 05:40 AM   #15
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,842

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
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.
 
  


Reply

Tags
bash scripting



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Edited bashrc not sure how to fix wangcow Linux - Newbie 3 12-22-2012 04:28 PM
[SOLVED] How to use my /home/kangjoo/.bashrc rather than root/.bashrc kangjoo.lee Linux - Newbie 2 11-05-2012 03:38 PM
[SOLVED] Edited .bashrc now cannot login as root Ajit Gunge Linux - Newbie 2 06-18-2012 07:13 AM
edited the wheel group file and i cant log in as root again in the terminal cheezy86 Linux - Newbie 6 05-16-2009 07:37 PM
Problem with root file .bashrc doraimom Debian 2 11-23-2008 08:43 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 05:06 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration