If you are like me, you will often find yourself typing long, bulky, and hard-to-remember commands in the Linux terminal, and if not, I will almost always find myself searching the bash history for a long command I typed earlier. If you are also like me, this is where bash aliases come in handy. Bash aliases are like shortcuts, short, quick replacements for long, bulky commands. For example, you can use rmopwrt
instead of opkg remove --force-remove --force-removal-of-dependent-packages ppp ppp-mod-pppoe odhcpd-ipv6only dnsmasq hostapd-common luci luci-ssl-openssl luci-base lua luci-app-firewall luci-lib-ip luci-lib-jsonc luci-lib-nixio luci-proto-ipv6 luci-proto-ppp luci-theme-bootstrap uhttpd uhttpd-mod-ubus
. In this post, I will show you how to create bash aliases in Linux, so you can save time on the command line, and be more productive.
Creating Bash Aliases
Creating bash aliases is very easy and straightforward. The basic command is as follows:
BASH SHELL
alias whatever_you_want_your_alias_to_be_called="command_to_run"
However, like always, make sure not to use spaces in the name, else Linux will think it is a command argument, and the alias
command does not take any. When you create an alias, you type “alias”, followed by your alias name, an equal sign without spaces, and then, without spaces, in quotes, what command the alias should run. In the case above, running whatever_you_want_your_alias_to_be_called
will do the same thing as running command_to_run
.
Let us try another example.
BASH SHELL
alias myip="hostname -I"
When you run myip
, you will get the same output as running hostname
-I
.