Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linux equivalent of the Mac OS X "open" command [closed]

People also ask

Is there an open command in Linux?

A quick guide to the `open` command, used to open files, directories and applications. I use it all the time to open the current directory: open .

Are macOS commands the same as Linux?

In general, both will have the same core commands and features (especially those defined in the Posix standard), but a lot of extensions will be different. For example, linux systems generally have a useradd command to create new users, but OS X doesn't.

Does Mac OS X run on Linux?

Mac OS X is based on BSD. BSD is similar to Linux but it is not Linux. However a big number of commands is identical.

Does Mac use Linux commands?

The command line functionality on Mac and Linux are indeed similar as OS X has a flavour of UNIX (called Darwin) underneath the GUI that you see. The default shell on OS X is bash, so if you're familiar with that you will adjust nicely. On a Mac, the default command line application is Terminal.


You could try xdg-open, most Linux distros have it. It will open default associated app for your file.

FYI https://portland.freedesktop.org/doc/xdg-open.html


The equivalent you are looking for is xdg-open, which can be used in the same way as OS X's open command. For example:

xdg-open ~/Documents/Chubby_Bubbies.odt

However, this is really hard to type quickly and accurately. Instead, you should make an alias to xdg-open, which makes the process much quicker.

Of course, you can alias it to open to make it match OS X (you can pick anything you want), but personally, I use the right square bracket (]) for my shortcut for speed reasons. To use this, add the following to your .bashrc file:

alias ']'='xdg-open'

Then, to open any resource, use it like any of these examples:

] www.google.com
] file.txt
] ~/Pictures
] ssh://myserver.local/home/jeremy

Also this lets you open a file browser (e.g. Nautilus) in the current directory:

] .

From experience I have found that one-letter aliases work best for the above shortcut. After all, the goal is efficiency. And you can go back and make the same alias on OS X — I leave that as an exercise to the reader. :-)


I just sorted this out myself so thought I would write down how I did it, which is specifically relevant to what Suan asked. These steps allow you just type "open " and not your terminal covered in messages you don't need:

Create a script called open in ~/bin, the content is just:

xdg-open "$1" &> /dev/null &

Save and close the script, then type "source .profile" (or .bash_profile if relevant). Thats it so typing "open Music" will open your music folder in the nautilus GUI and shouldn't enter anything onto your terminal.


Traditionally, you can use the "see" command. Which just uses run-mailcap. This will work without Gnome and X etc.

man see

gnome-open


If you have your mimes setup correctly, you can use mimeopen. Check out its man page, since it has some useful options.