LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 11-24-2007, 04:21 PM   #1
ngWho
LQ Newbie
 
Registered: Nov 2007
Posts: 8

Rep: Reputation: 0
I'm trying to find the Slackware equivalent to bashrc


I'm in my /etc directory trying to find what file would be the equivalent of bashrc in slackware. I want to setup some custom aliases and functions, and I understand that bashrc was meant for this?
 
Old 11-24-2007, 04:26 PM   #2
Vincent_Vega
Member
 
Registered: Nov 2003
Location: South Jersey
Distribution: Slackware, Raspbian, Manjaro
Posts: 826

Rep: Reputation: 31
In each home directory you make these settings in the .bashrc file. It's hidden, as you see by the preceding '.'
 
Old 11-24-2007, 04:36 PM   #3
Pratt
Member
 
Registered: Apr 2005
Location: Colombia
Distribution: Slackware 14.2
Posts: 82

Rep: Reputation: 18
You have to create the ".bashrc" file in your home Folder.

If you dont want to use .bashrc, i guess you could also edit "/etc/profile", but thoose changes would affect every user in the entire system.
 
Old 11-24-2007, 04:36 PM   #4
ngWho
LQ Newbie
 
Registered: Nov 2007
Posts: 8

Original Poster
Rep: Reputation: 0
I dont see it in my home directory. I'm in the home directory of my basic user account.

Edit: I see. Ok I didn't know I had to create the file. You've gotten me on the right track. I was using /etc/profile and got a bit confused when I learned about the bashrc.. Thanks guys.

Last edited by ngWho; 11-24-2007 at 04:40 PM.
 
Old 11-24-2007, 05:15 PM   #5
Dinithion
Member
 
Registered: Oct 2007
Location: Norway
Distribution: Slackware 14.1
Posts: 446

Rep: Reputation: 59
/etc/profile does only apply to login shells, and wont be used for a VT ie. xterm. Near the end of 'man bash' there is a description of all bash files.
 
Old 11-24-2007, 05:33 PM   #6
ngWho
LQ Newbie
 
Registered: Nov 2007
Posts: 8

Original Poster
Rep: Reputation: 0
I had to add this code to etc/profile but I'm not sure why... I mean, I know what it does but I dont quite get it. I vaguely understand the first part.. I'm guess it checks in the home directory for bashrc. The highlighted statement is what's throwing me off.

The code is to allow the /etc/profile to read the bashrc, but I dont know why and trying to understand it, as I'm currently learning shell scripting.


Code:
if [ -f ~/.bashrc ]; then
    . ~/.bashrc
fi

Last edited by ngWho; 11-24-2007 at 05:37 PM.
 
Old 11-24-2007, 05:42 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
Hi,

Quote:
Originally Posted by ngWho View Post
I'm in my /etc directory trying to find what file would be the equivalent of bashrc in slackware. I want to setup some custom aliases and functions, and I understand that bashrc was meant for this?
You would create your '.bashrc and .bash_profile' in the user home directory with your favorite text editor, vi of course.

My root .bash_profile;

Code:
~# cat .bash_profile
# .bash_profile
#08-30-06 12:21 gws copied loki:/root
#06-27-07 13:10 gws copied from odin for willi
#
# Source .bashrc
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi
My root .bashrc;

Code:
~# cat .bashrc

#.bashrc
#08-30-06 12:20 gws copied loki:/root
#
#06-27-07 13:06 gws added from odin for willi
#
# Add bin to path
export PATH="$PATH:/sbin:/usr/sbin:$HOME/bin"

#export PATH="$PATH:$HOME/bin"

# Dynamic resizing
shopt -s checkwinsize

# 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`

# 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 gws

#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
You can custom for each user if so desired;

Code:
#.bashrc
#08-30-06 12:20 gws copied loki:/root
#
#06-27-07 13:06 gws added from odin for willi
#
#06-27-07 13:14 gws added from oden:root to /home/gws/.bashrc

# Add bin to path

export PATH="$PATH:/sbin:/usr/sbin:$HOME/bin"

#export PATH="$PATH:$HOME/bin"

# Dynamic resizing
shopt -s checkwinsize

# 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`

# 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 gws

#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
 
Old 11-24-2007, 07:13 PM   #8
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,126

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
Quote:
Originally Posted by ngWho View Post
The code is to allow the /etc/profile to read the bashrc, but I dont know why and trying to understand it, as I'm currently learning shell scripting.
Basic bash - as suggested, try "man bash".
It's checking if the bashrc exists, then executing it. That leading "." is very significant. Also known as "source" - check that manpage. BTW, you can search in man with "/" (e.g. /source) - "n" will get the next occurence; should all be in the manpage ...

Last edited by syg00; 11-24-2007 at 07:14 PM.
 
Old 11-24-2007, 07:57 PM   #9
duryodhan
Senior Member
 
Registered: Oct 2006
Distribution: Slackware 12 Kernel 2.6.24 - probably upgraded by now
Posts: 1,054

