Hướng dẫn 2 cách đổi trình duyệt mặc định trong Ubuntu: dòng lệnh (update-alternatives) và cài đặt đồ họा (Settings).
Cách 1: Dòng lệnh – update-alternatives (hệ thống)
Áp dụng cho mọi ứng dụng dùng x-www-browser (xdg-open, mail client, IDE...).
- Mở Terminal, chạy:
sudo update-alternatives --config x-www-browser
- Nhập mật khẩu sudo. Menu tương tác xuất hiện:
There are 2 choices for the alternative x-www-browser (providing /usr/bin/x-www-browser).
Selection Path Priority Status
------------------------------------------------------------
* 0 /usr/bin/chromium 40 auto mode
1 /usr/bin/chromium 40 manual mode
2 /usr/bin/firefox 40 manual mode
Press to keep current choice[*], or type selection number:
- Nhập số lựa chọn (ví dụ: 2 cho Firefox) → Enter. Xong.
Cách 2: Ubuntu Settings (GUI – từng user)
- Menu hệ thống (góc trên phải) → Settings (Cài đặt).
- Cột trái cuộn xuống → Default Applications (Ứng dụng mặc định).
- Kéo menu thả xuống cạnh Web → chọn trình duyệt mong muốn (Firefox, Chrome, Chromium, Brave...).
- Đóng Settings. Hoàn tất.
So sánh 2 cách
| Đặc điểm | update-alternatives | Settings (GUI) |
|---|---|---|
| Phạm vi | Toàn hệ thống (all users) | Chỉ user hiện tại |
| Cơ chế | Cập nhật symlink /usr/bin/x-www-browser | Ghi vào ~/.config/mimeapps.list |
| Ưu tiên | Cao hơn (ghi đè user setting) | Thấp hơn |
| Phù hợp | Server, multi-user, script tự động | Desktop cá nhân, dễ dùng |
Kiểm tra trình duyệt mặc định hiện tại
# Xem symlink hệ thống
ls -l /usr/bin/x-www-browser
# Xem setting user
xdg-settings get default-web-browser
# Test mở link
xdg-open https://example.com
Thêm trình duyệt mới vào alternatives (nếu chưa có)
# Ví dụ thêm Brave browser
sudo update-alternatives --install /usr/bin/x-www-browser x-www-browser /usr/bin/brave-browser 50