1

This may seem like a stupid question.

I'm using Ubuntu 15.10 with GNOME Terminal 3.16.2. When I was new to the system, I often typed 'l' or 'la' instead of 'ls' to list files, and would then be told that these were not valid commands. I obviously then typed 'ls' properly. Now I notice that typing 'l' and 'la' do the same thing as 'ls'.

What's going on here? Has the terminal learnt the common mistakes that I make, and made aliases to account for them, or is this a new feature that I've installed without realising?

  • Are they aliases? type la will help. Are they links? /bin/ls -l $(type -p la ). Some programs behave differently depending on the name (argv[0]). – waltinator Apr 09 '16 at 20:37

2 Answers2

1

When you call l or la, you basically call aliases:

l='ls -lah'
la='ls -lAh'

You can check all aliases, currently configured in your system by running alias. It may be good to have some self-learining mechanism that will remember your typos an fix them, but for now it's just pre-configured aliases.

Related question on: Unix&Linux

kirill-a
  • 251
0

Shell itself doesn't have capability to do spellchecking for the user. What you have with la and l is aliases. In the .bashrc file you can set alias for any command. For instance, if I often mistype pwd command to print working directory, I'd use this in my .bashrc file:

alias pdw='pwd'

The aliases l and la should exist in bash shell by default and I don't see a reason why they wouldn't work for you before. If you are a user on a machine who has a different administrator , then it's likely he or she disabled or enabled those.

There is sl command , which is not included by default in Ubuntu, but shows an animation of steam locomotive (hence sl name) when you mistype ls. This however is something that needs to be manually installed.

If a command is a complex combination of other commands, you could always use a function, like so

sl()
{
  echo "You've mistyped ls again"
  echo "Don't rush" 
}

If you are writing a script, you can sort of do spell checking (and much more) on that using shellcheck

Sergiy Kolodyazhnyy
  • 105,154
  • 20
  • 279
  • 497