open a pdf in linux
Opening PDF Files in Linux: A Comprehensive Guide
Linux offers diverse methods to open PDF files, ranging from graphical viewers like Evince and Zathura, to powerful command-line tools such as less and fbgs.
Utilizing the terminal provides efficient access and control, while graphical interfaces offer user-friendly experiences for viewing and interacting with PDF documents.
Linux, renowned for its flexibility, provides a multitude of options for viewing PDF documents. Whether you prefer a graphical user interface (GUI) or the efficiency of the command line, Linux caters to all preferences. Initially, PDF viewing often involved dedicated applications like Evince, a popular choice pre-installed on many distributions. However, the terminal offers surprisingly robust alternatives.
Tools like less allow for quick viewing directly within the terminal, while pdftotext facilitates text extraction. More advanced options, such as fbgs, provide framebuffer-based viewing, rendering PDFs directly in the terminal. Even powerful text editors like Emacs can handle PDF display. The choice depends on your workflow and requirements – GUI viewers for interactive experiences, and command-line tools for scripting and remote access.
This guide explores these diverse methods, offering a comprehensive overview of PDF viewing in the Linux ecosystem, empowering you to choose the best approach for your needs.
Why Use the Command Line for PDFs?
While Linux offers intuitive graphical PDF viewers, utilizing the command line presents distinct advantages. For system administrators and developers, command-line tools enable scripting and automation of PDF-related tasks, such as batch processing or remote access. The terminal often consumes fewer system resources compared to GUI applications, making it ideal for servers or low-powered devices.
Furthermore, command-line tools like less and pdftotext provide direct access to PDF content without the overhead of a full viewer. This is particularly useful when extracting text or quickly inspecting a document. Accessing PDFs on remote servers via SSH is streamlined through the command line, eliminating the need for X11 forwarding.
Ultimately, mastering command-line PDF handling enhances your Linux proficiency and unlocks powerful capabilities beyond those offered by traditional GUI applications.

Graphical PDF Viewers
Linux boasts several excellent graphical PDF viewers, including Evince, Zathura, and Okular, offering user-friendly interfaces for seamless document viewing and interaction.
Evince: A Popular Choice
Evince, also known as Document Viewer, is a widely-used PDF viewer in the Linux world, particularly within GNOME desktop environments. It’s renowned for its simplicity and ease of use, making it an excellent choice for users seeking a straightforward viewing experience. You can open a PDF file with Evince directly from the file manager by double-clicking the file, assuming it’s the default PDF viewer.
Alternatively, you can launch Evince from the command line by typing ‘evince file.pdf’ – replacing ‘file.pdf’ with the actual filename and path. Evince supports various document formats beyond PDFs, including PostScript, DjVu, and TIFF images. It provides essential features like zooming, searching, printing, and navigating through pages. While it doesn’t offer extensive editing capabilities, it excels at reliably displaying PDF content. Its integration with the GNOME desktop ensures a consistent and polished user experience.
Zathura: Lightweight and Efficient
Zathura is a highly customizable and remarkably lightweight PDF viewer designed for Linux. It distinguishes itself through its minimalist interface and focus on keyboard-driven navigation, appealing to power users and those who prefer efficiency. Unlike some heavier viewers, Zathura prioritizes speed and resource conservation, making it ideal for older hardware or systems with limited resources.
To open a PDF with Zathura from the command line, simply type ‘zathura file.pdf’ (substituting ‘file.pdf’ with the correct filename). Zathura supports tabs for opening multiple documents simultaneously and offers a range of plugins to extend its functionality. These plugins can add features like DjVu support, OCR capabilities, and more. Its clean design and focus on keyboard shortcuts allow for rapid document navigation and a distraction-free reading experience. It’s a favorite among users who value speed and control.

Okular: Feature-Rich PDF Viewer
Okular is a versatile and powerful PDF viewer, particularly well-suited for Linux environments, offering a comprehensive set of features beyond basic viewing. Developed by KDE, it supports a wide array of document formats, including PDF, PostScript, DjVu, and more. Okular excels in annotation capabilities, allowing users to highlight text, add notes, draw shapes, and even digitally sign documents.
To open a PDF file, simply execute ‘okular file.pdf’ in the command line, replacing ‘file.pdf’ with the actual filename. It provides advanced features like text selection, copy-paste functionality, and zoom controls. Okular integrates seamlessly with the KDE desktop environment but is also available for other Linux distributions. Its robust feature set makes it a strong choice for users who require advanced PDF manipulation and annotation tools, offering a complete document viewing solution.

