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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
02-19-2017, 10:44 PM
|
#1
|
LQ Newbie
Registered: Feb 2017
Location: Za Warldo
Posts: 9
Rep: 
|
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?
|
|
|
02-19-2017, 11:24 PM
|
#2
|
LQ Guru
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,425
|
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
|
|
|
02-19-2017, 11:45 PM
|
#3
|
LQ Newbie
Registered: Feb 2017
Location: Za Warldo
Posts: 9
Original Poster
Rep: 
|
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?
|
|
|
02-19-2017, 11:49 PM
|
#4
|
Moderator
Registered: Feb 2003
Location: Arizona, USA
Distribution: Debian, EndeavourOS, OpenSUSE, KDE Neon
Posts: 4,027
|
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.
|
|
|
02-19-2017, 11:50 PM
|
#5
|
LQ Guru
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,425
|
Like I said NO spaces ....
The 'alias' cmd is a built in for the bash shell.
Which shell are you using
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
|
|
|
02-20-2017, 12:28 AM
|
#6
|
LQ Newbie
Registered: Feb 2017
Location: Za Warldo
Posts: 9
Original Poster
Rep: 
|
i see
thanks brethren i figured it all out
|
|
|
02-20-2017, 01:31 AM
|
#7
|
LQ Addict
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 23,652
|
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.
|
02-20-2017, 02:28 AM
|
#8
|
LQ Newbie
Registered: Feb 2017
Location: Za Warldo
Posts: 9
Original Poster
Rep: 
|
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
|
|
|
02-20-2017, 03:43 AM
|
#9
|
Senior Member
Registered: Feb 2003
Distribution: debian
Posts: 4,137
|
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).
|
|
|
All times are GMT -5. The time now is 02:40 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|