1. Overview
Linux, a popular and powerful operating system, offers many features and advantages:
- flexibility
- security
- performance
However, Linux applications may crash or encounter errors. Thus, Apport is a tool that helps us report and fix bugs in Linux applications.
In this tutorial, we’ll learn what Apport is, how it works, and how to enable and disable it on a Linux system.
2. Understanding Apport
Basically, Apport is a software package that performs the following actions when an application crashes:
- detects the crash and intercepts the signal by setting up a crash handler using the /proc/sys/kernel/core_pattern file
- collects relevant diagnostic information from the application and the system
- submits the error report to a central server, if desired
Further, Apport aims to improve the quality and stability of Linux applications by providing useful feedback to developers and users.
Notably, Apport was originally developed for Ubuntu but it has been adopted by other Linux distributions as well. As stated, its main purpose is to facilitate the reporting and fixing of bugs in Linux applications.
In particular, Apport works by intercepting the signals sent when an application crashes. Then, it collects diagnostic information from the crashed application:
- stack trace
- core dump
- system logs
Apport also checks if the crash is a known issue and if a fix or workaround is available.
Finally, Apport can submit the error report to a central server, such as Launchpad, where developers and administrators can analyze and process it.
3. Checking Apport Status
Before enabling or disabling, we should check the current status of Apport on the system.
In practice, we can run the systemctl command with root permission to verify whether Apport is running:
$ sudo systemctl status apport.service
● apport.service - LSB: automatic crash report generation
Loaded: loaded (/etc/init.d/apport; generated)
Active: active (exited) since Wed 2023-12-20 00:44:55 WAT; 23min left
Docs: man:systemd-sysv-generator(8)
Process: 779 ExecStart=/etc/init.d/apport start (code=exited, status=0/SUCC>
CPU: 26ms
Dec 20 00:44:54 abdulhameed-E5470 systemd[1]: Starting LSB: automatic crash rep>
Dec 20 00:44:54 abdulhameed-E5470 apport[779]: * Starting automatic crash repo>
Dec 20 00:44:55 abdulhameed-E5470 apport[779]: ...done.
Dec 20 00:44:55 abdulhameed-E5470 systemd[1]: Started LSB: automatic crash rep
The output shows that the Apport service is loaded and active. Further, this means that Apport is currently enabled on the system.
4. Enabling Apport in Linux
Enabling Apport can have several benefits:
- automatic error reporting
- timely bug detection and resolution
- improved user experience
However, the use of Apport can also have some drawbacks:
- increased storage space and network usage
- potential privacy and security risks
- possible performance degradation
Therefore, users should decide whether to enable Apport according to their needs and preferences. If Apport isn’t enabled on the system, we can enable it by using the command line or via graphical tools.
4.1. Using the service Command
Firstly, we can temporarily e****nable the Apport service with the service command:
$ sudo service apport start force_start=1
This will be in effect just for the current login session. Thus, Apport is automatically disabled the next time we log in to the system.
We can also enable it permanently by removing the force_start option.
4.2. Editing the Configuration File
We can also enable Apport permanently by editing the apport file in the /etc/default/ directory using the nano command:
$ sudo nano /etc/default/apport
Let’s display the typical content of this apport file using the cat command:
$ cat /etc/default/apport
# set this to 0 to disable apport, or to 1 to enable it
# you can temporarily override this with
# sudo service apport start force_start=1
enabled=0
Then, we can change the value of the enabled variable to 1 to enable Apport permanently.
4.3. Using the Graphical User Interface
Alternatively, we can enable Apport by using the system settings. For instance, on Ubuntu, we can go to Settings > Privacy > Diagnostics, and select Automatic in the drop-down menu.
After enabling the Apport service, we can check the Apport status to ensure it’s enabled.
5. Disabling Apport on Linux
To disable Apport on Linux, we can also use the service command, edit the configuration file, or remove the Apport package.
5.1. Using the service Command
We can disable Apport using the service command:
$ sudo service apport stop
As a result, the Apport service will be stopped and the system won’t detect application crashes again.
5.2. Configuration File Modifications
In this case, we edit the file /etc/default/apport and change the value of the enabled variable from 1 to 0, as we saw in the previous section.
Additionally, we can edit the file /etc/apport/crashdb.conf to disable crash reporting. Notably, the crashdb.conf file defines the crash databases that Apport can use to submit and retrieve error reports. It also specifies the implementation, the options, and the problem types for each database.
Let’s look at the typical content of the crashdb.conf configuration file:
$ cat /etc/apport/crashdb.conf
# map crash database names to CrashDatabase implementations and URLs
default = 'ubuntu'
...
databases = {
'ubuntu': {
'impl': 'launchpad',
'bug_pattern_url': 'http://people.canonical.com/~ubuntu-archive/bugpatterns/bugpatterns.xml',
'dupdb_url': 'http://people.canonical.com/~ubuntu-archive/apport-duplicates',
'distro': 'ubuntu',
# 'problem_types': ['Bug', 'Package'],
'escalation_tag': 'bugpattern-needed',
'escalated_tag': 'bugpattern-written',
},
'canonical-oem': {
'impl': 'launchpad',
'bug_pattern_url': 'http://people.canonical.com/~ubuntu-archive/bugpatterns/bugpatterns.xml',
'project': get_oem_project(),
},
'debug': {
# for debugging
'impl': 'memory',
'bug_pattern_url': '/tmp/bugpatterns.xml',
'distro': 'debug'
},
}
Thus, removing the hash symbol in front of the line that contains the problem_type variable prevents Apport from reporting any type of problem.
5.3. Removing Apport Packages
We can also use a package manager like apt to remove Apport packages from the system:
$ sudo apt purge apport apport-gtk apport-retrace apport-symptoms
Let’s understand the package names specified in the command:
- apport: main Apport package
- apport-gtk: Apport GTK user interface for handling crash reports
- apport-retrace: package that provides tools for automatically retracing crash reports
- apport-symptoms: package containing symptom scripts used by Apport for categorizing issues
Importantly, the purge option removes not only the package but also its configuration files, essentially wiping out all traces of Apport.
6. Conclusion
Apport is a useful tool for users and developers of Linux applications to detect bugs and errors. However, Apport may also cause some issues, such as privacy concerns and performance issues. Therefore, users may want to enable or disable Apport on a Linux system.
In this article, we learned what Apport is, how it works, and how to enable and disable it on a Linux system using the command line, graphical tools, and a configuration file.