LinuxQuestions.org
Review your favorite Linux distribution.
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 12-10-2020, 12:39 AM   #1
kali_noob
LQ Newbie
 
Registered: Oct 2020
Posts: 1

Rep: Reputation: Disabled
how to open a file or directory from the command-line, but in the default application. Not within the shell.


I've been looking for the answer to this one for a long time, but I can't find it at all. Basically, on mac os, you can run the following command: $ open filename.txt

When you run the above command, it'll actually execute the file and open it in its default application and not within the terminal. If I use that same command for a directory, it'll actually open the directory. But I haven't found any command like it on Linux. When I look online they always show me the cat command, or nano, etc.

Does a command like that exist in Linux?
 
Old 12-10-2020, 06:04 AM   #2
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,498

Rep: Reputation: Disabled
To associate a file type to a program you need to set its mime type.

Else you could create a script to open it in a particular program.

(For multiple types, you could use 'if then elseif' statements, for instance).
 
Old 12-10-2020, 06:31 AM   #3
l4tt3
LQ Newbie
 
Registered: Dec 2020
Location: UK
Distribution: Arch
Posts: 9

Rep: Reputation: 3
xdg-open should be able to do this for you.
 
1 members found this post helpful.
  


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] rsync - exclude a directory but include specific file(s) within that directory JavaMeister Programming 6 09-23-2020 12:49 PM
question: 'onclick' within 'onmouseover' within 'form' within 'table' - how is it possible? rblampain Programming 4 04-25-2017 08:49 PM
[SOLVED] Why would a command work from the command line but not within a script? RandomTroll Programming 14 09-22-2016 11:49 PM

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

All times are GMT -5. The time now is 04:30 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