LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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-16-2007, 09:25 AM   #1
coldbeerz
LQ Newbie
 
Registered: Nov 2007
Location: PA
Posts: 7

Rep: Reputation: 0
trouble creating alias


I am trying to create a permanent alias. I can create the alias from the prompt. example
This command works but is not permanent

{root@aardvark aardvark}#alias cls='clear'

This command does not work

If I edit .bashrc
{root@aardvark aardvark}#vi .bashrc

#bashrc

#User specific aliases and functions
alias cls='clear'
# Source global destinations
if [ -f /etc/bashrc ]; then
./etc/bashrc

fi
~
~
~
~
~
~
~


Thanks for your help!
 
Old 11-16-2007, 11:53 AM   #2
mrrangerman
Member
 
Registered: Oct 2007
Location: MI
Distribution: Debian Slackware
Posts: 528

Rep: Reputation: 59
If you are trying to set this up for a user account then, (you don't need to be root)

In a terminal ls ~/.bashrc if you get file not found returned you don't have a local ~/.bashrc file.
Create one like so touch ~/.bashrc
Edit the file with your favorite editor, vi ~/.bashrc

Then create your alias save and exit, and you should be set.
 
Old 11-16-2007, 12:07 PM   #3
laucian
Member
 
Registered: Oct 2005
Distribution: Ubuntu 9.04
Posts: 124
Blog Entries: 2

Rep: Reputation: 15
Quote:
Originally Posted by mrrangerman View Post
If you are trying to set this up for a user account then, (you don't need to be root)

In a terminal ls ~/.bashrc if you get file not found returned you don't have a local ~/.bashrc file.
Create one like so touch ~/.bashrc
Edit the file with your favorite editor, vi ~/.bashrc

Then create your alias save and exit, and you should be set.
i had the same problem..i did just like you wrote but it still doesn't work. any more tips?
 
Old 11-19-2007, 10:29 AM   #4
coldbeerz
LQ Newbie
 
Registered: Nov 2007
Location: PA
Posts: 7

Original Poster
Rep: Reputation: 0
Thanks mrangerman but

I have the ./bashrc file. I edit it and type in the line.
alias cls='clear'
It still does not work. Do I have the syntax correct?


[root@aardvark aardvark]# vi ~/.bashrc
# .bashrc

# User specific aliases and functions
alias cls='clear'
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
"~/.bashrc" 8L, 141C 7,2-9 All
 
Old 11-19-2007, 10:37 AM   #5
coldbeerz
LQ Newbie
 
Registered: Nov 2007
Location: PA
Posts: 7

Original Poster
Rep: Reputation: 0
Thank you I got it!

I had not exited the session. When I closed the session and restarted it the bashrc was running the cls command I edited.
You can also use a command . .bashrc and that will reload the bashrc.

Lucian - Are trying this for a class you are taking?
 
  


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
Creating Command Alias? carlosinfl Linux - General 3 07-14-2007 05:32 PM
Help creating an Alias that will mount floppy mral Linux - Newbie 8 12-24-2005 06:47 AM
Need advice on creating an alias thorney Linux - General 2 11-27-2005 07:33 PM
Creating an alias (name=value pair) where the name has spaces. Cubert Linux - Newbie 2 01-12-2005 06:42 AM
Creating mult command alias in BASH labob Linux - Newbie 1 11-18-2004 07:37 PM

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

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