(Last Updated On: November 7, 2018)

This blog post will take you through the steps to install Ledger double-entry accounting system on Ubuntu 18.04. Ledger is a powerful command-line accounting tool based on the power and completeness of double-entry accounting. Ledger gives you unparalleled command-line reporting interface to your data without the need for a flashy UI.

With Ledger, all entries are kept in a text file that you maintain.  It figures out from looking at your data what you mean by it and how you want it reported back to you. Ledger is a double-entry accounting tool, meaning that all entries must balance. If an entry does not balance, it will cause an error and the report will not be generated.

Install Ledger on Ubuntu 18.04 LTS

The ledger source code is available on GitHub but it can be installed through a PPA repository.

Add the PPA repository for Ledger to your Ubuntu 18.04 system:

sudo add-apt-repository ppa:mbudde/ledger

After adding the repository, update your packages list and install Ledger.

sudo apt update
sudo apt-get install ledger

To check the version of Ledger software installed, run:

$ ledger --version
Ledger 3.1.2-20160801, the command-line accounting tool

Copyright (c) 2003-2016, John Wiegley. All rights reserved.

This program is made available under the terms of the BSD Public License.
See LICENSE file included with the distribution for details and disclaimer.

Using Ledger double-entry accounting system on Ubuntu 18.04

Now that you have installed Ledger, it is time to use it for your accounting. The official Ledger Documentation cover many use cases with examples. Ledger needs a Journal File with a record of your financial transaction to work on.

An example journal is included with the source code distribution, called drewr3.dat (see Example Journal File). Download the file to your local machine:

wget https://raw.githubusercontent.com/ledger/ledger/next/test/input/drewr3.dat

This file exhibits many ledger features include automatic and virtual transactions.

Show balances of all of your accounts

$ ledger  -f drewr3.dat balance
         $ -3,804.00  Assets
          $ 1,396.00    Checking
             $ 30.00      Business
         $ -5,200.00    Savings
         $ -1,000.00  Equity:Opening Balances
          $ 6,654.00  Expenses
          $ 5,500.00    Auto
             $ 20.00    Books
            $ 300.00    Escrow
            $ 334.00    Food:Groceries
            $ 500.00    Interest:Mortgage
         $ -2,030.00  Income
         $ -2,000.00    Salary
            $ -30.00    Sales
            $ -63.60  Liabilities
            $ -20.00    MasterCard
            $ 200.00    Mortgage:Principal
           $ -243.60    Tithe
--------------------
           $ -243.60

This shows you the balance of all accounts. Options and search terms can pare this down to show only the accounts you want.

Show only your Assets and Liabilities:

A more useful report is to show only your Assets and Liabilities:

$ ledger -f drewr3.dat balance Assets Liabilities

See output below:

Register Report

To show all transactions and a running total:

$ ledger -f drewr3.dat register

Ledger will generate:

10-Dec-01 Checking balance                        Assets:Checking                                            $ 1,000.00              $ 1,000.00
                                                  Equity:Opening Balances                                   $ -1,000.00                       0
10-Dec-20 Organic Co-op                           Expenses:Food:Groceries                                       $ 37.50                 $ 37.50
                                                  Expenses:Food:Groceries                                       $ 37.50                 $ 75.00
                                                  Expenses:Food:Groceries                                       $ 37.50                $ 112.50
                                                  Expenses:Food:Groceries                                       $ 37.50                $ 150.00
                                                  Expenses:Food:Groceries                                       $ 37.50                $ 187.50
                                                  Expenses:Food:Groceries                                       $ 37.50                $ 225.00
                                                  Assets:Checking                                             $ -225.00                       0
10-Dec-28 Acme Mortgage                           Liabilities:Mortgage:Principal                               $ 200.00                $ 200.00
                                                  Expenses:Interest:Mortgage                                   $ 500.00                $ 700.00
                                                  Expenses:Escrow                                              $ 300.00              $ 1,000.00
                                                  Assets:Checking                                           $ -1,000.00                       0
11-Jan-02 Grocery Store                           Expenses:Food:Groceries                                       $ 65.00                 $ 65.00
                                                  Assets:Checking                                              $ -65.00                       0
11-Jan-05 Employer                                Assets:Checking                                            $ 2,000.00              $ 2,000.00
                                                  Income:Salary                                             $ -2,000.00                       0
                                                  (Liabilities:Tithe)                                         $ -240.00               $ -240.00
11-Jan-14 Bank                                    Assets:Savings                                               $ 300.00                 $ 60.00
                                                  Assets:Checking                                             $ -300.00               $ -240.00
11-Jan-19 Grocery Store                           Expenses:Food:Groceries                                       $ 44.00               $ -196.00
                                                  Assets:Checking                                              $ -44.00               $ -240.00
11-Jan-25 Bank                                    Assets:Checking                                            $ 5,500.00              $ 5,260.00
                                                  Assets:Savings                                            $ -5,500.00               $ -240.00
11-Jan-25 Tom's Used Cars                         Expenses:Auto                                              $ 5,500.00              $ 5,260.00
                                                  Assets:Checking                                           $ -5,500.00               $ -240.00
11-Jan-27 Book Store                              Expenses:Books                                                $ 20.00               $ -220.00
                                                  Liabilities:MasterCard                                       $ -20.00               $ -240.00
11-Dec-01 Sale                                    Assets:Checking:Business                                      $ 30.00               $ -210.00
                                                  Income:Sales                                                 $ -30.00               $ -240.00
                                                  (Liabilities:Tithe)                                           $ -3.60               $ -243.60

To limit this to a more useful subset, simply add the accounts you are  interested in seeing transactions for:

$ ledger  -f drewr3.dat register Groceries
10-Dec-20 Organic Co-op                           Expenses:Food:Groceries                                       $ 37.50                 $ 37.50
                                                  Expenses:Food:Groceries                                       $ 37.50                 $ 75.00
                                                  Expenses:Food:Groceries                                       $ 37.50                $ 112.50
                                                  Expenses:Food:Groceries                                       $ 37.50                $ 150.00
                                                  Expenses:Food:Groceries                                       $ 37.50                $ 187.50
                                                  Expenses:Food:Groceries                                       $ 37.50                $ 225.00
11-Jan-02 Grocery Store                           Expenses:Food:Groceries                                       $ 65.00                $ 290.00
11-Jan-19 Grocery Store                           Expenses:Food:Groceries                                       $ 44.00                $ 334.00

This matches the balance reported for the Groceries’ account:

$ ledger  -f drewr3.dat balance Groceries
            $ 334.00  Expenses:Food:Groceries

If you would like to find a transaction to only a certain payee use ‘payee’ or ‘@’:

$ ledger -f drewr3.dat register payee "Organic"
10-Dec-20 Organic Co-op                           Expenses:Food:Groceries                                       $ 37.50                 $ 37.50
                                                  Expenses:Food:Groceries                                       $ 37.50                 $ 75.00
                                                  Expenses:Food:Groceries                                       $ 37.50                $ 112.50
                                                  Expenses:Food:Groceries                                       $ 37.50                $ 150.00
                                                  Expenses:Food:Groceries                                       $ 37.50                $ 187.50
                                                  Expenses:Food:Groceries                                       $ 37.50                $ 225.00
                                                  Assets:Checking                                             $ -225.00                       0

Cleared Report

The cleared report shows what your obligations are versus what expenditures have actually been recorded.

$ ledger -f drewr3.dat cleared

Check Ledger Documentation to learn more.