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 02-19-2017, 10:44 PM   #1
cyfix
LQ Newbie
 
Registered: Feb 2017
Location: Za Warldo
Posts: 9

Rep: Reputation: Disabled
unable to use the alias command


Hello world,

I am fairly new to linux and just learning how to use the terminal.

I am unable to use the {alias} command (ie: alias list = "ls -a -l -t" )
in fact when i use {whatis alias} i get the message : alias nothing appropriate

i tried {sudo apt-get install alias} but it didn't find anything.

any suggestions?
 
Old 02-19-2017, 11:24 PM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.10, Centos 7.5
Posts: 17,700

Rep: Reputation: 2494Reputation: 2494Reputation: 2494Reputation: 2494Reputation: 2494Reputation: 2494Reputation: 2494Reputation: 2494Reputation: 2494Reputation: 2494Reputation: 2494
No spaces allowed around '=', but for a cmd like that you will need single quotes thus
Code:
alias list='ls -a -l -t' 
# OR
alias list='ls -alt'      # you can concatenate options/switches that take no args.
HTH & Welcome to LQ

NB: if you type that interactively, it will only persist for the current terminal session.
For permanence, add that line to your .bashrc file (ie /home/<username>/.bashrc.
PS: the 'alias' cmd with no args will list all current aliases.

Note that leading '.' at the start of a filename means its hidden from normal ls cmd; you'll need the -a option to list it.

Last edited by chrism01; 02-19-2017 at 11:26 PM. Reason: dupe typo
 
Old 02-19-2017, 11:45 PM   #3
cyfix
LQ Newbie
 
Registered: Feb 2017
Location: Za Warldo
Posts: 9

Original Poster
Rep: Reputation: Disabled
ty ty

well i know more about whats inside .bashrc and .bash_history now, but my alias still doesn't work

for example:

{alias Biglist = "ls -alt" } still wont work because my terminal does not acknowledge the command alias

also, where are the aliases saved?
 
Old 02-19-2017, 11:49 PM   #4
Timothy Miller
Moderator
 
Registered: Feb 2003
Location: Arizona, USA
Distribution: Debian, KDE Neon, Arch, Void
Posts: 3,296

Rep: Reputation: 1063Reputation: 1063Reputation: 1063Reputation: 1063Reputation: 1063Reputation: 1063Reputation: 1063Reputation: 1063
As chrism01 said, no spaces between alias and first quote.

aka alias biglist='ls -alt'

not alias biglist = 'ls -alt'

Alias's are saved in your bash environment until you log out, unless you make them permanent as pointed out earlier.

Last edited by Timothy Miller; 02-19-2017 at 11:50 PM.
 
Old 02-19-2017, 11:50 PM   #5
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.10, Centos 7.5
Posts: 17,700

Rep: Reputation: 2494Reputation: 2494Reputation: 2494Reputation: 2494Reputation: 2494Reputation: 2494Reputation: 2494Reputation: 2494Reputation: 2494Reputation: 2494Reputation: 2494
Like I said NO spaces ....
The 'alias' cmd is a built in for the bash shell.
Which shell are you using
Code:
echo $SHELL
NB: *nix is case sensitive for cmds, args filename , options etc..... so type it exactly like that.

Also, please use code tags as specified here https://www.linuxquestions.org/quest...do=bbcode#code
 
Old 02-20-2017, 12:28 AM   #6
cyfix
LQ Newbie
 
Registered: Feb 2017
Location: Za Warldo
Posts: 9

Original Poster
Rep: Reputation: Disabled
i see

thanks brethren i figured it all out
 
Old 02-20-2017, 01:31 AM   #7
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 13,576

Rep: Reputation: 4341Reputation: 4341Reputation: 4341Reputation: 4341Reputation: 4341Reputation: 4341Reputation: 4341Reputation: 4341Reputation: 4341Reputation: 4341Reputation: 4341
glad to hear that.
Please mark the thread solved if your issue is solved. Also please tell us a few words about the solution you found.
 
1 members found this post helpful.
Old 02-20-2017, 02:28 AM   #8
cyfix
LQ Newbie
 
Registered: Feb 2017
Location: Za Warldo
Posts: 9

Original Poster
Rep: Reputation: Disabled
yes,

for all nooblets:

the simple way i found for using aliases is to permanently add them into the terminal using

{gedit .bashrc} then type in any alias you want and restart the terminal to take effect
 
Old 02-20-2017, 03:43 AM   #9
Shadow_7
Senior Member
 
Registered: Feb 2003
Distribution: debian
Posts: 4,000
Blog Entries: 1

Rep: Reputation: 846Reputation: 846Reputation: 846Reputation: 846Reputation: 846Reputation: 846Reputation: 846
alias is part of bash, the package is bash, the executable is bash.

$ help alias

$ alias -p

$ unalias ls

$ alias ls='ls --color=auto'

alias is likely common among many shells, but it's part of the shell(s).
 
  


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
[SOLVED] Alias command actinide Linux - Newbie 33 08-09-2016 12:41 AM
bash: command works at command line, but not via an alias porphyry5 Programming 3 03-17-2012 03:48 PM
tar command alias command rlg Linux - Newbie 0 03-11-2008 08:21 AM
alias command zeviddalop Linux - Newbie 3 01-12-2005 10:59 PM
unable to route with ip alias using one NIC simayi Linux - Networking 0 10-27-2004 05:45 AM

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

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