1

I installed Viber on Ubuntu:

/home/nazar/Software/Viber/Viber.sh

I can run it from terminal specifying this path. I want to achieve some short command as:

viber

For lunching application.

How to solve this issue?

muru
  • 207,228
catch32
  • 1,286
  • 9
  • 32
  • 43

2 Answers2

4

You can create an alias of the full command by running the following in the terminal:

alias viber=/home/nazar/Software/Viber/Viber.sh

Now you can run the script by just typing viber.

Note that this will be working for the current session of the shell only. To make it permanent save it in ~/.bash_aliases (or ~/.bashrc):

$ echo 'alias viber=/home/nazar/Software/Viber/Viber.sh' >> ~/.bash_aliases
$ source ~/.bash_aliases 

The first command will save the alias permanently in ~/.bash_aliases, the preferred file to save aliases. It will create the file if not exists already. The second command will make the alias working from the current shell session.

An alternate method is to create a symbolic link of the executable script in the /usr/local/bin or /usr/bin directory(given they are in your PATH environment variable).

sudo ln -s /home/nazar/Software/Viber/Viber.sh /usr/local/bin/viber

As the directory is owned by user root and group root, make sure /usr/local/bin/viber has execute permission for all others (a+x).

By using any one of the above methods, you can run the script by simply typing viber.

heemayl
  • 93,925
4

Another option is to create a script with that name somewhere on your PATH. This is a little overkill for this specific case; overall heemayl's answer is probably better for you.

First, make the directory ~/bin if you don't have it already:

mkdir ~/bin

Now edit the file ~/bin/viber and save it with the following contents (change the first line if you use a different default shell):

#!/usr/bin/env bash

/home/nazar/Software/Viber/Viber.sh

Finally make the script executable:

chmod +x ~/bin/viber

And now you should be able to run the program with just viber.

TheSchwa
  • 3,860