LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-04-2020, 05:41 AM   #1
SomeLinuxUser
LQ Newbie
 
Registered: Mar 2020
Posts: 21

Rep: Reputation: Disabled
Does there exist an 'Open' command-line utility similar to MacOS?


In MacOS, the utility 'open' will detect the relevant program with which to open the target: default text editor, image viewer etc.

Does there exist such a thing in Linux where the user can specify with which program to run which file types?
 
Old 03-04-2020, 06:14 AM   #2
PasBern
Member
 
Registered: Dec 2009
Location: Near Frankfurt, Germany
Distribution: OpenSUSE Leap 15.5, MacOS
Posts: 122

Rep: Reputation: 2
Hello,

I am not sure if I completely understand your question.

When you are in a graphical environment in Linux (Gnome, KDE, etc.) and you use your file browser, you can choose with which application to open a file. Moreover, you can also set the default application associated with the file type in question.

Select the specific file, do a right-click and then choose "Open with". In Gnome's default file manager Nautilus, Dolphin from the KDE desktop environment should do the same as should all other graphical file browsers, you will be presented a list of suggested applications.

The preferred one is not among them, then choose a different one. There is also the option to set a specific program as the default option.

Does this answer your question?


There are also programs, KDE System Settings is the only one that I have in my memory, there are others as well, where you can set default applications for all kinds of file types (as well as icons). You can play around with that, but I remember I spent a lot of time, several hours, as pretty much all imaginable file types for a desktop system are listed there.

Last edited by PasBern; 03-04-2020 at 06:17 AM.
 
Old 03-04-2020, 06:15 AM   #3
yancek
LQ Guru
 
Registered: Apr 2008
Distribution: Slackware, Ubuntu, PCLinux,
Posts: 10,551

Rep: Reputation: 2498Reputation: 2498Reputation: 2498Reputation: 2498Reputation: 2498Reputation: 2498Reputation: 2498Reputation: 2498Reputation: 2498Reputation: 2498Reputation: 2498
The link below discusses several options which can be used to do this. Methods vary to some extent based upon which Desktop Environment and/or distribution of Linux you are using. You failed to mention that in your post so the link below is a how-to on Ubuntu. If you're using something else, an online search with that distribution name should provide you with more specific results.

https://www.howtogeek.com/117709/how...ubuntu-4-ways/
 
Old 03-04-2020, 06:25 AM   #4
SomeLinuxUser
LQ Newbie
 
Registered: Mar 2020
Posts: 21

Original Poster
Rep: Reputation: Disabled
Thanks for your responses!

Sorry, I should have clarified - I am running Linux Mint Tricia (19.3), with I3 gaps as the window manager.

I was more after a command line solution, since I mostly navigate around using the command line. So I was wondering if there was a utility with a config file for example such that when I type 'open foo.pdf' it will open it with zathura, open 'foo.mp4' it will open with VLC etc, or whichever programs I specify to open which type of file
 
Old 03-04-2020, 06:40 AM   #5
fatmac
LQ Guru
 
Registered: Sep 2011
Location: Upper Hale, Surrey/Hants Border, UK
Distribution: Mainly Devuan, antiX, & Void, with Tiny Core, Fatdog, & BSD thrown in.
Posts: 5,506

Rep: Reputation: Disabled
Check out 'MIME types'.

A text based file manager such as 'mc' allows for setting them, (if I remember right).
 
Old 03-04-2020, 08:23 AM   #6
ehartman
Senior Member
 
Registered: Jul 2007
Location: Delft, The Netherlands
Distribution: Slackware
Posts: 1,674

Rep: Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888
Quote:
Originally Posted by SomeLinuxUser View Post
Does there exist such a thing in Linux where the user can specify with which program to run which file types?
Looks like you're looking for something like
Quote:
xdg-open - opens a file or URL in the user's preferred application
although that is meant more for a desktop environment (as for URL's the default application is a web-browser). With the xdg-mime(1) or xdg-settings(1) commands you can specify your preferred MIME application associations.
See the man pages for those commands (if you got xdg-utils installed, of course).
These are tools from the free desktop organisarion www.freedesktop.org/wiki
 
Old 03-04-2020, 08:27 AM   #7
allend
LQ 5k Club
 
Registered: Oct 2003
Location: Melbourne
Distribution: Slackware64-15.0
Posts: 6,378

Rep: Reputation: 2757Reputation: 2757Reputation: 2757Reputation: 2757Reputation: 2757Reputation: 2757Reputation: 2757Reputation: 2757Reputation: 2757Reputation: 2757Reputation: 2757
This is the sort of thing where you could easily write a small shell script to configure your preferences.
Code:
#!/bin/bash

f=$1

suffix=${f##*.}

case $suffix in
  pdf)
    zathura "$f"
  ;;
  txt)
    nano "$f"
  ;;
  *)
    echo "no match for $f"
    exit
  ;;
esac
You could then add a function called 'open' to your ~.bash_profile and/or ~/.bashrc to call this script.

Last edited by allend; 03-04-2020 at 08:29 AM.
 
Old 03-04-2020, 10:07 AM   #8
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342

Rep: Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242
yeah MIME type determine what apps open what files. you can even open up your file manager, right click on the file then select what app to use to open it with. then that sets it too.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] cannot login to funtoo linux. UID 0 does not exist. no users or groups seem to exist. whansard Linux - Security 1 12-19-2018 03:40 AM
searching in command line like in windows search or macOS finder momeunier Linux - Software 1 01-25-2011 07:49 AM
does lynux have a defrag utility similar to windows third Linux - Newbie 4 11-29-2006 08:27 AM
Does anything similar to Apple's Final Cut Pro exist for Linux? lorengd Linux - Software 11 02-09-2004 12:36 PM
macos-like command line file viewer (open) in linux shunker Linux - Newbie 0 12-25-2003 07:21 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:46 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration