LinuxQuestions.org
Visit Jeremy's Blog.
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, 09: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, 10:24 PM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,348

Rep: Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749
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 10:26 PM. Reason: dupe typo
 
Old 02-19-2017, 10: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, 10:49 PM   #4
Timothy Miller
Moderator
 
Registered: Feb 2003
Location: Arizona, USA
Distribution: Debian, EndeavourOS, OpenSUSE, KDE Neon
Posts: 4,001
Blog Entries: 26

Rep: Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521
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 10:50 PM.
 
Old 02-19-2017, 10:50 PM   #5
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,348

Rep: Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749
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-19-2017, 11:28 PM   #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, 12:31 AM   #7
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,689

Rep: Reputation: 7274Reputation: 7274Reputation: 7274Reputation: 7274Reputation: 7274Reputation: 7274Reputation: 7274Reputation: 7274Reputation: 7274Reputation: 7274Reputation: 7274
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, 01: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, 02:43 AM   #9
Shadow_7
Senior Member
 
Registered: Feb 2003
Distribution: debian
Posts: 4,137
Blog Entries: 1

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

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

All times are GMT -5. The time now is 12:02 PM.

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