From Frustration to Efficiency: My Experience with Aliases on Mac Terminal

From Frustration to Efficiency: My Experience with Aliases on Mac Terminal

Realm Hacking

8 min read

Greetings Realmers πŸ‘‹. This is d3adr1nger back with a bite-sized treat of tech wizardry. Today, we're diving into a secret corridor of the Mac Terminal – a warm alley full of surprises known as aliases. Well... let's face it, I'm all about getting things done with minimal effort. Why type a paragraph when a word will do? That's the beauty of aliases – they're our sneaky shortcut in the command-line realm, turning tedious typing into a one-hit wonder. So, for my fellow efficiency enthusiasts (and yes, the proudly lazy among us), let's dive into the art of aliasing!

A command alias in computing is essentially a shortcut to run a specific command or set of commands. Think of it as a nickname you give to a longer command or a series of commands, so you don't have to type out the entire thing every time you want to execute it. In the context of the Mac Terminal, which typically runs the Zsh (Z Shell) as its default shell since macOS Catalina, aliases are incredibly handy for saving time and reducing repetitive typing.

How-To: Crafting Your First Alias on Your MacBook

So let's get down to business ( 🎢 I don't got no time to play around, what is this? 🎢). Creating your first alias on your MacBook is like a walk on the park. Here’s a step-by-step guide to make you an alias pro in no time:

  1. Open Terminal: Let's start by firing up the Terminal. You can find it in your Applications folder under Utilities, or just hit Command + Space and type "Terminal". Or if you've followed my iTerm2: Your Mac's Terminal, Upgraded! then feel free to follow using your ultra cool customized iTerm2. πŸ€“
  2. Access the Zsh Configuration File: Now, we need to edit your Zsh configuration file. This is where the magic happens. Type open -e ~/.zshrc and hit Enter. This command will open your .zshrc file in TextEdit (or your default text editor). Or if you are an ultra nerd like me you can type: nano ~/.zshrc to open up the config file directly in your terminal. ( You can become a nuclear nerd and use Vim too, but let's play safe for now πŸ„).
  3. Let’s Make an Alias: Time to create your very own alias. Think of a command you use often. For beginners, let’s start with something simple. Say, we want to create an alias for listing files in a detailed view. Normally, you’d type ls -l. We'll make an alias ll for this. In your .zshrc file, simply add a new line at the bottom: alias ll="ls -l"
  4. Save and Close the File: After typing in your alias, save the file and close the editor. ( If you chose to open the file with nano, you can hit ctrl + x then just y and enter).
  5. Activate Your Alias: For your alias to take effect, you need to reload your .zshrc file. Go back to the Terminal and type source ~/.zshrc. This command refreshes your configuration, activating the alias.
  6. Test Your New Alias: It's showtime! In the Terminal, type ll and hit Enter. VoilΓ ! You should see a detailed list of files in your current directory, just as if you had typed ls -l.

That was it... How easy was that? But wait... It can become much easier!

Creating Aliases with one command at a time

We can deploy our scripting knowledge and come up with a cool command that will create an alias on the spot. Let's see, let's say that we want to create an alias for quickly editing our zshrc.

The command is: nano ~/.zshrc. Ok not that bad, but who really wants to remember the name of the file? it would be nice if we could just type something like: edit-zsh and have it pop up.

#Command No1
echo alias edit-zsh="'nano ~/.zshrc'"  >> ~/.zshrc

#Command No2
echo alias sauce="'source ~/.zshrc'"  >> ~/.zshrc

#For the last time run to be able to run the aliases on the same terminal
source ~/.zshrc

Break down of the command

  • echo: This command is used to output the text that follows.
  • alias edit-zsh="'nano ~/.zshrc'": This is the text that will be added to your .zshrc file. It's the definition of your new alias.
  • >> ~/.zshrc: This part appends the output of the echo command to the end of your .zshrc file.

After running this command, you'll need to either restart your Terminal or source your .zshrc file with source ~/.zshrc for the changes to take effect. Once you do that, typing edit-zsh in your Terminal will execute nano ~/.zshrc.

At the end of the config file that has been opened with nano the following lines.

alias edit-zsh='nano ~/.zshrc'
alias sauce='source ~/.zshrc'

So from now on, you can just restart your terminal by typing sauce πŸ₯«.

Aliases you may like

Since you now have been taught how aliases work you are ready to play around and experiment on your own. Since every crazy experience needs a spark, here is a list of useful aliases to get you started!

Navigation Shortcuts

- alias back="cd ..": Move up one directory level.
- alias back2="cd ../../": Move up two directory levels.
- alias home="cd ~": Go to your home directory.
- alias root="cd /": Go to the root directory.


- alias ll="ls -lah": Show an extended list of files, including hidden ones.
- alias la="ls -A": List all files, excluding . and ...

File Management

- alias cpi="cp -iv": Copy files with interactive mode and verbose output.
- alias mvi="mv -iv": Move files interactively with verbose output.
- alias rm="rm -i": Remove files with confirmation prompt.

Quick Access

- alias docs="cd ~/Documents": Navigate to the Documents folder.
- alias downloads="cd ~/Downloads": Go straight to Downloads.

Git Shortcuts

- alias gs="git status": Check the status of your Git repository.
- alias ga="git add": Add files to your Git repository.
- alias gc="git commit": Commit changes in Git.
- alias gp="git push": Push changes to a remote Git repository.
- alias gi="git init": Initialize folder as a new repo
- alias gci="ga . && gc -m 'Initial Commit' && gs": First Initial Commit of project. 

Here you see for the first time a real glimpse of the power of aliases by chaining aliases to perform a task otherwise quite large.

Aliases for hackers

Nmap Scans

- alias nmapf='nmap -T4 -F': Fast Scan
- alias nmapa='nmap -T4 -A -v': Full Scan 
- alias nmapp='nmap -p': Port Scan

Network Requests

- alias curlv='curl -v': Curl with verbose output
- alias get='curl -X GET': HTTP GET
- alias post='curl -X POST': HTTP POST


- alias ffind='find . -type f -name': Find files
- alias grep='grep --color=auto': Grep with color

SSH and Networking

- alias sshv='ssh -v': SSH with verbose logging
- alias ncl='nc -lvnp': Netcat listener

🐍 Python Server

Love that one:

- alias pyserv='python -m SimpleHTTPServer': Start a simple HTTP server

Always keep in mind that aliases are a personal choice and should fit your workflow. You can customize these aliases to suit your preferences and the specific tasks you perform regularly in penetration testing.

Finishing Up: Your Command-Line, Your Rules

And there you have it, Realmers – a whirlwind tour through the enchanting world of aliases in the Mac Terminal. From the basics to some nifty hacker-style shortcuts, we've covered a lot of ground. Aliases are more than just shortcuts; they're a reflection of your unique style and approach to navigating the digital realm. They're about making your command-line experience not just faster, but also a lot more fun.

Remember, the list of aliases we explored is just the beginning. The real magic happens when you start creating aliases that fit your specific needs. Your Terminal is your playground, and with aliases, you're the one setting the rules. So go ahead, experiment, mix and match, and maybe even come up with something completely out of the box.

In the end, whether you're a coding newbie, a seasoned developer, or a stealthy hacker, aliases can make your life in the Terminal smoother, more efficient, and let's be honest – a whole lot cooler. So, keep exploring, keep tweaking, and most importantly, keep having fun with it. Until next time, this is d3adr1nger signing off. Happy aliasing, and stay curious!

πŸš€ Spread the Love & Support the Realm

Hey there, fellow Realmer! If this guide illuminated a new path in your coder/hacker journey, your support would mean a lot. Every bit of magic helps.

Spread the Love

πŸ‘‘ Crown & Share: If you found value in this post, please give it a crown and share it with your fellow coder/hacker enthusiasts. Spreading knowledge is what Sudorealm is all about! Fun fact the Author with the most crowns inside a realm will be crowned as the Realm King! 🀴

πŸ†‡ X Shoutout: Feeling extra grateful or have some cool feedback? Drop me a shoutout on Twitter – I'd love to hear from you! d3adR1nger on X

πŸ’¬ Join our Discord Server: Join the Sudorealm Discord Server connect with fellow enthusiasts and chat about everything that fascinates you! From new blog post suggestions to seeking support on tricky tutorials. Come, share your ideas, and let's grow together! πŸš€πŸŒ

Support the Realm

πŸ› Affiliate Treasures Below: Dive into the depths below the post to uncover some affiliate products I've curated just for you. It's a great way to support the realm and discover some nerdy treasures.

Affiliate Links

Check out what d3ad R1nger suggests for From Frustration to Efficiency: My Experience with Aliases on Mac Terminal!

    No affiliates available for this post!