How to open new Web browser tab from command line in Linux

Launching a Web browser isn't a big deal - all you have to do is to click its icon. Alternatively, you can also easily launch a Web browser from the command line. But what about a new tab?

While it's a cake walk to open a new tab from within the Web browser window, do you know how you can do the same from the command line? If your answer is no, then you don't have to worry as in this article, we will quickly let you know how to do this.

But before that, it's worth mentioning that all commands/instructions mentioned in this tutorial have been tested on Ubuntu 14.04LTS.

How to launch a Web browser tab from command line

The tool that'll help you do this is xdotool. If you are hearing about this tool for this first time, then you should first know what it does.

Here's what its man page says: "xdotool lets you programatically (or manually) simulate keyboard input and mouse activity, move and resize windows, etc."

So, with that in mind, here's the command that will let you open a new Chrome browser tab:

xdotool search --onlyvisible --name 'Chrome' windowactivate --sync key --clearmodifiers --window 0 ctrl+t

Of course, not everybody uses Chrome. So you can enter the name of your browser in the command (in place of 'Chrome'). For example, the following command will open a new tab in Firefox:

xdotool search --onlyvisible --name 'Firefox' windowactivate --sync key --clearmodifiers --window 0 ctrl+t

For more information on xdotool, head to its man page.

Via: Askubuntu

Leave a Comment