Gaining control over the Linux operating system requires mastering the terminal—and one of the foundational skills is learning how to open files from the command line. This not only builds confidence in using the Linux OS, but also opens the door to faster workflows and automation.
What’s the Point of Using the Terminal to Open Files?
Nowadays, graphical user interfaces (GUIs) dominate the way most people interact with their systems. For those accustomed to GUI-heavy workflows, it’s natural to wonder why anyone would opt to use the terminal to open files—especially when using a mouse might feel quicker and more intuitive.
For everyday tasks, yeah, a GUI would get the work done for you. But, for developers or power users, GUI-based workflows can quickly feel limiting.
Take opening a configuration file as an example. With a GUI, you typically open a file explorer, navigate through folders using your mouse, double-click several times, and finally access the file. Now, if you are using a terminal, you simply launch it, type the exact path if you know, and open the file—no mouse, no menus, fewer keystrokes. Oh! If the file needs admin permission, no worries, type sudo with filename, and you are good to go.
Beyond speed, the terminal offers more control and flexibility. For instance, if you want to view just the first 20 lines of a large log file, you can do so instantly with a single command. Achieving the same in a GUI will require you to search for an application that can do something similar. In certain environments—such as Raspberry Pi setups, remote servers, or headless systems—a GUI may not be available at all. In these cases, knowing how to use the terminal becomes essential.
Another key benefit of using the terminal apart from just opening files is automation. Let’s say you need to rename 100 files based on their modification dates, or you would like to open certain files or apps in batch. A simple script can handle this efficiently in the terminal. With a GUI, you’d have to search for a third-party tool, which may have limited features or even require you to pay for subscriptions.
Terminal-based text editors like Nano or less are significantly lighter than full-featured applications like VS Code or LibreOffice. On older machines—especially those with traditional hard drives—using the terminal can save time and resources.
Finally, working in the terminal encourages a deeper understanding of how your system works. You’ll naturally learn about Linux file systems, permissions, and text processing—concepts that often remain hidden when using only graphical interfaces. So, I wouldn’t say a terminal is better than a GUI, but if you are all in to learn and explore the world of computers and Linux systems, then it’s best to get used to with terminal.
How to View or Open Text Files in the Linux Terminal
On Linux, you have several built-in tools you can use to work with text files, like cat, less tail, and nano.
Cat Command
One of the most basic methods for opening text files is using the cat (short for concatenate) command. To open files using cat or any of the methods we are going to discuss, first you need to open a terminal in the directory where the text file is stored, or navigate to the directory of the text file. Then type:
cat my-text.txt
It’s fast and simple. But remember that this is not best suited for large text files.

Related
These 5 Linux Commands Make Reading Large Files Easier
Here is how you can easily read large text files.
Less Command
The less command displays text one page at a time. In order to scroll, you can press the Up and Down Arrow keys to navigate. If you want to quit, press the Q button on your keyboard.
less my-text.txt
Head and Tail Command
These commands show the beginning or ending of a file. So, if you want to see the first few lines of a file, type.
head my-text.txt
To see the ending lines of a text file, type.
tail my-text.txt
Nano
Nano is a command-line text editor, which means it’s different from the above utilities. With nano, you can create, open, and edit files all from your terminal. Also, nano comes pre-installed with many but not all Linux distros and instead provide you with alternative text editors like micro or vim. So you may have to install nano yourself if launching fails.
To open a file using nano, type.
nano my-text.txt
If the file exists in the directory, it will open it, otherwise it will create a new file with the name specified.
Editing text in nano is simple, just navigate using arrow keys and make changes. Once you are done, you can save your text file using Ctrl+O and then hit the Enter key to confirm the changes. To exit, press Ctrl+X.
You will also see keyboard shortcuts displayed on your screen when using nano. For example, if you want to cut a line, you can do so by pressing Ctrl+K, to paste a line pres Ctrl+U.
If you want to search for specific text, press Ctrl+W and type the word you want to search for.
Some shortcuts are hidden from nano’s main screen, such as undo and redo. If you want to undo some changes, press Alt+U. To redo changes in nano, press Alt+E. To see all the shortcuts available in nano, just press Ctrl+G. This will open a help screen which will show everything about nano, such as navigation commands, text editing, spellchecking and more.
If you were to open or edit a config file, you’re going to get a “permission denied” error. This is because you are not authorized to open the file. You can easily open system files by typing:
sudo nano system.config
You will be prompted to enter your password and the file will open.
Be careful when using the sudo command. Any small mistake in system config files can break things.
Not all files you have will be a text file. You will often have PDFs, images, and videos in your file system. You can open media files using the terminal, but typically you won’t be viewing them inside the terminal itself, like with text files. Instead, the terminal will act as a launcher for an external application that will open the media files.
Using XDG
You might be wondering what xdg-open is. It is a command-line utility that opens a file using the desktop system’s default application — just like double-clicking a file in a graphical file manager. It was introduced to simplify app launching in terminal emulators, letting different distros use the same command to open the same file but with different applications. So, almost all modern Linux desktop systems like Ubuntu, Fedora, and Linux Mint come with XDG.
You can use the xdg-open command in desktop environments to open media files. For example, if you want to open a PDF file, type:
xdg-open my-pdf.pdf
If you have an image file, type:
xdg-open wallpaper4.jpg
Similarly, you can open any kind of file, like an MP3 or video file, given that you have an application that can open it, like a media player for video file or PDF reader.
Launching With Specific Apps
Apart from using XDG, you can use specific apps to open files. For example, if you have a video file, you could use the terminal to open it using, let’s say, VLC.
vlc my-audio.mp3
You can also run VLC in headless mode (without its GUI), which means you will hear the audio, but won’t see the usual VLC media player screen shown up. To do so, type:
cvlc my-audio.mp3
Next, if you want to open a PDF using your browser, you can do so.
firefox my-pdf.pdf
This will run Firefox and open the desired PDF.
Other Ways to Open Media Files Inside the Terminal
Now, if you want to open media files literally inside the terminal, you can technically do so. That said, you’ll likely need to install specialized terminal apps.
For example, if you want to open a PDF file within the terminal and not launch another GUI app, you can do so by installing pdftotext, which will convert a PDF into text format and display it inside the terminal. There are more out there, like a command to stream videos in your terminal, or even a web browser that runs inside the terminal.
So, using the terminal to open files isn’t about rejecting GUIs—it’s about choosing the right tool for the job and also getting familiar with the command line. When you’re working with text files, troubleshooting a server, or automating tasks, the terminal is unbeatable. But for media files like images and videos, a GUI app is still important.
Mastering both approaches will give you the flexibility to handle just about any file on a Linux system, no matter where or how you’re working.