Make Your Own Linux Commands

Installing a package/software in linux is easy, if the package is available in linux repository then you just have to use apt/yum command or you can also install using debian/redhat package file and then you can use it’s command to run the program after installation. But sometimes you need to run it using binaries or from it’s source files. Suppose you have your program at /opt/<package>, now if you want to run the program(e.g-android-studio) then first you have to reach to it’s location to run the program file. To make this easy we can make our own command like ls,cd,mkdir which can be executed from anywhere to run your program without going to /opt/<package>. You can also create your own bash scripts and make them run using your own single command.

Recently I wanted to use android studio on my linux, so I downloaded from it’s official website which is a tar(tape archive) file. I extracted it in my /opt directory. Now whenever I want to run android studio I have to first reach /opt/android-studio/bin and execute file. To deal with this problem I decided to make my own command to run android studio directly from anywhere.

Many linux commands you run can be found inside /usr/bin, therefore this path is already available in your PATH variable. To check if /usr/bin is in your PATH or not you can use echo $PATH in your terminal.

As you can see in the picture above that /usr/bin is present in my PATH already.

There can be many methods to make your own commands but I am going to use symbolic links. What I am going to do is create a symbolic or soft link inside /usr/bin which will be mapping my android studio executable script file present inside /opt/android-studio/bin

ln -s -T /opt/android-studio/bin/ /usr/bin/studio

NOTE: You need to use sudo to execute this command

Breaking the command:

ln — Command to make links between files

-s — This flag is used to create symbolic/soft links

-T — This flag is used specify target that means actual file you want to execute, in my case it is /opt/android-studio/bin/

NOTE: Target file must be executable, you can use chmod to make it executable

then in last you need to specify the command name which is studio in my case, remember you also need to include “/usr/bin” before your command name.

In above picture you can see how my own command is executed, now I can run android studio from anywhere.

Similarly, you can make your own bash scripts place them anywhere you want and create a symbolic link inside /usr/bin to make them run using a command.

Thank you for reading this post……hope you learned something from this and enjoyed it.


An avid learner in the field of information security. A self learner and a ctf player sometimes.