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 find files on Linux There are many options you can use to find files on Linux, including searching by file name (or partial name), age, owner, group, size, type and inode number. By Sandra Henry Stocker Jun 24, 2024 8 mins Linux opinion Linux in your car: Red Hat’s milestone collaboration with exida With contributions from Red Hat and critical collaborators, the safety and security of automotive vehicles has reached a new level of reliability. By Sandra Henry Stocker Jun 17, 2024 5 mins Linux how-to How to print from the Linux command line: double-sided, landscape and more There's a lot more to printing from the Linux command line than the lp command. Check out some of the many available options. By Sandra Henry Stocker Jun 11, 2024 6 mins Linux how-to Converting between uppercase and lowercase on the Linux command line Converting text between uppercase and lowercase can be very tedious, especially when you want to avoid inadvertent misspellings. Fortunately, Linux provides a handful of commands that can make the job very easy. By Sandra Henry Stocker Jun 07, 2024 5 mins Linux PODCASTS VIDEOS RESOURCES EVENTS NEWSLETTERS Newsletter Promo Module Test Description for newsletter promo module. Please enter a valid email address Subscribe