Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Slackware This Forum is for the discussion of Slackware Linux.


  Search this Thread
Old 05-02-2014, 11:38 PM   #1
Registered: Aug 2004
Distribution: opensuse ,debian
Posts: 208

Rep: Reputation: 30
Slackware shell config help

This is a simple problem but I just can't get my head around with .
Too stupid

Problem is I want to have my interactive shell(kde konsole) to have same 'more-colorful' like in login shell so I put /etc/profile in my .bashrc.
And I want login shell has same config as interactive shell.

Here's my ~/.bashrc
. /etc/profile #the dilemma line
alias grep='grep --color'
export GREP_COLOR=';32'
export APP_MODE='development'

PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"
my ~/.bash_profile
if [ -f ./.bashrc ]; then
    source ./.bashrc
The problem with this is the fortune is run twice when I login through shell(I dont use gui login), because /etc/profile is invoked twice by login shell. And I don't want this,seems dirty and odd.

I put a diagram for you...
 ^         ^ 
 |          \
 |           \
.bash_profile \
 ^             /etc/profile 

interactive shell
Can you guys give me advice for this?

Last edited by hottdogg; 05-02-2014 at 11:40 PM.
Old 05-02-2014, 11:59 PM   #2
Senior Member
Registered: Oct 2005
Distribution: Slackware 14.1
Posts: 3,482

Rep: Reputation: 544Reputation: 544Reputation: 544Reputation: 544Reputation: 544Reputation: 544
When I had my web site running I had a nice how-to about harmonizing the bash scripts. If anybody is interested in moving that how-to the site, contact me and I'll forward the text.

In the mean time, try this:

# ~/.bash_profile
# Local/Personal aliases and functions go here
if [ -f $HOME/.bashrc ]; then
  source $HOME/.bashrc

# Local/Personal startup programs go here
# ~/.bashrc
# System-wide aliases and functions go here
if [ -f /etc/bashrc ]; then
  source /etc/bashrc

# Local/Personal environment variables go here
# Define bash prompts, non-X text editors, etc.

# --- Local aliases ---

# --- Local functions ---
Old 05-03-2014, 01:02 AM   #3
Registered: Apr 2009
Location: Oz
Distribution: slackware64-14.0
Posts: 866

Rep: Reputation: 264Reputation: 264Reputation: 264
You want Konsole to give you a shell like the one when you log in at boot?

Just change the setting in konsole

Settings -> Edit Current Profile
Change "Command:" from "/bin/bash" to "/bin/bash -ls"
Click Apply

The "-ls" on the end of the command tells bash you want to invoke it as if you were logging in and will execute the same scripts giving you the exact same environment.
1 members found this post helpful.
Old 05-03-2014, 02:31 AM   #4
Didier Spaier
LQ Addict
Registered: Nov 2008
Location: Paris, France
Distribution: Slint64-14.2 on Lenovo Thinkpad W520
Posts: 7,626

Rep: Reputation: 2564Reputation: 2564Reputation: 2564Reputation: 2564Reputation: 2564Reputation: 2564Reputation: 2564Reputation: 2564Reputation: 2564Reputation: 2564Reputation: 2564
Instead of sourcing /etc/profile, just cherry pick what you need in it and copy/paste that in ~/.bashrc. In addition, possibly run only (parts of) the scripts in /etc/profile.d that you need.
Old 05-03-2014, 07:51 AM   #5
Registered: Nov 2010
Posts: 227

Rep: Reputation: 61
And Didier is right again.

It's the second time someone has the crazy idea of sourcing /etc/profile form

By the way. If you don't want the fortune message do this:

# chmod -x /etc/profile.d/

Jaime Sommers
Old 05-03-2014, 08:07 AM   #6
Senior Member
Registered: Oct 2003
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,541

Rep: Reputation: 1060Reputation: 1060Reputation: 1060Reputation: 1060Reputation: 1060Reputation: 1060Reputation: 1060Reputation: 1060
It's a Real Good Idea to leave /etc/profile alone; i.e., don't ever edit it (it's system-wide).

For customization, system-wide, you can add files to /etc/profile.d. For personal customization, you can add a ~/.profile file in your home directory and you can add ~/.bashrc file as well.

Now, why would you want to do things like that?

Well, the sequence when you log in is execute (in this order)
  • /etc/profile
  • /etc/profile.d/<files relevant to the shell program you're using and other executable files there>
  • /home/your_id/.profile
  • /home/your_id/.bashrc
At the bottom of /etc/profile, you'll find this:
# Append any additional sh scripts found in /etc/profile.d/:
for profile_script in /etc/profile.d/*.sh ; do
  if [ -x $profile_script ]; then
    . $profile_script
unset profile_script
That's what executes the stuff in /etc/profile.d. Some of those files are shell-specific (BASH, KornShell, C-Shell, etc.), some are system-wide (setting Java environment and the like).

All that happens once at log in and it happens when you open a terminal window as a "log in shell" which is what you typically want -- you get all the environment settings, aliases you like and all that sort of thing.

Hope this helps some.
Old 05-03-2014, 08:22 AM   #7
Registered: Jan 2005
Location: Midwest USA, Central Illinois
Distribution: SlackwareŽ
Posts: 12,826
Blog Entries: 27

Rep: Reputation: 2123Reputation: 2123Reputation: 2123Reputation: 2123Reputation: 2123Reputation: 2123Reputation: 2123Reputation: 2123Reputation: 2123Reputation: 2123Reputation: 2123
Member Response


I like to provide my users with this;

sample .bash_profile;   
~$ cat .bash_profile 
# .bash_profile
#08-30-06 12:21

# Source .bashrc
if [ -f ~/.bashrc ]; then
. ~/.bashrc

#-----------------cut end--------------

 cat .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\] ' 
PS1='\[\033[1;32m\]\h:\w\$\[\033[0m\] ' 
# Add color 
eval `dircolors -b` 
#Terminus is a very nice Unicode font for the Linux console
#02-02-12 gws
#from dugan's site

#04-30-12 11:41 removed
#if [ $TERM = "linux" ]; then
# setfont ter-v16n

# 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 ~/'

#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!
1 members found this post helpful.
Old 05-04-2014, 08:01 AM   #8
Registered: Nov 2010
Posts: 227

Rep: Reputation: 61
Just for fun

Just for fun and off topic. This is my bash prompt.

function bg_jobs
	jobs | wc -l | grep -v 0 | sed "s/.*/[&]/"

case "$TERM" in
	# Window Title
	# Icon Title
PS1+='\$ '
With this fashion you can intercalate stuff and colors in a clean way.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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] Use shell script to modify kernel config dbrazeau Linux - Kernel 2 08-16-2013 01:10 PM
Sendmail Config--Two mail accounts from one shell user. signalman Linux - Server 10 06-23-2012 10:55 PM
Possible to save grub config directly from shell? jarodm Linux - Newbie 1 07-13-2009 02:15 PM
Shell Script Config Not Working? arew264 Programming 2 01-02-2008 09:42 PM
newbie: how to config shell to display i18l font? sirpelidor Linux - Newbie 1 06-01-2007 08:40 AM > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 12:46 PM.

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