How to open an HTML file on Linux, from the file manager or the terminal
Quick answer
In the file manager, double-click the .html file, or right-click it and choose Open With… to pick a browser. In a terminal, run xdg-open page.html for the app set for .html files, or google-chrome page.html or firefox page.html for that browser. Over SSH, serve it with python3 -m http.server and forward the port.
Free plan: no credit card, 1 published page.
On this page
- Open an HTML file from the file manager in 3 steps
- Open it from the terminal
- Set the browser that opens .html files
- Over SSH, or on a server with no screen
- Works on your computer, broken for others
- On WSL or a Raspberry Pi
- Ways to open it on Linux, compared
- Send a link that opens anywhere
- Frequently asked questions
- Sources
You have an .html file on Linux: a page ChatGPT or Claude made, a build's index.html, or a test run's report.html. This guide shows how to open it in a browser from the file manager or a terminal, how to choose the browser that opens it, and how to see it on a server you reach over SSH. On other computers, see the guides for Windows, Mac, and Chromebook. For one browser's own menus and options, see Firefox and Chrome.
Sending a file you made? The upload box at the top of this page turns it into a preview link without an account. That preview runs no scripts, so a quiz or game won't respond there. Click Keep this page — free, no card and sign up, and the page moves into your account, where its scripts run and you can publish it.
What we tested: on November 5, 2026, we worked over SSH on an Ubuntu 26.04.1 LTS desktop machine, with Files 50.2.2, GNOME Settings 50.3, xdg-utils 1.2.1, Google Chrome 155, and Firefox 159. We ran the browsers headless and only read the settings. We didn't double-click a file on the machine's screen, run xdg-open, or change a default, and we didn't test Fedora, Linux Mint, Raspberry Pi OS, or WSL.
Open an HTML file from the file manager in 3 steps
These steps come from GNOME's help and from the labels in Files 50.2.2, the file manager on Ubuntu 26.04.1, which we read in the app's own menu files. We didn't click through them on the screen. Other desktops have their own file managers and labels.
1. Double-click the file
GNOME's help says that when you double-click a file in the file manager, "it will be opened with the default application for that file type." On Ubuntu 26.04.1, that's Firefox for an .html file, unless you or another browser changed it: Ubuntu's list of defaults, /usr/share/applications/ubuntu-mimeapps.list, names firefox_firefox.desktop first for text/html, the type of .html files. A browser opens the page at an address that starts with file:///, the address of a file on your own disk.
2. Or right-click it and choose Open With…
GNOME's help says to "right-click the file and select the application you want from the top of the menu. If you do not see the application you want, select Open With…." In Files 50.2.2, the top item reads Open With and the default app's name. Open With… opens a list titled Open File, under the line "Choose an app to open" and the file's name, such as "Choose an app to open page.html". Pick Google Chrome or Firefox and click Open.
3. Turn on Always use for this file type
To keep that choice for every .html file, turn on Always use for this file type at the foot of the same list before you click Open. GNOME's help also describes an Open With tab under Properties, but the Properties window of Files 50.2.2 has no such tab.
To go on in a terminal from here, right-click an empty part of the folder: in Files 50.2.2, that menu can include Open in Terminal or Open in Console.
Open it from the terminal
Let xdg-open pick the app
xdg-open page.html
The xdg-utils manual, from freedesktop.org, says: "xdg-open opens a file or URL in the user's preferred application." A file "will be opened in the preferred application for files of that type", the same app a double-click uses. On GNOME, the xdg-open script on our Ubuntu machine passes the file to gio open, which, in GLib's manual, "Opens files with the default application that is registered to handle files of this type."
Run it in a terminal on the computer's own desktop: the manual says xdg-open "is for use inside a desktop session only". The xdg-open manual of xdg-utils 1.2.1, the version on our Ubuntu machine, also says xdg-open "can not handle arguments that begin with" a dash, and suggests a full path or ./ in front of the name. We didn't run xdg-open or gio open, because on our test machine they would have opened a window on its screen.
Check which app opens .html files
xdg-mime query default text/html
gio mime text/html
In xdg-utils' manual, query default "Returns the default application that the desktop environment uses for opening files of type mimetype". In GLib's, gio mime with no app named "lists the registered and recommended applications for the MIME type". On our Ubuntu 26.04.1 machine, run with the desktop session's name (XDG_CURRENT_DESKTOP=ubuntu:GNOME, from Ubuntu's own session file), both named Firefox:
Default application for “text/html”: firefox_firefox.desktop
gio mime also listed Google Chrome, GNOME's Text Editor, and Vim as apps that can open the file. Over a plain SSH connection, the same commands named Google Chrome (com.google.Chrome.desktop) instead: outside a desktop session, they didn't read Ubuntu's list of defaults. So run them in a terminal on the desktop. The xdg-mime manual of xdg-utils 1.2.1 also warns that the answer "may or may not match the application launched by xdg-open".
Name the browser
google-chrome page.html
firefox page.html
On November 5, 2026, on Ubuntu 26.04.1, we ran Google Chrome 155, installed from Google's .deb package, headless, in a test page's folder, with only the file's name after the command. Chrome opened the page at file:///tmp/…/t.html, and the script inside it ran. For Chrome's and Firefox's other command-line options, see the Chrome guide and the Firefox guide.
Ubuntu's Firefox can't open files in /tmp
On Ubuntu 26.04.1, /usr/bin/firefox is a short script that starts Firefox 159 from a snap package. Snap's documentation says snapd, the service that runs snaps, "Sets up a private /tmp directory using a per-snap private mount namespace and mounting a per-snap directory on /tmp." So Firefox sees a /tmp of its own, not yours.
In our test, firefox file:///tmp/…/ff.html loaded nothing: the page's script never ran, and inside the Firefox snap, the folder didn't exist ("No such file or directory"). The same page, served from http://127.0.0.1, ran in the same Firefox, its module script and data files included. Chrome, from Google's .deb, opened the file in /tmp. Because Firefox is Ubuntu's default app for .html files, a double-click on a file in /tmp may hit the same wall. We didn't test a double-click.
/tmp is the common case, not the only one. Snap's documentation describes what a snap can reach through its interfaces, and our Firefox snap had these two connected: home, which "allows access to non-hidden files owned by the user in the user's home ($HOME) directory", and removable-media, which "allows read/write access to mounted removable storage in /media, /run/media and /mnt". By that documentation, a file in another folder outside your home folder, such as /var/www/html or /srv, or in a hidden folder such as ~/.cache, is out of reach too. We tested only /tmp.
- Move the file to your home folder, such as Downloads or Documents, outside any folder whose name starts with a dot. We didn't test a file in the home folder.
- Open it in Chrome, or serve the folder and open
http://localhost, as in serve the folder and forward the port, without thesshstep.
Terminal commands compared
| Command | What it opens | On our Ubuntu 26.04.1 machine |
|---|---|---|
xdg-open page.html | The app set for .html files, in the desktop session | Not run: it opens a window |
gio open page.html | The same, through GNOME's GLib | Not run |
xdg-mime query default text/html | Prints that app's desktop file name | firefox_firefox.desktop with the desktop session's name; com.google.Chrome.desktop over plain SSH |
gio mime text/html | Lists the default app and the others that can open it | The same two answers |
google-chrome page.html | Google Chrome, at the file's file:/// address | Chrome 155, headless: opened it, and its script ran |
firefox page.html | Firefox, at the file's file:/// address | Firefox 159 snap, headless, run as firefox file:///tmp/…/ff.html: didn't open; the same page from 127.0.0.1 ran |
python3 -m http.server --bind 127.0.0.1 | Serves the folder at http://127.0.0.1:8000 | Python 3.14.4: in Chrome and Firefox, the module script and data files loaded |
Set the browser that opens .html files
- In Settings. GNOME's help says: "Open the Activities overview and start typing Apps. Select Settings ▸ Apps from the results." In Settings 50.3 on Ubuntu 26.04.1, Apps has Default Apps, "Set which apps open links, files, and media", and the browser is the Web row. GNOME's help says it decides "which web browser you would like to open links". In the source code of Settings 50.3, the Web row also makes that browser the app for
text/htmlwhen the browser lists that type, as Chrome and Firefox did on our machine. - In Files. Right-click an
.htmlfile, choose Open With…, and turn on Always use for this file type, as in step 3. - In a terminal. xdg-utils' manual gives
xdg-mime default, which asks "the desktop environment to make application the default application for opening files of type mimetype". The app is named by its desktop file: on our machine,com.google.Chrome.desktopfor Chrome andfirefox_firefox.desktopfor the Firefox snap.
xdg-mime default com.google.Chrome.desktop text/html
xdg-mime query default text/html
We didn't change any of these settings on our test machine. GNOME's help adds that a browser you open later "might tell you that it's not the default browser any more". To keep your choice, it says to click "the Cancel button (or similar)".
Over SSH, or on a server with no screen
xdg-open "is for use inside a desktop session only", so over a plain SSH connection, without X forwarding, it can't put the page on your screen. Use one of these ways instead.
Serve the folder and forward the port
On the server, in the file's folder:
python3 -m http.server 8000 --bind 127.0.0.1
On your own computer, in a new terminal:
ssh -L 8000:127.0.0.1:8000 you@server
Then open http://localhost:8000/page.html in your own browser. When you're done, press Ctrl + C in the server's terminal, the key Python's documentation calls "the interrupt key (normally Control-C or Delete)".
Python's documentation says the server "listens to port 8000 by default", and "By default, the server binds itself to all interfaces". --bind 127.0.0.1 keeps other computers on the network out, and your SSH forward still reaches it. On a server other people log in to, they can open it too while it runs, so serve a folder that holds only the page and its files. The same page warns that http.server "is not recommended for production. It only implements basic security checks." OpenSSH's manual says -L "Specifies that connections to the given TCP port or Unix socket on the local (client) host are to be forwarded to the given host and port, or Unix socket, on the remote side."
On November 5, 2026, we served a test folder this way on Ubuntu 26.04.1 with Python 3.14.4, forwarded it to a Mac with ssh -L, and opened it at http://localhost:18000/t.html in Chromium 156. The page's script and a module script ran, and the data files beside it loaded. We used other port numbers than 8000.
Print the page, or a picture of it, with headless Chrome
With Chrome installed on the server:
google-chrome --headless=new --virtual-time-budget=5000 --dump-dom page.html
google-chrome --headless=new --screenshot=page.png page.html
Chromium's source describes --dump-dom as "Print the serialized DOM (doctype + document.documentElement.outerHTML) to stdout" and --screenshot as "Save a screenshot of the loaded page." --virtual-time-budget=5000 makes Chrome wait "the specified number of virtual milliseconds before deeming the page to be ready", so the page's scripts get time to finish first. We ran both lines with Chrome 155 on Ubuntu 26.04.1 over SSH, with a throwaway profile. The printed HTML included the text the page's script had written, and the screenshot came out as a PNG file to copy back with scp.
Read it as text
Text-mode browsers show a page inside the terminal. Ubuntu's package list for 26.04 describes lynx as a "classic non-graphical (text-mode) web browser" and w3m as a "WWW browsable pager with excellent tables/frames support". Neither was installed on our test machine, so we didn't test them. To read the code itself, open the file in a text editor.
Works on your computer, broken for others
A page opened from your disk has a file:/// address, and Chrome blocks part of what it loads from there. On November 5, 2026, Chrome 155 on Ubuntu 26.04.1 opened a test page from /tmp, headless, three ways:
| In the test page | From file:/// (google-chrome t.html) | The same, with --allow-file-access-from-files | Served from http://127.0.0.1:8791 |
|---|---|---|---|
| A script written inside the file | Ran | Ran | Ran |
style.css and photo.png in the same folder | Loaded | Loaded | Loaded |
classic.js in the same folder, loaded with <script src="classic.js"> | Ran | Ran | Ran |
game.js in the same folder, loaded with <script type="module" src="./game.js"> | Didn't run | Ran | Ran |
fetch("data.json") for a file in the same folder | Failed, with "TypeError: Failed to fetch" | Loaded | Loaded |
fetch("sub/data.json") for a file in a subfolder | Failed | Loaded | Loaded |
A script reading frame.html from the same folder, shown in an <iframe> | Blocked | Read it | Read it |
Chrome's console said why, for the module and each data file:
Access to script at 'file:///tmp/…/game.js' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: chrome, chrome-experimental-site-token-provider, chrome-extension, chrome-untrusted, data, http, https, isolated-app.
Firefox 157 blocked the same 4 things in the Firefox guide's test on a Mac.
Don't start Chrome with --allow-file-access-from-files as your fix. Chromium's source says: "By default, file:// URIs cannot read other file:// URIs. This is an override for developers who need the old behavior for testing." With it on, our test page read the other files in its folder and subfolder, so a page you downloaded could read the files around it. It also changes only the Chrome you start with it, not the browser of the person you send the file to.
The file:///home/… address and the files beside it exist only on your computer. Send the HTML file alone, and style.css, photo.png, and game.js stay behind: HTML file missing images or styles covers that. These fixes work on any computer:
- Ask the AI for one file. Ask the chat that made the page for one HTML file with the CSS, the JavaScript, and any data inside it.
- Serve the folder. Run the local server above and open
http://localhost. For a page Codex or Claude Code made, see how to preview HTML from Codex or Claude Code. - Open it in the HTML viewer or publish it, as below.
If the browser shows the code instead of the page, or a blank page, see HTML file shows code or a blank page. For a file someone sent you, read Is it safe to open an HTML file? first.
On WSL or a Raspberry Pi
- WSL on Windows. Microsoft's WSL documentation shows how to open "the Windows File Explorer from the command line, using: explorer.exe ." Run
explorer.exe .in the file's folder, then double-click the file in File Explorer, and Windows opens it with its own app for.htmlfiles, as in the Windows guide. We didn't test WSL. - Raspberry Pi. Raspberry Pi's documentation says Raspberry Pi OS, the edition with a desktop, "includes applications such as Chromium and Firefox web browsers". It doesn't say which of them opens an
.htmlfile, and we didn't test a Raspberry Pi or its file manager.
Ways to open it on Linux, compared
| Way to open it | Where the page opens | Module scripts and data files beside it | Who sees the page |
|---|---|---|---|
| Double-click, or Open With… in Files | Your browser, from file:/// | Blocked in Chrome 155 (our test from the terminal) | Only you |
xdg-open page.html | The app set for .html files, from file:/// | Blocked (Chrome 155 here, Firefox 157 in the Firefox guide) | Only you |
google-chrome page.html, firefox page.html | That browser, from file:///; the Firefox snap can't reach /tmp or other folders outside your home folder | Blocked (Chrome 155 here, Firefox 157 in the Firefox guide) | Only you |
A local server, python3 -m http.server | http://localhost:8000 | Loaded (our test) | You, on that computer or through ssh -L |
| HTML viewer, Choose an .html file or Paste code | A walled-off frame on the viewer's page | Not loaded; the viewer lists files named in tags | Only you |
| A link to a published page | https://, on any phone or computer | One HTML file goes up, so fold them into the page first | Everyone with the link |
Send a link that opens anywhere
A file you send arrives as a file, and on the other person's computer it opens from file:///, with the limits above. A link opens the page from an https:// address, on Linux, Windows, a Mac, or a phone.
To check the page first without uploading it, open the free HTML viewer and click Choose an .html file, or choose Paste code, paste the code, and click Show the page. On November 5, 2026, in Chrome 155 on Ubuntu 26.04.1, headless and against a development copy of convika.com, the viewer ran a test page's script both ways, and its button counted 3 clicks out of 3. Files the page points to with tags can't show there, and the viewer lists them under the page. For a file you weren't expecting, ask the sender first, and turn off Run scripts before you choose it.
With Convika:
- Drop your file into the upload box at the top of this page, or paste the code. You get a preview link in seconds, without an account. It works for 3 minutes, with scripts and forms off.
- Click Keep this page — free, no card and sign up. The page moves into your account, and its scripts run in the dashboard preview.
- Click Publish page. Under Who can open this page?, choose Public and click Next. The first time, click Publish free.
- Copy the address under Live URL and paste it into the email or chat instead of the file.
On Free, the page is published as Public: anyone with the link can open it, and it may show up in search results and in Convika's gallery. To keep it out of both, choose Private link (Pro) under Who can open this page? when you publish. Anyone with a private link can still open it.
Convika hosts one HTML file per page, so fold any game.js or style.css into the page first. You can also start from the free HTML publishing tool, which has the same upload box. Working in VS Code? How to share an HTML file from VS Code covers the link from there, and how to share an HTML file as a link compares the other ways.
Frequently asked questions
How do I open an HTML file in the Linux terminal?
Run xdg-open page.html in a terminal on the desktop: the xdg-utils manual says it opens a file "in the preferred application for files of that type". To choose the browser, run google-chrome page.html or firefox page.html. On Ubuntu, Firefox is a snap that can't see files in /tmp or other folders outside your home folder, so move such a file into your home folder first.
How do I open an HTML file with the default browser on Linux?
Double-click it in the file manager, or run xdg-open page.html. Both use the app set for .html files. To see which app that is, run xdg-mime query default text/html in a terminal on the desktop. On Ubuntu 26.04.1, Ubuntu's own list of defaults names firefox_firefox.desktop, the Firefox snap.
How do I open an HTML file in Ubuntu?
Double-click it in Files, or right-click it, choose Open With…, pick a browser, and click Open. Turn on Always use for this file type to keep that browser for every .html file. These are the labels in Files 50.2.2 on Ubuntu 26.04.1.
How do I view an HTML file over SSH?
On the server, run python3 -m http.server 8000 --bind 127.0.0.1 in the file's folder. On your computer, connect with ssh -L 8000:127.0.0.1:8000 you@server and open http://localhost:8000/page.html. With Chrome on the server, google-chrome --headless=new --virtual-time-budget=5000 --dump-dom page.html prints the page's HTML with what its scripts wrote. xdg-open works only in a desktop session.
Why won't Firefox open my HTML file on Ubuntu?
If the file is in /tmp, Firefox can't see it: on Ubuntu it's a snap, and snaps get a private /tmp. In our Firefox 159 test, a file in /tmp didn't open, and the same page served from 127.0.0.1 did. Snap's documentation also limits the snap to non-hidden files in your home folder and to mounted drives, so a file in a folder such as /var/www/html is out of reach too; we tested only /tmp. Move the file to your home folder, or open it in Chrome.
How do I change the default browser for HTML files in Ubuntu?
Open Settings, go to Apps > Default Apps, and choose the browser under Web. In the source code of GNOME Settings 50.3, that also sets the app for .html files. Or right-click an .html file in Files, choose Open With…, and turn on Always use for this file type.
Why does my HTML file open blank or broken on Linux?
It may load a module script or data files from its folder, which Chrome 155 blocked on a file:/// page in our Ubuntu test. Serve the folder and open http://localhost, or ask the AI for one file with everything inside. If it shows the code instead, see HTML file shows code or a blank page.
How do I share an HTML file from Linux so it opens anywhere?
Send a link, not the file. Drop the file into the upload box at the top of this page, keep the page on the Free plan, and publish it. The link opens from an https:// address on Linux, Windows, a Mac, or a phone, with the page's scripts running.
Sources
- xdg-open (freedesktop.org, xdg-utils) (read November 5, 2026), and the xdg-open(1) manual of xdg-utils 1.2.1 on Ubuntu 26.04.1
- xdg-mime (freedesktop.org, xdg-utils) (read November 5, 2026), and the xdg-mime(1) manual of xdg-utils 1.2.1 on Ubuntu 26.04.1
- xdg-open and xdg-mime manual sources (xdg-utils, tag v1.2.1; read November 5, 2026)
- The gio(1) manual of GLib 2.88.0 on Ubuntu 26.04.1 (
man gio; read November 5, 2026) - Open files with other applications (GNOME Help) (read November 5, 2026)
- App chooser, nautilus-app-chooser.c (GNOME Files 50.2.2 source) (tag 50.2.2; read November 5, 2026)
- Change which web browser opens websites by default (GNOME Help) (read November 5, 2026)
- Default apps page, cc-default-apps-row.c (GNOME Settings 50.3 source) (tag 50.3; read November 5, 2026)
- Security policies (Snap documentation) (read November 5, 2026)
- home interface (Snap documentation) (read November 5, 2026)
- removable-media interface (Snap documentation) (read November 5, 2026)
- http.server (Python 3 documentation) (read November 5, 2026)
- Built-in exceptions, KeyboardInterrupt (Python 3 documentation) (read November 5, 2026)
- ssh(1) (OpenBSD manual pages) (read November 5, 2026)
- content_switches.cc, allow-file-access-from-files (Chromium source) (main branch; read November 5, 2026)
- headless_command_switches.cc, dump-dom and screenshot (Chromium source) (main branch; read November 5, 2026)
- Working across Windows and Linux file systems (Microsoft Learn) (dated September 27, 2021; read November 5, 2026)
- Raspberry Pi OS (Raspberry Pi documentation) (read November 5, 2026 from its source, rpi-os-introduction.adoc in raspberrypi/documentation)
- lynx and w3m in Ubuntu 26.04 (Ubuntu Packages; read November 5, 2026)
Next step
How to password protect an HTML page without code, on your own domain
JavaScript passwords sit in the page code. Put an HTML page from ChatGPT or Claude behind a server-checked password on your own domain.
Related articles
- How do I open an HTML file on Windows, and why won't my AI-made page work?Double-click an .html file and Windows uses the app set for .html files. Open it in Edge or Chrome, fix Notepad, and see why an AI-made page breaks.
- How do I open an HTML file on a Mac, and why does my AI-made page break?A Mac opens an .html file in your browser from a file:// address. Our October 2026 test shows what Chrome blocks there, and 3 fixes: one file, a server, a link.
- How do I open an HTML file on a Chromebook, and send one that opens?Double-click an .html file in the Chromebook Files app, or press Ctrl + O in Chrome. What a school Chromebook can block, and how to send a class a link.
- How to open an HTML file in Firefox on a computer, Android, or iPhoneOpen an .html file in Firefox with Ctrl + O or firefox page.html, make Firefox the app for .html, and see what Firefox on Android or iPhone can do.
- How to open an HTML file in Chrome (computer, iPhone, and Android)Open an .html file in Chrome with Open with or Ctrl + O, make Chrome the default, run it from the terminal or VS Code, and what works on a phone.
- My HTML file opens but the images and styling are missing. Why?An .html file is only the page: its images, style.css, scripts, and fonts are other files. Our October 2026 tests show what goes missing, and how to fix each.
AI Skill Pod
Share AI skills with your team, the easy way
Everyone uses your team's skills in their own ChatGPT, Claude or Gemini, on any plan. Send one invite link. Free to start.
Start free on AI Skill Pod