Open jbeadling opened 11 months ago
Aliases are custom shortcuts that you can make for the CLI. They allow you to create your own shortcuts for commands that might be long for you to type out. In Unix systems aliases are typically defined and managed in the shell environment. You can make aliases permanent by adding the shortcuts to your shell's config file (.bashrc, .zshrc, etc).
An example would the alias l, which is the shortcut for the command 'ls -lah', so now the CLI all you have to type is l and the shell will interpret that as 'ls -lah'.
In the screenshot below I make an alias for the grep command. This grep commands searches for error or warning in all the files ending in .log in the /var/log directory. The alias is: alias loggrep='grep -iE "error|warning" /var/log/*.log'
I now make the alias permanent by adding it to the .zshrc file and then sourcing the shell.
Finally I apply the new alias without restarting or opening a new shell by sourcing. I simply type source .zshrc and typed the alias to make sure it works as shown below
Summary
Learn how to create aliases for frequently used shell commands to enhance productivity and reduce repetitive typing. This task is crucial for anyone who spends much time in the shell environment.
Description
Objective: Understand the concept of command aliases and learn how to create them to simplify complex or frequently used commands.
Scope:
Learning Tasks
What are Aliases:
How to Create a Simple Alias:
alias
command.How to Make an Alias Persistent:
Hands-on Practice:
alias ll='ls -l'
..bashrc,
.zshrc
).Troubleshooting:
Learning Goals
Priority