How to use command lines to quickly open various types of files in Ubuntu (xdg-open)

Source: Internet
Author: User
In Ubuntu, when you need to open files of other formats, we usually go to the directory where the files are located and double-click to open the files, which affects efficiency. In fact, you can use the xdg-open command to open these format files, or even Web pages. a simple label is like opening a file: Ubuntu usually uses the command line to open a text file, for example, use commands such as gedit, more, cat, vim, and less. However, when you need to open other format files, such as pdf, jpg, and mp3 files, we usually go to the directory where the files are located and double-click to open them, which affects efficiency. In fact, you can run the xdg-open (opens a file or URL in the user's preferred application) command to open these format files, or even webpages, as easy as opening a file.

Here are two examples:

Copy codeThe code is as follows:
Jelline @ jelline :~ $ Xdg-open la_isla_bonita.mp3
Jelline @ jelline :~ $ Xdg-open http://baidu.com
Jelline @ jelline :~ $ A new window has been created in an existing browser session.


Xdg-open selects an appropriate program to open the specified file, which is the same as double-clicking to open the file. In my computer, the first example will be opened with Totem Movie Player, and the second example will be opened with Google browser instead of Firefox, because Google browser is my default browser.

The procedure is as follows:

Xdg-open {file | URL}
Xdg-open {-- help | -- manual | -- version}

OK. Now it's much more convenient. you can press Ctrl + Alt + T to open the shell, and F11 can be displayed in full screen (Alt + F9 to minimize the window, Alt + F10 to maximize/restore the window ), the xdg-open command greatly reduces mouse operations and improves efficiency.

Part of xdg-open manual information is provided:
Xdg-open opens a file or URL in the user's preferred application. if a URL is provided the URL will be opened in the user's preferred web browser. if a file is provided the file will be opened in the preferred application for files of that type. xdg-open supports file, ftp, http and https URLs.
Xdg-open is for use inside a desktop session only. It is not recommended to use xdg-open as root.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.