r0str0 avatar

Alias - a command that saves you time

r0str0

Published: 24 Mar 2021 › Updated: 24 Mar 2021Alias - a command that saves you time

Alias - a command that saves you time

Alias

You may be using aliases without knowing it if you use Linux, since a command as common as ll is an alias that already comes by default in distributions like Ubuntu.

alias ll='ls -alF'

Alias is an old cross-platform command that in our beloved Unix has inherited it with zsh and bash.

Alias is by definition a command for command line interpreters (shells), where a word or string is replaced by another string.

Alias is used to abbreviate or add default arguments to a commonly used command.

Alias Syntax

alias.png

To display the system aliases in Debian distributions, a alias is sufficient for all other unix distributions alias -p.

alias [-p] [name[=value] ... ]

Use of aliases

alias name="value"

delete an alias

unalias name="value"

Permanent alias

The use of aliases depends precisely on the use that we give him at session level, when you create an alias with the previous syntax, it is created for the active session, but if we close session or we restart the pc, these aliases will be erased.

If we want the aliases to be saved we will have to introduce them in the hidden file ~/.bashrc.

With our favorite editor we will do a sudo nano ~/.bashrc to edit it and add our aliases. In any part of the document with this syntax alias name='value'.

Examples

With a simple r and enter I am root

alias r='sudo -i'

root.png

If we want to generate a strong password under console I have programmed xxx and I get the password

alias xxx='openssl rand -base64 20'

base64.png

To clear the cache memory in our Debian based distributions.

alias mem='sudo -i && sync && echo 3 > /proc/sys/vm/drop_caches'

So common in our systems

alias update='sudo apt update && sudo apt upgrade'

To know our public ip

alias ip='curl ipinfo.io/ip'

To view our open ports

alias p='netstat -tulanp'

The use of aliases is limited only by our imagination or needs, it is a very useful command for those who live in bash.

Leave Alias - a command that saves you time to:

Written by

#Linux #Hive #Bitcoin

Read more #palnet posts


Best Posts From r0str0

We have not curated any of r0str0's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.

More Posts From r0str0