Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 11-05-2009, 04:24 AM   #1
LQ Newbie
Registered: Nov 2009
Posts: 5
Blog Entries: 1

Rep: Reputation: 0
Post How Do I Make An Alias Permanent

how to save alias peramanent
Old 11-05-2009, 06:05 AM   #2
Registered: Oct 2007
Location: MI
Distribution: Debian Slackware
Posts: 528

Rep: Reputation: 59
Do you want this to be a Global setting or Local per user?

I'm using Debian so I'm not sure if the file is the same in RedHat.
Edit as root /etc/bash.bashrc and add the alias.

Edit each users ~/.bashrc file and add the alias

Note: Some linux OS do not have a local .bashrc file, if not just create the file. To do this, in the home directory of the user run the command.

touch .bashrc

Now edit the file and add the alias.
Old 11-05-2009, 06:08 AM   #3
Registered: Nov 2004
Location: Wellington Somerset UK
Distribution: Debian lenny, also DSL-N
Posts: 32

Rep: Reputation: 15
a permanent alias

When you install Linux you usually get bash as the default shell. I use the C-shell instead for interactive
work (though I use bash for writing scripts). When you log in it runs the file ~/.tcshrc and in this I have
put things like

alias rm 'rm -i'
alias cp 'cp -i'
alias mv 'mv -i'
alias cat 'cat -v'
alias gt 'set D1=$cwd;cd $1'
alias gb 'cd $D1'
alias ls '/bin/ls -F'

and these all work from then on. I believe you can do something similar in bash using functions but this
way is easier.
Old 11-05-2009, 07:42 AM   #4
Gentoo support team
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,074

Rep: Reputation: 386Reputation: 386Reputation: 386Reputation: 386
It depends on the shell you use.

For bash, check the bash man page, section "Invocation". There you have a list of all the files that are used depending on the mode, and their order of precedence.
Old 11-05-2009, 07:51 AM   #5
Registered: Jan 2005
Location: Midwest USA, Central Illinois
Distribution: Slackware®
Posts: 12,867
Blog Entries: 27

Rep: Reputation: 2162Reputation: 2162Reputation: 2162Reputation: 2162Reputation: 2162Reputation: 2162Reputation: 2162Reputation: 2162Reputation: 2162Reputation: 2162Reputation: 2162

You could setup a .bashrc & .bash_profile for your user;

sample .bash_profile;

~$ cat .bash_profile
# .bash_profile
#08-30-06 12:21
# Source .bashrc
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
sample .bashrc;
:~$ cat .bashrc

#08-30-06 12:20 

# Add bin to path

export PATH="$PATH:/sbin:/usr/sbin:$HOME/bin"

#export PATH="$PATH:$HOME/bin"

# Dynamic resizing
shopt -s checkwinsize

# Custom prompt
#PS1='\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '

#08-29-06 11:40

if [ `id -un` = root ]; then
   PS1='\[\033[1;31m\]\h:\w\$\[\033[0m\] '
   PS1='\[\033[1;32m\]\h:\w\$\[\033[0m\] '

# Add color
eval `dircolors -b`

# User defined aliases
alias cls='clear'
alias clls='clear; ls'
alias ll='ls -l'
alias lsa='ls -A'
alias lsg='ls | grep'
alias lsp='ls -1 /var/log/packages/ > package-list'
alias na='nano'
alias web='links -g -download-dir ~/'

#08-29-06 11:50

#To clean up and cover your tracks once you log off
#Depending on your version of BASH, you might have to use
# the other form of this command
   trap "rm -f ~$LOGNAME/.bash_history" 0

#The older KSH-style form
#   trap 0 rm -f ~$LOGNAME/.bash_history
You can modify the '.bashrc' above for a user to reflect the environment for that user.

The .bashrc is very useful!



Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
make ip forwarding = 1 permanent jonfa Solaris / OpenSolaris 2 05-05-2008 08:47 AM
Make route permanent rust8y Solaris / OpenSolaris 9 12-10-2007 04:10 AM
How to make txqueuelen changes permanent? bcg121 Linux - Networking 0 11-02-2007 07:32 AM
permanent alias Haloony Linux - Newbie 2 03-09-2006 10:12 PM
Permanent Alias In Slackware dmcbeing Linux - Software 2 11-10-2005 11:18 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:21 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration