LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
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, 03: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, 03:44 PM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978
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 03:45 PM.
 
1 members found this post helpful.
Old 04-06-2012, 04:16 PM   #3
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

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

Rep: Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978
Oops!

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

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
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 09:43 PM
Alias question (2 commands for one alias) gflores Linux - Newbie 3 01-21-2006 01:40 AM
Another Newbie question....Alias tetpt Linux - Newbie 5 03-04-2005 11:58 AM
very newbie alias question ffang Linux - Newbie 4 09-04-2003 08:46 PM

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

All times are GMT -5. The time now is 03:52 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration