Install Tokei on Ubuntu 20.04

Install Tokei on Ubuntu 20.04

Tokei is a command line tool for counting blank lines, comment lines, and physical lines of source code. Results are displayed in the table. Tokei supports various programming languages.

This tutorial demonstrates how to install Tokei on Ubuntu 20.04.

Install Tokei

Execute the following command to download tar.gz file from releases page of the Tokei repository:

sudo wget -qO tokei.tar.gz

Extract a tar.gz file to /usr/local/bin directory.

sudo tar xf tokei.tar.gz -C /usr/local/bin

Now tokei command can be used for all users.

We can check Tokei version:

tokei --version

Remove unnecessary tar.gz file:

rm -rf tokei.tar.gz

Testing Tokei

Create a main.c file for testing:

nano main.c

Add the following code:

#include <stdio.h>

// Hello world program
int main() {
    printf("Hello world\n");

    return 0;

Now run tokei command to count lines of code:

tokei main.c

Command will print the following results:

 Language            Files        Lines         Code     Comments       Blanks
 C                       1            8            5            1            2
 Total                   1            8            5            1            2

We can provide directory as argument for tokei command. It will analyze a given directory and all subdirectories. For example, download the Tokei source code from GitHub:

wget -qO tokei-master.tar.gz
tar xf tokei-master.tar.gz

Run tokei command to analyze given directory:

tokei tokei-master

Uninstall Tokei

If Tokei is no longer needed, you can remove executable file:

sudo rm -rf /usr/local/bin/tokei

Leave a Comment

Cancel reply

Your email address will not be published.