Learn Ethical Hacking
Tools

nnn – Fast, Free and Friendly Terminal File Browser for Linux

nnn - Linux Terminal File Browser
Written by Ravi Saive

nnn is a terminal file browser with a strong focus on bridging the gap between the terminal and the desktop environment. It made its first release a couple of days back and brings some powerful features with it.

nnn builds on noice, a very fast but minimally featured terminal file browser. Historically, the terminal has been known to be a favourite medium to interact with the OS for developers and hackers.

However, regular desktop users tend to prefer the GUI subsystem. nnn brings the terminal and the GUI into harmony, by allowing a desktop opener to take control of opening all kinds of files completely, or selectively. And that’s just the beginning!

nnn - Terminal File Browser

nnn – Terminal File Browser

The best part of nnn is users do not need to remember too many shortcuts to get started. Navigation is designed to be simple, with keyboard shortcuts already familiar to the average desktop user i.e., the arrows, Enter, Home, End, Page Up/Down etc.

RedHat RHCSA and RHCE Certification Exam Study Ebook

nnn is written by Arun Prakash Jana, the author of popular command-line utilities like googler, Buku, imgp etc.

Features of nnn

  • Basic (default) and detail view modes.
  • Disk usage analyzer mode.
  • Familiar navigation shortcuts.
  • Filter contents in the current directory (supports regex).
  • Sort files by modification time and size (default: alphanumeric).
  • Open a desktop file manager in current directory.
  • Run top, open a file in EDITOR or PAGER, spawn a shell in the current directory.
  • Show detailed file information (stat and file combined).
  • Copy the full file path with a shortcut (needs a tiny external script).
  • Options to start in detail and disk usage analyzer modes.
  • Highly optimized code.
nnn - File Browser Showing Disk Usage

nnn – File Browser Showing Disk Usage

The developer of nnn makes some interesting choices:
  • No configuration file (only a few environment variables).
  • One utility instead of multiple popular utilities like ranger, ncdu, du etc.
  • Directories first in all modes (even in disk usage analyzer mode).
  • Numerical names sorter in the same order (1, 2, … 10, 11, …).
  • File size in binary format.
  • No potentially destructive/risky operations (e.g., mv, rm, cp), use ! to run commands from a shell instead.
  • No multi-pane mode, clean and clutter-free view focused on content.
  • Scan each directory on visit (even in disk usage analyzer mode) rather than storing all the information from the first scan. This keeps the information up to date and blocks lesser memory. The re-scan doesn’t take long due to very optimized algorithms.
  • No feature bloat.
nnn - Showing File Information

nnn – Showing File Information

nnn is under heavy development and you can contribute to or discuss new features you would like to see in the project’s ToDo list.

  Gmail Message Tray - Gmail Notifications in GNOME System Tray

Environment variables

NNN_OPENER: let a desktop opener handle it all. E.g.:

export NNN_OPENER=xdg-open
export NNN_OPENER="gio open"
export NNN_OPENER=gvfs-open

NNN_FALLBACK_OPENER: nnn pre-defines some static associations for popular file types with mpv, vi and zathura (for PDFs). The static association has no effect if NNN_OPENER is set.

However, if these are your favourite applications, you can set your desktop opener to NNN_FALLBACK_OPENER to handle the rest of the files. E.g.:

export NNN_FALLBACK_OPENER=xdg-open
export NNN_FALLBACK_OPENER="gio open"
export NNN_FALLBACK_OPENER=gvfs-open

NNN_DE_FILE_MANAGER: set to a desktop file manager to open with the o key. E.g.:

export NNN_DE_FILE_MANAGER=thunar

NNN_COPIER: set to a script to open with the ^K key and copy the current file path. Example script (for Linux):

#!/bin/sh
echo -n $1 | xsel --clipboard --input

Installation of nnn in Linux

To install on Ubuntu (and derivatives), run:

$ sudo add-apt-repository ppa:twodopeshaggy/jarun
$ sudo apt-get update
$ sudo apt-get install nnn

Arch Linux users can install nnn from AUR.

Users can also compile and install nnn from the source. nnn is written in C. The only dependency is the ncurses libray.

How to Use nnn in Linux

nnn can start in 3 different view modes (can be switched at runtime with keyboard shortcuts):

Start modes

  • Basic mode: just file names with no extra information (nnn).
  • Detail mode: shows file date, size and name (nnn -d).
  • Disk usage analyzer mode: shows sorted disk usage (directories first) (nnn -S).
  Ukuu Kernel Manager - Install and Upgrade Linux Kernels in Ubuntu

1-min setup

Install nnn using your preferred mode or Set nnn to open in detail view mode by adding.

alias n='nnn -d'

to your shell’s rc file (e.g. ~/.bashrc for bash).

  • Set either NNN_OPENER or NNN_FALLBACK_OPENER
  • Set NNN_DE_FILE_MANAGER
  • Start nnn using the alias n
  • Press ? at runtime for a list of keyboard shortcuts

Conclusion

nnn is for users who would like to enjoy the accessibility of the desktop from the comfort of the terminal. Those who use a drop-down terminal would benefit most because the terminal would also retain the context of any ongoing work. Try it out and let us know your feeback!

This tip is submitted by developer of the app, if you have any such product or tip do share with us here.

Join Our Community Of 250,000+ Linux Lovers by liking us on Facebook, or follow us on Twitter, Google+ and Instagram.

If you liked this article, sign up for the fossmint newsletter for handpicked selection of stories from FossMint delivered to your inbox every day.


Top Deals

About the author

Ravi Saive

I am Ravi Saive, creator of FossMint. A Computer Geek and Linux Guru who loves to share tricks and tips on Internet. Most Of My Servers runs on Open Source Platform called Linux. Follow Me: Twitter, Facebook and Google+

  • Arun

    nnn works on OS X too. OS X users can run:

    brew install jarun/nnn/nnn

    to install nnn.

  • Timothy Legg

    Where is the source tarball?

    • Arun

      Visit the Releases page.