linux

Bash Aliases

How to create bash aliases for commands you type often, remove them with unalias, and a few shortcuts for git, ls, mkdir, and rm to get you started.

Bash aliases turn long, repetitive commands into short ones you can actually remember. Here’s how to create them.

What is a bash alias

An alias is a shortcut for a command. You declare one with alias alias_name="command". For example, this alias lists hidden files and directories: alias lm="ls -la"

Note: don’t put spaces around the =.

Useful bash aliases

  • git init (initializing git)
bash
alias gi="git init"
  • git push master (pushing files to GitHub)
bash
alias gpm="git push your_repo_name master"
  • listing files vertically
bash
alias l="ls | more"
  • Creating directories with a shortcut
bash
alias n="mkdir"
  • Removing Directory
bash
alias r="rm -rf"
  • Removing an Alias
bash
unalias _alias_name