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
  • 197,895
  • 55
  • 485
  • 740
catch23
  • 1,254
  • 9
  • 31
  • 42
  • This post is contain everything you need

    http://askubuntu.com/questions/37401/how-do-i-add-a-launcher-for-sh-applications

    –  Apr 29 '15 at 23:05
  • 1
    If you want to run Viber.sh just by typing in terminal, then add /home/nazar/Software/Viber/ to your $PATH variable. This post explains how to do it. If you find this useful, don't forget to upvote the helpful answers there – Sergiy Kolodyazhnyy Apr 29 '15 at 23:25
  • Or put the script in a more standard location such as ~/bin/viper.sh (does not require root access) or /usr/local/bin/viper.sh (requires root access). – Panther Apr 30 '15 at 01:44

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
  • 91,753
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,820