Command-Line PDF Viewers
Linux provides several command-line tools to open PDF files, including less, pdftotext, fbgs, and Zathura, offering efficient document access and control.
Using ‘less’ to View PDFs
The ‘less’ command is a powerful and versatile tool readily available on most Linux systems, offering a simple yet effective way to view PDF files directly within the terminal. While not a dedicated PDF viewer, ‘less’ can display the textual content of a PDF, making it useful for quick inspections or when a graphical interface isn’t available.
To utilize ‘less’ for PDF viewing, simply execute the command less filename.pdf in your terminal. The PDF’s text will then be displayed, allowing you to navigate using standard ‘less’ commands like the arrow keys, Page Up/Down, and ‘q’ to quit. It’s important to note that ‘less’ won’t render the PDF’s formatting or images; it focuses solely on the text content.
This method is particularly beneficial for extracting text from PDFs or examining large documents without the overhead of a full PDF viewer. The GNU General Public License ensures its widespread availability and usability across various Linux distributions.
The ‘pdftotext’ Command for Text Extraction
The pdftotext command is a crucial utility for extracting text from PDF files on a Linux system. It’s part of the Poppler suite, commonly pre-installed or easily installable on most distributions. Unlike viewing the PDF directly, pdftotext converts the PDF’s content into a plain text file, stripping away formatting and images.
To use it, simply type pdftotext filename.pdf in your terminal. This will create a new text file with the same base name as the PDF (e.g., filename.txt). You can specify an output file name using pdftotext filename.pdf output.txt. This extracted text is then readily available for searching, editing, or further processing.
pdftotext is invaluable for tasks like indexing PDF content, automating text analysis, or creating searchable archives. It provides a clean and efficient way to access the textual information contained within PDF documents from the command line.
‘fbgs’: Framebuffer PDF Viewer for Terminals
fbgs is a unique PDF viewer designed for displaying PDF files directly within a Linux terminal using the framebuffer. This makes it ideal for systems without a graphical environment or for accessing PDFs over SSH. It leverages the fbi image viewer and Ghostscript (gs) to render the PDF content.
To use fbgs, you simply execute fbgs filename.pdf in your terminal. The PDF will then be displayed directly in the console window. Navigation is typically done using the arrow keys, and other keys are mapped for zooming and page control. It’s a lightweight and efficient solution for quick PDF viewing.
fbgs is particularly useful for remote server administration or embedded systems where a full desktop environment isn’t available, offering a practical way to view PDF documentation directly from the command line.
Zathura from the Command Line
Zathura is a highly customizable and lightweight PDF viewer that functions exceptionally well from the Linux command line. It’s known for its minimalist design and focus on keyboard navigation, making it a favorite among power users. To open a PDF, simply type zathura filename.pdf in your terminal.
Zathura supports various keybindings for page turning, searching, and zooming. Its configuration file allows extensive customization of these bindings and appearance. Unlike some other command-line viewers, Zathura provides a more visually appealing rendering of PDFs, closely resembling a graphical viewer.
It’s an excellent choice for those who prefer a fast, efficient, and keyboard-centric way to view PDF documents directly within their terminal, offering a seamless experience for Linux users;

Advanced Techniques
Linux empowers users to open PDFs with Emacs or Evince from the terminal, enabling remote access and sophisticated navigation through command-line interfaces.
Opening PDFs with Emacs
Emacs, a highly customizable text editor, provides a surprisingly effective way to view PDF files directly within the Linux terminal. If you already utilize Emacs, this method eliminates the need to launch a separate PDF viewer application. To open a PDF, simply launch Emacs and then use the command C-x C-f (Ctrl+x followed by Ctrl+f) to open the file.
Emacs will leverage its built-in or configured PDF viewing capabilities, often relying on external tools like pdf-tools. This allows you to virtually open and view a PDF even on a remote server, accessible via SSH. Navigating the document is done using Emacs’ standard keybindings. You can scroll, search, and even perform basic annotations, depending on the configured PDF support within your Emacs environment. This approach is particularly useful for server environments where a graphical interface isn’t available.
Ensure you have the necessary PDF viewing packages installed and configured within Emacs for optimal functionality.
Using ‘evince’ from the Terminal
Evince, a popular PDF viewer for Linux, can be conveniently launched from the command line, offering a quick way to view PDF documents without needing a graphical file manager. To open a PDF file using Evince from the terminal, simply type the command evince file.pdf, replacing “file.pdf” with the actual name of your PDF file.
Alternatively, you can specify the full path to the PDF file if it’s not located in your current working directory. For example, evince /path/to/your/file.pdf. This command will launch Evince in a new window, displaying the specified PDF document.
This method is particularly useful for scripting or automating PDF viewing tasks. It’s a straightforward and efficient way to integrate PDF viewing into your Linux workflow directly from the terminal, providing a seamless experience for users comfortable with the command line.
Navigating PDFs via Command Line
While direct, interactive navigation of PDFs within a pure command-line environment is limited, tools like less offer basic page-scrolling functionality. Using less, you can view the text content of a PDF after converting it with pdftotext. However, for more sophisticated control, consider leveraging Evince or Zathura from the terminal, which allow sending commands for navigation.
These viewers often support keyboard shortcuts for moving between pages (like arrow keys or Page Up/Down). Furthermore, scripting can automate page turns or specific actions within these viewers.
Although not as intuitive as a graphical interface, command-line navigation provides a powerful, scriptable alternative for managing PDFs, especially on servers or in automated workflows where a graphical display isn’t available. It’s a testament to Linux’s flexibility.

Installation and Setup
Linux distributions offer package managers for easy installation of PDF viewers like Evince, Zathura, and fbgs, streamlining the process of opening PDFs.
Installing Evince on Different Distributions
Evince, a widely-used PDF viewer, boasts straightforward installation procedures across various Linux distributions. On Debian-based systems, such as Ubuntu and Linux Mint, utilize the command sudo apt-get install evince in your terminal. This command retrieves and installs Evince along with its dependencies from the official repositories.
For Fedora and other RPM-based distributions like CentOS and Red Hat Enterprise Linux, employ the sudo dnf install evince command. Dnf, the package manager, handles the download and installation process efficiently. Arch Linux users can install Evince using sudo pacman -S evince, leveraging the Arch User Repository (AUR) for access to a vast software collection.
Following installation, Evince should be readily accessible from your application menu. Alternatively, you can launch it directly from the command line by typing evince. Ensure your package lists are updated before installation using commands like sudo apt update (Debian/Ubuntu) or sudo dnf update (Fedora) for optimal results.
Installing Zathura on Different Distributions
Zathura, a highly customizable and lightweight PDF viewer, offers a streamlined experience on Linux. Installation varies slightly depending on your distribution. For Debian-based systems like Ubuntu, use the command sudo apt-get install zathura in the terminal. This fetches Zathura and its core dependencies from the official repositories.
Fedora and related RPM-based distributions benefit from sudo dnf install zathura. The dnf package manager efficiently handles the download and installation. Arch Linux users can install Zathura via sudo pacman -S zathura, accessing it through the Arch User Repository (AUR).
To enhance functionality, consider installing plugins. For example, sudo apt-get install zathura-pdf-poppler (Debian/Ubuntu) adds PDF support. After installation, launch Zathura from the application menu or the command line by simply typing zathura.
Installing fbgs on Different Distributions
fbgs, a framebuffer PDF viewer, provides a unique way to view PDFs directly within the terminal. Installation procedures differ based on your Linux distribution. On Debian/Ubuntu-based systems, utilize the command sudo apt-get install fbgs to install it from the repositories. This will also install necessary dependencies like Ghostscript.
For Fedora and similar RPM-based distributions, employ sudo dnf install fbgs. Arch Linux users can install fbgs using sudo pacman -S fbgs, accessing it through the AUR. Ensure you have a framebuffer device configured for optimal viewing.
After installation, launch fbgs with fbgs filename.pdf in the terminal. fbgs leverages the framebuffer, offering a text-based PDF viewing experience, ideal for remote access or systems without a graphical environment.

