Science and technology

Handle your file system from the Linux terminal

I are likely to get pleasure from light-weight purposes. They’re good for low spec computers, for remote shells, for the impatient person (OK, I admit, that is me), and for the methods we scrap collectively to combat the inevitable zombie apocalypse. In my seek for an ideal mix of a light-weight utility with all the trendy conveniences we have discovered from expertise, I stumbled throughout a file supervisor referred to as nnn. The nnn file supervisor exists in a terminal solely, but it surely looks like a contemporary keyboard-driven utility with intuitive actions and straightforward navigation.

(Seth Kenlon, CC BY-SA 4.0)

Install nnn

On Linux, chances are you’ll discover nnn in your Linux distribution’s software program repository. For occasion, on Debian:

$ sudo apt set up nnn

If your repository would not have nnn out there, you’ll be able to obtain a bundle in your distribution from OBS or from the venture Git repository.

On macOS, use Homebrew or MacPort.

Using nnn

Launch nnn from a terminal:

$ nnn

Your terminal is now the nnn interface, and by default it lists the contents of your present listing:

1 2 3 4 ~


4/8 2022-12-01 15:54 drwxr-xr-x 6B

At the highest of the nnn interface are tabs (referred to as a “context” in nnn terminology), numbered one to 4.

At the underside of the nnn interface, there are possession and permission particulars about your present choice.

Use both the Up and Down arrow keys or the okay and j keys (as in Vim) to alter your choice. Use the Right arrow key, Return, or the l key to enter a listing or to open a file. Use the Left arrow key or h to again out of a listing.

That’s it for navigation. It’s simpler than any graphical file supervisor as a result of there are not any widgets that get in the way in which. There’s no must Tab over buttons, you simply use the arrow keys or the QWERTY dwelling row.

Open a file

One of the explanations you utilize a file supervisor is to discover a file after which open it. Your desktop already has default purposes set, and nnn inherits this information, so press Return or Right arrow to open a file in its default utility.

Should you have to open a file in one thing apart from its default utility, press = as an alternative, after which sort the title of the applying within the immediate on the backside of the nnn interface.

Copy a file

To copy a file or any variety of recordsdata, you need to first choose a file to repeat, then navigate to its meant vacation spot, and at last invoke the copy command. Thanks to nnn’s context management (these are the numbers on the high of the display screen, and you’ll consider them as tabs in an internet browser), it is a fast course of.

  1. First, choose the file you wish to copy and press Spacebar to pick the file. It’s marked with a plus signal (+) to point its chosen state.

  2. Press 2 to alter to a brand new context.

  3. Navigate to the goal listing and press p to repeat.

Move a file

Moving recordsdata is similar course of as copying a file, however the keyboard shortcut for the motion is v.

Selecting recordsdata

There are just a few methods to mark alternatives in nnn. The first is handbook choice. You discover a file you wish to choose, after which press Spacebar to mark it as chosen. Press Spacebar once more to deselect it.

One choice would not cancel one other, so you’ll be able to choose a number of recordsdata manually, however that may turn out to be tedious. Another approach to choose many recordsdata directly is to “mark in ” and “mark out”. To mark a variety, press m on the primary file you wish to choose, after which use your arrow keys to maneuver to the final file you wish to choose. Press m once more to shut the choice:

1 2 3 4 ~


6/8 [ +6 ] 2022-12-01 15:54 drwxr-xr-x 6B

Finally, the third approach to choose recordsdata is to press a to choose all. Use A to invert the choice (on this case, to choose none.)

Creating an archive

To create an archive of a file or a choice of recordsdata, press z. At the underside of the nnn interface, you are prompted to decide on between your present merchandise of your choice. Then you are prompted for a file title. Luckily, nnn is a brilliant utility and derives its file sort from the title you present. If you title your archive instance.tar.xz then nnn creates a TAR archive with lzma compression, however in case you title it then it creates a ZIP file.

You can confirm the file sort your self by urgent the f key together with your new archive chosen:

  File: /dwelling/tux/Downloads/
  Size: 184707          Blocks: 368        IO Block: 4096   common file
Device: fd00h/64768d    Inode: 17842380    Links: 1
Access: (0664/-rw-rw-r--)  Uid: ( 1002/     tux)   Gid: ( 1002/     tux)
Context: unconfined_u:object_r:user_home_t:s0
Access: 2022-09-20 15:12:09.770187616 +1200
Modify: 2022-09-20 15:12:09.775187704 +1200
Change: 2022-09-20 15:12:09.775187704 +1200
 Birth: 2022-09-20 15:12:09.770187616 +1200
Zip archive information, at the least v2.0 to extract
utility/zip; charset=binary

Cancel an motion

When you end up backed right into a nook and must press a panic button, use the Esc key. (This is more likely to be the only most complicated keyboard shortcut for a longtime terminal person who’s accustomed to Ctrl+C.)

Never shut nnn

To stop nnn, press Q at any time.

It’s a really succesful file supervisor, with features for symlinks, FIFO, bookmarks, batch renaming, and extra. For a full checklist of what nnn can do, press the ? key.

The most intelligent function is the shell perform. Press ! to open a shell over the nnn interface. You’ll overlook nnn is there, till you sort exit and you end up again within the nnn interface. It’s that simple to go away nnn open on a regular basis, so you’ll be able to all the time have fast entry to the quickest light-weight file administration you are more likely to expertise.

Most Popular

To Top