Can you create custom aliases for commands?

QuestionsQuestions8 SkillsProDec, 20 2025
0121

Yes, you absolutely can! Creating custom aliases is a great way to save time and make long commands easier to remember.

How to create an alias

You can create a temporary alias right now in your terminal using this syntax:
alias name='command'

For example, let's create an alias called search that runs grep with color highlighting:

alias search='grep --color=auto'

Now, if you use the word search, the system will actually execute grep --color=auto.

Try it yourself:

  1. Create an alias for a long ls command:
    alias ll='ls -lha'
  2. Now type ll and press Enter. You'll see a detailed list of all files (including hidden ones) in human-readable sizes.
  3. Check it with the type command:
    type ll
    It will show: ll is aliased to 'ls -lha'.

Important Notes:

  • Temporary: Aliases created this way only last as long as your current terminal session. If you close the terminal, they disappear.
  • Permanent: To make an alias permanent, you usually add that same alias line to a hidden file in your home directory called .bashrc or .zshrc.
  • Removing: If you want to remove an alias during your session, use unalias, like this: unalias ll.

Give it a try! Create an alias for your favorite command and see how it works. When you're ready, we can continue with the lab to learn how to get official help for these commands.

0 Comments

no data
Be the first to share your comment!