Monday, April 29, 2024
4
rated 0 times [  4] [ 0]  / answers: 1 / hits: 1536  / 3 Years ago, sat, october 9, 2021, 2:33:44

I am a beginner who just installed ubuntu 18.04 just fews days ago, and I am currently studying how to do everything from the terminal.



Chrome is a necessary application for me, for example, and I have already known how to run it by using the command line like/opt/google/chrome/chrome, which is the default path to chrome. But for Firefox, which was installed initially, I just need to type firefox and the browser works just fine.



And now I'm wondering if I can open Chrome in a similar way rather than typing the complicated path. Anyone has ideas?


More From » command-line

 Answers
4

There are different ways to customize the name by which you can launch an application:



Method 1 - Create an alias Next to all options given in the other answers, a convenient way to make it easier for you to start Chrome from the command line, and which does not require to be administrator, is to create an alias:



alias chrome=/opt/google/chrome/chrome


Add this command to your .bashrc file (already, some other aliases are defined there), so it is available anytime.



Method 2 - Create a symlink also does not require root permissions: you can create your personal bin folder in your home directory. There, create a symbolic link to the executable of Google Chrome as:



ln -s /usr/bin/google-chrome ~/bin/chrome


On Ubuntu, a local bin folder is automatically added to the PATH. After creating the bin folder, it will take only effect after your next log in.



Method 3 - Create a systemwide symlink If the change is to affect all users, create an appropriately named symlink in /usr/bin. As mentioned in the other answers, a symlink may already be available. If you prefer the shorter name chrome, feel free to create an additional symlink as



sudo ln -s /usr/bin/google-chrome /usr/bin/chrome


or rename the existing symlink.



Method 4 - Create a wrapper script. A simple executable bash script placed in your local bin folder or in urs/bin or another folder in your path would, for practical purposes, equally work. When executed, the script in turn calls the application by specifying its full pathway. A wrapper script is particularly suited if there is a need to customize the working environment prior to launching the application. Thus, the script could change the working directory, set or change environment variables, etc.


[#4141] Saturday, October 9, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ousear

Total Points: 395
Total Questions: 114
Total Answers: 89

Location: Jordan
Member since Thu, Aug 5, 2021
3 Years ago
ousear questions
Tue, Sep 27, 22, 03:29, 2 Years ago
Thu, Nov 25, 21, 00:51, 2 Years ago
Tue, Feb 22, 22, 17:47, 2 Years ago
Wed, Jul 6, 22, 14:55, 2 Years ago
;