How to use your Linux terminal as a file manager
A terminal is an application that provides access to the user shell of an operating system (OS). Traditionally, the shell is the place where the user and the OS could interface directly with one another. And historically, a terminal was a physical access point, consisting of a keyboard and a readout (a printer, long ago, and later a cathode ray tube), that provided convenient access to a mainframe. Don’t be fooled by this «ancient» history. The terminal is as relevant today as it was half a century ago, and in this article, I provide five common file management tasks you can do with nothing but the shell.
1. Open a terminal and look around
Today, everyone’s got a computer on their desk or in their bag. The mainframe-and-terminal model is now essentially emulated through an application. Your operating system might have a unique name for it, but generically it’s usually known as a «terminal» or «console».
- Linux: Look for Console, Konsole, or Terminal. Regardless of the name, you can usually launch it from your application menu using the key word «terminal.»
- macOS: The default terminal application isn’t open source and is widely considered lacking in features. Download iTerm2 to get a feature-rich, GPLv2 replacement.
- Windows: PowerShell is the open source terminal application, but it uses a language and syntax all its own. For this article to be useful on Windows, you can install Cygwin which provides a POSIX environment.
Once you have your terminal application open, you can get a view of your file system using the command ls .
2. Open a folder
In a graphical file manager, you open a folder by double-clicking on it. Once it’s open, that folder usually dominates the window. It becomes your current location.
In a terminal, the thought process is slightly different. Instead of opening a folder, you change to a location. The end result is the same: once you change to a folder, you are «in» that folder. It becomes your current location.
For example, say you want open your Downloads folder. The command to use is cd plus the location you want to change to:
To «close» a folder, you change out of that location. Taking a step out of a folder you’ve entered is represented by the cd command and two dots ( .. ):
You can practice entering a folder and then leaving again with the frequent use of ls to look around and confirm that you’ve changed locations:
$ cd Downloads $ ls cat-photo.jpg $ cd .. $ ls Documents Downloads Music Pictures Videos $ cd Documents $ ls zombie-apocalypse-plan-C.txt zombie-apocalypse-plan-D.txt $ cd .. $ ls Desktop Documents Downloads Music Pictures Videos
Repeat it often until you get used to it!
The advanced level of this exercise is to navigate around your files using a mixture of dots and folder names.
Suppose you want to look in your Documents folder, and then at your Desktop. Here’s the beginner-level method:
$ cd Documents $ ls zombie-apocalypse-plan-C.txt zombie-apocalypse-plan-D.txt $ cd .. $ ls Desktop Documents Downloads Music Pictures Videos $ cd Desktop $ ls zombie-apocalypse-plan-A.txt
There’s nothing wrong with that method. It works, and if it’s clear to you then use it! However, here’s the intermediate method:
$ cd Documents $ ls zombie-apocalypse-plan-C.txt zombie-apocalypse-plan-D.txt $ cd ../Desktop $ ls zombie-apocalypse-plan-A.txt
You effectively teleported straight from your Documents folder to your Desktop folder.
There’s an advanced method, of this, too, but because you know everything you need to know to deduce it, I leave it as an exercise for you. (Hint: It doesn’t use cd at all.)
3. Find a file
Admit it, you sometimes misplace a file. There’s a great Linux command to help you find it again, and that command is appropriately named find :
$ find $HOME -iname "*holiday*" /home/tux/Pictures/holiday-photos /home/tux/Pictures/holiday-photos/winter-holiday.jpeg
- The find command requires you to tell it where to look.
- Casting a wide net is usually best (if you knew where to look, you probably wouldn’t have to use find ), so I use $HOME to tell find to look through my personal data as opposed to system files.
- The -iname option tells find to search for a file by name, ignoring capitalization.
- Finally, the «*holiday*» argument tells find that the word «holiday» appears somewhere in the filename. The * characters are wildcards, so find locates any filename containing «holiday», whether «holiday» appears at the beginning, middle, or end of the filename.
The output of the find command is the location of the file or folder you’re looking for. You can change to a folder using the cd command:
$ cd /home/tux/Pictures/holiday-photos $ ls winter-holiday.jpeg
You can’t cd to a file, though:
$ cd /home/tux/Pictures/holiday-photos/winter-holiday.jpeg cd: Not a directory
4. Open a file
If you’ve got a file you want to open from a terminal, use the xdg-open command:
$ xdg-open /home/tux/Pictures/holiday-photos/winter-holiday.jpeg
Alternatively, you can open a file in a specific application:
$ kate /home/tux/Desktop/zombie-apocalypse-plan-A.txt
5. Copy or move a file or folder
The cp command copies and the mv file moves. You can copy or move a file by providing the current location of the file, followed by its intended destination.
For instance, here’s how to move a file from your Documents folder to its parent directory:
$ cd Documents $ ls zombie-apocalypse-plan-C.txt zombie-apocalypse-plan-D.txt $ mv zombie-apocalypse-plan-C.txt .. $ cd .. $ ls Documents Downloads Music Pictures Videos zombie-apocalypse-plan-C.txt
While moving or copying, you can also rename it. Here’s how to move a file called example.txt out of the directory with the new name old-example.txt :
$ mv example.txt ../old-example.txt
You don’t actually have to move a file from one directory to another just to rename it:
$ mv example.txt old-example.txt
Linux terminal for files
The Linux desktop has a lot of file managers available to it. There are simple ones, network-transparent ones, and dual-panel ones. There are ones written for GTK, Qt, ncurses, and Swing. Big ones, small ones, and so on. But you can’t talk about Linux file managers without talking about the one that’s been there from the beginning: the terminal.
The terminal is a powerful tool, and it takes practice to get good at it. When I was learning the terminal, I used it for what I could, and then I opened a graphical file manager for advanced operations that I hadn’t learned for the terminal yet. If you’re interested in learning the how to use a terminal, there’s no time like the present, so get started today!
8 Excellent Console Linux File Managers (Updated 2023)
A console application is computer software which can be used with a text-only computer interface, the command line interface, or a text-based interface included within a graphical user interface operating system, such as a terminal emulator (such as GNOME Terminal or the aforementioned Terminator). Whereas a graphical user interface application generally involves using the mouse and keyboard (or touch control), with a console application the primary (and often only) input method is the keyboard. Many console applications are command line tools, but there is a wealth of software that has a text-based user interface making use of ncurses, a library which allow programmers to write text-based user interfaces.
Console based applications are light on system resources (very useful on low specified machines), can be faster and more efficient than their graphical counterparts, they do not stop working when X is restarted, and are perfect for scripting purposes. When designed well, console applications offer a surprisingly improvement in productivity. The applications are leaner, faster, easier to maintain, and remove the need to have installed a whole raft of libraries.
The whole is greater than the sum of its parts is a very famous quote from Aristotle, a Greek philosopher and scientist. This quote is particularly pertinent to Linux. In my view, one of Linux’s biggest strengths is its synergy. The usefulness of Linux doesn’t derive only from the huge raft of open source (command line) utilities. Instead, it’s the synergy generated by using them together, sometimes in conjunction with larger applications.
So what does the command-line offer users? There is a wide range of console based software which provide the same or similar functionality to their graphical equivalents. In the field of system administration, Linux is blessed with a good range of graphical file managers. However, some users are in their comfort zone managing files from the shell, finding it the fastest way to navigate the file system and perform file operations. This is, in part, because console based file managers are more keyboard friendly, enabling users to perform file operations without using a mouse, and make it quicker to navigate the filesystem and issue commands in the console at the same time.
Some people may prefer to use the shell instead of a console file manager. We covered some great tools that let you navigate the file system quickly – check out 9 Best Command Line Navigation Tools.
To provide an insight into the quality of software that is available, we have compiled a list of 8 high quality console based open source file managers. Hopefully, there will be something of interest for anyone who wishes to revel in the power of the console.
Here’s our verdict on the file managers.
Let’s explore the 8 file managers at hand. For each title we have compiled its own portal page, a full description with an in-depth analysis of its features, screenshot, together with links to relevant resources.
Console File Managers | |
---|---|
nnn | Fast and flexible file manager |
Midnight Commander | User-friendly yet powerful orthodox file manager |
Ranger | File manager with an ncurses frontend written in Python |
lf | Terminal file manager heavily inspired by ranger |
CliFM | Shell-like, command line terminal file manager |
Vifm | ncurses based file manager with vi like keybindings |
Last File Manager | 1 or 2 pane Python based file manager |
WCM Commander | A Far Manager clone |
Popular series | |
---|---|
The largest compilation of the best free and open source software in the universe. Each article is supplied with a legendary ratings chart helping you to make informed decisions. | |
Hundreds of in-depth reviews offering our unbiased and expert opinion on software. We offer helpful and impartial information. | |
Replace proprietary software with open source alternatives: Google, Microsoft, Apple, Adobe, IBM, Autodesk, Oracle, Atlassian, Corel, Cisco, Intuit, and SAS. | |
Awesome Free Linux Games Tools showcases a series of tools that making gaming on Linux a more pleasurable experience. This is a new series. | |
Machine Learning explores practical applications of machine learning and deep learning from a Linux perspective. This is a new series. | |
New to Linux? Read our Linux for Starters series. We start right at the basics and teach you everything you need to know to get started with Linux. | |
Alternatives to popular CLI tools showcases essential tools that are modern replacements for core Linux utilities. | |
Essential Linux system tools focuses on small, indispensable utilities, useful for system administrators as well as regular users. | |
Linux utilities to maximise your productivity. Small, indispensable tools, useful for anyone running a Linux machine. | |
Surveys popular streaming services from a Linux perspective: Amazon Music Unlimited, Myuzi, Spotify, Deezer, Tidal. | |
Saving Money with Linux looks at how you can reduce your energy bills running Linux. | |
Home computers became commonplace in the 1980s. Emulate home computers including the Commodore 64, Amiga, Atari ST, ZX81, Amstrad CPC, and ZX Spectrum. | |
Now and Then examines how promising open source software fared over the years. It can be a bumpy ride. | |
Linux at Home looks at a range of home activities where Linux can play its part, making the most of our time at home, keeping active and engaged. | |
Linux Candy reveals the lighter side of Linux. Have some fun and escape from the daily drudgery. | |
Getting Started with Docker helps you master Docker, a set of platform as a service products that delivers software in packages called containers. | |
Best Free Android Apps. We showcase free Android apps that are definitely worth downloading. There’s a strict eligibility criteria for inclusion in this series. | |
These best free books accelerate your learning of every programming language. Learn a new language today! | |
These free tutorials offer the perfect tonic to our free programming books series. | |
Linux Around The World showcases usergroups that are relevant to Linux enthusiasts. | |
Stars and Stripes is an occasional series looking at the impact of Linux in the USA. |