Rep: Reputation: 46
Or you can read man pages in konqueror ... which is way more clearer ...

man:bash in address bar of konqueror .. then ctrl+f or whatever ..
 
Old 11-24-2007, 08:09 PM   #10
Woodsman
Senior Member
 
Registered: Oct 2005
Distribution: Slackware 14.1
Posts: 3,482

Rep: Reputation: 546Reputation: 546Reputation: 546Reputation: 546Reputation: 546Reputation: 546
Quote:
I'm in my /etc directory trying to find what file would be the equivalent of bashrc in slackware. I want to setup some custom aliases and functions, and I understand that bashrc was meant for this?
Perhaps the following will help:

Harmonizing the Bash Startup Scripts
 
Old 11-24-2007, 08:28 PM   #11
ngWho
LQ Newbie
 
Registered: Nov 2007
Posts: 8

Original Poster
Rep: Reputation: 0
Thanks alot guys. Will look into those, this was a big help.
 
Old 11-25-2007, 03:45 PM   #12
Alien_Hominid
Senior Member
 
Registered: Oct 2005
Location: Lithuania
Distribution: Hybrid
Posts: 2,247

Rep: Reputation: 53
Login shell doesn't use ~/.bashrc (only virtual terminal like xterm or konsole do). You need that code only if you wish that your login shell would execute commands in .bashrc.
 
Old 11-25-2007, 09:15 PM   #13
Mr_C
Member
 
Registered: Jan 2004
Location: Trinidad & Tobago
Distribution: Slackware
Posts: 317

Rep: Reputation: 30
Because I want my virtual term to have man pages colours I did this

~/.bashrc

Code:
source ~/.aliases

PS1="\[\033[0;31m\]\u\[\033[1;34m\] - \w
\[\033[0;36m\]()-\[\033[0m\] "
my ~/.bash_profile is a link to the .bashrc

the ~/.alias has

Code:
alias ls='ls --color=auto -p'
alias ll='ls -l'
alias lsa='ls -a'
alias lla='ls -la'
alias cls='clear ; ls'
alias df='df -h'
alias rm='rm -i'
alias who='who -T -H -u'
#alias ps='ps -W -a -f ux'
alias ssh2='ssh -p2200'
alias cp='cp -r'


export LESS_TERMCAP_mb=$'\E[01;31m'
export LESS_TERMCAP_md=$'\E[01;32m'
export LESS_TERMCAP_me=$'\E[0m'
export LESS_TERMCAP_se=$'\E[0m'
export LESS_TERMCAP_so=$'\E[01;44;33m'
export LESS_TERMCAP_ue=$'\E[0m'
export LESS_TERMCAP_us=$'\E[01;36m'


#Black       0;30     Dark Gray     1;30
#Blue        0;34     Light Blue    1;34
#Green       0;32     Light Green   1;32
#Cyan        0;36     Light Cyan    1;36
#Red         0;31     Light Red     1;31
#Purple      0;35     Light Purple  1;35
#Brown       0;33     Yellow        1;33
#Light Gray  0;37     White         1;37


#export PAGER="sh -c \"col -b | view -c 'set ft=man nomod nolist titlestring=MANPAGE' -\""
#alias man="TERMINFO=~/.terminfo/ LESS=C TERM=mostlike PAGER=less man"
#alias ls='ls -h --color=auto -p'
#alias du='du -h'
#alias grep='grep --color'
#alias mv='mv -i'
#alias pico='nano -w'
#alias tar2='tar --use-compress-program=bzip2'
#alias whois='whois -h whois.networksolutions.com'
#alias sftp2='sftp -oPort=2200'
 
Old 11-25-2007, 11:15 PM   #14
ngWho
LQ Newbie
 
Registered: Nov 2007
Posts: 8

Original Poster
Rep: Reputation: 0
To be honest I understand some of this stuff but a lot of it is foreign grounds. I'm a novice... and also a bit impatient, and that's something I'm working on. The impatience is part of the reason why I'm still a novice.
 
Old 11-25-2007, 11:46 PM   #15
Alien_Hominid
Senior Member
 
Registered: Oct 2005
Location: Lithuania
Distribution: Hybrid
Posts: 2,247

Rep: Reputation: 53
Read woodsman's guide then. They're are very good.
 
  


Reply



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
I can't find .bashrc in slackware ngan_yine Slackware 12 12-11-2019 09:50 AM
Does Slack have an equivalent to .bashrc? thorney Slackware 7 11-26-2005 01:08 PM
Help on Homework... Cant find .bashrc maravillasc Linux - Newbie 11 10-17-2005 09:39 PM
where could i find the file bashrc Paxmaster Linux - Software 4 07-15-2004 01:47 PM
HELP !!!can't find my .bashrc deadhead Slackware 4 11-03-2003 11:16 AM

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

All times are GMT -5. The time now is 01:53 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