Efficiently manage files with nnn
Tutorial – nnn
If you're a Linux lover, you'll know the command line is the slickest and most efficient way to interact with the system. Free yourself from point-and-click with the nnn command-line file manager.
Popular distros such as Ubuntu have given Linux to the masses with colorful icons and point-and-click interfaces. Still, experienced Linux users can save huge amounts of time and effort by staying within the command-line interface (CLI).
However, the Linux terminal itself doesn't make it easy to navigate quickly between files, plus you need to memorize a string of commands in order to rename, copy, and move files. This is where nnn comes in. If developer jarun's name sounds familiar, it's because he's also the author of ddgr – a CLI for the privacy-centric DuckDuckGo search engine, which we covered in issue 270 [1].
His utility nnn is inspired by an older minimalist file manager for the terminal, noice, from which it derives its rather recursive name (Nnn's Not Noice).
Like ddgr, nnn cuts out the GUI and allows you to perform operations efficiently. To get started, just fire up your regular terminal and run
sudo apt-get install nnn
for Debian-based Linux distros or
sudo dnf install nnn
for RHEL-based distros.
You can now fire up nnn by running nnn
from the command line (Figure 1).
nnn Navigation
Once you fire up nnn, you can start navigating files and folders using the arrow keys. Press right to open a folder and left to return. Alternatively, you can use the same keys as for navigating Vim: H (left), L (right), K (up), and J (down).
When browsing files, simply hit enter in order to open a file within its default app. Out of the box, nnn only has limited support for opening files from within the terminal. You can, however, press e when a text file is highlighted to display contents. (Use :wq
when you're done.)
nnn Names
Once you're comfortable hopping from directory to directory, you may want to perform more advanced file operations.
Press ? to view a complete list of all available commands. (You can also type :wq
here to return to the main window.)
This list can seem overwhelming at first, so start simple. During testing, I downloaded a text file of Shakespeare's Romeo and Juliet, which Project Gutenberg has given the rather unhelpful filename rg1513.txt
.
In order to rename it, I simply navigated to the folder in question, highlighted it, and pressed Ctrl+R. A prompt appeared at the bottom of the window to enter a new filename (e.g., romeoandjuliet.txt)
.
An interesting quirk of nnn is that you can also copy files and folders to a new destination from here. Just press Ctrl+R as if you wanted to rename the file/folder and then press enter (Figure 2). The prompt will now allow you to enter the destination to which you want to copy the file.
nnn Nominations
Although copying individual files can be useful, most often you'll need to move multiple files or even the contents of entire folders.
This is one area where using a file manager such as Nautilus can be much more convenient than entering multiple terminal commands to select individual files.
Luckily, nnn makes the selection process intuitive. In order to select a file or folder, just right-click on the file/folder or press the space bar (Figure 3). You can do this to multiple files within a folder or just press A to select them all. A + icon will appear next to selected files.
If you can't find what you're looking for, use /
to open the prompt, which allows you to filter listings by keyword (Figure 4). You can also use D to toggle detailed file information such as creation date and size.
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
System76 Refreshes Meerkat Mini PC
If you're looking for a small form factor PC powered by Linux, System76 has exactly what you need in the Meerkat mini PC.
-
Gnome 48 Alpha Ready for Testing
The latest Gnome desktop alpha is now available with plenty of new features and improvements.
-
Wine 10 Includes Plenty to Excite Users
With its latest release, Wine has the usual crop of bug fixes and improvements, along with some exciting new features.
-
Linux Kernel 6.13 Offers Improvements for AMD/Apple Users
The latest Linux kernel is now available, and it includes plenty of improvements, especially for those who use AMD or Apple-based systems.
-
Gnome 48 Debuts New Audio Player
To date, the audio player found within the Gnome desktop has been meh at best, but with the upcoming release that all changes.
-
Plasma 6.3 Ready for Public Beta Testing
Plasma 6.3 will ship with KDE Gear 24.12.1 and KDE Frameworks 6.10, along with some new and exciting features.
-
Budgie 10.10 Scheduled for Q1 2025 with a Surprising Desktop Update
If Budgie is your desktop environment of choice, 2025 is going to be a great year for you.
-
Firefox 134 Offers Improvements for Linux Version
Fans of Linux and Firefox rejoice, as there's a new version available that includes some handy updates.
-
Serpent OS Arrives with a New Alpha Release
After months of silence, Ikey Doherty has released a new alpha for his Serpent OS.
-
HashiCorp Cofounder Unveils Ghostty, a Linux Terminal App
Ghostty is a new Linux terminal app that's fast, feature-rich, and offers a platform-native GUI while remaining cross-platform.