15 command-line aliases to save you time

Some aliases are included by default in your installed Linux distro.
318 readers like this
318 readers like this
3 text editor alternatives to Emacs and Vim


Linux command-line aliases are great for helping you work more efficiently. Better still, some are included by default in your installed Linux distro.

This is an example of a command-line alias in Fedora 27:

default alias fedora.png

The command alias shows the list of existing aliases. Setting an alias is as simple as typing:

alias new_name="command"

Here are 15 command-line aliases that will save you time:

  1. To install any utility/application:

    alias install="sudo yum install -y"

    Here, sudo and -y are optional as per user’s preferences:

    install alias.png

  2. To update the system:

    alias update="sudo yum update -y"

  3. To upgrade the system:

    alias upgrade="sudo yum upgrade -y"

  4. To change to the root user:

    alias root="sudo su -"

  5. To change to "user," where "user" is set as your username:

    alias user="su user"

  6. To display the list of all available ports, their status, and IP:

    alias myip="ip -br -c a"

  7. To ssh to the server myserver:

    alias myserver="ssh user@my_server_ip”

  8. To list all processes in the system:

    alias process="ps -aux"

  9. To check the status of any system service:

    alias sstatus="sudo systemctl status"

  10. To restart any system service:

    alias srestart="sudo systemctl restart"

  11. To kill any process by its name:

    alias kill="sudo pkill"

    kill process alias.png

  12. To display the total used and free memory of the system:

    alias mem="free -h"

  13. To display the CPU architecture, number of CPUs, threads, etc. of the system:

    alias cpu="lscpu"

  14. To display the total disk size of the system:

    alias disk="df -h"

  15. To display the current system Linux distro (for CentOS, Fedora, and Red Hat):

    alias os="cat /etc/redhat-release"

    system_details alias.png

OpenStack enthusiast. Linux and Networking guy. Just trying to give my two cents in this billion-trillion dollar "Open Source" world.


One thing alias is very picky about is that you cannot have any spaces between the alias name and the equals sign, or between the equals sign and the quotes at the beginning of the command.

That's bash, not alias itself. Aliases are just a special kind of bash variables, and you gotta be careful with spaces whenever writing scripts with vars also.

In reply to by Greg Pittman

For number 7, I found a much more helpful way to do that was to add shortnames to your ~/.ssh/config file. That way, the shortnames work with all ssh related tools like scp, rsync, etc. You can also add default user swaps on a personal shortened host basis, too.

I believe install is already a posix command.

Yep, and so is kill, so I wouldn't promote those aliases.

Also, IMHO, aliases should be short: what's more efficient, typing 'process' or 'ps -aux'?
Both are 7 characters long, tab-completion notwithstanding :)

In reply to by Tyler Christian (not verified)

I agree about kill and install which can be a bit problematic and regarding short aliases, i wanted to go with the ones which can be easily used by a beginner and remembered, learning different commands might be a challenge to a new linux user

In reply to by Ricardo J. Barberis


alias updg="for ops in update upgrade; do sudo apt $ops -y; done;

Nice!! Thanks for sharing :)

In reply to by Carlos91 (not verified)

Bash functions are much more flexible than aliases. In particular, aliases can't take arguments.

Some specific quibbles:

alias root="sudo su -"

I'd use "sudo -i".

alias myserver="ssh user@my_server_ip”

The "_ip" suffix seems to imply using an IP address rather than a DNS name. There's rarely a good reason to do that.

alias kill="sudo pkill"

"kill" is already a built-in shell command. Aliasing it to something that uses sudo is a recipe for disaster. If you want "sudo pkill", you should probably just type "sudo pkill".

Several of these aliases are for commands I'd rather just type directly. Of course this is going to vary for different people.

I also agree most of these seem both dangerous and overkill. Why would you ever alias something that uses sudo to not use sudo? Plus everyone should learn/know these commands if they are system administrators.

Don't mean to shut OP down, just my take.

In reply to by Keith Thompson (not verified)

> "kill" is already a built-in shell command. Aliasing it to something that uses sudo is a recipe for disaster. If you want "sudo pkill", you should probably just type "sudo pkill".

You couldn't be more right there - and for a beginner (i.e. someone who actually uses aliases because they're usually on the same host) this is going to be doubly confusing when a desperate `kill -9 $PID` does absolutely nothing...

In reply to by Keith Thompson (not verified)

Correct, i must say kill and install are a bit problematic aliases, so i would just change that to something else. Also, sudo is optional if an experienced user like me is aliasing sudo than i know the consequences and would use it accordingly

In reply to by Gray

The last one should be /etc/os-release which works on any distribution.

Wouldn't this potentially clash when you have different package managers? ie. Using flatpak to install packages from flathub:

flatpak install flathub org.gnome.

Would become:

flatpak sudo yum install -y flathub org.gnome.

I wouldn't recommend using aliases for existing functions like `kill` - this breaks expected functionality: `which kill` prints the path a user who has forgotten about the alias wants to call but it's not what's actually being called so, unless the user remembers to check `alias`, there's going to be some confusion when `kill -9 $PID` has no effect.

What is 'ip -br -c a' supposed to do?

I tried it but see:
'Option "-br" is unknown, try "ip -help".'

-br stands for brief

Below is the man page entry for "ip" command:
Print only basic information in a tabular format for better
readability. This option is currently only supported by ip addr
show and ip link show commands.

In reply to by Gary

when I run one alias in bash it is working fine. But when I enter all aliases in an executable file "#!/bin/bash" none of the aliases is created. Any hint?

when you run the script ex- "./alias.sh", it executes in a sub-shell, you need to run it with "source alias.sh" so that the changes made by script are applied to the current env

In reply to by leder11011 (not verified)

Is there any casual distro where policykit isn't set to allow normal user to ``systemctl reboot''?

Creative Commons LicenseThis work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License.