LinuxQuestions.org
Review your favorite Linux distribution.
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 08-05-2009, 05:22 AM   #1
thomas2004ch
Member
 
Registered: Aug 2009
Posts: 539

Rep: Reputation: 33
How to set alias?


I have a file .bash_profile just in the home directory. I have set some alias in this file such as follow:
Code:
...
alias LOG="cd /var/log/jboss/test"
...
But as I type LOG, I got error:

Code:
-bash: LOG: command not found

Someone can help?
 
Old 08-05-2009, 05:26 AM   #2
linuxlover.chaitanya
Senior Member
 
Registered: Apr 2008
Location: Gurgaon, India
Distribution: Cent OS 6/7
Posts: 4,631

Rep: Reputation: Disabled
Have you logged out and then re logged in for .bash_profile script to run and set the alias? I usually set the alias in .bashrc file and use single quotes and NOT double quotes.

So it should be
Code:
alias LOG='cd /var/log/your/path'
 
Old 08-05-2009, 05:32 AM   #3
ranban282
LQ Newbie
 
Registered: Jul 2006
Location: Hyderabad
Distribution: Fedora 8
Posts: 28

Rep: Reputation: 1
Strange that it doesn't work. What is the output when you run
Code:
alias LOG
What about
Code:
which LOG
There may possibly a mistake in your .bash_profile. Could you post the contents of that file?
Thanks
 
Old 08-05-2009, 05:33 AM   #4
zQUEz
Member
 
Registered: Jun 2007
Distribution: Fedora, RHEL, Centos
Posts: 294

Rep: Reputation: 54
if you have root access to a machine, I usually put this in /etc/bashrc. This way the aliases are set for all users, like when I su to root I still have the same alias commands.
 
Old 08-05-2009, 06:58 AM   #5
thomas2004ch
Member
 
Registered: Aug 2009
Posts: 539

Original Poster
Rep: Reputation: 33
Quote:
Originally Posted by ranban282 View Post
Strange that it doesn't work. What is the output when you run
Code:
alias LOG
What about
Code:
which LOG
There may possibly a mistake in your .bash_profile. Could you post the contents of that file?
Thanks
Here is the result:

Code:
-bash-3.00$ alias LOG
-bash: alias: LOG: not found
-bash-3.00$ which LOG
/usr/bin/which: no LOG in (/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin)
-bash-3.00$
 
Old 08-05-2009, 07:02 AM   #6
thomas2004ch
Member
 
Registered: Aug 2009
Posts: 539

Original Poster
Rep: Reputation: 33
Quote:
Originally Posted by linuxlover.chaitanya View Post
Have you logged out and then re logged in for .bash_profile script to run and set the alias? I usually set the alias in .bashrc file and use single quotes and NOT double quotes.

So it should be
Code:
alias LOG='cd /var/log/your/path'
You are right!
 
  


Reply


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
Where to set global alias? exitsfunnel Linux - General 9 07-29-2014 09:12 AM
how do i set global alias in gentoo? lleb Linux - General 3 12-13-2007 01:38 PM
How to set an IP alias in Kubuntu leupi Ubuntu 1 04-14-2006 11:26 AM
Alias question (2 commands for one alias) gflores Linux - Newbie 3 01-21-2006 12:40 AM
How make a script in order to set global alias? RickHunter_Ve Linux - Newbie 7 06-08-2004 02:13 PM

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

All times are GMT -5. The time now is 01:44 AM.

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