We're an ISO27001:2013 Certified Supplier


File managers have their place, but sometimes you don’t have a graphical environment to work from, or you feel that it’s quicker to simply do everything from the command line. Under those circumstances, ranger may be worth a few minutes of your time to investigate.

In summary, ranger is a curses-based file manager written in Python, and with vi keybindings by default – and it’s fast to use.


The initial screen shows three Miller columns, showing successively deeper level of the directory structure:

  • the centre column shows the current directory with a file or directory highlighted
  • the left column, the narrowest, shows the parent directory with the current directory highlighted
  • If the centre column as a file highlighted, the right column, the widest, shows a preview of that file. If the centre column has a directory highlighted, the right column shows the contents of that directory. In either case, then, the right column can be thought of as a preview column.

Ranger display

There’s a lot of detail in the default display. As well as the current file and parent directories, the screen shows:

  • the current user@hostname:/current/directory is displayed at the top left
  • the protection, size and ownership of the current file or directory is shown at the bottom left
  • the bottom right: the total size of all files in the current directory; the free space in the current directory’s partition; and the total number of files in the current directory with the number of the current file.


Navigation between columns can be with the arrow keys, the vi keybindings h,j,k,l, or with the mouse.

It’s intuitive, too. For example, if the centre column has a directory highlighted, the return key or the l key will enter that directory. If the centre column has a normal file highlighted, the return or l key will preview it, thus making those keys consistent with “show me more detail”.

ranger supports some key pair bindings as well, again based upon the vi keybindings – and ranger is really helpful here. For example, gg will take you to the top of the middle column, just as it takes you to the top of the file in vi. But as soon as the first g is typed, ranger pops up a little window to show you all the possible second keys:

ranger g key completion

Not only does gg take you to the top of the column, but there are also lots of predefined shortcuts as can be seen above – gd takes us to /dev, ge to /etc, gh to our home directory, and more. After the first g, hitting esc will cancel the command.

Other useful vi-inspired navigation shortcuts include:

G: Go to the foot of the column
^F: Page down
^B: Page up

The actions that may be carried out on the currently highlighted file include:

r: (“read”) Open with (popup menu to choose application)
o: (“order”) Sort by various criteria (popup menu to choose how)
z: Toggle options, such as displaying hidden files (again, a popup menu)
/: Search
n: Next match
N: Previous match
yy: (“yank”) Copy file
pp: (“paste”) Paste file
<delete>: Delete selected file

Tabs Too

ranger has a tabbed interface if you want it. ^N will create a new tab; ^W will close the current tab; the tab key will move the next tab and shift-tab to the previous. So copying files from one location to another can be done by yy-ing them in one tab and pp-ing them in another. For operations on multiple files, they can be selected in one tab with the v key or space bar, then copied and pasted with yy and pp.


Help is available from within ranger, albeit with a somewhat unusual unconventional syntax. The following keys are defined:

?: Show the ranger man page
1?: Show the current keybindings
2?: Show the ranger built-in commands (not discussed above)
3?: Show the current settings
R: Reload current directory
Q: Quit


There are four configuration files for ranger and, as is not uncommon, it’s possible to have local versions under your home directory that override the system-wide defaults.

I recommend running the following command, which will make local copies of the configuration files under ~/.config/ranger:

$ ranger --copy-config=all

The four files created in ~/.config.ranger are:

  • commands.py, which contains custom commands that can be run from within ranger. The syntax for running them is similar to commands in vi, in that typing a colon will put the cursor on the bottom line ready for the commands. As you might expect from the .py extension, the commands are written in Python.
  • rc.conf, which is the configuration file that defines default settings and key bindings.
  • rifle.conf, the configuration file for rifle, ranger‘s file opening utility, and defines which external programs are used. It’s possible to define a search list of external programs so that if the first is not installed, the second is tried, and so on.
  • scope.sh, which defines how the various types of file are previewed from within ranger. Again, a search list of “helpers” can be constructed.


File managers are not for everyone, but ranger does have some advantages. For me, key is its ability to preview many types of file without having to launch external graphical programs. That makes it ideal for tasks such as tidying up directories.

In this article, I’ve barely scratched the surface of what ranger can do. It is a hugely configurable, very powerful text based file manager.

Could This Tech Tip Be Improved?

Let us know in the comments below.

Leave a Reply

Your email address will not be published. Required fields are marked *

Get free Linux business strategies

Fill in this form and we'll send you updated Linux business strategies and ideas each week
  • This field is for validation purposes and should be left unchanged.