13

I can use compgen -a to list all the aliases:

$ compgen -a
egrep
fgrep
grep
l
la
ll
ls

l, la and ll are defined in my ~/.bashrc:

# some more ls aliases
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'

What command can I run to see what an alias expands to? I have found the whatis, whereis and which, but they don't do what I want.

3
  • The command you probably want to use is type which you can use on any command. If your command is an alias or function, type tells you the definition; if it's an executable, you get the path; if it's superseeded by a shell built-in, it will tell you so. Available in bourne shell and successors.
    – Philippos
    Commented Jul 14, 2017 at 14:25
  • also, if you use alias without arguments, you'll get list of aliases in the reusable form 'alias NAME=VALUE' on standard output
    – Sundeep
    Commented Jul 14, 2017 at 15:19
  • @Sundeep Amazing..I have not realized this..
    – yode
    Commented Jul 14, 2017 at 15:30

1 Answer 1

22

You can use alias (without equals) or type

$ alias l
alias l='ls -CF'

$ type l
l is aliased to `ls -CF'
1
  • The first option alias l gave me -bash: alias: l: not found. The second type l gave me useful information.
    – WolfLink
    Commented Sep 29, 2021 at 21:26

Not the answer you're looking for? Browse other questions tagged .