How To Install gosu on Debian 9

In this tutorial we learn how to install gosu on Debian 9. gosu is Simple Go-based setuid+setgid+setgroups+exec

Introduction

In this tutorial we learn how to install gosu on Debian 9.

What is gosu

gosu is:

This is a simple tool grown out of the simple fact that “su” and “sudo” have very strange and often annoying TTY and signal-forwarding behavior. They’re also somewhat complex to setup and use (especially in the case of “sudo”), which allows for a great deal of expressivity, but falls flat if all you need is “run this specific application as this specific user and get out of the pipeline”.

The core of how “gosu” works is stolen directly from how Docker/libcontainer itself starts an application inside a container (and in fact, is using the “/etc/passwd” processing code directly from libcontainer’s codebase).

Once the user/group is processed, we switch to that user, then we “exec” the specified process and “gosu” itself is no longer resident or involved in the process lifecycle at all. This avoids all the issues of signal passing and TTY, and punts them to the process invoking “gosu” and the process being invoked by “gosu”, where they belong.

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

Install gosu Using apt-get

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

sudo apt-get update

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

sudo apt-get -y install gosu

Install gosu Using apt

Update apt database with apt using the following command.

sudo apt update

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

sudo apt -y install gosu

Install gosu 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 Debian. Update apt database with aptitude using the following command.

sudo aptitude update

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

sudo aptitude -y install gosu

How To Uninstall gosu on Debian 9

To uninstall only the gosu package we can use the following command:

sudo apt-get remove gosu

Uninstall gosu And Its Dependencies

To uninstall gosu and its dependencies that are no longer needed by Debian 9, we can use the command below:

sudo apt-get -y autoremove gosu

Remove gosu Configurations and Data

To remove gosu configuration and data from Debian 9 we can use the following command:

sudo apt-get -y purge gosu

Remove gosu configuration, data, and all of its dependencies

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

sudo apt-get -y autoremove --purge gosu

Dependencies

gosu have the following dependencies:

References

Summary

In this tutorial we learn how to install gosu package on Debian 9 using different package management tools: apt, apt-get and aptitude.