Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
alias dont work, dont read my .bashrc .bash_profile
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
Qubax
Guru
Guru


Joined: 19 Jul 2002
Posts: 451
Location: Tirol, Austria

PostPosted: Fri Aug 09, 2002 7:47 pm    Post subject: alias dont work, dont read my .bashrc .bash_profile Reply with quote

i copied my .bashrc und .bashprofile to /etc/skel before adding a user
i now that they are working cause i copied them from my root directory, but after adding a user and logging in with the new user, it seem that bash don't read in ~ the .bash* files, cause my aliases are not working

the users can use the commands, so the alias should be possible to be executed
the .bash* files are owned by the users, that should not cause a problem

so what can i do?
Back to top
View user's profile Send private message
pjp
Administrator
Administrator


Joined: 16 Apr 2002
Posts: 20067

PostPosted: Fri Aug 09, 2002 8:09 pm    Post subject: Reply with quote

Do you use a graphical login manager (xdm/kdm/gdm)?
_________________
Quis separabit? Quo animo?
Back to top
View user's profile Send private message
Qubax
Guru
Guru


Joined: 19 Jul 2002
Posts: 451
Location: Tirol, Austria

PostPosted: Fri Aug 09, 2002 9:54 pm    Post subject: Reply with quote

no, just terminal and fluxbox, without any *dm
Back to top
View user's profile Send private message
Naan Yaar
Bodhisattva
Bodhisattva


Joined: 27 Jun 2002
Posts: 1549

PostPosted: Fri Aug 09, 2002 10:09 pm    Post subject: Reply with quote

/etc/profile will not get executed for non-login shells. You can put your aliases in your .bashrc file to ensure that they get set or put it in /etc/bashrc and do:
Code:

source /etc/bashrc

in your .bashrc file. This will ensure that it will be set for both login and non-login shells.

Also, you may want to look at this regarding prompts:
http://www.tldp.org/HOWTO/Bash-Prompt-HOWTO/setps.html
Back to top
View user's profile Send private message
Qubax
Guru
Guru


Joined: 19 Jul 2002
Posts: 451
Location: Tirol, Austria

PostPosted: Sat Aug 10, 2002 4:15 pm    Post subject: Reply with quote

i already have my aliases in my ~/.bashrc -> ?
what's the difference between login and nonlogin -shells? cause i "login" at initlevel 3 without a *dm as user, so i thought bash should read these files in my home directory
Back to top
View user's profile Send private message
Naan Yaar
Bodhisattva
Bodhisattva


Joined: 27 Jun 2002
Posts: 1549

PostPosted: Sat Aug 10, 2002 7:44 pm    Post subject: Reply with quote

A login shell is basically that: one which you get when you log into the console, do "bash --login", etc. If you just do "bash" at the command prompt the new shell that is launched is a non-login shell. A non-login shell will not source /etc/profile, .bash_profile, etc., but will look at your .bashrc. In addition, you have non-interactive shells that are invoked when a script is executed by bash using the "#!/bin/bash" construct. This shell (when launched without a --login option) will execute the file specified by a variable, BASH_ENV. This is typically exported to ~/.bashrc in /etc/profile or ~/.bash_profile. In addition, when bash is launched as 'sh' (which is a symlink), it does not read the .bashrc file.

Coming back to your issue, you may want to check whether you have chown'ed the files to the user after copying them over from /root if you did this as root. In addition, check /etc/passwd to see whether your shell is set to /bin/bash instead of /bin/sh or /bin/tcsh. If you login at the console as a user, the .bash_profile file will be executed. It should contain a line like this:
Code:

[ -f ~/.bashrc ] && . ~/.bashrc
Back to top
View user's profile Send private message
Qubax
Guru
Guru


Joined: 19 Jul 2002
Posts: 451
Location: Tirol, Austria

PostPosted: Sun Aug 11, 2002 8:28 pm    Post subject: Reply with quote

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

does this the same?
Back to top
View user's profile Send private message
Naan Yaar
Bodhisattva
Bodhisattva


Joined: 27 Jun 2002
Posts: 1549

PostPosted: Sun Aug 11, 2002 8:36 pm    Post subject: Reply with quote

The line itself is not syntactically correct (assuming it is not a cut and paste error). This will work:
Code:

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

or this:
Code:

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

Qubax wrote:
mine contains
Code:
if [ -f ~/.bashrc ]; then . ~/.bashrc

does this the same?
Back to top
View user's profile Send private message
Qubax
Guru
Guru


Joined: 19 Jul 2002
Posts: 451
Location: Tirol, Austria

PostPosted: Mon Aug 12, 2002 12:03 pm    Post subject: Reply with quote

ok, my post was a bit "unclear"
in my user .bashrc there is the first code you wrote
Back to top
View user's profile Send private message
Naan Yaar
Bodhisattva
Bodhisattva


Joined: 27 Jun 2002
Posts: 1549

PostPosted: Tue Aug 13, 2002 1:18 am    Post subject: Reply with quote

It should work then. Can you verify that it does not work if you:

- go to a console (Ctrl-Alt-F<n> where n=1...6)
- login as the user
- do not do startx, etc. Instead do: 'alias' and see whether the aliases are shown.

Also, can you edit the .bashrc file when logged in as a user?
Back to top
View user's profile Send private message
Qubax
Guru
Guru


Joined: 19 Jul 2002
Posts: 451
Location: Tirol, Austria

PostPosted: Tue Aug 13, 2002 6:30 pm    Post subject: Reply with quote

got it working
the shell at creating the user was missing. i thought bash would be default and did not thought of it much more, but today i had a look at /etc/passwd and swa that the shell for my user was missing. so i added the user and everything worked. i tried it out a second time with an other user. this time the box gave me an empty .bashrc, but adding my aliases it works.

thx and sorry for this bad mistake
as punishment i'll write down :don't trust default
Back to top
View user's profile Send private message
Naan Yaar
Bodhisattva
Bodhisattva


Joined: 27 Jun 2002
Posts: 1549

PostPosted: Tue Aug 13, 2002 10:36 pm    Post subject: Reply with quote

If you do:
Code:

useradd -m ...

it will create the home directory from the skeleton files in /etc/skel. useradd should typically default to /bin/bash. You can check the current state of defaults by doing:
Code:

useradd -D

You can adjust defaults by doing things like:
Code:

useradd -D -s /bin/bash


man useradd will give you a lot of information regarding this.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum