How I Manage My Finances From the Command Line

I don't know about you, but the pit in my stomach that develops when I don't know my own finances is humongous. The relief I feel when I just know I can pay bills, everything is fine, I'm saving money, etc. is worth the work I put into it.

The crux of my financial handling came when I discovered a piece of free and open source software known as Ledger CLI. It was a "double-entry accounting" software; I didn't know what that meant, but as someone looking to fix that pit in my stomach, I was happy to try it out.

While double-entry accounting is a little bit to wrap your head around, it's also a really good way to think about transactions, so I think it's worth the effort. The main idea of double entry accounting is that you don't just keep track of where money goes, but also where it comes from; i.e. if you pay $15 (flat) for a video game, you would subtract $15 from your bank account but also add $15 to the expense account related to video games. This lets you see not only your current balance, but where your money is going, what you are spending it on.

Unlike most accounting software I've found, which use either a proprietary (yuck!) binary "project" format or CSV, Ledger uses a plain-text file that you maintain however you'd like to; the software never alters your ledger file. To add a new transaction, you open the file in a text editor and add an entry; it is quite a human-friendly format, once you get the basics down.

Transactions

2023/07/14 Starbucks
  Expenses:Wants:Coffee  $9.08
  Assets:Checking

While it may be slightly confusing as to what exactly is going on, I have a good way to break it down for you. The date is in year/month/day format, followed by the "payee"; think of the payee like the name you would write on a check, or who is receiving the money: in this case, Starbucks. The following lines, indented with at least one space, are the postings of the transaction. Each posting has an account and an amount, which must be separated by at least two spaces. The accounts are entirely up to you how you keep track of things, just know they are hierarchical; that is, the total of `Expenses` will include the total of `Expenses:Wants`. While you are able to use any accounts you would like (there is no requirement) Ledger CLI recommends these five top level categories, and all of your accounts are sub-accounts of the main five. I highly recommend this system as well, to keep your ledger reports, well, legible, and to make sure others can help you if you need it.

  1. Expenses: where money goes,
  2. Assets: where money sits,
  3. Income: where money comes from,
  4. Liabilities: money you owe,
  5. Equity: the real value of your property.

With these five top-level accounts, it makes it quite easy to describe most transactions relatively easily with only one or two specifying accounts.

Continuing on the coffee posting up above: you probably noticed the posting on the very bottom has no amount; this is because we are taking advantage of Ledger's ability to automatically calculate the amount needed to make the transaction equal to zero. In double entry accounting, you keep track of both where money comes from and where money goes, so all the postings in a transaction should add up to zero. In this case, Ledger will calculate $-9.08, as there is only a single posting without an amount. If you want, you could always write this value explicitly, but I see no reason to. After writing an entry like this in your ledger file, you can then run reports on it. We'll talk more about that after going over what it looks like when you get payed.

2023/07/14 Me
  Assets:Checking  $69.420
  Income:Salary

The date is self-explanatory, I would hope :Þ. As you can see, you are now the one receiving the money, which means you get to write your name, "me", etc. in the payee section. The money is credited into your checking account, and being sourced from the salary account (where your salary is paid from). Personally, I like to further specify which salary I'm being paid using a sub-account, as at times you may have multiple.

Generating Basic Reports

Finally, let's get to the meat and potatoes of Ledger CLI; the reports it can generate.

Let's imagine the following ledger file, ./.test.ledger.

2023/06/17 Me
  Assets:Checking  $69.420
  Income:Salary

2023/06/19 Starbucks
  Expenses:Wants:Coffee  $6.84
  Assets:Checking

2023/07/14 Me
  Assets:Checking  $69.420
  Income:Salary

2023/07/14 Starbucks
  Expenses:Wants:Coffee  $9.08
  Assets:Checking

Here is the balance report, which should always add up to zero; it tells you where money comes from and where money goes.

$ ledger -f ./.test.ledger bal
            $122.920  Assets:Checking
             $15.920  Expenses:Wants:Coffee
           $-138.840  Income:Salary
--------------------
                   0

The balance report is the one I use the most often; it lets me see how much money is left in my accounts/budget, as well as how much money has been allotted to different expenses.

One of the most powerful features of Ledger is it's ability to specify periods. This means you can specify "this week", "last month", "from 2 weeks ago", etc, and it will generate a report for the transactions within that time frame. With this feature, you can generate quarterly reports as well as see weekly spending habits.

As well as the balance report, there is also the register report; this mimics what you might see in a checkbook. The register report makes it easier to see how each transaction adds to the totals that appear in the balance report.

23-Jun-17 Me                    Assets:Checking             $69.420      $69.420
                                Income:Salary              $-69.420            0
23-Jun-19 Starbucks             Expenses:Wants:Coffee        $6.840       $6.840
                                Assets:Checking             $-6.840            0
23-Jul-14 Me                    Assets:Checking             $69.420      $69.420
                                Income:Salary              $-69.420            0
23-Jul-14 Starbucks             Expenses:Wants:Coffee        $9.080       $9.080
                                Assets:Checking             $-9.080            0

And that's how I manage my finances from the command line :). Interested in Ledger CLI? This is just the tip of the iceberg. Here is an online manual (highly recommend).

Explore Similar Posts Through Tags