Results 1 to 9 of 9

Thread: Problems with .bash_profile

  1. #1
    Join Date
    Jun 2011
    Location
    United Kingdom
    Beans
    Hidden!
    Distro
    Lubuntu Development Release

    Question Problems with .bash_profile

    Am in the process of learning the terminal, and the basics of scripting, however have come up against a problem.

    Performing some alias tweaks to save me some time for common tasks in the terminal requires me to edit .bash_profile, which is under /home/.myusername. However, if I open it in gedit, e.g. sudo gedit .bash_profile it opens a blank gedit document. It can't seriously be telling me there is nothing in there?

    Any help, especially from terminal gurus, is much appreciated

  2. #2
    Join Date
    Jan 2008
    Location
    Manchester UK
    Beans
    13,573
    Distro
    Ubuntu

    Re: Problems with .bash_profile

    1. You don't have a .bash_profile by default so it will be empty.

    2. Don't edit stuff in your $HOME with sudo

    3. If you do want to open gedit as root use gksudo not sudo

    4. You may wan't to consider putting all your aliases in ~/.bash_aliases, which you will also have to create.

    Any questions, post back

  3. #3
    Join Date
    May 2006
    Location
    Boston
    Beans
    1,918
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: Problems with .bash_profile

    Quote Originally Posted by MG&TL View Post
    Am in the process of learning the terminal, and the basics of scripting, however have come up against a problem.

    Performing some alias tweaks to save me some time for common tasks in the terminal requires me to edit .bash_profile, which is under /home/.myusername. However, if I open it in gedit, e.g. sudo gedit .bash_profile it opens a blank gedit document. It can't seriously be telling me there is nothing in there?

    Any help, especially from terminal gurus, is much appreciated
    did u try :

    Code:
    gedit ~/.bashrc
    ?
    Last edited by fdrake; July 11th, 2011 at 10:55 PM.

    blog
    Donations BTC : 12FwoB7uAM5FnweykpR1AEEDVFaTLTYFkS
    DOUBLEPLUSGOOD!!

  4. #4
    Join Date
    Apr 2009
    Location
    Midwest, U.S.A.
    Beans
    1,209
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Problems with .bash_profile

    Quote Originally Posted by MG&TL View Post
    Performing some alias tweaks to save me some time for common tasks in the terminal requires me to edit .bash_profile, which is under /home/.myusername. However, if I open it in gedit, e.g. sudo gedit .bash_profile it opens a blank gedit document. It can't seriously be telling me there is nothing in there?
    Actually ~/.bash_profile is NOT the best place to put your personal aliases...

    Better in ~/.bashrc

    ...and even better in ~/.bash_aliases if you have the following code in your ~/.bashrc
    Code:
    if [ -r ~/.bash_aliases ]; then
        . ~/.bash_aliases
    fi
    Laptop: Dell Inspiron 8200 - Fedora 13 - Goddard
    Desktop: Self-Built - [Ku, Lu, Xu, U]buntu - Lucid 10.04.3 (LTS)
    Linux User: 498249 / Ubuntu User: 29241

  5. #5
    Join Date
    Jun 2011
    Location
    United Kingdom
    Beans
    Hidden!
    Distro
    Lubuntu Development Release

    Talking Re: Problems with .bash_profile

    Ok, lots of questions with 'newbie' stamped ALL over them now...

    If there is no text file with bash source code in it, how does bash run in the first place? And how do I 'create' something that logically has always been there, but I can't see it? I realise bash_profile is useless for aliases now, but I'm curious to see what the code looks like.

    So a separate directory is better for personal tweaks, just create a new text file, call it .bash_aliases. How do I create a .something_hidden_behind_a_dot file in gedit?

    bashrc works, and it has the bash_alias clause, too.

  6. #6
    Join Date
    Jan 2008
    Location
    Manchester UK
    Beans
    13,573
    Distro
    Ubuntu

    Re: Problems with .bash_profile

    Just type

    Code:
    gedit .bash_aliases
    Fill it with aliases.
    When you save it, it will be created.

    Then type

    Code:
    . ~/.bashrc
    so that bash will read your .bashrc (and .bash_aliases).

  7. #7
    Join Date
    Apr 2009
    Location
    Midwest, U.S.A.
    Beans
    1,209
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Problems with .bash_profile

    Quote Originally Posted by MG&TL View Post
    Ok, lots of questions with 'newbie' stamped ALL over them now...

    If there is no text file with bash source code in it, how does bash run in the first place? And how do I 'create' something that logically has always been there, but I can't see it? I realise bash_profile is useless for aliases now, but I'm curious to see what the code looks like.

    So a separate directory is better for personal tweaks, just create a new text file, call it .bash_aliases. How do I create a .something_hidden_behind_a_dot file in gedit?

    bashrc works, and it has the bash_alias clause, too.
    Bash reads these files:

    1. /etc/profile executed automatically at login, first.
    2. The first file found from this list: ~/.bash_profile, ~/.bash_login, ~/.profile
    3. ~/.bashrc is read by every shell after the login files.
    Laptop: Dell Inspiron 8200 - Fedora 13 - Goddard
    Desktop: Self-Built - [Ku, Lu, Xu, U]buntu - Lucid 10.04.3 (LTS)
    Linux User: 498249 / Ubuntu User: 29241

  8. #8
    Join Date
    Jun 2011
    Beans
    46

    Re: Problems with .bash_profile

    Quote Originally Posted by MG&TL View Post
    Ok, lots of questions with 'newbie' stamped ALL over them now...

    If there is no text file with bash source code in it, how does bash run in the first place? And how do I 'create' something that logically has always been there, but I can't see it? I realise bash_profile is useless for aliases now, but I'm curious to see what the code looks like.

    So a separate directory is better for personal tweaks, just create a new text file, call it .bash_aliases. How do I create a .something_hidden_behind_a_dot file in gedit?

    bashrc works, and it has the bash_alias clause, too.
    If you're looking for the source code of the program "bash" itself, it won't be in any files. The files like .bashrc and .bash_aliases just let you define aliases and functions that you can run using bash.
    “So this SEO copywriter walks into a bar, grill, pub, public house, Irish bar, bartender, drinks, beer, wine, liquor”

  9. #9
    Join Date
    Jun 2011
    Location
    United Kingdom
    Beans
    Hidden!
    Distro
    Lubuntu Development Release

    Re: Problems with .bash_profile

    Ok, thanks people, another newbie sent on his way!

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •