<---- template headericclude ----->
Error in Editing .bash_profile
FedoraForum.org - Fedora Support Forums and Community
Page 1 of 2 12 LastLast
Results 1 to 15 of 24
  1. #1
    Join Date
    Jun 2012
    Location
    India
    Posts
    27
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Error in Editing .bash_profile

    I am working on Fedora 16. II have artha dictionary installed in my system. I was willing to start it automatically whenever i log in to my system. So i editted ~/.bash_profile file and just added the command artha at the end of the file. But when i rebooted the system, it asked me for the password but failed to load the GUI. Same thing happened when i added the command in /etc/profile.

    Was i wrong somewhere??

    Whats the correct way to add a command to run it at startup. And how to edit .bash_profile or /etc/profile file

  2. #2
    Join Date
    Aug 2009
    Location
    Waldorf, Maryland
    Posts
    7,343
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Error in Editing .bash_profile

    Wrong place to put it.

    .bashrc is used when logging in in a terminal - but not when using the GUI. If you start a terminal window then it will be started... each time you open a terminal window, and I doubt that is what you want.

    Modifying the /etc/profile will do the same changes everywhere - including the root login (where you likely don't want it).

    There should be an "autostart" menu somewhere in Gnome (if you are using it), If using lxde/xfce then there is an autostart menu entry that allows you to specify what to start when you log in.

    Now if you want it to start at boot time then you can't assume the GUI is available (nobody is logged in). So I really doubt that is what you want either.

  3. #3
    Join Date
    Jul 2011
    Location
    Birmingham, UK
    Age
    41
    Posts
    2,759
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Error in Editing .bash_profile

    In GNOME, run "gnome-session-properties" in a terminal or Alt+F2, and add the program you want started there.

  4. #4
    Join Date
    Jun 2012
    Location
    India
    Posts
    27
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Error in Editing .bash_profile

    In GNOME, run "gnome-session-properties" in a terminal or Alt+F2, and add the program you want started there
    this worked fine for me.

    @jpollard
    i have heard of that if you want to initialize something or some variables automatically when you login, then they must be kept in either /etc/profile (which is the first file to run while booting) or ~/.bash_profile (which is next to run for the user). That was the only reason why i put my command there. and i think /etc/profile gets run as root user and .bash_profile as current user. so why it failed to load my GUI.

    ---------- Post added at 12:43 PM ---------- Previous post was at 12:10 PM ----------

    Suddenly i got one more query. What will happen if i put some echo command in ~/.bash_profile file. where will it display the output or where will it go because file will get run only once at the time of login, and at login, after entering username password it shows GUI not the terminal.

    Please help m a bit confused

  5. #5
    Join Date
    Jul 2011
    Location
    Birmingham, UK
    Age
    41
    Posts
    2,759
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Error in Editing .bash_profile

    Quote Originally Posted by pratporetw
    i have heard of that if you want to initialize something or some variables automatically when you login, then they must be kept in either /etc/profile (which is the first file to run while booting) or ~/.bash_profile (which is next to run for the user). That was the only reason why i put my command there. and i think /etc/profile gets run as root user and .bash_profile as current user. so why it failed to load my GUI.
    No, it's (conceptually) simpler than that. (In practise the subtleties can be quite complex unfortunately.) Non are run on boot. When a user logs in, the commands in both /etc/profile and that user's ~/.bash_profile are executed as that user. /etc/profile also executes individual scripts in /etc/profile.d. However, this system is designed for text-terminal logins, and graphical logins complicate things. I think bash_profile is still loaded, but I may well be wrong. However the normal approach with graphical environments is to use the session manager to load programs.

    Suddenly i got one more query. What will happen if i put some echo command in ~/.bash_profile file. where will it display the output or where will it go because file will get run only once at the time of login, and at login, after entering username password it shows GUI not the terminal.
    Most programs run in graphical mode without a terminal window have their output redirected to ~/.xsession-errors. I'm not sure how early in the login process that redirection is set up, although it should be as soon as possible, so I'd look there for output.

  6. #6
    Join Date
    Aug 2009
    Location
    Waldorf, Maryland
    Posts
    7,343
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Error in Editing .bash_profile

    In addition to the above...

    Most things will work just fine putting echo commands in .bashrc...

    Unfortunately, some things don't.

    Some of the remote commands support an error stream, some don't. Those that don't tend to use the convention that when the first return (expecting a null byte) will error out when the character is not a null. This is caused by the bashrc echo commands being output before the remote application starts.

    Most times, for single user systems, this isn't an issue. Exactly what happens with applications like sshfs (a remote file service capabililty supported by ssh) I'm not sure.

  7. #7
    Join Date
    Jun 2012
    Location
    India
    Posts
    27
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Error in Editing .bash_profile

    I read the .xsession-errors and the only thing i understood is that it only saves the errors maybe of the boot time. I still didn't get the correct logic to know where the output will go if i put some echo commands in .bash_profile or /etc/profile.

    .bashrc is executed everytime i start my terminal. So it has no problem in printing or executing what my echo command says.
    My concern was with .bash_profile or /etc/profile.

    Meanwhile i understood one thing on my own when i tried o execute "artha"(Command for Artha Dictionary) command at my terminal that the command needs some input from standard input when it gets executed. May be thats why it failed to load my GUI coz boot process got stuck in between expecting a user-input from terminal which is not available in graphical interface from the beginning.

  8. #8
    Join Date
    Aug 2009
    Location
    Waldorf, Maryland
    Posts
    7,343
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Error in Editing .bash_profile

    .xsession-errors doesn't have ANY boot time errors. Only errors after login.

    For boot time errors you need to look in /var/log/Xorg.* files.

    It sounds more like you need to understand how terminals work, and the commands that require input there is a shell thing called "redirection" that allows you to provide data from files, store data from the program, and record errors.

    for that, I suggest a shell script to start the program, and have the script supply whatever the program needs.

  9. #9
    Join Date
    Jun 2012
    Location
    India
    Posts
    27
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Error in Editing .bash_profile

    Well i am quite familiar with redirection and shell scripts and i can do as you suggested buti dont know whats wrong with the "artha" dictionary. artha command is available in /usr/bin and can be executed but i found that it works only after you launch dictionary manually from GUI.

    I wont create any more havoc here just for loading a dictionary.

    but you are right that i need to learn basics and functionality of the terminal. I will be glad if you could suggest me a link or tutorial to learn more. i have got hands on shell programming and i am familiar with concepts. only thing i seek is guidance.
    Last edited by pratporetw; 8th July 2012 at 08:45 AM.

  10. #10
    stevea Guest

    Re: Error in Editing .bash_profile

    The explanations here leave me cold. "man bash" tells half the story ...


    INVOCATION
    A login shell is one whose first character of argument zero is a -, or one started with the --login option.

    An interactive shell is one started without non-option arguments and without the -c option whose standard input and error are
    both connected to terminals (as determined by isatty(3)), or one started with the -i option. PS1 is set and $- includes i if
    bash is interactive, allowing a shell script or a startup file to test this state.
    So there are two distinct modifiers of shells based on how they are invoked. 'login' and 'interactive'

    The man page continues (with redactions) ....
    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.
    ....
    When an interactive shell that is not a login shell is started, bash reads and executes commands from ~/.bashrc, if that file
    exists.

    As a practical matter there is one login shell created very early in the login process when gdm or whatever greeter performs the authentication and before the Xsession begins. The controlling terminal at that time is also the session terminal - typically /dev/tty1 on Fedora. That login shell exits before your desktop appears.

    During a Fedora gui login, the one and only login shell that is created for your login executes,
    /etc/profile
    ~/.bash_profile
    The global variables, PATH and such are inherited from this.


    But a regular non-login interactive shell (like in your gnome-terminal) just executes,
    ~/.bashrc

    -------

    To make the plot thicker,
    the default /etc/profile sources /etc/profile.d/*.sh generally
    the default ~/.bash_profile sources ~/.bashrc
    the default ~/.bashrc sources /etc/bashrc
    the default /etc/bashrc also sources /etc/profile.d/*.sh unless it's a login shell

    ========

    So the login bash shell executes
    Code:
    /etc/profile
         /etc/profile.d/*.sh
    ~/.bash_profile
        ~/.bashrc
            /etc/bashrc
    while the normal fedora interactive non-login shell executes ...
    Code:
    ~/.bashrc
        /etc/bashrc
            /etc/profile.d/*.sh

  11. #11
    Join Date
    Jun 2012
    Location
    India
    Posts
    27
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Error in Editing .bash_profile

    Thanks a lot stevea for the explanations here. i was familiar with execution hierarchy of the files but not with the types of shells and scripts they execute.

    Although i didn't get my problem solved with artha but i got to new many interesting facts and also the source from where i should read. Manuals are probably best source one should refer first.

    Thanks to all for valuable suggestions.

  12. #12
    Join Date
    Oct 2005
    Location
    British Columbia, Canada
    Posts
    1,063
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Error in Editing .bash_profile

    Quote Originally Posted by stevea
    The explanations here leave me cold. "man bash" tells half the story ...




    So there are two distinct modifiers of shells based on how they are invoked. 'login' and 'interactive'

    The man page continues (with redactions) ....



    As a practical matter there is one login shell created very early in the login process when gdm or whatever greeter performs the authentication and before the Xsession begins. The controlling terminal at that time is also the session terminal - typically /dev/tty1 on Fedora. That login shell exits before your desktop appears.

    During a Fedora gui login, the one and only login shell that is created for your login executes,
    /etc/profile
    ~/.bash_profile
    The global variables, PATH and such are inherited from this.


    But a regular non-login interactive shell (like in your gnome-terminal) just executes,
    ~/.bashrc

    -------

    To make the plot thicker,
    the default /etc/profile sources /etc/profile.d/*.sh generally
    the default ~/.bash_profile sources ~/.bashrc
    the default ~/.bashrc sources /etc/bashrc
    the default /etc/bashrc also sources /etc/profile.d/*.sh unless it's a login shell

    ========

    So the login bash shell executes
    Code:
    /etc/profile
         /etc/profile.d/*.sh
    ~/.bash_profile
        ~/.bashrc
            /etc/bashrc
    while the normal fedora interactive non-login shell executes ...
    Code:
    ~/.bashrc
        /etc/bashrc
            /etc/profile.d/*.sh
    Hi stevea
    At what point does the /etc/gdm/Init/Default script run when booting and going to a GUI Login Screen? I put a chunk of code there under F16 and it worked for me. Now under F17 it does not work. Has something changed in the order or even the use of this script under F17?
    Thanks
    Robert :)

  13. #13
    stevea Guest

    Re: Error in Editing .bash_profile

    Main problem for OP ....
    artha is an X11 program and there is no X11 display setup when ~/.bash_profile executes.
    This belongs in the desktop(e.g. Gnome) 'session' control.

    Hi stevea
    At what point does the /etc/gdm/Init/Default script run when booting and going to a GUI Login Screen? I put a chunk of code there under F16 and it worked for me. Now under F17 it does not work. Has something changed in the order or even the use of this script under F17?
    Thanks
    gdm is nominally the desktop manager, however it is responsible for the 'greeter' and login procedures. It runs as root (or else some special users). I wonder if you are having SELinux issues.

    If you use 'pstree' you'll get a picture of how the current processes are inherited.
    For me,
    ├─kdm─┬─X
    │ └─kdm───sh─┬─ssh-agent
    │ ├─xfce4-session
    │ └─xscreensaver
    ├─ksmtuned───sleep
    Where kdm is the gdm analog.


    Sadly the gnomes have been removing functionality from gdm for several years now. And the documentation of what it actually does in practice is not well documented (please someone - prove me wrong !). So 'look at the source' is the precise answer - sorry.

  14. #14
    Join Date
    Oct 2005
    Location
    British Columbia, Canada
    Posts
    1,063
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Error in Editing .bash_profile

    Quote Originally Posted by stevea
    Main problem for OP ....
    artha is an X11 program and there is no X11 display setup when ~/.bash_profile executes.
    This belongs in the desktop(e.g. Gnome) 'session' control.



    gdm is nominally the desktop manager, however it is responsible for the 'greeter' and login procedures. It runs as root (or else some special users). I wonder if you are having SELinux issues.

    If you use 'pstree' you'll get a picture of how the current processes are inherited.
    For me,


    Where kdm is the gdm analog.


    Sadly the gnomes have been removing functionality from gdm for several years now. And the documentation of what it actually does in practice is not well documented (please someone - prove me wrong !). So 'look at the source' is the precise answer - sorry.
    Hi stevea
    Thank you.
    Robert :)

  15. #15
    Join Date
    Jun 2012
    Location
    India
    Posts
    27
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Error in Editing .bash_profile

    Hi stevea,

    I was willing to mount my windows partitions automatically in login process so that i dont have to mount it explicitly afterwards. I put these lines of code in the ~/.bash_profile
    Code:
    mkdir /media/New\ VolumeC
    mkdir /media/New\ VolumeD
    mount /dev/sda2 /media/New\ VolumeC
    mount /dev/sda3 /media/New\ VolumeD
    But since mkdir dont have right to write /media and even sda2 and sda3 are accessible to only root (i feel) i got permission denied error and an alert in SELinuxTroubleshooter regarding "mkdir tried to write in /media".

    Please help me to do my task

Page 1 of 2 12 LastLast

Similar Threads

  1. F13 .bash_profile
    By dysphorichermit in forum Using Fedora
    Replies: 2
    Last Post: 28th May 2010, 09:12 PM
  2. grubby "no suitable template" error causes no editing of grob.conf
    By marko in forum Fedora 12 Alpha, Beta & Release Candidates
    Replies: 3
    Last Post: 12th July 2009, 03:18 AM
  3. .bash_profile
    By laughingteacake in forum Using Fedora
    Replies: 24
    Last Post: 19th January 2008, 10:17 PM
  4. .bash_profile
    By armen in forum Using Fedora
    Replies: 3
    Last Post: 12th March 2005, 08:04 PM
  5. .bash_Profile
    By chitech in forum Using Fedora
    Replies: 9
    Last Post: 24th August 2004, 08:50 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
[[template footer(Guest)]]