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.
you can use grep for, say, "PS1=" to check if the PS1 variable is changed. and you must have permission to any file you read... so run the command as root or something.
Expanding on the above, the only place a .bashrc file should exist is in the /home dirs. Its a user specific/customisable file, along with .bash_profile.
To show perms use
ls -l
Im having quite of a bit of trouble with this one.
so far i have done:
find / -name .bashrc
to display all the .bashrc files on the system
-How can i tell which one ( if not all ) of these files modify the PS1 varaible?
I'll respond with a quote from `man bash` (see that man page -search for "INVOCATION"- for more info).
Quote:
When bash is invoked as an interactive login shell, or as a non-interactive
shell with the --login option, it first reads and executes commands from the
file /etc/profile, if that file exists. After reading that file, it looks
for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads
and executes commands from the first one that exists and is readable. The
--noprofile option may be used when the shell is started to inhibit this
behavior.
When a login shell exits, bash reads and executes commands from the file
~/.bash_logout, if it exists.
When an interactive shell that is not a login shell is started, bash reads
and executes commands from ~/.bashrc, if that file exists. This may be
inhibited by using the --norc option. The --rcfile file option will force
bash to read and execute commands from file instead of ~/.bashrc.
Quote:
Im guessing that the output is displaying the full path name. Although most paths have permission denied.
Yep.
Quote:
-What command can i use to display the file protection?
If you mean, to see the permissions of the file, use ls -l which will display all the info. The permissions are the first thing on each row.
Quote:
-When i redirect the output to an emacs file i only the /home entries
Dunno what do you mean by "emacs file". Maybe it's a plain text file that you open in emacs(?), but in any case, all the output except maybe the errors should be redirected into the file. To output everything you can add ">myfile 2>&1" instead of just ">myfile".
However, why do you want to do so? Did you read the fragment of the man page I gave you? You will find .bashrc only on the home directory of your users, and nowhere else. And only the one for the current active user is relevant for you. I don't know what do you expect to find.
Hehehe, well, right. Then it's time to learn, no one is born knowing everything.
Everything you need to know is in that bit of info I pasted from the bash man page. However, since I have some spare time right now I will explain it a bit better for you.
You can consider /etc/profile like kind of a global bash configuration file. You shouldn't ever need to change it, unless you know what you are doing (and in that case, you wouldn't be asking here).
So, that leaves one less option. For the rest...
If you login on text mode, in a pure text console outside X, then bash will be in login mode (easy to understand). In login mode, bash reads one and only one amongst these files: ~/.bash_profile, ~/.bash_login, and ~/.profile. Bash looks for them in that same order, and only the first one found is used, even if it's an empty file (as long as you have read permissions over them).
If you didn't log in text mode, then you will be accessing bash using an xterm or a similar terminal emulator (konsole, gnome-terminal, urxvt or whatever). Then bash is in non-login mode. In this case, the relevant file is ~/.bashrc.
So, there you are: that's the info you need. If you want to change the value of PS1, just put it in the right file, and it will work. If these files do not exist, just create them using a regular text editor and make sure you name them correctly, starting with a dot.
Since you're using the find command, consider using the -exec grep -H PS1 {} option to implement Chris' suggestion. (You will, of course, need to prepend the find with a sudo or su -c, or just run in a root shell.)
I'm not sure as to your reasoning but if you would read the 'man bash' then things may clear up.
Code:
excerpt 'man bash';
When bash is invoked as an interactive login shell, or as a non-inter-
active shell with the --login option, it first reads and executes com-
mands from the file /etc/profile, if that file exists. After reading
that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile,
in that order, and reads and executes commands from the first one that
exists and is readable. The --noprofile option may be used when the
shell is started to inhibit this behavior.
When a login shell exits, bash reads and executes commands from the
file ~/.bash_logout, if it exists.
When an interactive shell that is not a login shell is started, bash
reads and executes commands from ~/.bashrc, if that file exists. This
may be inhibited by using the --norc option. The --rcfile file option
will force bash to read and execute commands from file instead of
~/.bashrc.
Below is an example of a '.bashrc' that I use on my systems. Very useful for the user. I really don't see the need to modify the 'PS1=' within '.bashrc' system wide. What is your reasoning?
Code:
#.bashrc
#08-30-06 12:17 gws copied loki:/home/gws
# Add bin to path
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 na='nano'
alias web='links -g -download-dir ~/ www.google.com'
#08-29-06 11:45 gws
#To clean this 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
Notice the '.bash_profile';
Code:
# .bash_profile
#08-30-06 12:18 copied loki:/home/gws
# Source .bashrc
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.