LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 11-05-2009, 04:24 AM   #1
sanchetanparmar
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
mrrangerman
Member
 
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?

Global
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.

Local
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
whittycat
Member
 
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
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,083

Rep: Reputation: 405Reputation: 405Reputation: 405Reputation: 405Reputation: 405
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
onebuck
Moderator
 
Registered: Jan 2005
Location: Central Florida 20 minutes from Disney World
Distribution: Slackware®
Posts: 13,925
Blog Entries: 44

Rep: Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159
Hi,


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

Code:
sample .bash_profile;

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

#.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\] '
 else
   PS1='\[\033[1;32m\]\h:\w\$\[\033[0m\] '
fi

#
# 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 ~/ www.google.com'

#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!

 
  


Reply



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

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:49 PM.

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