Aliases provide an easy way to reuse complicated or often-used commands. Credit: Shutterstock I’ve undoubtedly said this before, but the most effective aliases on Linux are those that save you a lot of time or help you avoid typing errors – especially those errors that might cause problems on your system. Aliases allow you to run both complicated and frequently used commands with minimal effort. If you type a command like alias rec=‘ls -ltr | tail -10‘ in your terminal session, you will have created an alias that will display the ten most recently created or updated files in your current directory. This makes it easier to remember what you’ve most recently been working on and to make necessary updates. To preserve your aliases for future use, you can add them to your .bashrc file. If you do this, it’s a good idea to group them at the end of the file so that they’re easier to find, review and modify as needed. On the other hand, some of my techie friends prefer to store their aliases in a separate file and ensure that their shell will source that file whenever they log in by using a command like source aliases or simply . aliases. Note that the word “source” and the single character “.” do the same thing. The list below shows a group of aliases. Some are extremely simple, like the one that allows you to type just a “c” instead of typing the word “clear”. I actually use that one very frequently and appreciate that I only have to type a single letter to clear my screen. One shows the largest files in the current directory, one shows the most recently updated files, and another installs system updates. There are many good reasons to use aliases to simplify commands without losing track of what those commands do. alias big5='du -h | sort -h | tail -5' alias c='clear' alias install='sudo dnf install' alias myprocs='ps -ef | grep `whoami`’V alias myps='ps -ef | grep `whoami` | awk '{print \$2}' alias recent='history | tail -10' alias rec='ls -ltr | tail -5' alias update='sudo dnf upgrade –refresh' You can list aliases with the alias command and, when it’s helpful, sort them or use a sort or grep command to list only those containing certain strings. $ alias | sort | head -2 alias big5='du -h | sort -h | tail -5' alias c='clear' $ alias | grep rec alias recent='history | tail -10' alias rec='ls -ltr | tail -5' If you want an alias to go away temporarily for some reason, you can use the unalias command. As long as your alias is included in your .bashrc file, or a file that you source to make your aliases available to you, they’ll all be easily ready when you need to use them again. $ unalias big5 The aliases below can save you a little time when you need to back up a directory or two. Just remember that aliases will not be available on your next login unless you save them in your .bashrc or separate aliases file. alias up='cd ..' alias up2='cd ../..' When an alias won’t cut it Aliases are extremely useful, but they have their limitations. When a task that you need to perform periodically is too complex for an alias because of various options that will change from time to time, consider writing a script instead. Wrap-up Aliases provide an easy way to reuse complicated commands and those that you use often without much effort. Related content how-to How to examine files on Linux Linux provides very useful options for viewing file attributes, such as owners and permissions, as well as file content. By Sandra Henry Stocker Oct 24, 2024 6 mins Linux how-to 8 easy ways to reuse commands on Linux Typing the same command again and again can become tiresome. Here are a number of ways you can make repeating commands – or repeating commands but with some changes – a lot easier than you might expect. By Sandra Henry-Stocker Oct 15, 2024 5 mins Linux news SUSE Edge upgrade targets Kubernetes and Linux at the edge SUSE Edge 3.1 includes a new stack validation framework and an image builder tool that are aimed at improving the scalability and manageability of complex Kubernetes and Linux edge-computing deployments. By Sean Michael Kerner Oct 15, 2024 6 mins Edge Computing Linux Network Management Software how-to Lesser-known xargs command is a versatile time saver Boost your Linux command line options and simplify your work with xargs, a handy tool for a number of data manipulation tasks. By Sandra Henry Stocker Oct 11, 2024 6 mins Linux PODCASTS VIDEOS RESOURCES EVENTS NEWSLETTERS Newsletter Promo Module Test Description for newsletter promo module. Please enter a valid email address Subscribe