LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 04-06-2012, 02:30 PM   #1
agape801
LQ Newbie
 
Registered: Apr 2012
Posts: 2

Rep: Reputation: Disabled
Question about alias for my linux system ? newbie?


I want to enter an alias for my linux system. I go into a CLI and enter as the user named student which I type;

alias log=tail /var/log/messages

and then press enter

I go to the prompt within the CLI and type log and get

log: not found

1. Did I create the alias correctly

2. If I did not create the alias correctly type the command in its entirety as you would have created the alias

3.If I did enter it correctly why else did the command not work
 
Old 04-06-2012, 02:44 PM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
Since there is a space in the aliased command, you need to embed it in quotes. The correct syntax is
Code:
alias log='tail /var/log/messages'
Anyway without quotes you should have received an error and the alias should have been set as tail without arguments. Therefore, I think the real problem is that aliases, shell variables and shell functions set in the command line are local to the current shell session. If you open a new terminal all the previously defined aliases are lost. The same if you reboot the machine or simply log out of the current session.

If you want your aliases to be set-up every time you start a new shell (that is every time you open a new terminal) you need to put them in a configuration file, usually .bashrc in your home directory (provided your default shell is bash).

Some useful reading: http://tldp.org/LDP/Bash-Beginners-G...ect_03_01.html (about shell initialization) and http://tldp.org/LDP/Bash-Beginners-G...ect_03_05.html (about aliases). Hope this help.

And welcome to LinuxQuestions!

Last edited by colucix; 04-06-2012 at 02:45 PM.
 
1 members found this post helpful.
Old 04-06-2012, 03:16 PM   #3
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
Coo, a moderator duped into answering homework? You got played! http://answers.yahoo.com/question/in...6121001AAYcRUM
 
Old 04-06-2012, 03:33 PM   #4
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
Oops!

I didn't thought it was homework.
 
Old 04-06-2012, 03:34 PM   #5
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
his 2nd thread was much less subtle!
 
  


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
Perl newbie question about system command Guttorm Programming 8 06-30-2011 08:43 PM
Alias question (2 commands for one alias) gflores Linux - Newbie 3 01-21-2006 12:40 AM
Another Newbie question....Alias tetpt Linux - Newbie 5 03-04-2005 10:58 AM
very newbie alias question ffang Linux - Newbie 4 09-04-2003 07:46 PM

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

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