Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: [*buntu 13.04] Aliases forgotten after terminal close

  1. #1
    Join Date
    Jun 2013
    Location
    Somewhere on Earth.
    Beans
    513
    Distro
    Ubuntu 14.04 Trusty Tahr

    Unhappy [*buntu 13.04] Aliases forgotten after terminal close

    Hello all!

    I have made a set of aliases that I would like to implement. However when I try:

    Code:
    alias "quit"="exit"
    it works! Until I try the command again by opening another terminal:

    Code:
    -@-$ quit
    No command 'quit' found, did you mean:
     Command 'qgit' from package 'qgit' (universe)
     Command 'quilt' from package 'quilt' (main)
     Command 'quiz' from package 'bsdgames' (universe)
     Command 'luit' from package 'x11-utils' (main)
     Command 'quot' from package 'quota' (main)
    quit: command not found
    -@-:~$
    How can I make the alias permanent?
    Avatar credit: http://www.omgubuntu.co.uk/2010/07/d...-spread-ubuntu
    Status: Hit with the Dengue virus
    Happy new year to all!

  2. #2
    Join Date
    Feb 2007
    Location
    Romania
    Beans
    Hidden!

    Re: [*buntu 13.04] Aliases forgotten after terminal close

    Just put them in your ~/.bashrc file. Or you could create a separate file for your aliases and source it in ~/.bashrc

    I keep my aliases in ~/.bash_aliases and use the following line in my ~/.bashrc file to source it:
    Code:
    [ -f "$HOME/.bash_aliases" ] && . "$HOME/.bash_aliases"
    Last edited by sisco311; September 13th, 2013 at 11:31 PM.

  3. #3
    Join Date
    Sep 2008
    Location
    Chicago
    Beans
    Hidden!
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: [*buntu 13.04] Aliases forgotten after terminal close

    It works fine on my 12.04 LTS. Perhaps Raring has a regression with respect to 12.04 LTS. Edit with note to Sisco's posting: I don't use files for aliases, since mine are usually ephemeral. That could be the difference.
    Last edited by whitesmith; September 13th, 2013 at 11:33 PM. Reason: Comment on another postging
    In working with *nix...There be dragons. Newcomers: I recommend reading Linux is Not Windows (http://linux.oneandoneis2.org/LNW.htm) and The Linux Command Line (http://www.linuxcommand.org/tlcl.php) before beginning your quest for a better OS.

  4. #4
    Join Date
    Jun 2013
    Location
    Somewhere on Earth.
    Beans
    513
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re... Thank you!

    Quote Originally Posted by sisco311 View Post
    Just put them in your ~/.bash_aliases and use the following line in your ~/bashrc file to source it:
    Code:
    [ -f ~/.bash_aliases ] && . ~/.bash_aliases
    Would this work:

    Code:
    "quit"="exit"
    as a .bash_aliases file?

    PS. Thank you!
    Last edited by Jonathan Precise; September 13th, 2013 at 11:35 PM. Reason: Title --change {Re:Aliases... -> Re... Thank you!}
    Avatar credit: http://www.omgubuntu.co.uk/2010/07/d...-spread-ubuntu
    Status: Hit with the Dengue virus
    Happy new year to all!

  5. #5
    Join Date
    Jun 2013
    Location
    Somewhere on Earth.
    Beans
    513
    Distro
    Ubuntu 14.04 Trusty Tahr

    Arrow Re... Curiosity

    Quote Originally Posted by whitesmith View Post
    It works fine on my 12.04 LTS. Perhaps Raring has a regression with respect to 12.04 LTS.
    I used to have ubuntu-12.04-LTS and it worked! Just curious why 13.04 (the one I now use) has this?
    Avatar credit: http://www.omgubuntu.co.uk/2010/07/d...-spread-ubuntu
    Status: Hit with the Dengue virus
    Happy new year to all!

  6. #6
    Join Date
    Feb 2007
    Location
    Romania
    Beans
    Hidden!

    Re: [*buntu 13.04] Aliases forgotten after terminal close

    Nope you have to use the `alias' keyword:
    Code:
    alias quit='exit'
    Here is the content of my bash_aliases file:
    Code:
    alias ll='ls -ahl'
    alias la='ls -a'
    
    alias ..='cd ..'
    alias ...='cd ../..'
    
    alias grep='grep --color=auto'
    
    alias top='htop'
    
    alias xs='cd'
    alias vf='cd'
    alias cdx='cd ~/xtmp'
    alias cda='cd /home/apps'
    alias cdt='cd ~/torrent'
    
    alias pacman='pacman'
    alias s='sudo pacman -S'
    alias r='sudo pacman -R'
    alias rns='sudo pacman -Rns'
    alias syu='sudo pacman -Syu'
    alias ss='pacman -Ss'
    alias su='sudo pacman -Su'
    
    alias ping='ping -v'
    
    alias q='exit'
    alias e='exit'
    
    alias m='mousepad'
    alias n='nano'
    alias nb='nano ~/files/bash'
    
    alias f='cat ~/files/forum'
    
    alias punk='mplayer -really-quiet http://65.60.32.242:8600 < /dev/null &'
    
    alias a='adb shell busybox'
    
    alias ntp='sudo ntpd -qg'

  7. #7
    Join Date
    Jun 2007
    Location
    Arizona U.S.A.
    Beans
    1,858

    Re: [*buntu 13.04] Aliases forgotten after terminal close

    Any alias you define in the terminal is lost when you close the terminal. To retain them you put your alias definitions in a file which is read each time the terminal is started.

    Two possibilities:

    I put all alias definitions into ~/.bash_aliases. If this file doesn't already exist, create it. It is just a text file.

    Example:

    Code:
    #Roxanne's Alias File
    #bash_aliases is run each time the terminal is started
    
    alias dosgames='dosbox /home/dn/dosgames/'
    alias tcv='dosbox /home/dn/dosgames/TCV/COVE.EXE'
    alias brix='dosbox /home/dn/dosgames/brix/BRIX1.EXE'
    alias chess='dosbox /home/dn/dosgames/chess/GMCHESS.EXE'
    alias castle='dosbox /home/dn/dosgames/brain/BRAIN.EXE'
    Some people put them into ~/.bashrc instead.

  8. #8
    Join Date
    Jun 2013
    Location
    Somewhere on Earth.
    Beans
    513
    Distro
    Ubuntu 14.04 Trusty Tahr

    (Un)solved status.

    Thank you Dennis N and sisco311!
    Now marked as [solved]!
    Edit: Now marked as unsolved due to confusion.
    Edit: Now marked as [solved] due to clarification.
    Last edited by Jonathan Precise; September 14th, 2013 at 12:00 AM. Reason: Solved now!
    Avatar credit: http://www.omgubuntu.co.uk/2010/07/d...-spread-ubuntu
    Status: Hit with the Dengue virus
    Happy new year to all!

  9. #9
    Join Date
    Jun 2013
    Location
    Somewhere on Earth.
    Beans
    513
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: [*buntu 13.04] Aliases forgotten after terminal close

    Quote Originally Posted by sisco311 View Post
    I use the following line in my ~/.bashrc file to source it:
    Code:
    [ -f "$HOME/.bash_aliases" ] && . "$HOME/.bash_aliases"
    Does this work:

    Code:
    if [ -f ~/.bash_aliases ]; then
        . ~/.bash_aliases
    fi
    Last edited by Jonathan Precise; September 13th, 2013 at 11:47 PM. Reason: Code error.
    Avatar credit: http://www.omgubuntu.co.uk/2010/07/d...-spread-ubuntu
    Status: Hit with the Dengue virus
    Happy new year to all!

  10. #10
    Join Date
    Feb 2007
    Location
    Romania
    Beans
    Hidden!

    Re: [*buntu 13.04] Aliases forgotten after terminal close

    Quote Originally Posted by Jonathan Precise View Post
    Does this work:

    Code:
    if [ -f ~/.bash_aliases ]; then
        . ~/.bash_aliases
    fi
    Yes, they do the same thing.

    EDIT: Oh, I see, if it exists, ~/.bash_aliases is sourced in Ubuntu's default .bashrc file.
    Last edited by sisco311; September 13th, 2013 at 11:59 PM.

Page 1 of 2 12 LastLast

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
  •