How to open a directory/folder and a URL through Terminal

To Open Directory:

  • To open a Folder from terminal type the following,

    nautilus /path/to/that/folder
    

    or

    xdg-open /path/to/the/folder
    

    i.e

    nautilus /home/karthick/Music
    xdg-open /home/karthick/Music
    
  • Simply typing nautilus will take you file browser,

    nautilus
    

To Open URL:

  • You can type any one of the following in terminal,

    xdg-open http://google.com       
    google-chrome http://google.com                 
    opera http://google.com
    firefox http://google.com
    
  • If you want to open two URL's at the same time then leave some space after the first URL and type the second,

    firefox www.google.com www.gmail.com
    

Note:

  • Linux is case-sensitive, so type the file name correctly.
  • You can also add an alias to short the command,for example if you need openurl instead of x-www-browser you should edit the .bashrc file
    gedit ~/.bashrc
  • In the bottom of the file add the following lines

    alias openurl=x-www-browser
    

    alt text

  • Save and close the file.
  • Now you can open URLs by typing,

    openurl http://google.com
    

Instead of typing all the quotes etc. one could use:

nautilus .

Works with directories containing spaces in their names.


You can just call the aplication. Both Nautilus and Chrome accept path (url) as parameter.

nautilus /directory/subdirectory/subsubdirectory

or

cd /directory/subdirectory/subsubdirectory and then nautilus . (the dot is important -- it says to Nautilus to open the current directory)

google-chrome www.google.com

or

x-www-browser www.google.com -- this command calls the browser set as default (so if your default browser is Chrome, it will open Chrome)

Tags:

Command Line