How To Install can-utils on Ubuntu 20.04

In this tutorial we learn how to install can-utils on Ubuntu 20.04. can-utils is SocketCAN userspace utilities and tools

Introduction

In this tutorial we learn how to install can-utils on Ubuntu 20.04.

What is can-utils

can-utils is:

CAN is a message-based network protocol designed for vehicles originally created by Robert Bosch GmbH. SocketCAN is a set of open source CAN drivers and a networking stack contributed by Volkswagen Research to the Linux kernel.

This package contains some userspace utilities for Linux SocketCAN subsystem.

Basic tools to display, record, generate and replay CAN traffic: candump, canplayer, cansend, cangen, cansniffer. CAN access via IP sockets: canlogserver, bcmserver, socketcand. CAN in-kernel gateway configuration: cangw. CAN bus measurement and testing: canbusload, can-calc-bit-timing, canfdtest. ISO-TP (ISO 15765-2 2016) tools: isotpsend, isotprecv, isotpsniffer, isotpdump, isotpserver, isotpperf, isotptun. CAN log file converters: asc2log, log2asc, log2long. CAN Serial Line Discipline configuration (for slcan driver): slcan_attach, slcand, slcanpty. SAE J1939 tools and demo: jacd, jspy, jsr, testj1939.

There are three methods to install can-utils on Ubuntu 20.04. We can use apt-get, apt and aptitude. In the following sections we will describe each method. You can choose one of them.

Install can-utils Using apt-get

Update apt database with apt-get using the following command.

sudo apt-get update

After updating apt database, We can install can-utils using apt-get by running the following command:

sudo apt-get -y install can-utils

Install can-utils Using apt

Update apt database with apt using the following command.

sudo apt update

After updating apt database, We can install can-utils using apt by running the following command:

sudo apt -y install can-utils

Install can-utils Using aptitude

If you want to follow this method, you might need to install aptitude first since aptitude is usually not installed by default on Ubuntu. Update apt database with aptitude using the following command.

sudo aptitude update

After updating apt database, We can install can-utils using aptitude by running the following command:

sudo aptitude -y install can-utils

How To Uninstall can-utils on Ubuntu 20.04

To uninstall only the can-utils package we can use the following command:

sudo apt-get remove can-utils

Uninstall can-utils And Its Dependencies

To uninstall can-utils and its dependencies that are no longer needed by Ubuntu 20.04, we can use the command below:

sudo apt-get -y autoremove can-utils

Remove can-utils Configurations and Data

To remove can-utils configuration and data from Ubuntu 20.04 we can use the following command:

sudo apt-get -y purge can-utils

Remove can-utils configuration, data, and all of its dependencies

We can use the following command to remove can-utils configurations, data and all of its dependencies, we can use the following command:

sudo apt-get -y autoremove --purge can-utils

References

Summary

In this tutorial we learn how to install can-utils package on Ubuntu 20.04 using different package management tools: apt, apt-get and aptitude.