Progress: 0/62 (0%)

⚡ Aliases and Custom Commands

Aliases and Custom Commands

Aliases are like shortcuts or nicknames for longer commands. Custom commands let you create your own mini-tools to make life in the terminal faster. Think of it as creating your own "cheat codes" for the shell.

Creating Simple Aliases

Syntax:

alias shortname='long command here'
alias ll='ls -alF'

Now, instead of typing ls -alF every time, just type ll.

alias

Use this command to check your current aliases.

Making Aliases Permanent

Aliases created in the terminal disappear when you close the shell. To make them permanent, add them to your ~/.bashrc or ~/.bash_aliases file:

echo "alias ll='ls -alF'" >> ~/.bashrc
source ~/.bashrc

The source ~/.bashrc command reloads the file without restarting the terminal.

Custom Commands (Mini Scripts)

Sometimes, you want a command that does multiple things. Create a script file:

nano ~/myscript.sh

Example script:

📌 Example:
#!/bin/bash
echo "Starting backup..."
tar -czvf ~/backup_$(date +%F).tar.gz ~/Documents
echo "Backup done!"

Make it executable:

chmod +x ~/myscript.sh

Run it anywhere if you add its folder to PATH:

~/myscript.sh

Real-life analogy

Aliases are like shortcuts on your phone home screen for apps you use every day. Custom scripts are like creating your own app that does several things with one tap.