Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
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.
bash's source command doesn't work with .bashrc -- solved
"source .bashrc" didn't have any effect after I made some changes to .bashrc, then I tried to make some experiments to figure out what is wrong, and got the following interesting but weird results:
1. I add "echo hello" to the beginning of .bashrc and source it, no "hello" being printed.
2. I renamed ".bashrc" to "test_source" (just an arbitrary name) and ran "source test_source", surprisingly, it worked, I got the desired result and "hello" was printed on the screen.
3. I ran "bash" in current shell, and got the same result as 2.
So it seems that "source" just don't like the name ".bashrc" , Any ideas? (I'm using Ubuntu 8.10)
Thanks!
Last edited by crs_zxf; 03-06-2009 at 07:30 PM.
Reason: solved
"source .bashrc" didn't have any effect after I made some changes to .bashrc, then I tried to make some experiments to figure out what is wrong, and got the following interesting but weird results:
1. I add "echo hello" to the beginning of .bashrc and source it, no "hello" being printed.
2. I renamed ".bashrc" to "test_source" (just an arbitrary name) and ran "source test_source", surprisingly, it worked, I got the desired result and "hello" was printed on the screen.
3. I ran "bash" in current shell, and got the same result as 2.
So it seems that "source" just don't like the name ".bashrc" , Any ideas? (I'm using Ubuntu 8.10)
Unfortunately, the problem stated in that thread is different from mine, in my case, even the first line in .bashrc which is just an "echo" command isn't executed when source, and I don't have anything related to bash_completion in my .bashrc.
Unfortunately, the problem stated in that thread is different from mine, in my case, even the first line in .bashrc which is just an "echo" command isn't executed when source, and I don't have anything related to bash_completion in my .bashrc.
Anyway, thanks for your reply.
You're welcome. It's very strange. I just added
Code:
echo "hello"
as the first line of my .bashrc went to my terminal (already opened) and entered
Code:
source .bashrc
and got this:
Code:
jdkaye@Attila:~$ source .bashrc
hello
What terminal program are you running. I'm using konsole (KDE).
Cheers,
jdk
# There are 3 different types of shells in bash: the login shell, normal shell
# and interactive shell. Login shells read ~/.profile and interactive shells
# read ~/.bashrc; in our setup, /etc/profile sources ~/.bashrc - thus all
# settings made here will also take effect in a login shell.
#
# NOTE: It is recommended to make language settings in ~/.profile rather than
# here, since multilingual X sessions would not work properly if LANG is over-
# ridden in every subshell.
# Some applications read the EDITOR variable to determine your favourite text
# editor. So uncomment the line below and enter the editor of your choice :-)
export EDITOR=/usr/bin/vim
# export EDITOR=/usr/bin/mcedit
# For some news readers it makes sense to specify the NEWSSERVER variable here
# export NEWSSERVER=your.news.server
# If you want to use a Palm device with Linux, uncomment the two lines below.
# For some (older) Palm Pilots, you might need to set a lower baud rate
# e.g. 57600 or 38400; lowest is 9600 (very slow!)
#
# export PILOTPORT=/dev/pilot
# export PILOTRATE=115200
setterm -blength 0
if [ "`echo $PATH | grep software`" = "" ]; then
export PATH=/usr/bin:/root:/usr/sbin:/sbin:$PATH
export MANPATH=$MANPATH:/usr/X11R6/share/man/
export PATH=$PATH:/home/chenrs/chenrs-mini-tools/bin:/home/chenrs/software
fi
# for app intallation
alias config-make-install='./configure && make && sudo make install'
# for mplayer
alias mp='mplayer -subcp cp936 -subfont-osd-scale 3 -subfont-text-scale 3'
alias gmp='gmplayer'
alias mplist='mplayer -playlist'
alias mps='mplayer -shuffle'
# for xset
alias xset-before='xset dpms 3600 3600 3600'
alias xset-after='xset dpms 0 0 180'
alias xset-off='xset dpms force off'
# for network
alias lprhp='lpr -P hp -o sides=two-sided-long-edge'
alias ssh-132xt='ssh xiaotong@10.10.10.132'
alias ssh-23crs='ssh chenrs@10.10.10.23'
alias ssh-48xt='ssh xiaotong@202.118.18.181'
alias ssh-10crs='ssh chenrs@ics.neu.edu.cn'
alias lftp-132xt='lftp -u xiaotong,. 10.10.10.132'
alias lftp-23crs='lftp -u chenrs,. 10.10.10.23'
alias lftp-48xt='lftp -u xiaotong,. 202.118.18.181'
alias lftp-10crs='lftp -u chenrs,123456 ics.neu.edu.cn'
# for mount
alias mount-fat='sudo mount -o iocharset=utf8'
alias mount='sudo mount -o uid=1000,gid=100'
alias umount='sudo umount'
alias umount-sdb='sudo umount /mnt/mobile*'
alias umount-dvd='sudo umount /mnt/dvd'
alias umount-win='sudo umount /mnt/win'
# for urxvt encoding
alias gb-encoding='export LC_CTYPE="zh_CN.gb2312"; printf "\33]701;$LC_CTYPE\007"'
alias utf8-encoding='export LC_CTYPE="zh_CN.utf8"; printf "\33]701;$LC_CTYPE\007"'
# for apt
alias apt-search='apt-cache search'
alias apt-install='sudo apt-get install'
# misc
alias l='ls -alF'
alias xrar='unrar x'
alias s2ram='sudo s2ram -f'
alias ls='ls --color=always'
alias ..='cd ..'
alias export-cwd='export PATH=$PATH:$(pwd)'
# the following "bind" command is for bash vi-editing mode
bind -m vi-insert "\C-l":clear-screen
bind -m vi-insert "\C-e":vi-append-eol
bind -m vi-insert "\C-a":vi-insert-beg
bind -m vi-insert "\C-p":history-search-backward
bind -m vi-insert "\C-n":history-search-forward
export PS1="~~~~~~ \w ~~~~~~\n$ "
Very odd. I just copy/pasted your output, made it my .bashrc and sourced it, and it worked fine. Then added 'echo "hello"' to the top and sourced again, and got the echo. Know that doesn't help you much!
Do you get the same problem on a non-graphical login (Ctrl+alt+F1)? Not sure whether or not that's the same program as gnome-terminal, but I guess not.
Do you get the same problem on a non-graphical login (Ctrl+alt+F1)? Not sure whether or not that's the same program as gnome-terminal, but I guess not.
What you said makes me find another stranger problem, when I login the virtual terminal, I found .bashrc not being executed at all, then I run ". .bashrc", it took effect, after that, I tried to run it again, nothing happened except the PS1 being set to the system default (this happened in graphical enviroment too), so it seems that in my case .bashrc can only be executed once. Why? I'm totally confused.
Which version of bash are you running and what distribution do you have?
I would suggest you update to the latest version of bash if you are not up to date.
Does the install of your operating system work OK other than this bizarre problem, and if it doesn't perhaps the install of the OS did not complete correctly, in which case I would reinstall and check all media before continuing.
Which version of bash are you running and what distribution do you have?
I would suggest you update to the latest version of bash if you are not up to date.
Does the install of your operating system work OK other than this bizarre problem, and if it doesn't perhaps the install of the OS did not complete correctly, in which case I would reinstall and check all media before continuing.
I use bash 3.2.39(1)-release in Ubuntu 8.10, and this system will automatically update itself on a regular basis.
In fact, recently I installed this system on my girlfriend's laptop, and got the same problem. I think this may be a bug of bash.
Though this problem may not be solved, thanks for your time.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.