No spaces around =, and wrap the value in single quotes. A one-line function needs a space after { and a ;
before }.
Inspect
Command
What it does
alias
all aliases in this shell
alias ll
one alias: alias ll='ls -alF'
type ll
what the name points to: alias, function, or program
type -a ls
every match under this name; the first one runs
type duh
full function definition
On Ubuntu, type -a ls prints the alias, then /usr/bin/ls and /bin/ls. Both paths point to the same file: /bin
is a symlink to /usr/bin.
Bypass and remove
Command
What it does
\ls
run without the alias
command ls
bypass both alias and function
unalias ll
remove an alias for the rest of the session
unalias -a
remove all aliases in this shell
unset -f duh
remove a function
exec bash
fresh shell from what is currently in your files
When names collide, lookup order is: alias, function, Bash builtin, then external program. source doesn’t remove
an alias deleted from the file — it only adds or overwrites. exec bash reads everything from scratch, but drops
unexported variables from the current session.
Check what loads
Command
What it does
grep bash_aliases ~/.bashrc
whether ~/.bash_aliases is sourced
bash -lic 'type ports'
whether the alias loads on SSH login
ls ~/.bash_profile
whether a file exists that makes SSH login skip .profile