Troubleshooting Common Issues
PDF viewing problems in Linux often stem from missing dependencies, incorrect permissions, or display configurations. Verify file integrity and viewer installations.
PDF Files Not Opening
Encountering issues when attempting to open PDF files in Linux is a common frustration, but often easily resolved. First, confirm the file isn’t corrupted by trying to open it on another system. If the problem persists, verify you have a suitable PDF viewer installed – Evince, Okular, or Zathura are excellent choices.
Permissions can also be a culprit; ensure your user account has read access to the PDF file and its containing directory. Use the command line to check permissions with ‘ls -l’ and modify them with ‘chmod’ if necessary. Sometimes, a missing dependency prevents the viewer from functioning correctly. Utilize your distribution’s package manager (apt, yum, dnf) to install any required packages.
Finally, try opening the PDF from the terminal using a command-line viewer like ‘less’ or ‘pdftotext’ to see if it reveals any underlying errors. These tools can provide valuable clues about the problem, such as font issues or invalid PDF structure.
Display Issues with Command-Line Viewers
Command-line PDF viewers, while efficient, can sometimes exhibit display problems in Linux. Issues like incorrect character encoding, missing fonts, or garbled text are not uncommon, particularly with tools like ‘less’ or ‘fbgs’. Ensure your terminal supports UTF-8 encoding, as this is crucial for proper character rendering.
Font configuration is often the root cause. Verify that necessary fonts are installed on your system and correctly configured. ‘fbgs’, relying on Ghostscript, may require specific font packages. Experiment with different terminal emulators, as some handle PDF rendering better than others. Adjusting terminal font size and style can also improve readability.
For ‘less’, try using the ‘-r’ option to disable raw control characters. If problems persist, consider using a graphical PDF viewer for a more reliable display experience, or explore alternative command-line options like Zathura.
Permissions Errors
Encountering “Permission denied” errors when attempting to open a PDF in Linux signifies insufficient access rights to the file. This commonly occurs when the user lacks read permissions for the PDF itself, or for the directory containing it. Utilize the ‘ls -l’ command to inspect file permissions; the output reveals read, write, and execute permissions for the owner, group, and others.
To rectify this, employ the ‘chmod’ command to grant appropriate permissions. For example, ‘chmod +r filename.pdf’ adds read permission for all users. Alternatively, ‘chmod 755 directoryname’ sets permissions for a directory, allowing read, write, and execute access for the owner, and read and execute for group and others.
Ensure the user attempting to open the PDF is the owner or a member of the group with sufficient permissions. If the file resides on a network share, verify network permissions are correctly configured.

Alternative Methods
Linux users can leverage web browsers to directly open PDF files, or utilize conversion tools to transform them into editable formats like text or images.
Using Web Browsers to Open PDFs
Modern web browsers, such as Chrome, Firefox, and Edge, possess built-in PDF viewing capabilities, offering a convenient alternative to dedicated PDF viewers in Linux.
Simply dragging and dropping a PDF file onto an open browser window will typically initiate the viewing process directly within the browser tab.
Alternatively, you can right-click the PDF file in your file manager and select “Open with” followed by your preferred browser.
This method eliminates the need for installing additional software and provides a familiar interface for those accustomed to web browsing.
Browser-based PDF viewers generally support essential functionalities like zooming, searching, and printing, making them suitable for basic PDF viewing tasks.
However, advanced features like form filling or PDF editing might be limited compared to specialized PDF applications.
The browser’s rendering engine handles the display, ensuring compatibility across various PDF versions.
Converting PDFs to Other Formats
While Linux excels at viewing PDFs, sometimes converting them to other formats—like text, images, or editable documents—becomes necessary. Several tools facilitate this process.

The ‘pdftotext’ command, a part of the Poppler utilities, efficiently extracts text content from PDFs, saving it as a plain text file. This is useful for archiving or text analysis.
For image conversion, tools like ImageMagick can render PDF pages into various image formats (JPEG, PNG, etc.).
LibreOffice Draw can open and edit PDFs, allowing you to save them in formats like DOCX, ODT, or even as editable PDFs with modifications.
Online conversion services also provide a convenient option, though privacy considerations should be kept in mind.
The choice of conversion tool depends on the desired output format and the complexity of the PDF document.
Remember to verify the converted file’s integrity and formatting after the conversion process.