View previous topic :: View next topic |
Author |
Message |
Qubax Guru
Joined: 19 Jul 2002 Posts: 451 Location: Tirol, Austria
|
Posted: Fri Aug 09, 2002 7:47 pm Post subject: alias dont work, dont read my .bashrc .bash_profile |
|
|
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 |
|
|
pjp Administrator
Joined: 16 Apr 2002 Posts: 20067
|
Posted: Fri Aug 09, 2002 8:09 pm Post subject: |
|
|
Do you use a graphical login manager (xdm/kdm/gdm)? _________________ Quis separabit? Quo animo? |
|
Back to top |
|
|
Qubax Guru
Joined: 19 Jul 2002 Posts: 451 Location: Tirol, Austria
|
Posted: Fri Aug 09, 2002 9:54 pm Post subject: |
|
|
no, just terminal and fluxbox, without any *dm |
|
Back to top |
|
|
Naan Yaar Bodhisattva
Joined: 27 Jun 2002 Posts: 1549
|
Posted: Fri Aug 09, 2002 10:09 pm Post subject: |
|
|
/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:
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 |
|
|
Qubax Guru
Joined: 19 Jul 2002 Posts: 451 Location: Tirol, Austria
|
Posted: Sat Aug 10, 2002 4:15 pm Post subject: |
|
|
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 |
|
|
Naan Yaar Bodhisattva
Joined: 27 Jun 2002 Posts: 1549
|
Posted: Sat Aug 10, 2002 7:44 pm Post subject: |
|
|
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 |
|
|
Qubax Guru
Joined: 19 Jul 2002 Posts: 451 Location: Tirol, Austria
|
Posted: Sun Aug 11, 2002 8:28 pm Post subject: |
|
|
mine contains Code: | if [ -f ~/.bashrc ]; then . ~/.bashrc |
does this the same? |
|
Back to top |
|
|
Naan Yaar Bodhisattva
Joined: 27 Jun 2002 Posts: 1549
|
Posted: Sun Aug 11, 2002 8:36 pm Post subject: |
|
|
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 |
|
|
Qubax Guru
Joined: 19 Jul 2002 Posts: 451 Location: Tirol, Austria
|
Posted: Mon Aug 12, 2002 12:03 pm Post subject: |
|
|
ok, my post was a bit "unclear"
in my user .bashrc there is the first code you wrote |
|
Back to top |
|
|
Naan Yaar Bodhisattva
Joined: 27 Jun 2002 Posts: 1549
|
Posted: Tue Aug 13, 2002 1:18 am Post subject: |
|
|
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 |
|
|
Qubax Guru
Joined: 19 Jul 2002 Posts: 451 Location: Tirol, Austria
|
Posted: Tue Aug 13, 2002 6:30 pm Post subject: |
|
|
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 |
|
|
Naan Yaar Bodhisattva
Joined: 27 Jun 2002 Posts: 1549
|
Posted: Tue Aug 13, 2002 10:36 pm Post subject: |
|
|
If you do:
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:
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 |
|
|
|