Unix & Linux Stack Exchange
Q&A for users of Linux, FreeBSD and other Unix-like operating systems
Latest Questions
26
votes
5
answers
17079
views
Is there an "open with" command for the command line?
Does the command line have a way to get a recommended list of programs used to open a particular file, based on the file type? For example, a `.pdf` file would have an `open with...` recommendation using the programs `Evince` and `Document Viewer`. I use the command line for most things, but sometim...
Does the command line have a way to get a recommended list of programs used to open a particular file, based on the file type? For example, a
.pdf
file would have an open with...
recommendation using the programs Evince
and Document Viewer
.
I use the command line for most things, but sometimes I forget the name of a program that I want to use to open a particular type of file.
BTW I am using Ubuntu 13.10.
**pro-tip**
Thanks to @slm 's selected answer below, I made the following bash script in a file called openwith.sh
:
xdg-mime query default $(xdg-mime query filetype $1)
Add as an alias or execute directly as an openwith
command.
modulitos
(3275 rep)
Apr 15, 2014, 01:16 AM
• Last activity: Apr 30, 2025, 12:57 PM
5
votes
2
answers
7663
views
Which config-file stores file associations in KDE/Plasma?
With the 15.04 release of Kubuntu, I switched from Gnome (Ubuntu) to KDE/Plasma. I did a clean install, while keeping my home directory. Now, libreoffice (mostly Calc) seems to be associated with every unknown file-type. Instead of manually fixing the associations for every file I encounter, I'd rat...
With the 15.04 release of Kubuntu, I switched from Gnome (Ubuntu) to KDE/Plasma. I did a clean install, while keeping my home directory. Now, libreoffice (mostly Calc) seems to be associated with every unknown file-type. Instead of manually fixing the associations for every file I encounter, I'd rather understand what went wrong and fix it by looking at the corresponding config file that KDE/Plasma uses. Which config-file is it?
burnpanck
(153 rep)
Jun 30, 2015, 02:01 PM
• Last activity: Mar 20, 2025, 02:49 AM
15
votes
3
answers
11769
views
Where does firefox get the “default” applications for opening files from?
By default, the Firefox (33.0) on my FreeBSD 11.0-CURRENT has the default application for opening PDF files set to Inkscape. Firefox does remember my previous choice, *evince*, in the “What should Firefox do with this file?” dialog, so until recently I was just confused where this configuration came...
By default, the Firefox (33.0) on my FreeBSD 11.0-CURRENT has the default application for opening PDF files set to Inkscape. Firefox does remember my previous choice, *evince*, in the “What should Firefox do with this file?” dialog, so until recently I was just confused where this configuration came from, but mostly ignored it because it did barely concern me.
I have however recently started using Zotero as my literature database. Zotero runs as a firefox plugin, and ignores the choices made in my Firefox preferences to open PDF files with evince or ask me what to do with them, and just opens them using Inkscape. This made me try to follow up on this particular configuration item of Firefox, but I could not find where that default is set.
I could not find the string
Inkscape
(or inkscape
) in any Firefox-related file in my home directory.
Anaphory
(762 rep)
Oct 17, 2014, 04:14 PM
• Last activity: Dec 23, 2023, 04:02 PM
4
votes
2
answers
1106
views
How do I open a file at specific line in a running emacs?
emacs can be run from the command line to open a file at line n with a `+n` command line argument like so : $ emacs +n file I'd like to do the same from a running emacs instance, either via `find-file` or other means. Is that possible ?
emacs can be run from the command line to open a file at line n with a
+n
command line argument like so :
$ emacs +n file
I'd like to do the same from a running emacs instance, either via find-file
or other means. Is that possible ?
ychaouche
(1033 rep)
Feb 20, 2022, 03:02 PM
• Last activity: Dec 1, 2022, 04:51 PM
33
votes
4
answers
119786
views
Opening current directory from a terminal onto a file browser?
My current directory is buried deep in multiple subfolder layers from my home directory. If I want to open this directory in a *gui-based* file browser, I have to double click folder after folder to reach it. This is very time consuming. On the other hand, with very few key strokes and several times...
My current directory is buried deep in multiple subfolder layers from my home directory. If I want to open this directory in a *gui-based* file browser, I have to double click folder after folder to reach it. This is very time consuming. On the other hand, with very few key strokes and several times hitting the tab button, it is very easily reachable via a terminal.
I want to know if there is a way to open the current directory in a terminal onto a a file browser. What is the command to do this?
For reference, I have an ubuntu system, but I'd like to know what the commands are across the various distributions of linux.
Paul
(9823 rep)
Nov 23, 2015, 05:53 PM
• Last activity: Oct 18, 2022, 02:20 AM
5
votes
2
answers
3593
views
Change default web browser to lynx from terminal
I'm on Linux Mint Olivia. I just installed Lynx. How do I set Lynx as my browser, so when I open links from the terminal, they open in that terminal with Lynx?
I'm on Linux Mint Olivia. I just installed Lynx.
How do I set Lynx as my browser, so when I open links from the terminal, they open in that terminal with Lynx?
user193661
(153 rep)
Jan 23, 2016, 04:50 AM
• Last activity: Aug 24, 2022, 06:00 AM
7
votes
2
answers
4124
views
If I open the same file twice in Okular, switch to the existing window
I have always been confused why the file manager in Linux cannot stop applications from opening a single file twice at the same time? Specifically, I want to stop the PDF file reader Okular from opening the file `A.pdf` again when I have already opened it. I need to get an warning or just show me th...
I have always been confused why the file manager in Linux cannot stop applications from opening a single file twice at the same time?
Specifically, I want to stop the PDF file reader Okular from opening the file
A.pdf
again when I have already opened it. I need to get an warning or just show me the opened copy of the file A.pdf
.
More generally, I would like this to happen with any application, not just Okular. I want to make the document management behavior in Linux the same as in Windows.
lovelyzlf
(113 rep)
Nov 20, 2013, 04:22 AM
• Last activity: May 23, 2022, 05:38 PM
15
votes
2
answers
9728
views
Make Firefox use xdg-open for opening files
Is there any way to force Firefox to use system-wide defaults, i.e. xdg-open for opening all types of files?
Is there any way to force Firefox to use system-wide defaults, i.e. xdg-open for opening all types of files?
marmistrz
(2792 rep)
Feb 12, 2015, 04:35 PM
• Last activity: May 12, 2022, 01:27 AM
1
votes
1
answers
360
views
How to set Open File Dialog path explicitly?
### Description I'd like to point a folder so any application will start its "File Open Dialog" in it. How can I do that? ### Rationale I'm naturally using many applications while working on a project, like FreeCAD, LibreCAD, VLC, SimpleScan, etc. It's frustrating to navigate to my work folder for e...
### Description
I'd like to point a folder so any application will start its "File Open Dialog" in it. How can I do that?
### Rationale
I'm naturally using many applications while working on a project, like FreeCAD, LibreCAD, VLC, SimpleScan, etc. It's frustrating to navigate to my work folder for every single one of those applications. If I could set such a path, any application will start that dialog within my work folder, so I can easily handle my files.
ceremcem
(2451 rep)
Jun 14, 2021, 04:14 PM
• Last activity: Jun 14, 2021, 04:47 PM
3
votes
1
answers
10202
views
Launch executable with xdg-open
I am trying to write a function `launchSystemFile` which works like windows `ShellExecuteEx` from the command line or from C++. If I `ShellExecuteEx` a `blah.txt` it opens it in the default editor. If I `ShellExecuteEx` a `firefox.exe` it launches the executable. I have been doing from C++ `popen "x...
I am trying to write a function
launchSystemFile
which works like windows ShellExecuteEx
from the command line or from C++.
If I ShellExecuteEx
a blah.txt
it opens it in the default editor.
If I ShellExecuteEx
a firefox.exe
it launches the executable.
I have been doing from C++ popen "xdg-open blah"
and it works great except for executables.
Is there anyway to make xdg-open
execute an executable? Such as Firefox at path /usr/lib/firefox/firefox
?
I tried xdg-open "/usr/lib/firefox/firefox"
but this fails with the error message:
> gvfs-open: /usr/lib/firefox/firefox: error opening location: No application is registered as handling this file
Noitidart
(307 rep)
Jan 27, 2017, 12:39 PM
• Last activity: Jun 11, 2021, 09:56 AM
4
votes
6
answers
17772
views
File extensions and association with programs in linux
In windows we can associate a file's extension with programs. E.g. a file `test.pl` can be run by the installed `Perl` interpreter due to the `pl` extension. In linux though it needs `#!/usr/bin/perl` as the first line. Is this because there is no association between file extensions and programs in...
In windows we can associate a file's extension with programs.
E.g. a file
test.pl
can be run by the installed Perl
interpreter due to the pl
extension.
In linux though it needs #!/usr/bin/perl
as the first line.
Is this because there is no association between file extensions and programs in Linux?
Cratylus
(529 rep)
Apr 5, 2013, 07:49 PM
• Last activity: May 14, 2021, 08:05 AM
56
votes
8
answers
7629
views
How are file types known if not from file suffix?
I would like to know how file types are known if filenames don't have suffixes. For example, a file named `myfile` could be binary or text to start with, how does the system know if the file is binary or text?
I would like to know how file types are known if filenames don't have suffixes.
For example, a file named
myfile
could be binary or text to start with, how does the system know if the file is binary or text?
Niklas Rosencrantz
(4324 rep)
Jun 3, 2015, 11:21 AM
• Last activity: Nov 10, 2020, 08:59 AM
3
votes
2
answers
1414
views
Configuring Org-mode to open PDFs with evince
I'm starting to use `org-mode` to export text to LaTeX. My problem is that it opens the generated PDF with `ebook-viewer` (it is a EPUB, CHM reader) instead of using evince. *Question* Does anyone know how to change this behaviour and configure `evince` to be the default viewer?
I'm starting to use
org-mode
to export text to LaTeX.
My problem is that it opens the generated PDF with ebook-viewer
(it is a EPUB, CHM reader) instead of using evince.
*Question*
Does anyone know how to change this behaviour and configure evince
to be the default viewer?
Dox
(241 rep)
Sep 17, 2013, 01:49 PM
• Last activity: Oct 15, 2020, 09:09 PM
2
votes
2
answers
322
views
Linux Fedora: How to open a file with a random application
I downloaded a cross-assembler that as far I can tell, i am supposed to open a .txt file with it and the assembler will create an a.out file somewhere. But Fedora only lets me open .txt files with programs in its apps list. How do I put a program in the apps list or how do I simply open a file with...
I downloaded a cross-assembler that as far I can tell, i am supposed to open a .txt file with it and the assembler will create an a.out file somewhere. But Fedora only lets me open .txt files with programs in its apps list. How do I put a program in the apps list or how do I simply open a file with an application outside of Fedora's app list? Thanks so much.
mosesturner
(21 rep)
Oct 2, 2015, 06:32 PM
• Last activity: Oct 12, 2020, 09:18 AM
25
votes
4
answers
80818
views
`open` command to open a file in an application
Why can't I run this command in my terminal: open index.html Wasn't it supposed open this file on my browser? Also can't I run this command: `open index.html -a "Sublime Text"`. The result of these commands are: $ open index.html Couldn't get a file descriptor referring to the console $ open index.h...
Why can't I run this command in my terminal:
open index.html
Wasn't it supposed open this file on my browser? Also can't I run this command:
open index.html -a "Sublime Text"
. The result of these commands are:
$ open index.html
Couldn't get a file descriptor referring to the console
$ open index.html -a "Sublime Text" -
open: invalid option -- 'a'
Usage: open [OPTIONS] -- command
Edgar Oliveira
(2031 rep)
Jan 5, 2016, 01:24 PM
• Last activity: Mar 25, 2020, 11:41 PM
16
votes
2
answers
61381
views
How to open any file through the command line?
I would like to know if there is a command to open any file in Linux independently of their extension, just as if you were double-clicking it.
I would like to know if there is a command to open any file in Linux independently of their extension, just as if you were double-clicking it.
Carl Rojas
(1139 rep)
Jul 18, 2015, 11:58 PM
• Last activity: Oct 17, 2019, 06:59 PM
8
votes
1
answers
3593
views
How to find/remove file associations for a certain program in KDE
I had a program installed on my Kubuntu system that was able to open a lot of different graphics file types and registered as default program for many of those file types. I have unistalled the program, but in the file associations it is still present and every now and then as I try to open a file f...
I had a program installed on my Kubuntu system that was able to open a lot of different graphics file types and registered as default program for many of those file types. I have unistalled the program, but in the file associations it is still present and every now and then as I try to open a file from the file manager, it tries to launch the no longer existing program.
I could remove that association for the most often used file types via the file associations dialogue in KDE's settings menu. Unfortunately, in this dialog I can only search for a file type and see/edit the associated programs, but in this case, I would need to search for the program and see all file types that it is associated to.
Is there a way to achieve this? If not via the settings, maybe in some config file, where I can just remove all hints to that program?
Benedikt Bauer
(509 rep)
Oct 26, 2014, 07:54 PM
• Last activity: Sep 9, 2019, 10:21 AM
-1
votes
2
answers
566
views
Reading file with different formats
I am a new user to Linux. I have several files and documents in my directory and sometimes when I want to read or display data in these files, I do not know which command I need to type for this purpose. I would be appreciated if one helps me with that.
I am a new user to Linux. I have several files and documents in my directory and sometimes when I want to read or display data in these files, I do not know which command I need to type for this purpose. I would be appreciated if one helps me with that.
user1
(1 rep)
Aug 19, 2014, 09:26 PM
• Last activity: Jul 30, 2019, 02:48 PM
21
votes
8
answers
30010
views
Use xdg-open to open a url with a new process
I'm starting to experiment with [Crunchbang][1] (which is based on Debian, and uses [terminator][2]) as a web development environment, and one of the things I am struggling with is the behaviour of ``xdg-open``. I come from an OSX background, so forgive me if this question comes off as dense. I woul...
I'm starting to experiment with Crunchbang (which is based on Debian, and uses terminator ) as a web development environment, and one of the things I am struggling with is the behaviour of `
xdg-open
`. I come from an OSX background, so forgive me if this question comes off as dense.
I would like to be able to open a url with `xdg-open http://www.google.com
and then continue to use the same terminal window to work (it's how
open
functions in OSX). Right now, using
xdg-open
occupies the current tab/session until I close browser window, or manually end things with
ctrl + c
`. I'd much prefer it start a new process, that way I can open up a URL, refer to data on the page, and use it in the same tab/window without needing to open an additional one.
Nick Tomlin
(452 rep)
May 3, 2013, 06:55 PM
• Last activity: Jun 11, 2019, 10:25 AM
2
votes
2
answers
3771
views
KDE opens .deb files with ar instead of a package manager
I just installed Debian for the first time. I use KDE. I'm trying to install Google Chrome and Steam. I download the installation package, then I double-click it. Instead of installing, both display the error > Failed to execute child process "ar" no file or directory
I just installed Debian for the first time. I use KDE. I'm trying to install Google Chrome and Steam. I download the installation package, then I double-click it. Instead of installing, both display the error
> Failed to execute child process "ar" no file or directory
Villa Caleb
(23 rep)
May 1, 2015, 02:42 AM
• Last activity: Apr 16, 2019, 03:41 PM
Showing page 1 of 20 total questions