Visit Jeremy's Blog.
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 10-08-2012, 03:11 AM   #1
LQ Newbie
Registered: Sep 2012
Location: India
Posts: 6

Rep: Reputation: Disabled
Post Problems defining an alias in .bashrc


I tried creating an alias under .bashrc file of my home dir.. shown below - "list1"

# User specific aliases and functions

alias list1='ls -lrt /tmp/zaayu/ | tail -3'

But it doesn't work. when i list out the aliases on system, the alias i created doesn't show up.. neither i am able to run it on the prompt.

Please suggest.
Old 10-08-2012, 05:21 AM   #2
LQ Veteran
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738
I think you may need to restart the system for things in .bashrc to take effect.

Note the "normal" way of changing the PATH:
export PATH="$PATH:/sbin:/usr/sbin"
1 members found this post helpful.
Old 10-08-2012, 06:37 AM   #3
LQ Newbie
Registered: Sep 2012
Location: India
Posts: 6

Original Poster
Rep: Reputation: Disabled
Thanks for the correction in the PATH env var..

Is there no other way to get the changes permanent without the system restart? as I am not the root admin for the box.
Old 10-08-2012, 11:40 AM   #4
David the H.
Bash Guru
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian + kde 4 / 5
Posts: 6,837

Rep: Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981
You don't need to restart the system. You just need to re-source the startup file.

. /path/to/bashrc	#the dot is the source command
Sourcing means reading the file into the current shell environment and executing everything in it, just as if it were manually run.

So of course you can also simply run the commands manually once so that they come into affect in the current session.

For login shells you may have to log out and back in again, but that's a far cry from having to restart. But then again, login shells don't read the .bashrc.

Now for the theory. Nothing you set in the shell is ever "permanent". When a shell starts, it automatically sources one or more start-up files, just as above. This allows you to run commands that configure the default environment or do other things. The shell may also inherit a few settings from the parent process (such as the system init), which is how you can get a default path even without any startup files.

And whenever a shell (or any process, really) exits, its environment is lost too.

Last edited by David the H.; 10-08-2012 at 11:44 AM. Reason: minor wording edits
1 members found this post helpful.


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
using alias's and editing the bashrc cynicalpsycho Linux - Newbie 11 05-07-2009 01:41 AM
bashrc alias issue noir911 Linux - General 1 08-22-2006 06:24 AM
My first alias in .bashrc...'apostrophes 'getting' in the way?' Baix Linux - Newbie 3 06-17-2004 03:36 PM
alias and .bashrc whaase Linux - General 3 11-02-2003 08:03 PM
alias and bashrc Haldir Linux - Newbie 3 06-14-2002 06:11 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:01 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