5 Useful Aliases to Help Your Development Life

Majority of software developers make use of aliases to make their daily work easier. In general, an “alias” is an alternate name for someone or something. It serves many different purposes, such as to conceal a person or organization’s real identity or make something easier to recall or memorize. In the world of computer programming, an alias is also an alternative name or code for a defined data object that is easier to understand and remember.

What is an alias?

Through aliasing, one can access particular data location using different symbolic names in the program. Imagine have to type a long set of texts and characters for the same commands you use every single day. Isn’t it tiresome? Wouldn’t it be better if you could use some sort of ‘shortcuts’ for these commands?

Aliases are mainly used for abbreviating a system commands as well as for adding default arguments to existing commands.

 

Example:

alias copy=’cp’

 

This alias means that when the command “copy” is read in the shell, it will be replaced with “cp” and to execute the same command. No need to type the entire word!

An alias is basically a code (made with texts) used in place of longer and more complex commands. It can be as simple as a one-letter code or a combination of letters.

Creating aliases is one of the easiest and helpful strategies used custom software development. Without aliases, it’s hard to imagine creating programs with long strings of commands. It absolutely saves time, effort, and energy.

 

How to Create an Alias

Creating aliases for computer commands is easy. On the terminal, simply type ‘alias’ and press <enter> and a list of available aliases on your machine will come up.

You will notice that there’s a common pattern used in creating aliases:

alias alias_name=”command_to_run”

You can actually create your own aliases for different commands. Most programmers like to save their aliases in <.bashrc file> to make them readily available every time they log in.

Follow the following syntax to create a Linux alias:

  1. Type <alias> in your terminal screen  
  2. Type your preferred name or code of the alias (could be an abbreviation, word, or combination of letters)
  3. Type the equal (=) sign. No spaces in between the alias and the command
  4. Then type the command/commands you want. Be careful with this step. Make sure you enter the exact command array. Note that this can be a simple command, or can be a powerful combination of commands.

 

Example:

alias alias_name=”command_to_run”

 

alias logs=”cd /web/apache/htdocs/devdaily/logs”

If you want to get rid of an alias, just use the unalias command:

unalias logs

This means when you enter < logs>, you will see your daily logs without having to type such a lengthy command on your terminal screen. Unix shell is highly programmable, thus, you can you can create your own aliases to do just about anything.

 

5 Useful Aliases for Everyday Programming

1.Entering/Making a directory

alias mkcd=’foo(){ mkdir -p “$1”; cd “$1” }; foo ‘

 

2.  Showing your IP address

alias myip=”curl http://ipecho.net/plain; echo”

 

3. Opening files with admin access

sudo vim filename ️ svim filename

 

4. Updating your server

alias update=’sudo apt-get update && sudo apt-get upgrade’

 

5. Viewing large directory listings

alias lsl=”ls -lhFA | less”

 

Important Reminders when Using Aliases

 

Aliases are no doubt a powerful instrument that make you do a lot and simplify things. However, like any other programming technique, it should be used carefully.

  • There is a possibility of overriding some system application by accident. Make sure that your alias is not the same with any important command. Otherwise, it could lead to potential system errors. For example, some programmers use “gcc” as an alias for “git commit –amend” but it could also mean Gnu C Compiler, which is one of the most instruments for compiling software.
  • More aliases require more time for your <shell>rc file to start up. Use aliases for the most commonly used commands you use every day, not the ones you occasionally use. Otherwise, your aimed productivity goals might just be killed by the long terminal startup.
  • Whenever possible, the “purity” of a computer system should be maintained to lessen the probability of your computer setup being broken.

 

Using aliases in computer programming definitely makes your life easier. If you’re after productivity, you should learn to incorporate them in your daily work. Nonetheless, you should be a little careful with using aliases as it does have a few downsides too.