# Chapter 12

![](https://1209410422-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FeghnpTQ7npkdA7nmIC2s%2Fuploads%2FerYS3G3oRJBmYHrz1209%2F0.jpeg?alt=media)

### Chapter 12 <a href="#toc171120120" id="toc171120120"></a>

### Predator-OS Configuration <a href="#toc171120121" id="toc171120121"></a>

### Configuring the System for another language <a href="#toc171120122" id="toc171120122"></a>

If the system was installed using Frenc&#x68;**,** the machine will probably already have French set as the default languag&#x65;**.** However, it is good to know what the installer does to set the languag&#x65;**,** so that late&#x72;**,** if the need arise&#x73;**,** you can change i&#x74;**.**

***TOOL*****&#x20;The locale command to display the current configuration**

The **locale** command lists a summary of the current configuration of various locale parameters **(**&#x64;ate forma&#x74;**,** numbers forma&#x74;**,** et&#x63;**.),** presented in the form of a group of standard environment variables dedicated to the dynamic modification of these setting&#x73;**.**

### Setting the Default Language <a href="#toc171120123" id="toc171120123"></a>

A locale is a group of regional setting&#x73;**.** This includes not only the language for tex&#x74;**,** but also the format for displaying number&#x73;**,** date&#x73;**,** time&#x73;**,** and monetary sum&#x73;**,** as well as the alphabetical comparison rule&#x73;**.** Although each of these parameters can be specified independently from the other&#x73;**,** we generally use a local&#x65;**,** which is a coherent set of values for these parameters corresponding to a **“**&#x72;egio&#x6E;**”** in the broadest sens&#x65;**.** These locales are usually indicated under the for&#x6D;**,** **language-code\_COUNTRY-CODE,** sometimes with a suffix to specify the character set and encoding to be use&#x64;**.** This enables consideration of idiomatic or typographical differences between different regions with a common languag&#x65;**.**

The locales package includes all the elements required for proper functioning of **“**&#x6C;ocalizatio&#x6E;**”** of various application&#x73;**.** During installatio&#x6E;**,** this package will ask you to select a set of supported language&#x73;**.** This set can be changed at any time by running **dpkg-reconfigure locales** as roo&#x74;**.**

**#** dpk&#x67;**-**&#x72;econfigure locales

![](https://1209410422-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FeghnpTQ7npkdA7nmIC2s%2Fuploads%2FpK9mr3gv38yiUwkU24QS%2F1.jpeg?alt=media)

The first question invites you to select **“**&#x6C;ocale&#x73;**”** to suppor&#x74;**.** Selecting all English locales **(**&#x6D;eaning those beginning with **“en\_”)** is a reasonable choic&#x65;**.** Do not hesitate to also enable other locales if the machine will host foreign user&#x73;**.** The list of locales enabled on the system is stored in the **/etc/locale.gen** fil&#x65;**.** It is possible to edit this file by han&#x64;**,** but you should run **locale-gen** after any modification&#x73;**.** It will generate the necessary files for the added locales to wor&#x6B;**,** and remove any obsolete file&#x73;**.**

The second questio&#x6E;**,** entitled **“**&#x44;efault locale for the system environmen&#x74;**”,** requests a default local&#x65;**.** The recommended choice in the USA is **“en\_US.UTF-8”.** British

English speakers will prefer **“en\_GB.UTF-8”,** and Canadians will prefer either **“en\_CA.UTF-8”** o&#x72;**,** for Frenc&#x68;**,** **“fr\_CA.UTF-8”.** The **/etc/default/locale** file will then be modified to store this choic&#x65;**.** From ther&#x65;**,** it is picked up by all user sessions since PAM will inject its content in the **LANG** environment variabl&#x65;**.**

The **/etc/environment** file provides the **login,** **gdm,** or even **ssh** programs with the correct environment variables to be create&#x64;**.**

![](https://1209410422-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FeghnpTQ7npkdA7nmIC2s%2Fuploads%2FLhN8f0BTvXxn8gi8Svvy%2F2.jpeg?alt=media)

The **/**&#x65;t&#x63;**/**&#x64;efaul&#x74;**/**&#x6C;ocale file works in a similar manne&#x72;**,** but contains only the LANG environment variabl&#x65;**.** Thanks to this spli&#x74;**,** some PAM users can inherit a complete environment without localizatio&#x6E;**.** Indee&#x64;**,** it is generally discouraged to run server programs with localization enable&#x64;**;** on the other han&#x64;**,** localization and regional settings are recommended for programs that open user session&#x73;**.**

![](https://1209410422-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FeghnpTQ7npkdA7nmIC2s%2Fuploads%2FXbVRjqVJ4fTi6wpzkXjQ%2F3.jpeg?alt=media)

### Configuring the Keyboard <a href="#toc171120124" id="toc171120124"></a>

Even if the keyboard layout is managed differently in console and graphical mod&#x65;**,** it offers a single configuration interface that works for bot&#x68;**:** it is based on debconf and is implemented in the keyboar&#x64;**-**&#x63;onfiguration packag&#x65;**.** Thus the **dpkgreconfigure keyboard-configuration** command can be used at any time to reset the keyboard layou&#x74;**.**

**$sudo dpkg-reconfigure keyboard-configuration**

![](https://1209410422-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FeghnpTQ7npkdA7nmIC2s%2Fuploads%2F414qY5vPdyCbmY98Ex6a%2F4.jpeg?alt=media)

### Migrating to UTF-8 <a href="#toc171120125" id="toc171120125"></a>

The generalization of UT&#x46;**-**&#x38; encoding has been a long-awaited solution to numerous difficulties with interoperabilit&#x79;**,** since it facilitates international exchange and removes the arbitrary limits on characters that can be used in a documen&#x74;**.** The one drawback is that it had to go through a rather difficult transition phas&#x65;**.** Since it could not be completely transparent **(**&#x74;hat i&#x73;**,** it could not happen at the same time all over the worl&#x64;**),** two conversion operations were require&#x64;**:** one on file content&#x73;**,** and the other on filename&#x73;**.** Fortunatel&#x79;**,** the bulk of this migration has been completed and we discuss it largely for referenc&#x65;**.**

### Configuring the Network <a href="#toc171120126" id="toc171120126"></a>

If Network Manager is not installe&#x64;**,** then the installer will configure ifupdown by creating the **/etc/network/interfaces** fil&#x65;**.** A line starting with **auto** gives a list of interfaces to be automatically configured on boot by the **networking** servic&#x65;**.** When there are many interface&#x73;**,** it is good practice to keep the configuration in different files inside **/etc/network/interfaces.d/** as described in sidebar[ ](https://debian-handbook.info/browse/stable/sect.apt-get.html#sidebar.directory.d)BACK TO[ BASICS Directories ending in **.d.**](https://debian-handbook.info/browse/stable/sect.apt-get.html#sidebar.directory.d)

![](https://1209410422-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FeghnpTQ7npkdA7nmIC2s%2Fuploads%2FACg5lal4T3VfQIAYVeOn%2F5.jpeg?alt=media)

### Ethernet Interface <a href="#toc171120127" id="toc171120127"></a>

If the computer has an Ethernet car&#x64;**,** the IP network that is associated with it must be configured by choosing from one of two method&#x73;**.** The simplest method is dynamic configuration with DHC&#x50;**,** and it requires a DHCP server on the local networ&#x6B;**.** It may indicate a desired hostnam&#x65;**,** corresponding to the **hostname** setting in the example belo&#x77;**.** The DHCP server then sends configuration settings for the appropriate networ&#x6B;**.**

### Names of network interfaces <a href="#toc171120128" id="toc171120128"></a>

By defaul&#x74;**,** the kernel attributes generic names such as **eth0** **(**&#x66;or wired Etherne&#x74;**)** or **wlan0** **(**&#x66;or WiF&#x69;**)** to the network interface&#x73;**.** The number in those names is a simple incremental counter representing the order in which they have been detecte&#x64;**.** With modern hardwar&#x65;**,** that order **(**&#x61;t least in theor&#x79;**)** might change for each reboot and thus the default names are not reliabl&#x65;**.**

![](https://1209410422-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FeghnpTQ7npkdA7nmIC2s%2Fuploads%2FocdT3vLgZTsk3osFsdI1%2F6.jpeg?alt=media)

### Wireless Interface <a href="#toc171120129" id="toc171120129"></a>

Getting wireless network cards to work can be a bit more challengin&#x67;**.** First of al&#x6C;**,** they often require the installation of proprietary firmwares which are not installed by defaul&#x74;**.** Then wireless networks rely on cryptography to restrict access to authorized users onl&#x79;**,** this implies storing some secret key in the network configuratio&#x6E;**.** Le&#x74;**’**&#x73; tackle those topics one by on&#x65;**.**

Network Manager knows how to handle various types of connections **(**&#x44;HC&#x50;**,** manual configuratio&#x6E;**,** local networ&#x6B;**),** but only if the configuration is set with the program itsel&#x66;**.** This is why it will systematically ignore all network interfaces in **/etc/network/interfaces** and **/etc/network/interfaces.d/** for which it is not suite&#x64;**.** Since Network Manager does not give details when no network connections are show&#x6E;**,** the easy way is to delete from **/etc/network/interfaces** any configuration for all interfaces that must be managed by Network Manage&#x72;**.**

### Setting the Hostname and Configuring the Name Service <a href="#toc171120130" id="toc171120130"></a>

The purpose of assigning names to IP numbers is to make them easier for people to remembe&#x72;**.** In realit&#x79;**,** an IP address identifies a network interface associated with a device such as a network car&#x64;**.** Since each machine can have several network card&#x73;**,** and several interfaces on each car&#x64;**,** one single computer can have several names in the domain name syste&#x6D;**.**

Each machine i&#x73;**,** howeve&#x72;**,** identified by a main **(**&#x6F;r **“**&#x63;anonica&#x6C;**”)** nam&#x65;**,** stored in the **/etc/hostname** file and communicated to the Linux kernel by initialization scripts through the **hostname** comman&#x64;**.** The current value is available in a virtual filesyste&#x6D;**,** and you can get it with the **cat /proc/sys/kernel/hostname** comman&#x64;**.**

![](https://1209410422-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FeghnpTQ7npkdA7nmIC2s%2Fuploads%2FGlo2OM4WCu4xHGVlcvaM%2F7.jpeg?alt=media)

Surprisingl&#x79;**,** the domain name is not managed in the same wa&#x79;**,** but comes from the complete name of the machin&#x65;**,** acquired through name resolutio&#x6E;**.** You can change it in the **/etc/hosts** fil&#x65;**;** simply write a complete name for the machine there at the beginning of the list of names associated with the address of the machin&#x65;**,** as in the following exampl&#x65;**:**

12&#x37;**.**&#x30;**.**&#x30;**.**&#x31; localhost

### Name Resolution <a href="#toc171120131" id="toc171120131"></a>

The mechanism for name resolution in Linux is modular and can use various sources of information declared in the **/etc/nsswitch.conf** fil&#x65;**.** The entry that involves host name resolution is **hosts.** By defaul&#x74;**,** it contains **files dns,** which means that the system consults the **/etc/hosts** file firs&#x74;**,** then DNS server&#x73;**.** NI&#x53;**/**&#x4E;I&#x53;**+** or LDAP servers are other possible source&#x73;**.**

![](https://1209410422-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FeghnpTQ7npkdA7nmIC2s%2Fuploads%2F9GKO9SFyOt0U57kztLsk%2F8.jpeg?alt=media)

### Configuring DNS Servers <a href="#toc171120132" id="toc171120132"></a>

DNS **(**&#x44;omain Name Servic&#x65;**)** is a distributed and hierarchical service mapping names to IP addresse&#x73;**,** and vic&#x65;**-**&#x76;ers&#x61;**.** Specificall&#x79;**,** it can turn a huma&#x6E;**-**&#x66;riendly name such as **[www.Predator-OS.com](http://www.Predator-OS.com)** into the actual IP addres&#x73;**,** **213.244.11.247.**

To access DNS informatio&#x6E;**,** a DNS server must be available to relay request&#x73;**.** Falcot Corp has its ow&#x6E;**,** but an individual user is more likely to use the DNS servers provided by their IS&#x50;**.**

The DNS servers to be used are indicated in **/etc/resolv.conf,** one per lin&#x65;**,** with the **nameserver** keyword preceding an IP addres&#x73;**,** as in the following exampl&#x65;**:**

nameserver 21&#x32;**.**&#x32;&#x37;**.**&#x33;&#x32;**.**&#x31;76 nameserver 21&#x32;**.**&#x32;&#x37;**.**&#x33;&#x32;**.**&#x31;77 nameserver &#x38;**.**&#x38;**.**&#x38;**.**&#x38;

Note that the **/etc/resolv.conf** file may be handled automatically **(**&#x61;nd overwritte&#x6E;**)** when the network is managed by NetworkManager or configured via DHC&#x50;**,** or when resolvconf is installed or system&#x64;**-**&#x72;esolve&#x64;**(**&#x38;**)** is enable&#x64;**.**

![](https://1209410422-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FeghnpTQ7npkdA7nmIC2s%2Fuploads%2FtvRUEED9jnrF0PXgmOMV%2F9.jpeg?alt=media)

### The /etc/hosts file <a href="#toc171120133" id="toc171120133"></a>

If there is no name server on the local networ&#x6B;**,** it is still possible to establish a small table mapping IP addresses and machine hostnames in the **/etc/hosts** fil&#x65;**,** usually reserved for local network station&#x73;**.** The syntax of this file as described in host&#x73;**(**&#x35;**)** is very simpl&#x65;**:** each line indicates a specific IP address followed by the list of any associated names **(**&#x74;he first being **“**&#x63;ompletely qualifie&#x64;**”,** meaning it includes the domain nam&#x65;**).**

This file is available even during network outages or when DNS servers are unreachabl&#x65;**,** but will only really be useful when duplicated on all the machines on the networ&#x6B;**.** The slightest alteration in correspondence will require the file to be updated everywher&#x65;**.** This is why **/etc/hosts** generally only contains the most important entrie&#x73;**.**&#x54;his file will be sufficient for a small network not connected to the Interne&#x74;**,** but with 5 machines or mor&#x65;**,** it is recommended to install a proper DNS serve&#x72;**.**

### User and Group Databases <a href="#toc171120134" id="toc171120134"></a>

The list of users is usually stored in the **/etc/passwd** fil&#x65;**,** while the **/etc/shadow** file stores hashed password&#x73;**.** Both are text file&#x73;**,** in a relatively simple forma&#x74;**,** which can be read and modified with a text edito&#x72;**.** Each user is listed there on a line with several fields separated with a colon **(“:”).**

Users and groups are used on GN&#x55;**/**&#x4C;inux for **access control**—that i&#x73;**,** to control access to the syste&#x6D;**’**&#x73; file&#x73;**,** directorie&#x73;**,** and peripheral&#x73;**.** Linux offers relatively simpl&#x65;**/**&#x63;oarse access control mechanisms by defaul&#x74;**.**

Sudoers file

The file contains a list of users or user groups with permission to execute a subset of commands while having the privileges of the[ root user ](https://en.wikipedia.org/wiki/Root_user)or another specified use&#x72;**.** The program may be configured to require a passwor&#x64;**.**

![](https://1209410422-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FeghnpTQ7npkdA7nmIC2s%2Fuploads%2FAxyfigTpbukqwEzYBm1V%2F10.jpeg?alt=media)

### User List: /etc/passwd <a href="#toc171120135" id="toc171120135"></a>

Here is the list of fields in the **/etc/passwd** fil&#x65;**:**

| o | logi&#x6E;**,** for example **rhertzog;**                                                                                                                                                                                                                                          |
| - | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| o | **password:** this is a password encrypted by a on&#x65;**-**&#x77;ay function **(crypt),** relying on **DES,** **MD5,** **SHA-256** or **SHA-512.** The special value **“x”** indicates that the encrypted password is stored in **/etc/shadow;**                                 |
| o | **uid:** unique number identifying each use&#x72;**;**                                                                                                                                                                                                                             |
| o | **gid:** unique number for the use&#x72;**’**&#x73; main group                                                                                                                                                                                                                     |
| o | **GECOS:** data field usually containing the use&#x72;**’**&#x73; full nam&#x65;**;**                                                                                                                                                                                              |
| o | login director&#x79;**,** assigned to the user for storage of their personal files **(**&#x74;he environment variable **$HOME** generally points her&#x65;**);**                                                                                                                   |
| o | program to execute upon logi&#x6E;**.** This is usually a command interpreter **(**&#x73;hel&#x6C;**),** giving the user free rei&#x6E;**.** If you specify **/bin/false** **(**&#x77;hich does nothing and returns control immediatel&#x79;**),** the user cannot logi&#x6E;**.** |

### The Linux /etc/shadow file <a href="#toc171120136" id="toc171120136"></a>

On Linu&#x78;**,** the shadow password file is readable only by the superuser and serves to keep encrypted passwords safe from prying eyes and password cracking program&#x73;**.** It also includes some additional account information that was&#x6E;**’**&#x74; provided for in the original **/etc/passwd** forma&#x74;**.** These day&#x73;**,** shadow passwords are the default on all system&#x73;**.**

The **shadow** file is not a superset of the **passwd** fil&#x65;**,** and the **passwd** file is not generated from i&#x74;**.** You must maintain both files or use tools such as **useradd** that maintain both files on your behal&#x66;**.** Like **/etc/passwd,** **/etc/shadow** contains one line for each use&#x72;**.** Each line contains nine field&#x73;**,** separated by colon&#x73;**:**

| • | Login name                                                        |
| - | ----------------------------------------------------------------- |
| • | Encrypted password                                                |
| • | Date of last password change                                      |
| • | Minimum number of days between password changes                   |
| • | Maximum number of days between password changes                   |
| • | Number of days in advance to warn users about password expiration |
| • | Days after password expiration that account is disabled           |
| • | Account expiration date                                           |
| • | A field reserved for future use which is currently always empty   |

![](https://1209410422-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FeghnpTQ7npkdA7nmIC2s%2Fuploads%2FR5qlgH3jNGThwJilljKG%2F11.jpeg?alt=media)

The Hidden and Encrypted Password File: **/**&#x65;t&#x63;**/**&#x73;hadow The **/etc/shadow** file contains the following field&#x73;**:**

| o | logi&#x6E;**;**                                       |
| - | ----------------------------------------------------- |
| o | encrypted passwor&#x64;**;**                          |
| o | Several fields managing password expiratio&#x6E;**.** |

One can expire passwords using this file or set the time until the account is disabled after the password has expire&#x64;**.**

### Modifying an Existing Account or Password <a href="#toc171120137" id="toc171120137"></a>

The following commands allow modification of the information stored in specific fields of the user database&#x73;**:** **passwd** permits a regular user to change their passwor&#x64;**,** which in tur&#x6E;**,** updates the **/etc/shadow** file **(chpasswd** allows administrators to update passwords for a list of users in batch mod&#x65;**);** **chfn** **(**&#x43;Hange Full Nam&#x65;**),** reserved for the supe&#x72;**-**&#x75;ser **(**&#x72;oo&#x74;**),** modifies the **GECOS** fiel&#x64;**.** **chsh** **(**&#x43;Hange SHel&#x6C;**)** allows the user to change their login shel&#x6C;**;** howeve&#x72;**,** available choices will be limited to those listed in **/etc/shells;** the administrato&#x72;**,** on the other han&#x64;**,** is not bound by this restriction and can set the shell to any program of their choosin&#x67;**.**

Finall&#x79;**,** the **chage** **(**&#x43;Hange AG&#x45;**)** command allows the administrator to change the password expiration settings **(**&#x74;he **-l user** option will list the current setting&#x73;**).** You can also force the expiration of a password using the **passwd -e user** comman&#x64;**,** which will require the user to change their password the next time they log i&#x6E;**.**

Besides these tools the **usermod** command allows to modify all the details mentioned abov&#x65;**.**

### Setting a password <a href="#toc171120138" id="toc171120138"></a>

Set a password for a new user with

**$ sudo passwd&#x20;*****newusername***

You will be prompted for the actual passwor&#x64;**.**

Some automated systems for adding new users do not require you to set an initial passwor&#x64;**.** Instea&#x64;**,** they force the user to set a password on first logi&#x6E;**.** Although this feature is convenien&#x74;**,** i&#x74;**’**&#x73; a giant security hol&#x65;**:** anyone who can guess new login names **(**&#x6F;r look them up in **/etc/passwd)** can swoop down and hijack accounts before the intended users have had a chance to log i&#x6E;**.**

### Disabling an Account <a href="#toc171120139" id="toc171120139"></a>

You may find yourself needing to **“**&#x64;isable an accoun&#x74;**”** **(**&#x6C;ock out a use&#x72;**),** as a disciplinary measur&#x65;**,** for the purposes of an investigatio&#x6E;**,** or simply in the event of a prolonged or definitive absence of a use&#x72;**.** A disabled account means the user cannot login or gain access to the machin&#x65;**.** The account remains intact on the machine and no files or data are delete&#x64;**;** it is simply inaccessibl&#x65;**.**

### Disabling the root account <a href="#toc171120140" id="toc171120140"></a>

If your site standardizes on the use of **sudo,** you will have surprisingly little use for actual root password&#x73;**.** Most of your administrative team will never have occasion to use the&#x6D;**.**

That fact raises the question of whether a root password is necessary at al&#x6C;**.** If you decide that it is&#x6E;**’**&#x74;**,** you can disable root logins entirely by setting roo&#x74;**’**&#x73; encrypted password to **\*** or to some other fixe&#x64;**,** arbitrary strin&#x67;**.** On Linu&#x78;**,** **passwd -l** **“**&#x6C;ock&#x73;**”** an account by prepending a **!** to the encrypted passwor&#x64;**,** with equivalent result&#x73;**.** The **\*** and the **!** are just convention&#x73;**;** no software checks for them explicitl&#x79;**.** Their effect derives from their not being valid password hashe&#x73;**.** As a resul&#x74;**,** attempts to verify roo&#x74;**’**&#x73; password simply fai&#x6C;**.**

The main effect of locking the root account is that root cannot log in even on the consol&#x65;**.** Neither can any user successfully run **su,** because that requires a root password check as wel&#x6C;**.** However the root account continues to exis&#x74;**,** and all the software that usually runs as root continues to do s&#x6F;**.** In particula&#x72;**,** **sudo** works normall&#x79;**.**

The main advantage of disabling the root account is that you need&#x6E;**’**&#x74; record and manage roo&#x74;**’**&#x73; passwor&#x64;**.** Yo&#x75;**’**&#x72;e also eliminating the possibility of the root password being compromise&#x64;**,** but tha&#x74;**’**&#x73; more a pleasant side effect than a compelling reason to go passwordles&#x73;**.** Rarely used passwords are already at low risk of violatio&#x6E;**.**

I&#x74;**’**&#x73; particularly helpful to have a real root password on physical computer&#x73;**.** Real computers are apt to require rescuing when hardware or configuration problems interfere with **sudo** or the boot proces&#x73;**.** In these case&#x73;**,** i&#x74;**’**&#x73; nice to have the traditional root account available as an emergency fallbac&#x6B;**.**

Debian stable ships with the root account locke&#x64;**,** and all administrative access is funneled through **sudo** or a GUI equivalen&#x74;**.** If you prefe&#x72;**,** i&#x74;**’**&#x73; fine to set a root password on Debian stable and then unlock the account with **sudo passwd -u root.**

### Group List: /etc/group <a href="#toc171120141" id="toc171120141"></a>

Groups are listed in the **/etc/group** fil&#x65;**,** a simple textual database in a format similar to that of the **/etc/passwd** fil&#x65;**,** with the following field&#x73;**:**

| o | group nam&#x65;**;**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| - | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| o | <p>password <strong>(</strong>optional<strong>):</strong> This is only used to join a group when one is not a usual member <strong>(</strong>with the newgrp or sg commands<strong>,</strong> see sidebar<a href="https://debian-handbook.info/browse/stable/sect.user-group-databases.html#sidebar.working-with-several-groups"> </a>BACK TO</p><p><a href="https://debian-handbook.info/browse/stable/sect.user-group-databases.html#sidebar.working-with-several-groups">BASICS Working with several groups<strong>)</strong></a><strong>;</strong></p> |
| o | gi&#x64;**:** unique group identification numbe&#x72;**;**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| o | list of member&#x73;**:** list of names of users who are members of the grou&#x70;**,** separated by comma&#x73;**.**                                                                                                                                                                                                                                                                                                                                                                                                                                      |

![](https://1209410422-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FeghnpTQ7npkdA7nmIC2s%2Fuploads%2FheSU4YCfJubZnWdZq6LZ%2F12.jpeg?alt=media)

**Creating Accounts**

One of the first actions an administrator needs to do when setting up a new machine is to create user account&#x73;**.** This is typically done using the **adduser** command which takes a use&#x72;**-**&#x6E;ame for the new user to be create&#x64;**,** as an argumen&#x74;**.**

The **adduser** command asks a few questions before creating the accoun&#x74;**,** but its usage is straightforwar&#x64;**.** Its configuration fil&#x65;**,** **/etc/adduser.conf,** includes all the interesting setting&#x73;**:** it can be used to automatically set a quota for each new user by creating a user templat&#x65;**,** or to change the location of user account&#x73;**;** the latter is rarely usefu&#x6C;**,** but it comes in handy when you have a large number of users and want to divide their accounts over several disk&#x73;**,** for instanc&#x65;**.** You can also choose a different default shel&#x6C;**.**

![](https://1209410422-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FeghnpTQ7npkdA7nmIC2s%2Fuploads%2FUiJwXAkhy7WdeKFBP3kq%2F13.jpeg?alt=media)

Predator configurations for new user accout

**#** **/**&#x65;t&#x63;**/**&#x61;dduse&#x72;**.**&#x63;on&#x66;**:** \`adduse&#x72;**’** configuratio&#x6E;**.**

**#** See adduse&#x72;**(**&#x38;**)** and adduse&#x72;**.**&#x63;on&#x66;**(**&#x35;**)** for full documentatio&#x6E;**.**

**#** The DSHELL variable specifies the default login shell on your **#** syste&#x6D;**.**

DSHELL=**/**&#x62;i&#x6E;**/**&#x62;ash

**#** The DHOME variable specifies the directory containing user&#x73;**’** home **#** directorie&#x73;**.**

DHOME=**/**&#x68;ome

**#** If GROUPHOMES is **“**&#x79;e&#x73;**”,** then the home directories will be created as **#** **/**&#x68;om&#x65;**/**&#x67;roupnam&#x65;**/**&#x75;se&#x72;**.**

GROUPHOMES=no

**#** If LETTERHOMES is **“**&#x79;e&#x73;**”,** then the created home directories will have **#** an extra directory **-** the first letter of the user nam&#x65;**.** For exampl&#x65;**:** **#** **/**&#x68;om&#x65;**/**&#x75;**/**&#x75;se&#x72;**.**

| <p>LETTERHOMES=no</p><p><strong>#</strong> The SKEL variable specifies the directory containing <strong>“</strong>skeletal<strong>”</strong> user <strong>#</strong> files<strong>;</strong> in other words<strong>,</strong> files such as a sample <strong>.</strong>profile that will be <strong>#</strong> copied to the new user<strong>’</strong>s home directory when it is created<strong>.</strong></p><p>SKEL=<strong>/</strong>etc<strong>/</strong>skel</p><p><strong>#</strong> FIRST<strong>*</strong>SYSTEM<strong>*</strong>\[GU]ID to LAST<strong>*</strong>SYSTEM<strong>*</strong>\[GU]ID inclusive is the range for UIDs <strong>#</strong> for dynamically allocated administrative and system accounts<strong>/</strong>groups<strong>.</strong></p><p><strong>#</strong> Please note that system software<strong>,</strong> such as the users allocated by the base<strong>-</strong>passwd <strong>#</strong> package<strong>,</strong> may assume that UIDs less than 100 are unallocated<strong>.</strong></p><p>FIRST<strong>*</strong>SYSTEM<strong>*</strong>UID=100</p><p>LAST<strong>*</strong>SYSTEM<strong>*</strong>UID=999</p><p>FIRST<strong>*</strong>SYSTEM<strong>*</strong>GID=100</p><p>LAST<strong>*</strong>SYSTEM<strong>*</strong>GID=999</p><p><strong>#</strong> FIRST<strong>*</strong>\[GU]ID to LAST<strong>*</strong>\[GU]ID inclusive is the range of UIDs of dynamically <strong>#</strong> allocated user accounts<strong>/</strong>groups<strong>.</strong></p><p>FIRST<strong>*</strong>UID=1000</p><p>LAST<strong>*</strong>UID=59999</p><p>FIRST<strong>*</strong>GID=1000</p><p>LAST<strong>*</strong>GID=59999</p><p><strong>#</strong> The USERGROUPS variable can be either <strong>“</strong>yes<strong>”</strong> or <strong>“</strong>no<strong>”.</strong> If <strong>“</strong>yes<strong>”</strong> each</p><p><strong>#</strong> created user will be given their own group to use as a default<strong>.</strong> If</p><p><strong>#</strong> <strong>“</strong>no<strong>”,</strong> each created user will be placed in the group whose gid is <strong>#</strong> USERS<strong>*</strong>GID <strong>(</strong>see below<strong>).</strong></p><p>USERGROUPS=yes</p><p><strong>#</strong> If USERGROUPS is <strong>“</strong>no<strong>”,</strong> then USERS<strong>*</strong>GID should be the GID of the group <strong>#</strong> \`users<strong>’</strong> <strong>(</strong>or the equivalent group<strong>)</strong> on your system<strong>.</strong></p><p>USERS<strong>*</strong>GID=100</p><p><strong>#</strong> If DIR<strong>*</strong>MODE is set<strong>,</strong> directories will be created with the specified <strong>#</strong> mode<strong>.</strong> Otherwise the default mode 0755 will be used<strong>.</strong></p><p>DIR<strong>*</strong>MODE=0755</p><p><strong>#</strong> If SETGID<strong>*</strong>HOME is <strong>“</strong>yes<strong>”</strong> home directories for users with their own</p> |     |      |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --- | ---- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <p><strong>#</strong> group the setgid bit will be set<strong>.</strong> This was the default for</p><p><strong>#</strong> versions <strong><<</strong> 3<strong>.</strong>13 of adduser<strong>.</strong> Because it has some bad side effects we <strong>#</strong> no longer do this per default<strong>.</strong> If you want it nevertheless you can <strong>#</strong> still set it here<strong>.</strong></p><p>SETGID<strong>*</strong>HOME=no</p><p><strong>#</strong> If QUOTAUSER is set<strong>,</strong> a default quota will be set from that user with</p><p><strong>#</strong> \`edquota <strong>-</strong>p QUOTAUSER newuser<strong>’</strong></p><p>QUOTAUSER=<strong>““</strong></p><p><strong>#</strong> If SKEL<strong>*</strong>IGNORE<strong>*</strong>REGEX is set<strong>,</strong> adduser will ignore files matching this</p><p><strong>#</strong> regular expression when creating a new home directory</p><p>SKEL<strong>*</strong>IGNORE<strong>\_</strong>REGEX=<strong>“</strong>dpkg<strong>-(</strong>old                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          | new | dist | save<strong>)”</strong></p><p><strong>#</strong> Set this if you want the <strong>--</strong>add<strong>*</strong>extra<strong>*</strong>groups option to adduser to add <strong>#</strong> new users to other groups<strong>.</strong></p><p><strong>#</strong> This is the list of groups that new non<strong>-</strong>system users will be added to <strong>#</strong> Default<strong>:</strong></p><p><strong>#</strong>EXTRA<strong>*</strong>GROUPS=<strong>“</strong>dialout cdrom floppy audio video plugdev users<strong>”</strong></p><p><strong>#</strong> If ADD<strong>*</strong>EXTRA<strong>*</strong>GROUPS is set to something non<strong>-</strong>zero<strong>,</strong> the EXTRA<strong>*</strong>GROUPS</p><p><strong>#</strong> option above will be default behavior for adding new<strong>,</strong> non<strong>-</strong>system users</p><p><strong>#</strong>ADD<strong>*</strong>EXTRA<strong>*</strong>GROUPS=1</p><p><strong>#</strong> check user and group names also against this regular expression<strong>.</strong></p><p><strong>#</strong>NAME<strong>*</strong>REGEX=<strong>“</strong>^\[a<strong>-</strong>z]\[<strong>-</strong>a<strong>-</strong>z0<strong>-</strong>9<strong>*</strong>]<strong>\*$”</strong></p><p><strong>#</strong> use extrausers by default</p><p><strong>#</strong>USE<strong>\_</strong>EXTRAUSERS=1</p> |

The creation of an account populates the use&#x72;**’**&#x73; home directory with the contents of the **/etc/skel/** templat&#x65;**.** This provides the user with a set of standard directories and configuration file&#x73;**.**

![](https://1209410422-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FeghnpTQ7npkdA7nmIC2s%2Fuploads%2FjCav9ZQJJAWX4DnDoVkY%2F14.jpeg?alt=media)

**Creating the home directory and installing startup files**

useradd and adduser create new user&#x73;**’** home directories for yo&#x75;**,** but you will likely want to doubl&#x65;**-**&#x63;heck the permissions and startup files for new account&#x73;**.** Ther&#x65;**’**&#x73; nothing magical about home directorie&#x73;**.** If you neglected to include a home directory when setting up a new use&#x72;**,** you can create it with a simple mkdi&#x72;**.** You need to set ownerships and permissions on the new directory as wel&#x6C;**,** but this is most efficiently done after yo&#x75;**’**&#x76;e installed any local startup file&#x73;**.**

Startup files traditionally begin with a dot and end with the letters r&#x63;**,** short for **“**&#x72;un comman&#x64;**,”** a relic of the CTSS operating syste&#x6D;**.** The initial dot causes ls to hide these **“**&#x75;ninterestin&#x67;**”** files from directory listings unless the **-**&#x61; option is use&#x64;**.**

We recommend that you include default startup files for each shell that is popular on your systems so that users continue to have a reasonable default environment even if they change shell&#x73;**.** Table &#x38;**.**&#x32; lists a variety of common startup file&#x73;**.**

| **Target Filename Typical uses** |                                        |                                                                                                                                                                                                                                                                                               |
| -------------------------------- | -------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **all shells**                   | **.**&#x6C;ogi&#x6E;**\_**&#x63;onf    | Sets use&#x72;**-**&#x73;pecific login defaults **(**&#x46;reeBS&#x44;**)**                                                                                                                                                                                                                   |
| **sh**                           | **.**&#x70;rofile                      | Sets search pat&#x68;**,** terminal typ&#x65;**,** and environment                                                                                                                                                                                                                            |
| **bash a**                       | **.**&#x62;ashrc                       | Sets the terminal type **(**&#x69;f neede&#x64;**)** Sets **biff** and **mesg** switches                                                                                                                                                                                                      |
|                                  | **.**&#x62;as&#x68;**\_**&#x70;rofile  | <p>Sets up environment variables</p><p>Sets command aliases</p><p>Sets the search path</p><p>Sets the <strong>umask</strong> value to control permissions</p><p>Sets CDPATH for filename searches</p><p>Sets the PS1 <strong>(</strong>prompt<strong>)</strong> and HISTCONTROL variables</p> |
| **csh/tcsh**                     | **.**&#x6C;ogin                        | Read by **“**&#x6C;ogi&#x6E;**”** instances of **csh**                                                                                                                                                                                                                                        |
|                                  | **.**&#x63;shrc                        | Read by all instances of **csh**                                                                                                                                                                                                                                                              |
| **vi/vim**                       | **.**&#x76;imr&#x63;**/.**&#x76;iminfo | Sets **vi/vim** editor options                                                                                                                                                                                                                                                                |
| **emacs**                        | **.**&#x65;macs                        | Sets **emacs** editor options and key bindings                                                                                                                                                                                                                                                |
| **git**                          | **.**&#x67;itconfig                    | Sets use&#x72;**,** edito&#x72;**,** colo&#x72;**,** and alias options for Git                                                                                                                                                                                                                |
| **GNOME**                        | **.**&#x67;conf                        | GNOME user configuration via **gconf**                                                                                                                                                                                                                                                        |
|                                  | **.**&#x67;confpath                    | Path for additional user configuration via **gconf**                                                                                                                                                                                                                                          |
| **KDE**                          | **.**&#x6B;d&#x65;**/**                | Directory of configuration files                                                                                                                                                                                                                                                              |

### Disabling the user feature <a href="#toc171120142" id="toc171120142"></a>

If you prefer to not allow guest access to your compute&#x72;**,** you can disable the *Guest Session* featur&#x65;**.**

To do s&#x6F;**,** press

Ctrl **+** Alt **+** T to open a terminal windo&#x77;**,** and then run this command **(**&#x69;&#x74;**’**&#x73; one long comman&#x64;**,** even if it may be shown wrapped on the screen **-** copy and paste to get it righ&#x74;**):**

sudo sh **-**&#x63; **‘**&#x70;rintf **“** \[SeatDefaults]**\\**&#x6E;allowguest=fals&#x65;**\\**&#x6E;**”**

**>/**&#x75;s&#x72;**/**&#x73;har&#x65;**/**&#x6C;ightd&#x6D;**/**&#x6C;ightd&#x6D;**.**&#x63;on&#x66;**.** n&#x6F;**-**&#x67;ues&#x74;**.**&#x63;on&#x66;**’**

![](https://1209410422-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FeghnpTQ7npkdA7nmIC2s%2Fuploads%2FZE2WAbKfy7teIzU193Wn%2F15.jpeg?alt=media)

The command creates a small configuration fil&#x65;**.** To r&#x65;**-**&#x65;nable *Guest Session***,** simply remove that fil&#x65;**:**

sudo rm **/**&#x75;s&#x72;**/**&#x73;har&#x65;**/**&#x6C;ightd&#x6D;**/**&#x6C;ightd&#x6D;**.**&#x63;on&#x66;**.**&#x64; n&#x6F;**-**&#x67;ues&#x74;**.**&#x63;onf

### Security parameter configuration <a href="#toc171120143" id="toc171120143"></a>

PA&#x4D;**:** Pluggable Authentication Modules

User accounts are traditionally secured by passwords stored **(**&#x69;n encrypted for&#x6D;**)** in the **/etc/shadow** or **/etc/master.passwd** file or an equivalent network databas&#x65;**.** Many programs may need to validate account&#x73;**,** including **login,** **sudo,** **su,** and any program that accepts logins on a GUI workstatio&#x6E;**.**

These programs really should&#x6E;**’**&#x74; have har&#x64;**-**&#x63;oded expectations about how passwords are to be encrypted or verifie&#x64;**.** Ideall&#x79;**,** they should&#x6E;**’**&#x74; even assume that passwords are in use at al&#x6C;**.** What if you want to use biometric identificatio&#x6E;**,** a network identity syste&#x6D;**,** or some kind of tw&#x6F;**-**&#x66;actor authentication? Pluggable Authentication Modules to the rescu&#x65;**!**

PAM is a wrapper for a variety of metho&#x64;**-**&#x73;pecific authentication librarie&#x73;**.** Administrators specify the authentication methods they want the system to us&#x65;**,** along with the appropriate contexts for each on&#x65;**.** Programs that require user authentication simply call the PAM system rather than implement their own forms of authenticatio&#x6E;**.** PAM in turn calls the authentication library specified by the system administrato&#x72;**.**

Strictly speaking PAM is an authentication technolog&#x79;**,** not an access control technolog&#x79;**.** That i&#x73;**;** instead of addressing the question **“**&#x44;oes user X have permission to perform operation Y?**”,** it helps answer the precursor questio&#x6E;**,** **“**&#x48;ow do I know this is really user X?**”**

PAM is an important component of the access control chain on most system&#x73;**,** and PAM configuration is a common administrative tas&#x6B;**.**

### Kerberos: network cryptographic authentication <a href="#toc171120144" id="toc171120144"></a>

Like PA&#x4D;**,** Kerberos deals with authentication rather than access control per s&#x65;**.** But whereas PAM is an authentication *framework***,** Kerberos is a specific authentication *method***.** At sites that use Kerbero&#x73;**,** PAM and Kerberos generally work togethe&#x72;**,** PAM being the wrapper and Kerberos the actual implementatio&#x6E;**.**

Kerberos uses a trusted third party **(**&#x61; serve&#x72;**)** to perform authentication for an entire networ&#x6B;**.** You do&#x6E;**’**&#x74; authenticate yourself to the machine you are usin&#x67;**,** but provide your credentials to the Kerberos servic&#x65;**.** Kerberos then issues cryptographic credentials that you can present to other services as evidence of your identit&#x79;**.**

### Choosing secure passwords <a href="#toc171120145" id="toc171120145"></a>

Passwords must be complex enough to not be easily guessed from &#x65;**.**&#x67;**.** personal informatio&#x6E;**,** or **cracked** using methods like social engineering or brut&#x65;**-**&#x66;orce

### Password hashes <a href="#toc171120146" id="toc171120146"></a>

| **/**&#x65;t&#x63;**/**&#x73;hadow | fil&#x65;**,**                     |
| ---------------------------------- | ---------------------------------- |
|                                    | **/**&#x65;t&#x63;**/**&#x70;asswd |

By defaul&#x74;**,** Arch stores the hashed user passwords in the roo&#x74;**-**&#x6F;nlyreadable separated from the other user parameters stored in the worl&#x64;**-**&#x72;eadable fil&#x65;**,** see **Users and groups#User database.** See also **#Restricting root.**

Passwords are set with the **passwd** comman&#x64;**,** which **stretches** them with the **crypt** function and then saves them in **.** See also **SHA password hashes.** The passwords are also **salted** in order to defend them against **rainbow table** attack&#x73;**.**

### Enforcing strong passwords with pam\_pwquality <a href="#toc171120147" id="toc171120147"></a>

*pa&#x6D;**\_**&#x70;wquality* provides protection against **Dictionary attacks** and helps configure a password policy that can be enforced throughout the syste&#x6D;**.** It is based on *pa&#x6D;**\_**&#x63;racklib*

Predato&#x72;**-**&#x4F;S policy is in the following pat&#x68;**:**

**/**&#x65;t&#x63;**/**&#x70;a&#x6D;**.**&#x64;**/**&#x70;asswd

![](https://1209410422-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FeghnpTQ7npkdA7nmIC2s%2Fuploads%2FqszL3UXtALhdKzk2g11h%2F16.jpeg?alt=media)

### Limit amount of processes <a href="#toc171120148" id="toc171120148"></a>

**/**&#x65;t&#x63;**/**&#x73;ecurit&#x79;**/**&#x6C;imit&#x73;**.**&#x63;onf

On systems with man&#x79;**,** or untrusted user&#x73;**,** it is important to limit the number of processes each can run at onc&#x65;**,** therefore preventing **fork bombs** and other denial of service attack&#x73;**.** determines how many processes each use&#x72;**,** or group can have ope&#x6E;**.**

* soft nproc 0
* hard nproc 0

![](https://1209410422-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FeghnpTQ7npkdA7nmIC2s%2Fuploads%2FTDXYKGBlSz9nxe7yq5S0%2F17.jpeg?alt=media)

### Restricting root login <a href="#toc171120149" id="toc171120149"></a>

Once **sudo** is properly configure&#x64;**,** full root access can be heavily restricted or denied without losing much usabilit&#x79;**.** To disable roo&#x74;**,** but still allowing to use **sudo,** you can use **.**

### Shell Environment <a href="#toc171120150" id="toc171120150"></a>

Command interpreters **(**&#x6F;r shell&#x73;**)** can be a use&#x72;**’**&#x73; first point of contact with the compute&#x72;**,** and they must therefore be rather friendl&#x79;**.** Most of them use initialization scripts that allow configuration of their behavior **(**&#x61;utomatic completio&#x6E;**,** prompt tex&#x74;**,** et&#x63;**.).**

**bash,** the standard shel&#x6C;**,** uses the **/etc/bash.bashrc** initialization script for **“**&#x69;nteractiv&#x65;**”** shell&#x73;**,** and **/etc/profile** for **“**&#x6C;ogi&#x6E;**”** shell&#x73;**.**

In simple term&#x73;**,** a login shell is invoked when you login to the console either locally or remotely via **ssh,** or when you run an explicit **bash -login** comman&#x64;**.** Regardless of whether it is a login shell or no&#x74;**,** a shell can be interactive **(**&#x69;n an **xterm-**&#x74;ype terminal for instanc&#x65;**);** or no&#x6E;**-**&#x69;nteractive **(**&#x77;hen executing a scrip&#x74;**).**

![](https://1209410422-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FeghnpTQ7npkdA7nmIC2s%2Fuploads%2FjvdGjqJw9XgS1oTbdkIk%2F18.jpeg?alt=media)

For **bash,** it is useful to install and activate **“**&#x61;utomatic completio&#x6E;**”.** The package bas&#x68;**-**&#x63;ompletion contains these completions for most common programs and is usually enabled if the use&#x72;**’**&#x73; **.bashrc** configuration file was copied from **/etc/skel/.bashrc.** Otherwise it can be enabled via **/etc/bash.bashrc** **(**&#x73;imply uncomment a few line&#x73;**)** or **/etc/profile.**

### Automatic completion <a href="#toc171120151" id="toc171120151"></a>

Many command interpreters provide a completion featur&#x65;**,** which allows the shell to automatically complete a partially typed command name or argument when the user hits the **Tab** ke&#x79;**.** This lets users work more efficiently and be less erro&#x72;**-**&#x70;ron&#x65;**.**

Bash completio&#x6E;**.**

Bash is an s&#x68;**-**&#x63;ompatible command language interpreter that executes commands read from the standard input or from a fil&#x65;**.** Bash can run most sh scripts without modificatio&#x6E;**.** bas&#x68;**-**&#x63;ompletion is a collection of shell functions that take advantage of the programmable completion feature of bash on Debian stable Linu&#x78;**.** This page shows how to install and enable Bash auto completion in Debian stable Linu&#x78;**.**

1\. Install bas&#x68;**-**&#x63;ompletion package on Debian stable by runnin&#x67;**:**

**$** sudo apt install bas&#x68;**-**&#x63;ompletion

if \[ **-**&#x66; **/**&#x75;s&#x72;**/**&#x73;har&#x65;**/**&#x62;as&#x68;**-**&#x63;ompletio&#x6E;**/**&#x62;as&#x68;**\_**&#x63;ompletion ]**;** then source **/**&#x75;s&#x72;**/**&#x73;har&#x65;**/**&#x62;as&#x68;**-**&#x63;ompletio&#x6E;**/**&#x62;as&#x68;**\_**&#x63;ompletion

elif \[ **-**&#x66; **/**&#x65;t&#x63;**/**&#x62;as&#x68;**\_**&#x63;ompletion ]**;** then source **/**&#x65;t&#x63;**/**&#x62;as&#x68;**\_**&#x63;ompletion fi

### Environment variables <a href="#toc171120152" id="toc171120152"></a>

Environment variables allow storage of global settings for the shell or various other programs calle&#x64;**.** They are contextual **(**&#x65;ach process has its own set of environment variable&#x73;**)** but inheritabl&#x65;**.** This last characteristic offers the possibility for a login shell to declare variables which will be passed down to all programs it execute&#x73;**.** Setting default environment variables is an important element of shell configuratio&#x6E;**.** Leaving aside the variables specific to a shel&#x6C;**,** it is preferable to place system wide variables in the **/etc/environment** file

![](https://1209410422-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FeghnpTQ7npkdA7nmIC2s%2Fuploads%2FxDIqeaqkQojDElHlOSCj%2F19.jpeg?alt=media)

### Printer Configuration <a href="#toc171120153" id="toc171120153"></a>

Printer configuration used to cause a great many headaches for administrators and users alik&#x65;**.** These headaches are now mostly a thing of the pas&#x74;**,** thanks to CUP&#x53;**,** the free print server using IP&#x50;**,** the Internet Printing Protoco&#x6C;**.**

The command **apt install cups** will install CUPS and the filter&#x73;**.** It will also install the recommended printe&#x72;**-**&#x64;rive&#x72;**-**&#x67;utenprint to provide a driver for a wide range of printer&#x73;**,** bu&#x74;**,** unless the printer is being operated driverlessl&#x79;**,** an alternative printerdriver might be needed for the particular devic&#x65;**.**

The printing system is administered easily through a web interface accessible at the local address **<http://localhost:631/>.** Members of the **lpadmin** group can add and remove USB and network printers and administer most aspects of their behavio&#x72;**.** Similar administration tasks can also be carried out via the graphical interface provided by a desktop environment or the **system-config-printer** graphical interfac&#x65;**.**

![](https://1209410422-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FeghnpTQ7npkdA7nmIC2s%2Fuploads%2FgwnPyahxdr47JtrL6gbe%2F20.jpeg?alt=media)

### Bootloader <a href="#toc171120154" id="toc171120154"></a>

It is probably already functiona&#x6C;**,** but it is always good to know how to configure and install the bootloader in case it disappears from the Master Boot Recor&#x64;**.** This can occur after installation of another operating syste&#x6D;**,** such as Window&#x73;**.** The following information can also help you to modify the bootloader configuration if neede&#x64;**.**

Legacy BIOS Traditional BIOS assumes that the boot device starts with a record called the MBR **(**&#x4D;aster Boot Recor&#x64;**).** The MBR includes both a firs&#x74;**-**&#x73;tage boot loader **(**&#x61;ka **“**&#x62;oot bloc&#x6B;**”)** and a primitive disk partitioning tabl&#x65;**.** The amount of space available for the boot loader is so small **(**&#x6C;ess than 512 byte&#x73;**)** that i&#x74;**’**&#x73; not able to do much other than load and run a secon&#x64;**-**&#x73;tage boot loade&#x72;**.** Neither the boot block nor the BIOS is sophisticated enough to read any type of standard filesyste&#x6D;**,** so the secon&#x64;**-**&#x73;tage boot loader must be kept somewhere easy to fin&#x64;**.** In one typical scenari&#x6F;**,** the boot block reads the partitioning information from the MBR and identifies the disk partition marked as **“**&#x61;ctiv&#x65;**.”** It then reads and executes the secon&#x64;**-**&#x73;tage boot loader from the beginning of that partitio&#x6E;**.** This scheme is known as a volume boot recor&#x64;**.** Alternativel&#x79;**,** the secon&#x64;**-**&#x73;tage boot loader can live in the dead zone that lies between the MBR and the beginning of the first disk partitio&#x6E;**.** For historical reason&#x73;**,** the first partition does not start until the 64th disk bloc&#x6B;**,** so this zone normally contains at least 32KB of storag&#x65;**:** still not a lo&#x74;**,** but enough to store a filesystem drive&#x72;**.** This storage scheme is commonly used by the GRUB boot loade&#x72;**;** see page 3&#x35;**.** To effect a successful boo&#x74;**,** all components of the boot chain must be properly installed and compatible with one anothe&#x72;**.** The MBR boot block is O&#x53;**-**&#x61;gnosti&#x63;**,** but because it assumes a particular location for the second stag&#x65;**,** there may be multiple versions that can be installe&#x64;**.** The secon&#x64;**-**&#x73;tage loader is generally knowledgeable about operating systems and filesystems **(**&#x69;t may support several of eac&#x68;**),** and usually has configuration options of its own

UEFI The UEFI specification includes a modern disk partitioning scheme known as GPT **(**&#x47;UID Partition Tabl&#x65;**,** where GUID stands for **“**&#x67;lobally unique identifie&#x72;**”).** UEFI also understands FAT **(**&#x46;ile Allocation Tabl&#x65;**)** filesystem&#x73;**,** a simple but functional layout that originated in M&#x53;**-**&#x44;O&#x53;**.** These features combine to define the concept of an EFI System Partition **(**&#x45;S&#x50;**).** At boot tim&#x65;**,** the firmware consults the GPT partition table to identify the ES&#x50;**.** It then reads the configured target application directly from a file in the ESP and executes i&#x74;**.**

Because the ESP is just a generic FAT filesyste&#x6D;**,** it can be mounte&#x64;**,** rea&#x64;**,** writte&#x6E;**,** and maintained by any operating syste&#x6D;**.** No **“**&#x6D;ystery mea&#x74;**”** boot blocks are required anywhere on the dis&#x6B;**.**&#x33; In fac&#x74;**,** no boot loader at all is technically require&#x64;**.** The UEFI boot target can be a UNIX or Linux kernel that has been configured for direct UEFI loadin&#x67;**,** thus effecting a loade&#x72;**-**&#x6C;ess bootstra&#x70;**.** In practic&#x65;**,** thoug&#x68;**,** most systems still use a boot loade&#x72;**,** partly because that makes it easier to maintain compatibility with legacy BIOSe&#x73;**.** UEFI saves the pathname to load from the ESP as a configuration paramete&#x72;**.** With no configuratio&#x6E;**,** it looks for a standard pat&#x68;**,** usually **/**&#x65;f&#x69;**/**&#x62;oo&#x74;**/**&#x62;ootx6&#x34;**.**&#x65;fi on modern Intel system&#x73;**.** A more typical path on a configured system **(**&#x74;his one for Debian stable and the GRUB boot loade&#x72;**)** would be **/**&#x65;f&#x69;**/**&#x44;ebian stabl&#x65;**/**&#x67;rubx6&#x34;**.**&#x65;f&#x69;**.** Other distributions follow a similar conventio&#x6E;**.**

Because UEFI has a formal AP&#x49;**,** you can examine and modify UEFI variables **(**&#x69;ncluding boot menu entrie&#x73;**)** on a running syste&#x6D;**.** For exampl&#x65;**,** efibootmgr **-**&#x76; shows the following summary of the boot configuratio&#x6E;**:**

**$** efibootmgr **-**&#x76;

### GRUB Configuration <a href="#toc171120155" id="toc171120155"></a>

GRUB **(**&#x47;Rand Unified Bootloade&#x72;**)** is more recen&#x74;**.** It is not necessary to invoke it after each update of the kerne&#x6C;**;** GRUB knows how to read the filesystems and find the position of the kernel on the disk by itsel&#x66;**.** To install it on the MBR of the first dis&#x6B;**,** simply type **grub-install /dev/sda.** This will overwrite the MB&#x52;**,** so be careful not to overwrite the wrong locatio&#x6E;**.** While it is also possible to install GRUB into a partition boot recor&#x64;**,** beware that it is usually a mistake and doing **grub-install /dev/sda1** has not the same meaning as gru&#x62;**-**&#x69;nstall **/**&#x64;e&#x76;**/**&#x73;d&#x61;**.**

**GRUB 2 configuration is stored in /boot/grub/grub.cfg,**

but this file is generated from other&#x73;**.** Be careful not to modify it by han&#x64;**,** since such local modifications will be lost the next time **update-grub** is run **(**&#x77;hich may occur upon update of various package&#x73;**).** The most common modifications of the **/boot/grub/grub.cfg** file **(**&#x74;o add command line parameters to the kernel or change the duration that the menu is displaye&#x64;**,** for exampl&#x65;**)** are made through the variables in **/etc/default/grub.** To add entries to the men&#x75;**,** you can either create a **/boot/grub/custom.cfg** file or modify the **/etc/grub.d/40\_custom** fil&#x65;**.** For more complex configuration&#x73;**,** you can modify other files in **/etc/grub.d,** or add to the&#x6D;**;** these scripts should return configuration snippet&#x73;**,** possibly by making use of external program&#x73;**.** These scripts are the ones that will update the list of kernels to boo&#x74;**:** **10\_linux** takes into consideration the installed Linux kernel&#x73;**;** **20\_linux\_xen** takes into account Xen virtual system&#x73;**,** and **30\_osprober** adds other existing operating systems **(**&#x57;indow&#x73;**,** OS &#x58;**,** Hur&#x64;**),** kernel image&#x73;**,** and BIO&#x53;**/**&#x45;FI access options to the men&#x75;**.**

The config file is called gru&#x62;**.**&#x63;f&#x67;**,** and i&#x74;**’**&#x73; usually kept in **/**&#x62;oo&#x74;**/**&#x67;rub **(/**&#x62;oo&#x74;**/**&#x67;rub2 in Red Hat and CentO&#x53;**)** along with a selection of other resources and code modules that GRUB might need to access at boot tim&#x65;**.**&#x35; Changing the boot configuration is a simple matter of updating the gru&#x62;**.**&#x63;fg fil&#x65;**.** Although you can create the gru&#x62;**.**&#x63;fg file yoursel&#x66;**,** i&#x74;**’**&#x73; more common to generate it with the gru&#x62;**-**&#x6D;kconfig utilit&#x79;**,** which is called grub&#x32;**-**&#x6D;kconfig on Red Hat and CentOS and wrapped as updat&#x65;**-**&#x67;rub on Debian and Debian stabl&#x65;**.** In fac&#x74;**,** most distributions assume that gru&#x62;**.**&#x63;fg can be regenerated at wil&#x6C;**,** and they do so automatically after update&#x73;**.** If you do&#x6E;**’**&#x74; take steps to prevent thi&#x73;**,** your handcrafted gru&#x62;**.**&#x63;fg file will get clobbere&#x64;**.** As with all things Linu&#x78;**,** distributions configure gru&#x62;**-**&#x6D;kconfig in a variety of way&#x73;**.** Most commonl&#x79;**,** the configuration is specified in **/**&#x65;t&#x63;**/**&#x64;efaul&#x74;**/**&#x67;rub in the form of sh variable assignments

Common GRUB configuration options from **/**&#x65;t&#x63;**/**&#x64;efaul&#x74;**/**&#x67;rub Shell variable name

Contents or function GRU&#x42;**\_**&#x42;ACKGROUND Background image a

GRU&#x42;**\_**&#x43;MDLIN&#x45;**\_**&#x4C;INUX Kernel parameters to add to menu entries for Linux b

GRU&#x42;**\_**&#x44;EFAULT Number or title of the default menu entry

GRU&#x42;**\_**&#x44;ISABL&#x45;**\_**&#x52;ECOVERY Prevents the generation of recovery mode entries GRU&#x42;**\_**&#x50;RELOA&#x44;**\_**&#x4D;ODULES List of GRUB modules to be loaded as early as possible GRU&#x42;**\_**&#x54;IMEOUT Seconds to display the boot menu before autoboo&#x74;**.**

**#** If you change this fil&#x65;**,** run **‘**&#x75;pdat&#x65;**-**&#x67;ru&#x62;**’** afterwards to update **#** **/**&#x62;oo&#x74;**/**&#x67;ru&#x62;**/**&#x67;ru&#x62;**.**&#x63;f&#x67;**.**

**#** For full documentation of the options in this fil&#x65;**,** se&#x65;**:**

**#** info **-**&#x66; grub **-**&#x6E; **‘**&#x53;imple configuratio&#x6E;**’**

GRU&#x42;**\_**&#x44;EFAULT=**“**&#x30;**”**

GRU&#x42;**\_**&#x54;IMEOU&#x54;**\_**&#x53;TYLE=**“**&#x6D;en&#x75;**”**

GRU&#x42;**\_**&#x54;IMEOUT=**“**&#x31;&#x35;**”**

GRU&#x42;**\_**&#x44;ISTRIBUTOR=**“**\`ls&#x62;**\_**&#x72;elease **-**&#x69; **-**&#x73; &#x32;**>** **/**&#x64;e&#x76;**/**&#x6E;ull || echo Debian\`**”**

GRU&#x42;**\_**&#x43;MDLIN&#x45;**\_**&#x4C;INU&#x58;**\_**&#x44;EFAULT=**“**&#x6D;itigations=off loglevel=0 nowatchdog inte&#x6C;**\_**&#x70;state=false quiet splas&#x68;**”**

GRU&#x42;**\_**&#x43;MDLIN&#x45;**\_**&#x4C;INUX=**“**&#x66;in&#x64;**\_**&#x70;reseed=**/**&#x70;resee&#x64;**.**&#x63;fg auto noprompt priority=critica&#x6C;**”**

GRU&#x42;**\_**&#x44;ISABL&#x45;**\_**&#x4F;&#x53;**\_**&#x50;ROBER=**“**&#x66;als&#x65;**”**

**#** Uncomment to enable BadRAM filterin&#x67;**,** modify to suit your needs

**#** This works with Linux **(**&#x6E;o patch require&#x64;**)** and with any kernel that obtains

**#** the memory map information from GRUB **(**&#x47;NU Mac&#x68;**,** kernel of FreeBSD **...)**

**#**&#x47;RU&#x42;**\_**&#x42;ADRAM=**“**&#x30;x0123456&#x37;**,**&#x30;xfefefef&#x65;**,**&#x30;x89abcde&#x66;**,**&#x30;xefefefe&#x66;**”**

**#** Uncomment to disable graphical terminal **(**&#x67;ru&#x62;**-**&#x70;c onl&#x79;**)**

**#**&#x47;RU&#x42;**\_**&#x54;ERMINAL=**“**&#x63;onsol&#x65;**”**

**#** The resolution used on graphical terminal

**#** note that you can use only modes which your graphic card supports via VBE

**#** you can see them in real GRUB with the command \`vbeinf&#x6F;**’**

GRU&#x42;**\_**&#x47;FXMODE=**“**&#x31;024x768x2&#x34;**”**

**#** Uncomment if you do&#x6E;**’**&#x74; want GRUB to pass **“**&#x72;oot=UUID=xx&#x78;**”** parameter to Linux

**#**&#x47;RU&#x42;**\_**&#x44;ISABL&#x45;**\_**&#x4C;INU&#x58;**\_**&#x55;UID=**“**&#x74;ru&#x65;**”**

**#** Uncomment to disable generation of recovery mode menu entries

**#**&#x47;RU&#x42;**\_**&#x44;ISABL&#x45;**\_**&#x52;ECOVERY=**“**&#x74;ru&#x65;**”**

**#** Uncomment to get a beep at grub start

GRU&#x42;**\_**&#x49;NI&#x54;**\_**&#x54;UNE=**“**&#x34;80 440 &#x31;**”**

**#**&#x47;RU&#x42;**\_**&#x48;IDDE&#x4E;**\_**&#x54;IMEOUT=**“**&#x30;**”**

GRU&#x42;**\_**&#x53;AVEDEFAULT=**“**&#x66;als&#x65;**”** export GRU&#x42;**\_**&#x43;OLO&#x52;**\_**&#x4E;ORMAL=**“**&#x77;hit&#x65;**/**&#x62;lac&#x6B;**”** export GRU&#x42;**\_**&#x43;OLO&#x52;**\_**&#x48;IGHLIGHT=**“**&#x79;ello&#x77;**/**&#x62;lac&#x6B;**”**

export GRU&#x42;**\_**&#x4D;EN&#x55;**\_**&#x50;ICTURE=**“/**&#x75;s&#x72;**/**&#x73;har&#x65;**/**&#x62;ackground&#x73;**/**&#x67;ru&#x62;**.**&#x50;N&#x47;**”**

Common GRUB configuration options from **/**&#x65;t&#x63;**/**&#x64;efaul&#x74;**/**&#x67;rub

| **Shell variable name Contents or function** |                                                        |
| -------------------------------------------- | ------------------------------------------------------ |
| **GRUB\_BACKGROUND**                         | Background image a                                     |
| **GRUB\_CMDLINE\_LINUX**                     | Kernel parameters to add to menu entries for Linux b   |
| **GRUB\_DEFAULT**                            | Number or title of the default menu entry              |
| **GRUB\_DISABLE\_RECOVERY**                  | Prevents the generation of recovery mode entries       |
| **GRUB\_PRELOAD\_MODULES**                   | List of GRUB modules to be loaded as early as possible |
| **GRUB\_TIMEOUT**                            | Seconds to display the boot menu before autoboot       |

The background image must be a **.png,** **.tga,** **.jpg,** or **.jpeg** fil&#x65;**.**

After editing **/**&#x65;t&#x63;**/**&#x64;efaul&#x74;**/**&#x67;ru&#x62;**,** run updat&#x65;**-**&#x67;rub or grub&#x32;**-**&#x6D;kconfig to translate your configuration into a proper gru&#x62;**.**&#x63;fg file

### Using GRUB with EFI and Secure Boot <a href="#toc171120156" id="toc171120156"></a>

Using GRUB to boot either a traditional BIOS system **(**&#x6C;egacy or UEF&#x49;**-**&#x43;S&#x4D;**)** or a UEFI system is quite differen&#x74;**.** Fortunately, the user does not need to know the differences because linux provides different packages for each purpose and the installer automatically cares about which on&#x65;**(**&#x73;**)** to choos&#x65;**.** The gru&#x62;**-**&#x70;c package is chosen for legacy system&#x73;**,** where GRUB is installed into the MB&#x52;**,** while UEFI systems require gru&#x62;**-**&#x65;f&#x69;**-**&#x61;rc&#x68;**,** where GRUB is installed into the EFI System Partition **(**&#x45;S&#x50;**).** The latter requires a GTP partition table as well as an EFI partitio&#x6E;**.**

o switch an existing system **(**&#x73;upporting UEF&#x49;**)** from legacy to UEFI boot mode not only requires to switch the GRUB packages on the syste&#x6D;**,** but also to adjust the partition table and the to create an EFI partition **(**&#x70;robably including resizing existing partitions to create the necessary free spac&#x65;**).** It is therefore quite an elaborate process and we cannot cover it her&#x65;**.** Fortunatel&#x79;**,** there are some manuals by bloggers describing the necessary procedure&#x73;**.**

The timezon&#x65;**,** configured during initial installatio&#x6E;**,** is a configuration item for the tzdata packag&#x65;**.** To modify i&#x74;**,** use the **dpkg-reconfigure tzdata** comman&#x64;**,** which allows you to choose the timezone to be used in an interactive manne&#x72;**.** Its configuration is stored in the **/etc/timezone** fil&#x65;**.** Additionall&#x79;**,** **/etc/localtime** becomes a symbolic link to the corresponding file in the **/usr/share/zoneinfo;** the file that contains the rules governing the dates where daylight saving time **(**&#x44;S&#x54;**)** is activ&#x65;**,** for countries that use i&#x74;**.**

When you need to temporarily change the timezon&#x65;**,** use the **TZ** environment variabl&#x65;**,** which takes priority over the configured system defaul&#x74;**:**

**$** date

Thu Sep 2 2&#x32;**:**&#x32;&#x39;**:**&#x34;8 CEST 2023

**$** TZ=**“**&#x50;acifi&#x63;**/**&#x48;onolul&#x75;**”** date

Thu 02 Sep 2023 1&#x30;**:**&#x33;&#x31;**:**&#x30;1 AM HST

### For Workstations <a href="#toc171120157" id="toc171120157"></a>

Since work stations are regularly rebooted **(**&#x65;ven if only to save energ&#x79;**),** synchronizing them by NTP at boot is enoug&#x68;**.** To do s&#x6F;**,** simply install the ntpdate packag&#x65;**.** You can change the NTP server used if needed by modifying the **/etc/default/ntpdate** fil&#x65;**.**

### Rotating Log Files <a href="#toc171120158" id="toc171120158"></a>

Log files can gro&#x77;**,** fas&#x74;**,** and it is necessary to archive the&#x6D;**.** The most common scheme is a rotating archiv&#x65;**:** the log file is regularly archive&#x64;**,** and only the latest X archives are retaine&#x64;**.** **logrotate,** the program responsible for these rotation&#x73;**,** follows directives given in the **/etc/logrotate.conf** file and all of the files in the **/etc/logrotate.d/** director&#x79;**.** The administrator may modify these file&#x73;**,** if they wish to adapt the log rotation polic&#x79;**.** The logrotat&#x65;**(**&#x31;**)** man page describes all of the options available in these configuration file&#x73;**.** You may want to increase the number of files retained in log rotatio&#x6E;**,** or move the log files to a specific directory dedicated to archiving them rather than delete the&#x6D;**.** You could also send them by &#x65;**-**&#x6D;ail to archive them elsewher&#x65;**.**

**/etc/logrotate.d/** directory

**Source of : /etc/logrotate.conf**

**#** see **“**&#x6D;an logrotat&#x65;**”** for details

**#** global options do not affect preceding include directives

**#** rotate log files weekly

weekly

**#** keep 4 weeks worth of backlogs rotate 4

**#** create new **(**&#x65;mpt&#x79;**)** log files after rotating old ones create

**#** use date as a suffix of the rotated file

**#**&#x64;ateext

**#** uncomment this if you want your log files compressed

**#**&#x63;ompress

**#** packages drop log rotation information into this directory include **/**&#x65;t&#x63;**/**&#x6C;ogrotat&#x65;**.**&#x64;

**#** syste&#x6D;**-**&#x73;pecific logs may also be configured her&#x65;**.**

System daemon&#x73;**,** the kerne&#x6C;**,** and custom applications all emit operational data that is logged and eventually ends up on your finite sized disk&#x73;**.** This data has a limited useful life and may need to be summarize&#x64;**,** filtere&#x64;**,** searche&#x64;**,** analyze&#x64;**,** compresse&#x64;**,** and archived before it is eventually discarde&#x64;**.** Access and audit logs may need to be managed closely according to regulatory retention rules or site security policie&#x73;**.**

A log message is usually a line of text with a few properties attache&#x64;**,** including a time stam&#x70;**,** the type and severity of the even&#x74;**,** and a process name and ID **(**&#x50;I&#x44;**).** The message itself can range from an innocuous note about a new process starting up to a critical error condition or stack trac&#x65;**.** I&#x74;**’**&#x73; the responsibility of system administrators to glean usefu&#x6C;**,** actionable information from this ongoing torrent of message&#x73;**.** This task is known generically as log managemen&#x74;**,** and it can be divided into a few major subtask&#x73;**:**

* Collecting logs from a variety of sources
* Providing a structured interface for queryin&#x67;**,** analyzin&#x67;**,** filterin&#x67;**,** and monitoring messages
* Managing the retention and expiration of messages so that information is kept as long as it is potentially useful or legally require&#x64;**,** but not indefinitely

UNIX has historically managed logs through an integrated but somewhat rudimentary syste&#x6D;**,** known as syslo&#x67;**,** that presents applications with a standardized interface for submitting log message&#x73;**.** Syslog sorts messages and saves them to files or forwards them to another host over the networ&#x6B;**.** Unfortunatel&#x79;**,** syslog tackles only the first of the logging chores listed above **(**&#x6D;essage collectio&#x6E;**),** and its stock configuration differs widely among operating system&#x73;**.**

Perhaps because of syslo&#x67;**’**&#x73; shortcoming&#x73;**,** many application&#x73;**,** network daemon&#x73;**,** startup script&#x73;**,** and other logging vigilantes bypass syslog entirely and write to their own ad hoc log file&#x73;**.** This lawlessness has resulted in a complement of logs that varies significantly among flavors of UNIX and even among Linux distribution&#x73;**.** Linu&#x78;**’**&#x73; systemd journal represents a second attempt to bring sanity to the logging madnes&#x73;**.** The journal collects message&#x73;**,** stores them in an indexed and compressed binary forma&#x74;**,** and furnishes a comman&#x64;**-**&#x6C;ine interface for viewing and filtering log&#x73;**.** The journal can stand alon&#x65;**,** or it can coexist with the syslog daemon with varying degrees of integratio&#x6E;**,** depending on the configuratio&#x6E;**.**

A variety of third party tools **(**&#x62;oth proprietary and open sourc&#x65;**)** address the more complex problem of curating messages that originate from a large network of system&#x73;**.** These tools feature such aids as graphical interface&#x73;**,** query language&#x73;**,** data visualizatio&#x6E;**,** alertin&#x67;**,** and automated anomaly detectio&#x6E;**.** They can scale to handle message volumes on the order of terabytes per da&#x79;**.** You can subscribe to these products as a cloud service or host them yourself on a private networ&#x6B;**.**

Exhibit A on the next page depicts the architecture of a site that uses all the log management services mentioned abov&#x65;**.** Administrators and other interested parties can run a GUI against the centralized log cluster to review log messages from systems across the networ&#x6B;**.** Administrators can also log in to individual nodes and access messages through the systemd journal or the plain text files written by syslo&#x67;**.** When debugging problems and error&#x73;**,** experienced administrators turn to the logs sooner rather than late&#x72;**.** Log files often contain important hints that point toward the source of vexing configuration error&#x73;**,** software bug&#x73;**,** and security issue&#x73;**.** Logs are the first place you should look when a daemon crashes or refuses to star&#x74;**,** or when a chronic error plagues a system that is trying to boo&#x74;**.**

The importance of having a wel&#x6C;**-**&#x64;efine&#x64;**,** sit&#x65;**-**&#x77;ide logging strategy has grown along with the adoption of formal IT standards such as PCI DS&#x53;**,** COBI&#x54;**,** and ISO 2700&#x31;**,** as well as with the maturing of regulations for individual industrie&#x73;**.** Toda&#x79;**,** these external standards may require you to maintain a centralize&#x64;**,** hardene&#x64;**,** enterpris&#x65;**-**&#x77;ide repository for log activit&#x79;**,** with time stamps validated by NTP and with a strictly defined retention schedul&#x65;**.**&#x31; Howeve&#x72;**,** even sites without regulatory or compliance requirements can benefit from centralized loggin&#x67;**.**

### Log locations <a href="#toc171120159" id="toc171120159"></a>

UNIX is often criticized for being inconsisten&#x74;**,** and indeed it i&#x73;**.** Just take a look at a directory of log files and yo&#x75;**’**&#x72;e sure to find some with names like maillo&#x67;**,** some like cro&#x6E;**.**&#x6C;o&#x67;**,** and some that use various distributio&#x6E;**-** and daemo&#x6E;**-**&#x73;pecific naming convention&#x73;**.** By defaul&#x74;**,** most of these files are found in **/**&#x76;a&#x72;**/**&#x6C;o&#x67;**,** but some renegade applications write their log files elsewhere on the filesyste&#x6D;**.**

Table 1&#x30;**.**&#x31; compiles information about some of the more common log files on our example system&#x73;**.** The table lists the followin&#x67;**:**

| • | The log files to archiv&#x65;**,** summariz&#x65;**,** or truncate       |
| - | ------------------------------------------------------------------------ |
| • | The program that creates each                                            |
| • | An indication of how each filename is specified                          |
| • | The frequency of cleanup that we consider reasonable                     |
| • | The systems **(**&#x61;mong our example&#x73;**)** that use the log file |
| • | A description of the fil&#x65;**’**&#x73; contents                       |

**File Program Contents**

### The systemd journal <a href="#toc171120160" id="toc171120160"></a>

In accordance with its mission to replace all other Linux subsystem&#x73;**,** **systemd** includes a logging daemon called **systemd-journald.** It duplicates most of syslo&#x67;**’**&#x73; functions but can also run peacefully in tandem with syslo&#x67;**,** depending on how you or the system have configured i&#x74;**.** If yo&#x75;**’**&#x72;e leery of switching to **systemd** because syslog has always **“**&#x6A;ust worke&#x64;**”** for yo&#x75;**,** spend some time to get to know **systemd.** After a little practic&#x65;**,** you may be pleasantly surprise&#x64;**.**

Unlike syslo&#x67;**,** which typically saves log messages to plain text file&#x73;**,** the **systemd** journal stores messages in a binary forma&#x74;**.** All message attributes are indexed automaticall&#x79;**,** which makes the log easier and faster to searc&#x68;**.** As discussed abov&#x65;**,** you can use the **journalctl** command to review messages stored in the journa&#x6C;**.** The journal collects and indexes messages from several source&#x73;**:**

* The **/dev/log** socke&#x74;**,** to harvest messages from software that submits messages according to syslog conventions
* The device file **/dev/kmsg,** to collect messages from the Linux kerne&#x6C;**.** The **systemd** journal daemon replaces the traditional **klogd** process that previously listened on this channel and formerly forwarded the kernel messages to syslo&#x67;**.**
* The UNIX socket **/run/systemd/journal/stdout,** to service software that writes log messages to standard output
* The UNIX socket **/run/systemd/journal/socket,** to service software that submits messages through the **systemd** journal API
* Audit messages from the kerne&#x6C;**’**&#x73; **auditd** daemon

Intrepid administrators can use the **systemd-journal-remote** utility **(**&#x61;nd its relative&#x73;**,** **systemd-journal-gateway** and **systemd-journal-upload,)** to stream serialized journal messages over the network to a remote journa&#x6C;**.** Unfortunatel&#x79;**,** this feature does not come preinstalled on vanilla distribution&#x73;**.** As of this writin&#x67;**,** packages are available for Debian and Debian stable but not for Red Hat or CentO&#x53;**.** We expect this lapse to be rectified soo&#x6E;**;** in the meantim&#x65;**,** we recommend sticking with syslog if you need to forward log messages among system&#x73;**.**

### Configuring the systemd journal <a href="#toc171120161" id="toc171120161"></a>

The default journal configuration file is **/etc/systemd/journald.conf;** howeve&#x72;**,** this file is not intended to be edited directl&#x79;**.** Instea&#x64;**,** add your customized configurations to the **/etc/systemd/journald.conf.d** director&#x79;**.** Any files placed there with a **.conf** extension are automatically incorporated into the configuratio&#x6E;**.** To set your own option&#x73;**,** create a new **.conf** file in this directory and include the options you wan&#x74;**.** The default **journald.conf** includes a commente&#x64;**-**&#x6F;ut version of every possible optio&#x6E;**,** along with each optio&#x6E;**’**&#x73; default valu&#x65;**,** so you can see at a glance which options are availabl&#x65;**.** They include the maximum size of journa&#x6C;**,** the retention period for message&#x73;**,** and various rat&#x65;**-**&#x6C;imiting setting&#x73;**.** **/etc/systemd/journald.conf**

**#** This file is part of system&#x64;**.**

**#** systemd is free softwar&#x65;**;** you can redistribute it an&#x64;**/**&#x6F;r modify it

**#** Entries in this file show the compile time default&#x73;**.**

**#** You can change settings by editing this fil&#x65;**.**

**#** Defaults can be restored by simply deleting this fil&#x65;**.** **#** See journal&#x64;**.**&#x63;on&#x66;**(**&#x35;**)** for detail&#x73;**.**

\[Journal]

Storage=none

Compress=no

**#**&#x53;eal=yes

**#**&#x53;plitMode=uid

**#**&#x53;yncIntervalSec=5m

**#**&#x52;ateLimitIntervalSec=30s

**#**&#x52;ateLimitBurst=10000

**#**&#x53;ystemMaxUse=

**#**&#x53;ystemKeepFree=

**#**&#x53;ystemMaxFileSize=

**#**&#x53;ystemMaxFiles=100

**#**&#x52;untimeMaxUse=

**#**&#x52;untimeKeepFree=

**#**&#x52;untimeMaxFileSize=

**#**&#x52;untimeMaxFiles=100

**#**&#x4D;axRetentionSec=

**#**&#x4D;axFileSec=1month

**#**&#x46;orwardToSyslog=yes

**#**&#x46;orwardToKMsg=no

**#**&#x46;orwardToConsole=no **#**&#x46;orwardToWall=yes

**#**&#x54;TYPath=**/**&#x64;e&#x76;**/**&#x63;onsole

**#**&#x4D;axLevelStore=debug

**#**&#x4D;axLevelSyslog=debug

**#**&#x4D;axLevelKMsg=notice

**#**&#x4D;axLevelConsole=info

**#**&#x4D;axLevelWall=emerg

**#**&#x4C;ineMax=48K

**#**&#x52;eadKMsg=yes

Audit=no

Journal logs help you debug your syste&#x6D;**.** But for most of the time journaling may write a lot to your storag&#x65;**,** and overtime the logs becomes hug&#x65;**.** I&#x74;**’**&#x73; then truncate&#x64;**,** but if tha&#x74;**’**&#x73; not what you wan&#x74;**,** you can disable it by editing

**/**&#x65;t&#x63;**/**&#x73;ystem&#x64;**/**&#x6A;ournal&#x64;**.**&#x63;on&#x66;**,** and se&#x74;**:**

Storage=none

### systemd logging <a href="#toc171120162" id="toc171120162"></a>

Capturing the log messages produced by the kernel has always been something of a challeng&#x65;**.** It became even more important with the advent of virtual and cloudbased system&#x73;**,** since it is&#x6E;**’**&#x74; possible to simply stand in front of these system&#x73;**’** consoles and watch what happen&#x73;**.** Frequentl&#x79;**,** crucial diagnostic information was lost to the ethe&#x72;**.**

**systemd** alleviates this problem with a universal logging framework that includes all kernel and service messages from early boot to final shutdow&#x6E;**.** This facilit&#x79;**,** called the journa&#x6C;**,** is managed by the **journald** daemo&#x6E;**.**

System messages captured by **journald** are stored in the **/run** director&#x79;**.** **rsyslog** can process these messages and store them in traditional log files or forward them to a remote syslog serve&#x72;**.** You can also access the logs directly with the **journalctl** comman&#x64;**.**

Without argument&#x73;**,** **journalctl** displays all log entries **(**&#x6F;ldest firs&#x74;**):** **$** journalctl

You can configure **journald** to retain messages from prior boot&#x73;**.** To do thi&#x73;**,** edit **/**&#x65;t&#x63;**/**&#x73;ystem&#x64;**/**&#x6A;ournal&#x64;**.**&#x63;onf and configure the Storage attribut&#x65;**:**

\[Journal]

Storage=persistent

Once yo&#x75;**’**&#x76;e configured journal&#x64;**,** you can obtain a list of prior boots with **$** journalctl **--**&#x6C;is&#x74;**-**&#x62;oots

### Log files locations <a href="#toc171120163" id="toc171120163"></a>

There are many different log files that all serve different purpose&#x73;**.** When trying to find a log about somethin&#x67;**,** you should start by identifying the most relevant fil&#x65;**.** Below is a list of common log file location&#x73;**.**

### System logs <a href="#toc171120164" id="toc171120164"></a>

System logs deal with exactly that **-** the Debian stable system **-** as opposed to extra applications added by the use&#x72;**.** These logs may contain information about authorization&#x73;**,** system daemons and system message&#x73;**.**

### Authorization log <a href="#toc171120165" id="toc171120165"></a>

Locatio&#x6E;**:** **/**&#x76;a&#x72;**/**&#x6C;o&#x67;**/**&#x61;ut&#x68;**.**&#x6C;og

Keeps track of authorization system&#x73;**,** such as password prompt&#x73;**,** the sudo command and remote login&#x73;**.**

### Daemon Log <a href="#toc171120166" id="toc171120166"></a>

Locatio&#x6E;**:** **/**&#x76;a&#x72;**/**&#x6C;o&#x67;**/**&#x64;aemo&#x6E;**.**&#x6C;og

Daemons are programs that run in the backgroun&#x64;**,** usually without user interactio&#x6E;**.** For exampl&#x65;**,** display serve&#x72;**,** SSH session&#x73;**,** printing service&#x73;**,** bluetoot&#x68;**,** and mor&#x65;**.**

### Debug log <a href="#toc171120167" id="toc171120167"></a>

Locatio&#x6E;**:** **/**&#x76;a&#x72;**/**&#x6C;o&#x67;**/**&#x64;ebug

Provides debugging information from the Debian stable system and application&#x73;**.**

### Kernel log <a href="#toc171120168" id="toc171120168"></a>

Locatio&#x6E;**:** **/**&#x76;a&#x72;**/**&#x6C;o&#x67;**/**&#x6B;er&#x6E;**.**&#x6C;og

Logs from the Linux kerne&#x6C;**.**

### System log <a href="#toc171120169" id="toc171120169"></a>

Locatio&#x6E;**:** **/**&#x76;a&#x72;**/**&#x6C;o&#x67;**/**&#x73;yslog

Contains more information about your syste&#x6D;**.** If you ca&#x6E;**’**&#x74; find anything in the other log&#x73;**,** i&#x74;**’**&#x73; probably her&#x65;**.**

### Application logs <a href="#toc171120170" id="toc171120170"></a>

Some applications also create logs in **/**&#x76;a&#x72;**/**&#x6C;o&#x67;**.** Below are some example&#x73;**.**

### Apache logs <a href="#toc171120171" id="toc171120171"></a>

Locatio&#x6E;**:** **/**&#x76;a&#x72;**/**&#x6C;o&#x67;**/**&#x61;pache&#x32;**/** **(**&#x73;ubdirector&#x79;**)**

Apache creates several log files in the **/**&#x76;a&#x72;**/**&#x6C;o&#x67;**/**&#x61;pache&#x32;**/** subdirector&#x79;**.** The acces&#x73;**.**&#x6C;og file records all requests made to the server to access file&#x73;**.** erro&#x72;**.**&#x6C;og records all errors thrown by the serve&#x72;**.**

### X11 server logs <a href="#toc171120172" id="toc171120172"></a>

Locatio&#x6E;**:** **/**&#x76;a&#x72;**/**&#x6C;o&#x67;**/**&#x58;or&#x67;**.**&#x30;**.**&#x6C;og

The X11 server creates a seperate log file for each of your display&#x73;**.** Display numbers start at zer&#x6F;**,** so your first display **(**&#x64;isplay &#x30;**)** will log to Xor&#x67;**.**&#x30;**.**&#x6C;o&#x67;**.** The next display **(**&#x64;isplay &#x31;**)** would log to Xor&#x67;**.**&#x31;**.**&#x6C;o&#x67;**,** and so o&#x6E;**.**

### Non-human-readable logs <a href="#toc171120173" id="toc171120173"></a>

Not all log files are designed to be read by human&#x73;**.** Some were made to be parsed by application&#x73;**.** Below are some of example&#x73;**.**

### Login failures log <a href="#toc171120174" id="toc171120174"></a>

Locatio&#x6E;**:** **/**&#x76;a&#x72;**/**&#x6C;o&#x67;**/**&#x66;aillog

Contains info about login failure&#x73;**.** You can view it with the faillog comman&#x64;**.**

### Last logins log <a href="#toc171120175" id="toc171120175"></a>

Locatio&#x6E;**:** **/**&#x76;a&#x72;**/**&#x6C;o&#x67;**/**&#x6C;astlog

Contains info about last login&#x73;**.** You can view it with the lastlog comman&#x64;**.**

### Login records log <a href="#toc171120176" id="toc171120176"></a>

Locatio&#x6E;**:** **/**&#x76;a&#x72;**/**&#x6C;o&#x67;**/**&#x77;tmp

Syslog severity levels **(**&#x64;escending severit&#x79;**)**

| **Level**   | **Approximate meaning**                               |
| ----------- | ----------------------------------------------------- |
| **emerg**   | Panic situation&#x73;**;** system is unusable         |
| **alert**   | Urgent situation&#x73;**;** immediate action required |
| **crit**    | Critical conditions                                   |
| **err**     | Other error conditions                                |
| **warning** | Warning messages                                      |
| **notice**  | Things that might merit investigation                 |
| **info**    | Informational messages                                |
| **debug**   | For debugging only                                    |

### loglevel — Set the default console log level. <a href="#toc171120177" id="toc171120177"></a>

Making sense out of logs is not an easy tas&#x6B;**.** Log management solutions gather and accept data from multiple source&#x73;**.** Those sources can have different log events structure&#x73;**,** providing a different granularit&#x79;**.** They may not follow common logging best practices and be hard to get some meaning fro&#x6D;**.**

Because of tha&#x74;**,** it is important to follow good practices when we develop an applicatio&#x6E;**.** One of those is keeping meaningful log level&#x73;**.** That allows a person who will read the logs and try to give them meaning to understand the importance of the message that they see in the text files or one of those awesome observability tools out ther&#x65;**.**

### What Is a Logging Level? <a href="#toc171120178" id="toc171120178"></a>

A log level or log severity is a piece of information telling how important a given log message i&#x73;**.** It is a simpl&#x65;**,** yet very powerful way of distinguishing log events from each othe&#x72;**.** If the log levels are used properly in your applicatio&#x6E;**,** all you need is to look at the severity firs&#x74;**.** It will tell you if you can continue sleeping during the o&#x6E;**-**&#x63;all night or you need to jump out of bed right away and hit another personal best in running between your bedroom and laptop in the living roo&#x6D;**.**

You can think of the log levels as a way to filter the critical information about your system state and the one that is purely informativ&#x65;**.** The log levels can help to reduce the information noise and alert fatigu&#x65;**.**

### The History of Log Levels <a href="#toc171120179" id="toc171120179"></a>

Before continuing with the description of the log levels themselves it would be good to know where the log levels come fro&#x6D;**.** It all started with syslo&#x67;**.** In the 80&#x73;**,** the Sendmail a mailer daemon project developed by Eric Allman required a logging solutio&#x6E;**.** This is how Syslog was bor&#x6E;**.** It was rapidly adopted by other applications in the Uni&#x78;**-**&#x6C;ike ecosystem and became a standar&#x64;**.** Btw – at Sematext we do support Syslog format with Sematext Log&#x73;**,** our log management too&#x6C;**.**

The console log level can also be changed by the *klogd* progra&#x6D;**,** or by writing the specified level to the ***/**&#x70;ro&#x63;**/**&#x73;y&#x73;**/**&#x6B;erne&#x6C;**/**&#x70;rintk* fil&#x65;**.**

The kernel log levels ar&#x65;**:**

1. **(**&#x4B;ER&#x4E;**\_**&#x45;MER&#x47;**)**

The system is unusabl&#x65;**.**

1. **(**&#x4B;ER&#x4E;**\_**&#x41;LER&#x54;**)**

Actions that must be taken care of immediatel&#x79;**.**

1. **(**&#x4B;ER&#x4E;**\_**&#x43;RI&#x54;**)**

Critical condition&#x73;**.**

1. **(**&#x4B;ER&#x4E;**\_**&#x45;R&#x52;**)**

No&#x6E;**-**&#x63;ritical error condition&#x73;**.**

1. **(**&#x4B;ER&#x4E;**\_**&#x57;ARNIN&#x47;**)**

Warning conditions that should be taken care o&#x66;**.**

1. **(**&#x4B;ER&#x4E;**\_**&#x4E;OTIC&#x45;**)**

Norma&#x6C;**,** but significant event&#x73;**.**

1. **(**&#x4B;ER&#x4E;**\_**&#x49;NF&#x4F;**)**

Informational messages that require no actio&#x6E;**.**

1. **(**&#x4B;ER&#x4E;**\_**&#x44;EBU&#x47;**)**

Kernel debugging message&#x73;**,** output by the kernel if the developer enabled debugging at compile tim&#x65;**.**

By defaul&#x74;**,** the log level of Predato&#x72;**-**&#x4F;S is &#x30;**.**

### Message logging with printk <a href="#toc171120180" id="toc171120180"></a>

[**printk()** ](https://www.kernel.org/doc/html/latest/core-api/printk-basics.html#c.printk)is one of the most widely known functions in the Linux kerne&#x6C;**.** I&#x74;**’**&#x73; the standard tool we have for printing messages and usually the most basic way of tracing and debuggin&#x67;**.** If yo&#x75;**’**&#x72;e familiar with print&#x66;**(**&#x33;**)** you can tell[ **printk()** ](https://www.kernel.org/doc/html/latest/core-api/printk-basics.html#c.printk)is based on i&#x74;**,** although it has some functional difference&#x73;**:**

* * [**printk()** ](https://www.kernel.org/doc/html/latest/core-api/printk-basics.html#c.printk)messages can specify a log leve&#x6C;**.**
  * the format strin&#x67;**,** while largely compatible with C9&#x39;**,** does not follow the exact same specificatio&#x6E;**.** It has some extensions and a few limitations **(**&#x6E;o **%**&#x6E; or floating point conversion specifier&#x73;**).** See[ How to get printk format specifiers righ&#x74;**.**](https://www.kernel.org/doc/html/latest/core-api/printk-formats.html#printk-specifiers)

where KER&#x4E;**\_**&#x49;NFO is the log level **(**&#x6E;ote that i&#x74;**’**&#x73; concatenated to the format strin&#x67;**,** the log level is not a separate argumen&#x74;**).** The available log levels ar&#x65;**:**

The log level specifies the importance of a messag&#x65;**.** The kernel decides whether to show the message immediately **(**&#x70;rinting it to the current consol&#x65;**)** depending on its log level and the current *consol&#x65;**\_**&#x6C;oglevel* **(**&#x61; kernel variabl&#x65;**).** If the message priority is higher **(**&#x6C;ower log level valu&#x65;**)** than the *consol&#x65;**\_**&#x6C;oglevel* the message will be printed to the consol&#x65;**.**

If the log level is omitte&#x64;**,** the message is printed with KER&#x4E;**\_**&#x44;EFAULT leve&#x6C;**.** You can check the current *consol&#x65;**\_**&#x6C;oglevel* wit&#x68;**:**

**$** cat **/**&#x70;ro&#x63;**/**&#x73;y&#x73;**/**&#x6B;erne&#x6C;**/**&#x70;rintk

### locate and updatedb <a href="#toc171120181" id="toc171120181"></a>

The **locate** command can find the location of a file when you only know part of the nam&#x65;**.** It sends a result almost instantaneousl&#x79;**,** since it consults a database that stores the location of all the files on the syste&#x6D;**;** this database is updated daily by the **updatedb** comman&#x64;**.** There are multiple implementations of the **locate** command and picked mlocate for its standard syste&#x6D;**.** If you want to consider an alternativ&#x65;**,** you can try plocate which provides the same command line options and can be considered a dro&#x70;**-**&#x69;n replacemen&#x74;**.** **locate** is smart enough to only return files which are accessible to the user running the command even though it uses a database that knows about all files on the system **(**&#x73;ince its **updatedb** implementation runs with root right&#x73;**).** For extra safet&#x79;**,** the administrator can use **PRUNEDPATHS** in **/etc/updatedb.conf** to exclude some directories from being indexe&#x64;**.**

### syslog System Events <a href="#toc171120182" id="toc171120182"></a>

### Principle and Mechanism <a href="#toc171120183" id="toc171120183"></a>

The **rsyslogd** daemon is responsible for collecting service messages coming from applications and the kerne&#x6C;**,** then dispatching them into log files **(**&#x75;sually stored in the **/var/log/** director&#x79;**).** It obeys the **/**&#x65;t&#x63;**/**&#x72;syslo&#x67;**.**&#x63;onf configuration fil&#x65;**.**

**#** **/**&#x65;t&#x63;**/**&#x72;syslo&#x67;**.**&#x63;onf configuration file for rsyslog **#**

**#** For more information install rsyslo&#x67;**-**&#x64;oc and see

**#** **/**&#x75;s&#x72;**/**&#x73;har&#x65;**/**&#x64;o&#x63;**/**&#x72;syslo&#x67;**-**&#x64;o&#x63;**/**&#x68;tm&#x6C;**/**&#x63;onfiguratio&#x6E;**/**&#x69;nde&#x78;**.**&#x68;tml

**#**

**#** Default logging rules can be found in **/**&#x65;t&#x63;**/**&#x72;syslo&#x67;**.**&#x64;**/**&#x35;&#x30;**-**&#x64;efaul&#x74;**.**&#x63;onf

**#################**

**####** MODULES **####**

**#################**

modul&#x65;**(**&#x6C;oad=**“**&#x69;muxsoc&#x6B;**”)** **#** provides support for local system logging **#**&#x6D;odul&#x65;**(**&#x6C;oad=**“**&#x69;mmar&#x6B;**”)** **#** provides **--**&#x4D;AR&#x4B;**--** message capability

**#** provides UDP syslog reception

**#**&#x6D;odul&#x65;**(**&#x6C;oad=**“**&#x69;mud&#x70;**”)**

**#**&#x69;npu&#x74;**(**&#x74;ype=**“**&#x69;mud&#x70;**”** port=**“**&#x35;1&#x34;**”)**

**#** provides TCP syslog reception

**#**&#x6D;odul&#x65;**(**&#x6C;oad=**“**&#x69;mtc&#x70;**”)**

**#**&#x69;npu&#x74;**(**&#x74;ype=**“**&#x69;mtc&#x70;**”** port=**“**&#x35;1&#x34;**”)**

**#** provides kernel logging support and enable no&#x6E;**-**&#x6B;ernel klog messages modul&#x65;**(**&#x6C;oad=**“**&#x69;mklo&#x67;**”** permitnonkernelfacility=**“**&#x6F;&#x6E;**”)**

**###########################**

**####** GLOBAL DIRECTIVES **####**

**###########################**

**#**

**#** Use traditional timestamp forma&#x74;**.**

**#** To enable high precision timestamp&#x73;**,** comment out the following lin&#x65;**.**

**#**

**$**&#x41;ctionFileDefaultTemplate RSYSLO&#x47;**\_**&#x54;raditionalFileFormat

**#** Filter duplicated messages

**$**&#x52;epeatedMsgReduction on

**#**

**#** Set the default permissions for all log file&#x73;**.**

**#**

**$**&#x46;ileOwner syslog

**$**&#x46;ileGroup adm

**$**&#x46;ileCreateMode 0640

**$**&#x44;irCreateMode 0755

**$**&#x55;mask 0022

**$**&#x50;rivDropToUser syslog

**$**&#x50;rivDropToGroup syslog

**#**

**#** Where to place spool and state files

**#**

**$**&#x57;orkDirectory **/**&#x76;a&#x72;**/**&#x73;poo&#x6C;**/**&#x72;syslog

**#**

**#** Include all config files in **/**&#x65;t&#x63;**/**&#x72;syslo&#x67;**.**&#x64;**/**

**#**

**$IncludeConfig /etc/rsyslog.d/\*.conf**

Each log message is associated with an application subsystem **(**&#x63;alled **“**&#x66;acilit&#x79;**”** in the documentatio&#x6E;**):**

|                                                                                                                | <ul><li><strong>auth</strong> and <strong>authpriv:</strong> for authentication<strong>;</strong></li><li><strong>cron:</strong> comes from task scheduling services<strong>,</strong> <strong>cron</strong> and <strong>atd;</strong></li><li><strong>daemon:</strong> affects a daemon without any special classification <strong>(</strong>DNS<strong>,</strong> NTP<strong>,</strong> etc<strong>.);</strong> o <strong>ftp:</strong> concerns the FTP server<strong>;</strong> o <strong>kern:</strong> message coming from the kernel<strong>;</strong> o <strong>lpr:</strong> comes from the printing subsystem<strong>;</strong> o <strong>mail:</strong> comes from the e<strong>-</strong>mail subsystem<strong>;</strong></li><li><strong>news:</strong> Usenet subsystem message <strong>(</strong>especially from an NNTP — Network News</li></ul><p>Transfer Protocol — server that manages newsgroups<strong>);</strong> o <strong>syslog:</strong> messages from the <strong>syslogd</strong> server<strong>,</strong> itself<strong>;</strong></p><ul><li><strong>user:</strong> user messages <strong>(</strong>generic<strong>);</strong></li><li><strong>uucp:</strong> messages from the UUCP server <strong>(</strong>Unix to Unix Copy Program<strong>,</strong> an old protocol notably used to distribute e<strong>-</strong>mail messages<strong>);</strong></li><li><strong>local0</strong> to <strong>local7:</strong> reserved for local use<strong>.</strong></li></ul> |
| -------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| Each message is also associated with a priority leve&#x6C;**.** Here is the list in decreasing orde&#x72;**:** |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
|                                                                                                                | <ul><li><strong>emerg:</strong> <strong>“</strong>Help<strong>!”</strong> There is an emergency<strong>,</strong> the system is probably unusable<strong>.</strong></li><li><strong>alert:</strong> hurry up<strong>,</strong> any delay can be dangerous<strong>,</strong> action must be taken immediately<strong>;</strong> o <strong>crit:</strong> conditions are critical<strong>;</strong> o <strong>err:</strong> error<strong>;</strong></li><li><strong>warn:</strong> warning <strong>(</strong>potential error<strong>);</strong></li><li><strong>notice:</strong> conditions are normal<strong>,</strong> but the message is important<strong>;</strong> o <strong>info:</strong> informative message<strong>;</strong> o <strong>debug:</strong> debugging message<strong>.</strong></li></ul>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |

### Plasma <a href="#toc171120184" id="toc171120184"></a>

Plasma is a simple and lightweight graphical deskto&#x70;**,** which is a perfect match for

computers with limited resource&#x73;**.** It can be installed with **apt install Plasma4** **(**&#x74;as&#x6B;**-**&#x50;lasm&#x61;**-**

deskto&#x70;**).** Like GNOM&#x45;**,** Plasma is based on the GT&#x4B;**+** toolki&#x74;**,** and several components are common across both desktop&#x73;**.**

Unlike GNOME and Plasm&#x61;**,** Plasma does not aim to become a vast projec&#x74;**.** Beyond the basic components of a modern desktop **(**&#x66;ile manage&#x72;**,** window manage&#x72;**,** session manage&#x72;**,** a panel for application launchers and so o&#x6E;**),** it only provides a few specific application&#x73;**:** a termina&#x6C;**,** a calendar **(**&#x6F;rag&#x65;**),** an image viewe&#x72;**,** a C&#x44;**/**&#x44;VD burning too&#x6C;**,** a media player **(**&#x70;arol&#x65;**),** sound volume control and a text editor **(**&#x6D;ousepa&#x64;**).**

### Menu and tools overview <a href="#toc171120185" id="toc171120185"></a>

Modern desktop environments and many window managers provide menus listing the available applications for the use&#x72;**.** In order to keep menus u&#x70;**-**&#x74;&#x6F;**-**&#x64;ate in relation to the actual set of available application&#x73;**,** each package usually provides

a **.desktop** file in **/usr/share/applications:**

### Introduction to AppArmor <a href="#toc171120186" id="toc171120186"></a>

AppArmor is a Mandatory Access Control **(**&#x4D;A&#x43;**)** system built on Linu&#x78;**’**&#x73; LSM **(**&#x4C;inux Security Module&#x73;**)** interfac&#x65;**.** In practic&#x65;**,** the kernel queries AppArmor before each system call to know whether the process is authorized to do the given operatio&#x6E;**.** Through this mechanis&#x6D;**,** AppArmor confines programs to a limited set of resource&#x73;**.**

AppArmor applies a set of rules **(**&#x6B;nown as **“**&#x70;rofil&#x65;**”)** on each progra&#x6D;**.** The profile applied by the kernel depends on the installation path of the program being execute&#x64;**.**

Contrary to SELinux **(**&#x64;iscussed in[ Section 1&#x34;**.**&#x35;**,** **“**&#x49;ntroduction to SELinu&#x78;**”)**](https://debian-handbook.info/browse/stable/sect.selinux.html)**,** the rules applied do not depend on the use&#x72;**.** All users face the same set of rules when they are executing the same program **(**&#x62;ut traditional user permissions still apply and might result in different behavio&#x72;**!).**

AppArmor profiles are stored in **/etc/apparmor.d/** and they contain a list of access control rules on resources that each program can make use o&#x66;**.** The profiles are compiled and loaded into the kernel by the **apparmor\_parser** comman&#x64;**.** Each profile can be loaded either in enforcing or complaining mod&#x65;**.** The former enforces the policy and reports violation attempt&#x73;**,** while the latter does not enforce the policy but still logs the system calls that would have been denie&#x64;**.**

### AppArmor <a href="#toc171120187" id="toc171120187"></a>

AppArmor is a product of Canonica&#x6C;**,** Lt&#x64;**.,** releasers of the Debian stable distributio&#x6E;**.**

I&#x74;**’**&#x73; supported by Debian and Debian stabl&#x65;**,** but has also been adopted as a standard by SUSE distribution&#x73;**.** Debian stable and SUSE enable it on default install&#x73;**,** although the complement of protected services is not extensiv&#x65;**.**

AppArmor implements a form of MAC and is intended as a supplement to the traditional UNIX access control syste&#x6D;**.** Although any configuration is possibl&#x65;**,** AppArmor is not designed to be a use&#x72;**-**&#x66;acing syste&#x6D;**.** Its main goal is service securemen&#x74;**;** that i&#x73;**,** limiting the damage that individual programs can do if they should be compromised or run amo&#x6B;**.**

Protected programs continue to be subject to all the limitations imposed by the standard mode&#x6C;**,** but in additio&#x6E;**,** the kernel filters their activities through a designated and tas&#x6B;**-**&#x73;pecific AppArmor profil&#x65;**.** By defaul&#x74;**,** AppArmor denies all request&#x73;**,** so the profile must explicitly name everything the process is allowed to d&#x6F;**.**

Programs without profile&#x73;**,** such as user shell&#x73;**,** have no special restrictions and run as if AppArmor were not installe&#x64;**.**

This service securement role is essentially the same configuration tha&#x74;**’**&#x73; implemented by SELinux in Red Ha&#x74;**’**&#x73; targeted environmen&#x74;**.** Howeve&#x72;**,** AppArmor is designed more specifically for service securemen&#x74;**,** so it sidesteps some of the more puzzling nuances of SELinu&#x78;**.**

AppArmor profiles are stored in **/**&#x65;t&#x63;**/**&#x61;pparmo&#x72;**.**&#x64;**,** and they are relatively readable even without detailed knowledge of the syste&#x6D;**.**

### Enabling AppArmor and managing AppArmor profiles <a href="#toc171120188" id="toc171120188"></a>

AppArmor support is built into the standard kernels provided by Debia&#x6E;**.** Enabling AppArmor is thus just a matter of installing some packages by executing **apt install apparmor apparmor-profiles apparmor-utils** with root privilege&#x73;**.**

AppArmor is functional after the installatio&#x6E;**,** and **aa-status** will confirm it quickl&#x79;**:**

**#** **aa-status**

SELinux **(***Security Enhanced Linux***)** is a *Mandatory Access Control* system built on Linu&#x78;**’**&#x73; LSM **(***Linux Security Modules***)** interfac&#x65;**.** In practic&#x65;**,** the kernel queries SELinux before each system call to know whether the process is authorized to do the given operatio&#x6E;**.**

SELinux uses a set of rules — collectively known as a *policy* — to authorize or forbid operation&#x73;**.** Those rules are difficult to creat&#x65;**.** Fortunatel&#x79;**,** two standard policies **(***targeted* and *strict***)** are provided to avoid the bulk of the configuration wor&#x6B;**.**

With SELinu&#x78;**,** the management of rights is completely different from traditional Unix system&#x73;**.** The rights of a process depend on its *security context***.** The context is defined by the *identity* of the user who started the proces&#x73;**,** the *role* and the *domain* that the user carried at that tim&#x65;**.** The rights really depend on the domai&#x6E;**,** but the transitions between domains are controlled by the role&#x73;**.** Finall&#x79;**,** the possible transitions between roles depend on the identit&#x79;**.**

### Setting Up SELinux <a href="#toc171120189" id="toc171120189"></a>

SELinux support is built into the standard kernels provided by Debia&#x6E;**.** The core Unix tools support SELinux without any modification&#x73;**.** It is thus relatively easy to enable SELinu&#x78;**.**

The **apt install selinux-basics selinux-policy-defaulti auditd** command will automatically install the packages required to configure an SELinux syste&#x6D;**.**

The selinu&#x78;**-**&#x70;olic&#x79;**-**&#x64;efault package contains a set of standard rule&#x73;**.** By defaul&#x74;**,** this policy only restricts access for a few widely exposed service&#x73;**.** The user sessions are not restricted and it is thus unlikely that SELinux would block legitimate user operation&#x73;**.**

### Modern access control <a href="#toc171120190" id="toc171120190"></a>

Given the worl&#x64;**’**&#x73; wide range of computing environments and the mixed success of efforts to advance the standard mode&#x6C;**,** kernel maintainers have been reluctant to act as mediators in the larger debate over access contro&#x6C;**.** In the Linux worl&#x64;**,** the situation came to a head in 200&#x31;**,** when the &#x55;**.**&#x53;**.** National Security Agency proposed to integrate its Securit&#x79;**-**&#x45;nhanced Linux **(**&#x53;ELinu&#x78;**)** system into the kernel as a standard facilit&#x79;**.**

For several reason&#x73;**,** the kernel maintainers resisted this merg&#x65;**.** Instead of adopting SELinux or anothe&#x72;**,** alternative syste&#x6D;**,** they developed the Linux Security Modules AP&#x49;**,** a kerne&#x6C;**-**&#x6C;evel interface that allows access control systems to integrate themselves as loadable kernel module&#x73;**.**

LS&#x4D;**-**&#x62;ased systems have no effect unless users load them and turn them o&#x6E;**.** This fact lowers the barriers for inclusion in the standard kerne&#x6C;**,** and Linux now ships with SELinux and four other systems **(**&#x41;ppArmo&#x72;**,** Smac&#x6B;**,** TOMOY&#x4F;**,** and Yam&#x61;**)** ready to g&#x6F;**.**

Developments on the BSD side have roughly paralleled those of Linu&#x78;**,** thanks largely to Robert Watso&#x6E;**’**&#x73; work on TrustedBS&#x44;**.** This code has been included in FreeBSD since version &#x35;**.** It also provides the application sandboxing technology used in Appl&#x65;**’**&#x73; macOS and iO&#x53;**.**

When multiple access control modules are active simultaneousl&#x79;**,** an operation must be approved by all of them to be permitte&#x64;**.** Unfortunatel&#x79;**,** the LSM system requires explicit cooperation among active module&#x73;**,** and none of the current modules include this featur&#x65;**.** For no&#x77;**,** Linux systems are effectively limited to a choice of one LSM ad&#x64;**-**&#x6F;n module

### SELinux: Security-Enhanced Linux <a href="#toc171120191" id="toc171120191"></a>

SELinux is one of the oldest Linux MAC implementations and is a product of the &#x55;**.**&#x53;**.** National Security Agenc&#x79;**.** Depending on on&#x65;**’**&#x73; perspectiv&#x65;**,** that might be a source of either comfort or suspicio&#x6E;**.**&#x37;

SELinux takes a maximalist approac&#x68;**,** and it implements pretty much every flavor of MAC and RBAC one might envisio&#x6E;**.** Although it has gained footholds in a few distribution&#x73;**,** it is notoriously difficult to administer and troubleshoo&#x74;**.** This unattributed quote from a former version of the SELinux Wikipedia page vents the frustration felt by many sysadmin&#x73;**:**

Intriguingl&#x79;**,** although the stated raison &#x64;**’**&#xEA;tre of SELinux is to facilitate the creation of individualized access control policies specifically attuned to organizational data custodianship practices and rule&#x73;**,** the supportive software tools are so sparse and unfriendly that the vendors survive chiefly on **“**&#x63;onsultin&#x67;**,’** which typically takes the form of incremental modifications to boilerplate security policie&#x73;**.**

Despite its administrative complexit&#x79;**,** SELinux adoption has been slowly growin&#x67;**,** particularly in environments such as governmen&#x74;**,** financ&#x65;**,** and health care that enforce strong and specific security requirement&#x73;**.** It **is** also a standard part of the Android platfor&#x6D;**.**

Our general opinion regarding SELinux is that it **is** capable of delivering more harm than benefi&#x74;**.** Unfortunatel&#x79;**,** that harm can manifest not only as wasted time and as aggravation for system administrator&#x73;**,** but ironicall&#x79;**,** as security lapse&#x73;**.** Complex models are hard to reason abou&#x74;**,** and SELinux is not really a level playing fiel&#x64;**;** hackers that focus on it understand the system far more thoroughly than the average sysadmi&#x6E;**.**

In particula&#x72;**,** SELinux policy development is a complicated endeavo&#x72;**.** To protect a new daemo&#x6E;**,** for exampl&#x65;**,** a policy must carefully enumerate all the file&#x73;**,** directorie&#x73;**,** and other objects to which the process needs acces&#x73;**.** For complicated software like sendmail or http&#x64;**,** this task can be quite comple&#x78;**.** At least one company offers a thre&#x65;**-**&#x64;ay class on policy developmen&#x74;**.**

Fortunatel&#x79;**,** many general policies are available o&#x6E;**-**&#x6C;in&#x65;**,** and most SELinu&#x78;**-**&#x65;nabled distributions come with reasonable default&#x73;**.** These can easily be installed and configured for your particular environmen&#x74;**.** A ful&#x6C;**-**&#x62;lown policy editor that aims to ease policy application can be found at [seedi&#x74;**.**&#x73;ourceforg&#x65;**.**&#x6E;e&#x74;**.**](http://seedit.sourceforge.net/)

SELinux is well supported by both Red Hat **(**&#x61;nd henc&#x65;**,** CentO&#x53;**)** and Fedor&#x61;**.** Red Hat enables it by defaul&#x74;**.**

Debian and SUSE Linux also have some available support for SELinu&#x78;**,** but you must install additional package&#x73;**,** and the system is less aggressive in its default configuratio&#x6E;**.**

Debian stable inherits some SELinux support from Debia&#x6E;**,** but over the last few release&#x73;**,** Debian stabl&#x65;**’**&#x73; focus has been on AppArmor **(**&#x73;ee page 8&#x37;**).** Some vestigial SELinu&#x78;**-**&#x72;elated packages are still availabl&#x65;**,** but they are generally not up to dat&#x65;**.**

**/etc/selinux/config** is the to&#x70;**-**&#x6C;evel control for SELinu&#x78;**.** The interesting lines are

SELINUX=enforcing

SELINUXTYPE=targeted

The first line has three possible value&#x73;**:** enforcin&#x67;**,** permissiv&#x65;**,** or disable&#x64;**.** The enforcing setting ensures that the loaded policy is applied and prohibits violation&#x73;**.** permissive allows violations to occur but logs them through syslo&#x67;**,** which is valuable for debugging and policy developmen&#x74;**.** disabled turns off SELinux entirel&#x79;**.**

SELINUXTYPE refers to the name of the policy database to be applie&#x64;**.** This is essentially the name of a subdirectory within **/**&#x65;t&#x63;**/**&#x73;elinu&#x78;**.** Only one policy can be active at a tim&#x65;**,** and the available policy sets vary by syste&#x6D;**.**

### Managing an SELinux System <a href="#toc171120192" id="toc171120192"></a>

The SELinux policy is a modular set of rule&#x73;**,** and its installation detects and enables automatically all the relevant modules based on the already installed service&#x73;**.** The system is thus immediately operationa&#x6C;**.** Howeve&#x72;**,** when a service is installed after the SELinux polic&#x79;**,** you must be able to manually enable the corresponding modul&#x65;**.** That is the purpose of the **semodule** comman&#x64;**.** Furthermor&#x65;**,** you must be able to define the roles that each user can endors&#x65;**,** and this can be done with the **semanage** comman&#x64;**.**

Those two commands can thus be used to modify the current SELinux configuratio&#x6E;**,** which is stored in **/etc/selinux/default/.** Unlike other configuration files that you can find in **/etc/,** all those files must not be changed by han&#x64;**.** You should use the programs designed for this purpos&#x65;**.**

### systemd <a href="#toc171120193" id="toc171120193"></a>

systemd is a suite of basic building blocks for a Linux syste&#x6D;**.** It provides a system and service manager that runs as PID 1 and starts the rest of the

syste&#x6D;**.** systemd provides aggressive parallelization capabilitie&#x73;**,** uses socket and[ DBus ](https://wiki.archlinux.org/title/D-Bus)activation for starting service&#x73;**,** offers o&#x6E;**-**&#x64;emand starting of daemon&#x73;**,** keeps track of processes using Linux[ control group&#x73;**,**](https://wiki.archlinux.org/title/Control_groups) maintains mount and automount point&#x73;**,** and implements an elaborate transactional dependenc&#x79;**-**&#x62;ased service control logi&#x63;**.** systemd supports SysV and LSB init scripts and works as a replacement for sysvini&#x74;**.** Other parts include a logging daemo&#x6E;**,** utilities to control basic system configuration like the hostnam&#x65;**,** dat&#x65;**,** local&#x65;**,** maintain a list of logge&#x64;**-**&#x69;n users and running containers and virtual machine&#x73;**,** system account&#x73;**,** runtime directories and setting&#x73;**,** and daemons to manage simple network configuratio&#x6E;**,** network time synchronizatio&#x6E;**,** log forwardin&#x67;**,** and name resolutio&#x6E;**.** systemd in detail The configuration and control of system services is an area in which Linux distributions have traditionally differed the most from one anothe&#x72;**.** systemd aims to standardize this aspect of system administratio&#x6E;**,** and to do s&#x6F;**,** it reaches further into the normal operations of the system than any previous alternativ&#x65;**.**

To see the target the system boots into by defaul&#x74;**,** run the **get-default** subcomman&#x64;**:**

**$** systemctl ge&#x74;**-**&#x64;efault

**graphical.target**

Most Linux distributions boot to **graphical.target** by defaul&#x74;**,** which is&#x6E;**’**&#x74; appropriate for servers that do&#x6E;**’**&#x74; need a GU&#x49;**.** But tha&#x74;**’**&#x73; easily change&#x64;**:**

**$** sudo systemctl se&#x74;**-**&#x64;efault mult&#x69;**-**&#x75;se&#x72;**.**&#x74;arget

To see all the syste&#x6D;**’**&#x73; available target&#x73;**,** run **systemctl list-units:**

**$** systemctl lis&#x74;**-**&#x75;nits **--**&#x74;ype=target

### systemctl <a href="#toc171120194" id="toc171120194"></a>

Activates a service immediatel&#x79;**:**

systemctl start you&#x72;**\_**&#x73;ervic&#x65;**.**&#x73;ervice

Deactivates a service immediatel&#x79;**:**

systemctl stop you&#x72;**\_**&#x73;ervic&#x65;**.**&#x73;ervice

Restarts a servic&#x65;**:**

systemctl restart you&#x72;**\_**&#x73;ervic&#x65;**.**&#x73;ervice

Shows status of a service including whether it is running or no&#x74;**:**

systemctl status you&#x72;**\_**&#x73;ervic&#x65;**.**&#x73;ervice

Enables a service to be started on bootu&#x70;**:**

systemctl enable you&#x72;**\_**&#x73;ervic&#x65;**.**&#x73;ervice

Disables a service to not start during bootu&#x70;**:**

systemctl disable you&#x72;**\_**&#x73;ervic&#x65;**.**&#x73;ervice

### Microcode <a href="#toc171120195" id="toc171120195"></a>

Processor manufacturers release stability and security updates to the processor **microcode.** These updates provide bug fixes that can be critical to the stability of your syste&#x6D;**.** Without the&#x6D;**,** you may experience spurious crashes or unexpected system halts that can be difficult to track dow&#x6E;**.** All users with an AMD or Intel CPU should install the microcode updates to ensure system stabilit&#x79;**.** To acquire updated microcod&#x65;**,** depending on the processo&#x72;**,** pr&#x65;**-**&#x69;nstalled the following packages on Predato&#x72;**-**&#x4F;&#x53;**:**

am&#x64;**-**&#x75;code for AMD processor&#x73;**,** inte&#x6C;**-**&#x75;code for Intel processor&#x73;**.**

### Power management with systemd <a href="#toc171120196" id="toc171120196"></a>

### ACPI events <a href="#toc171120197" id="toc171120197"></a>

systemd handles some powe&#x72;**-**&#x72;elated ACPI event&#x73;**,** whose actions can be configured in **/**&#x65;t&#x63;**/**&#x73;ystem&#x64;**/**&#x6C;ogin&#x64;**.**&#x63;onf or **/**&#x65;t&#x63;**/**&#x73;ystem&#x64;**/**&#x6C;ogin&#x64;**.**&#x63;on&#x66;**.**&#x64;**/\*.**&#x63;onf **.**

source of **:** **/**&#x65;t&#x63;**/**&#x73;ystem&#x64;**/**&#x6C;ogin&#x64;**.**&#x63;onf

**#** This file is part of system&#x64;**.**

**#**

**#** systemd is free softwar&#x65;**;** you can redistribute it an&#x64;**/**&#x6F;r modify it

**#** under the terms of the GNU Lesser General Public License as published by **#** the Free Software Foundatio&#x6E;**;** either version &#x32;**.**&#x31; of the Licens&#x65;**,** or **#** **(**&#x61;t your optio&#x6E;**)** any later versio&#x6E;**.**

**#**

**#** Entries in this file show the compile time default&#x73;**.**

**#** You can change settings by editing this fil&#x65;**.**

**#** Defaults can be restored by simply deleting this fil&#x65;**.**

**#**

**#** See login&#x64;**.**&#x63;on&#x66;**(**&#x35;**)** for detail&#x73;**.**

\[Login]

**#**&#x4E;AutoVTs=6

**#**&#x52;eserveVT=6

**#**&#x4B;illUserProcesses=no

**#**&#x4B;illOnlyUsers=

**#**&#x4B;illExcludeUsers=root

**#**&#x49;nhibitDelayMaxSec=5

**#**&#x55;serStopDelaySec=10

**#**&#x48;andlePowerKey=poweroff

**#**&#x48;andleSuspendKey=suspend

**#**&#x48;andleHibernateKey=hibernate

**#**&#x48;andleLidSwitch=suspend

**#**&#x48;andleLidSwitchExternalPower=suspend

**#**&#x48;andleLidSwitchDocked=ignore

**#**&#x48;andleRebootKey=reboot

**#**&#x50;owerKeyIgnoreInhibited=no

**#**&#x53;uspendKeyIgnoreInhibited=no

**#**&#x48;ibernateKeyIgnoreInhibited=no

**#**&#x4C;idSwitchIgnoreInhibited=yes

**#**&#x52;ebootKeyIgnoreInhibited=no

**#**&#x48;oldoffTimeoutSec=30s

**#**&#x49;dleAction=ignore

**#**&#x49;dleActionSec=30min

**#**&#x52;untimeDirectorySize=1&#x30;**%**

**#**&#x52;untimeDirectoryInodes=400k

**#**&#x52;emoveIPC=yes

**#**&#x49;nhibitorsMax=8192 **#**&#x53;essionsMax=8192

**/**&#x65;t&#x63;**/**&#x73;ystem&#x64;**/**

On systems with no dedicated power manage&#x72;**,** this may replace the **acpid** daemon which is usually used to react to these ACPI event&#x73;**.**

### acpi <a href="#toc171120198" id="toc171120198"></a>

### acpid command <a href="#toc171120199" id="toc171120199"></a>

The specified action for each event can be one

of ignor&#x65;**,** powerof&#x66;**,** reboo&#x74;**,** hal&#x74;**,** suspen&#x64;**,** hibernat&#x65;**,** hybri&#x64;**-**&#x73;lee&#x70;**,** suspen&#x64;**-**&#x74;henhibernat&#x65;**,** lock or kexe&#x63;**.** In case of hibernation and suspensio&#x6E;**,** they must be properly set u&#x70;**.** If an event is not configure&#x64;**,** systemd will use a default actio&#x6E;**.**

| **Event handler Description**    | **Default action**                                                                                                                        |                                |
| -------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------ |
| **HandlePowerKey**               | Triggered when the power ke&#x79;**/**&#x62;utton is presse&#x64;**.**                                                                    | poweroff                       |
| **HandleSuspendKey**             | Triggered when the suspend ke&#x79;**/**&#x62;utton is presse&#x64;**.**                                                                  | suspend                        |
| **HandleHibernateKey**           | Triggered when the hibernate ke&#x79;**/**&#x62;utton is presse&#x64;**.**                                                                | hibernate                      |
| **HandleLidSwitch**              | Triggered when the lid is close&#x64;**,** except in the cases belo&#x77;**.**                                                            | suspend                        |
| **HandleLidSwitchDocked**        | Triggered when the lid is closed if the system is inserted in a docking statio&#x6E;**,** or more than one display is connecte&#x64;**.** | ignore                         |
| **HandleLidSwitchExternalPower** | Triggered when the lid is closed if the system is connected to external powe&#x72;**.**                                                   | action set for HandleLidSwitch |

To apply any change&#x73;**,** signal **:**

**#** systemctl kill **-**&#x73; HUP system&#x64;**-**&#x6C;ogind

By defaul&#x74;**,** these features are Disabled in the Predato&#x72;**-**&#x4F;&#x53;**:**

sudo systemctl disable slee&#x70;**.**&#x74;arget suspen&#x64;**.**&#x74;arget hibernat&#x65;**.**&#x74;arget hybri&#x64;**-**&#x73;lee&#x70;**.**&#x74;arget sudo systemctl stop slee&#x70;**.**&#x74;arget suspen&#x64;**.**&#x74;arget hibernat&#x65;**.**&#x74;arget hybri&#x64;**-**&#x73;lee&#x70;**.**&#x74;arget

### Bluetooth <a href="#toc171120200" id="toc171120200"></a>

To disable bluetooth completel&#x79;**,**[ **blacklist** ](https://wiki.archlinux.org/title/Blacklist)the module&#x73;**.**

To turn off bluetooth only temporaril&#x79;**,** use *rfkill***:**

**#** rfkill block bluetooth

Or with udev rul&#x65;**:**

**/**&#x65;t&#x63;**/**&#x75;de&#x76;**/**&#x72;ule&#x73;**.**&#x64;**/**&#x35;&#x30;**-**&#x62;luetoot&#x68;**.**&#x72;ules

**#** disable bluetooth

SUBSYSTEM==**“**&#x72;fkil&#x6C;**”,** ATTR{type}==**“**&#x62;luetoot&#x68;**”,** ATTR{state}=**“**&#x30;**”**

### PulseAudio <a href="#toc171120201" id="toc171120201"></a>

By defaul&#x74;**,** PulseAudio suspends any audio sources that have become idle for too lon&#x67;**.** When using an external USB microphon&#x65;**,** recordings may start with a pop soun&#x64;**.** As a workaroun&#x64;**,** comment out the following line in

**###** Automatically suspend sink&#x73;**/**&#x73;ources that become idle for too long loa&#x64;**-**&#x6D;odule modul&#x65;**-**&#x73;uspen&#x64;**-**&#x6F;&#x6E;**-**&#x69;dle

### Blacklist Unneeded Modules <a href="#toc171120202" id="toc171120202"></a>

Modules can hog memory and may slow down your syste&#x6D;**.** You can list all the modules currently required by your system by issuing \`lsmod\` command as regular or root use&#x72;**.** Blacklist modules that you do&#x6E;**’**&#x74; nee&#x64;**.**

The Linux kernel is modula&#x72;**,** which makes it more flexible than monolithic kernel&#x73;**.** New functionality can be easily added to a run kerne&#x6C;**,** by loading the related modul&#x65;**.** While that is grea&#x74;**,** it can also be misuse&#x64;**.** You can think of loading malicious modules **(**&#x65;**.**&#x67;**.** rootkit&#x73;**),** or unauthorized access to the server and copy data via a USB por&#x74;**.** In our previous article about kernel module&#x73;**,** we looked at how to prevent loading any modul&#x65;**.** In this cas&#x65;**,** we specifically disallow the ones we do&#x6E;**’**&#x74; wan&#x74;**.**

### Blacklisting modules <a href="#toc171120203" id="toc171120203"></a>

Blacklisting modules is one way to disallow the&#x6D;**.** This defines which modules should no longer be loade&#x64;**.** Howeve&#x72;**,** it will only limit the loading of modules during the boot proces&#x73;**.** You can still load a module manually after bootin&#x67;**.** Blacklisting a module is simpl&#x65;**.** Create a file in the **/**&#x65;t&#x63;**/**&#x6D;odprob&#x65;**.**&#x64; directory and give it a proper name **(**&#x65;**.**&#x67;**.** blacklis&#x74;**-**&#x6D;odul&#x65;**.**&#x63;on&#x66;**).**

For me the **/**&#x65;t&#x63;**/**&#x6D;odprob&#x65;**.**&#x64;**/**&#x62;lacklis&#x74;**.**&#x63;onf goes like thi&#x73;**:**

blacklist iTC&#x4F;**\_**&#x77;dt blacklist pcspkr blacklist joydev blacklist mousedev blacklist ma&#x63;**\_**&#x68;id blacklist uvcvideo

**source of /etc/modprobe.d/blacklist.conf**

| <p><strong>#</strong> This file lists those modules which we don<strong>’</strong>t want to be loaded by <strong>#</strong> alias expansion<strong>,</strong> usually so some other driver will be loaded for the <strong>#</strong> device instead<strong>.</strong></p><p><strong>#</strong> evbug is a debug tool that should be loaded explicitly blacklist evbug</p><p><strong>#</strong> these drivers are very simple<strong>,</strong> the HID drivers are usually preferred</p><p><strong>#</strong>blacklist usbmouse</p><p><strong>#</strong>blacklist usbkbd</p><p><strong>#</strong> replaced by e100</p><p>blacklist eepro100</p><p><strong>#</strong> replaced by tulip</p><p>blacklist de4x5</p><p><strong>#</strong> causes no end of confusion by creating unexpected network interfaces blacklist eth1394</p><p><strong>#</strong> snd<strong>*</strong>intel8x0m can interfere with snd<strong>*</strong>intel8x0<strong>,</strong> does not seem to support much</p><p><strong>#</strong> hardware on its own <strong>(</strong>Debian stable bug <strong>#</strong>2011<strong>,</strong> <strong>#</strong>6810<strong>)</strong> blacklist snd<strong>*</strong>intel8x0m</p><p><strong>#</strong> Conflicts with dvb driver <strong>(</strong>which is better for handling this device<strong>)</strong> blacklist snd<strong>*</strong>aw2</p><p><strong>#</strong> replaced by p54pci</p><p>blacklist prism54</p><p><strong>#</strong> replaced by b43 and ssb<strong>.</strong></p><p>blacklist bcm43xx</p><p><strong>#</strong> most apps now use garmin usb driver directly <strong>(</strong>Debian stable<strong>:</strong> <strong>#</strong>114565<strong>)</strong> blacklist garmin<strong>\_</strong>gps</p> |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <p><strong>#</strong> replaced by asus<strong>-</strong>laptop <strong>(</strong>Debian stable<strong>:</strong> <strong>#</strong>184721<strong>)</strong> blacklist asus<strong>*</strong>acpi</p><p><strong>#</strong> low<strong>-</strong>quality<strong>,</strong> just noise when being used for sound playback<strong>,</strong> causes</p><p><strong>#</strong> hangs at desktop session start <strong>(</strong>Debian stable<strong>:</strong> <strong>#</strong>246969<strong>)</strong> blacklist snd<strong>*</strong>pcsp</p><p><strong>#</strong> ugly and loud noise<strong>,</strong> getting on everyone<strong>’</strong>s nerves<strong>;</strong> this should be done by a</p><p><strong>#</strong> nice pulseaudio bing <strong>(</strong>Debian stable<strong>:</strong> <strong>#</strong>77010<strong>)</strong> blacklist pcspkr</p><p><strong>#</strong> EDAC driver for amd76x clashes with the agp driver preventing the aperture</p><p><strong>#</strong> from being initialised <strong>(</strong>Debian stable<strong>:</strong> <strong>#</strong>297750<strong>).</strong> Blacklist so that the driver <strong>#</strong> continues to build and is installable for the few cases where its <strong>#</strong> really needed<strong>.</strong></p><p>blacklist amd76x<strong>*</strong>edac</p><p>blacklist iTCO<strong>*</strong>wdt blacklist joydev</p>                                                                                                                                                                                                                                                                                                                                                    |

### Disabling NMI watchdog <a href="#toc171120204" id="toc171120204"></a>

The[ **NMI** ](https://en.wikipedia.org/wiki/Non-maskable_interrupt)watchdog is a debugging feature to catch hardware hangs that cause a kernel pani&#x63;**.** On some systems it can generate a lot of interrupt&#x73;**,** causing a noticeable increase in power usag&#x65;**:**

**/**&#x65;t&#x63;**/**&#x73;ysct&#x6C;**.**&#x64;**/**&#x64;isabl&#x65;**\_**&#x77;atchdo&#x67;**.**&#x63;onf kerne&#x6C;**.**&#x6E;m&#x69;**\_**&#x77;atchdog = 0

or add to the[ **kernel line** ](https://wiki.archlinux.org/title/Kernel_line)to disable it completely from early boo&#x74;**.**

### Writeback Time <a href="#toc171120205" id="toc171120205"></a>

Increasing the virtual memory dirty writeback time helps to aggregate disk &#x49;**/**&#x4F; togethe&#x72;**,** thus reducing spanned disk write&#x73;**,** and increasing power savin&#x67;**.** To set the value to 60 seconds **(**&#x64;efault is 5 second&#x73;**):**

**/**&#x65;t&#x63;**/**&#x73;ysct&#x6C;**.**&#x64;**/**&#x64;irt&#x79;**.**&#x63;onf

v&#x6D;**.**&#x64;irt&#x79;**\_**&#x77;ritebac&#x6B;**\_**&#x63;entisecs = 6000

To do the same for journal commits on supported filesystems **(**&#x65;**.**&#x67;**.** ext&#x34;**,** btrf&#x73;**...),** use as a option in[ **fstab.**](https://wiki.archlinux.org/title/Fstab)

### Swappiness <a href="#toc171120206" id="toc171120206"></a>

The *swappiness*[ **sysctl** ](https://wiki.archlinux.org/title/Sysctl)parameter represents the kerne&#x6C;**’**&#x73; preference **(**&#x6F;r avoidanc&#x65;**)** of swap spac&#x65;**.**

Swappiness can have a value between 0 and 200 **(**&#x6D;ax 100 if Linux **<** &#x35;**.**&#x38;**),** the default value is 6&#x30;**.** A low value causes the kernel to avoid swappin&#x67;**,** a high value causes the kernel to try to use swap spac&#x65;**,** and a value of 100 means IO cost is assumed to be equa&#x6C;**.** Using a low value on sufficient memory is known to improve responsiveness on many system&#x73;**.**

To check the current swappiness valu&#x65;**:**

**$** sysctl v&#x6D;**.**&#x73;wappiness

Alternativel&#x79;**,** the files **/**&#x73;y&#x73;**/**&#x66;&#x73;**/**&#x63;grou&#x70;**/**&#x6D;emor&#x79;**/**&#x6D;emor&#x79;**.**&#x73;wappiness **(**&#x63;group v1specifi&#x63;**)** or **/**&#x70;ro&#x63;**/**&#x73;y&#x73;**/**&#x76;&#x6D;**/**&#x73;wappiness can be read in order to obtain the raw integer valu&#x65;**.**

To temporarily set the swappiness valu&#x65;**:**

**#** sysctl **-**&#x77; v&#x6D;**.**&#x73;wappiness=10

### Using zswap or zram <a href="#toc171120207" id="toc171120207"></a>

[**Zswap** ](https://wiki.archlinux.org/title/Zswap)is a Linux kernel feature providing a compressed writ&#x65;**-**&#x62;ack cache for swapped page&#x73;**,**[ **ZRAM** ](https://wiki.archlinux.org/title/ZRAM)creates a virtual compressed swap block in memory as alternative to a swap partitio&#x6E;**/**&#x66;ile on dis&#x6B;**.** Both approaches increase the swapping performance and decrease the disk &#x49;**/**&#x4F; operation&#x73;**.**

### Changing I/O scheduler <a href="#toc171120208" id="toc171120208"></a>

The best choice of scheduler depends on both the device and the exact nature of the workloa&#x64;**.** Als&#x6F;**,** the throughput in M&#x42;**/**&#x73; is not the only measure of performanc&#x65;**:** deadline or fairness deteriorate the overall throughput but may improve system responsivenes&#x73;**.**[ **Benchmarking** ](https://wiki.archlinux.org/title/Benchmarking)may be useful to indicate each &#x49;**/**&#x4F; scheduler performanc&#x65;**.**

To list the available schedulers for a device and the active scheduler **(**&#x69;n bracket&#x73;**):**

**$** cat **/**&#x73;y&#x73;**/**&#x62;loc&#x6B;**/*****sda*****/**&#x71;ueu&#x65;**/**&#x73;cheduler m&#x71;**-**&#x64;eadline kyber \[bfq] none

To list the available schedulers for all device&#x73;**:**

**$** grep **““** **/**&#x73;y&#x73;**/**&#x62;loc&#x6B;**/\*/**&#x71;ueu&#x65;**/**&#x73;cheduler

To change the active &#x49;**/**&#x4F; scheduler to *bfq* for device *sda***,** us&#x65;**:**

**#** echo ***bfq*** **>** **/**&#x73;y&#x73;**/**&#x62;loc&#x6B;**/*****sda*****/**&#x71;ueu&#x65;**/**&#x73;cheduler

HDD &#x49;**/**&#x4F; Scheduler Benchmarks **-** BFQ

If you are an SSD use&#x72;**,** use m&#x71;**-**&#x64;eadline IO schedule&#x72;**.**

If you use NVME SS&#x44;**,** use none IO schedule&#x72;**.**

To let your system select the scheduler automatically for yo&#x75;**,** use a udev rule for tha&#x74;**!**

For SSDs

**/**&#x65;t&#x63;**/**&#x75;de&#x76;**/**&#x72;ule&#x73;**.**&#x64;**/**&#x36;&#x30;**-**&#x73;s&#x64;**.**&#x72;ules

ACTION==**“**&#x61;dd|chang&#x65;**”,** KERNEL==**“**&#x73;d\[&#x61;**-**&#x7A;]**\*”,** ATTR{queu&#x65;**/**&#x72;otational}==**“**&#x30;**”,**

ATTR{queu&#x65;**/**&#x73;cheduler}=**“**&#x6D;&#x71;**-**&#x64;eadlin&#x65;**”**

For NVME SSDs

**/**&#x65;t&#x63;**/**&#x75;de&#x76;**/**&#x72;ule&#x73;**.**&#x64;**/**&#x36;&#x30;**-**&#x6E;vm&#x65;**.**&#x72;ules

ACTION==**“**&#x61;dd|chang&#x65;**”,** KERNEL==**“**&#x6E;vme\[&#x30;**-**&#x39;]**\*”,** ATTR{queu&#x65;**/**&#x73;cheduler}=**“**&#x6E;on&#x65;**”**

For HDDs

**/**&#x65;t&#x63;**/**&#x75;de&#x76;**/**&#x72;ule&#x73;**.**&#x64;**/**&#x36;&#x30;**-**&#x68;d&#x64;**.**&#x72;ules

ACTION==**“**&#x61;dd|chang&#x65;**”,** KERNEL==**“**&#x73;d\[&#x61;**-**&#x7A;]**\*”,**

ATTR{queu&#x65;**/**&#x72;otational}==**“**&#x31;**”,** ATTR{queu&#x65;**/**&#x73;cheduler}=**“**&#x62;f&#x71;**”**

This will set the IO scheduler for all the no&#x6E;**-**&#x72;otational block devices starting from sda to sdzzz or the maximum devices supported by your syste&#x6D;**.**

### Tuning I/O scheduler <a href="#toc171120209" id="toc171120209"></a>

Each of the kerne&#x6C;**’**&#x73; &#x49;**/**&#x4F; scheduler has its own tunable&#x73;**,** such as the latency tim&#x65;**,** the expiry time or the FIFO parameter&#x73;**.** They are helpful in adjusting the algorithm to a particular combination of device and workloa&#x64;**.** This is typically to achieve a higher throughput or a lower latency for a given utilizatio&#x6E;**.** The tunables and their description can be found within the[ **kernel documentation.**](https://docs.kernel.org/block/index.html) To list the available tunables for a devic&#x65;**,** in the example below *sdb* which is using *deadline***,** us&#x65;**:**

**$** ls **/**&#x73;y&#x73;**/**&#x62;loc&#x6B;**/*****sda*****/**&#x71;ueu&#x65;**/**&#x69;osched

To improve *deadlin&#x65;**’***&#x73; throughput at the cost of latenc&#x79;**,** one can increase with the comman&#x64;**:**

**#** echo *32* **>** **/**&#x73;y&#x73;**/**&#x62;loc&#x6B;**/*****sda*****/**&#x71;ueu&#x65;**/**&#x69;osche&#x64;**/fifo\_batch**

### CPU Overclocking <a href="#toc171120210" id="toc171120210"></a>

[**Overclocking** ](https://en.wikipedia.org/wiki/Overclocking)improves the computational performance of the CPU by increasing its peak clock frequenc&#x79;**.** The ability to overclock depends on the combination of CPU model and motherboard mode&#x6C;**.** It is most frequently done through the BIO&#x53;**.** Overclocking also has disadvantages and risk&#x73;**.** It is neither recommended nor discouraged her&#x65;**.**

Many Intel chips will not correctly report their clock frequency to acp&#x69;**\_**&#x63;pufreq and most other utilitie&#x73;**.** This will result in excessive messages in[ **dmesg,**](https://wiki.archlinux.org/title/Dmesg) which can be avoided by unloading and blacklisting the kernel module **.** To read their clock speed use *i7z* from the[ **i7z** ](https://archlinux.org/packages/?name=i7z)packag&#x65;**.** To check for correct operation of an overclocked CPU

[**CPU performance scaling** ](https://docs.kernel.org/admin-guide/pm/cpufreq.html)enables the operating system to scale the CPU frequency up or down in order to save power or improve performanc&#x65;**.** Scaling can be done automatically in response to system loa&#x64;**,** adjust itself in response to ACPI event&#x73;**,** or be manually changed by user space program&#x73;**.**

The Linux kernel offers CPU performance scaling via the *CPUFreq* subsyste&#x6D;**,** which defines two layers of abstractio&#x6E;**:**

* [**Scaling governors** ](https://wiki.archlinux.org/title/CPU_frequency_scaling#Scaling_governors)implement the algorithms to compute the desired CPU frequenc&#x79;**,** potentially based off of the syste&#x6D;**’**&#x73; need&#x73;**.**
* [**Scaling drivers** ](https://wiki.archlinux.org/title/CPU_frequency_scaling#Scaling_drivers)interact with the CPU directl&#x79;**,** enacting the desired frequencies that the current governor is requestin&#x67;**.**

A default scaling driver and governor are selected automaticall&#x79;**,** but userspace tools like[ **cpupower,**](https://wiki.archlinux.org/title/CPU_frequency_scaling#cpupower)[ **acpid,**](https://wiki.archlinux.org/title/Acpid)[ **Laptop Mode Tools,**](https://wiki.archlinux.org/title/Laptop_Mode_Tools) or GUI tools provided for your desktop environmen&#x74;**,** may still be used for advanced configuratio&#x6E;**.**

### Thermald <a href="#toc171120211" id="toc171120211"></a>

**thermald** is a **Linux daemon** used to prevent the overheating of Intel CPU&#x73;**.** This daemon proactively controls thermal parameters using &#x50;**-**&#x73;tate&#x73;**,** &#x54;**-**&#x73;tate&#x73;**,** and the Intel power clamp drive&#x72;**.** thermald can also be used for older Intel CPU&#x73;**.** If the latest drivers are not availabl&#x65;**,** then the daemon will revert to x86 model specific registers and the Linux **“**&#x63;pufreq subsyste&#x6D;**”** to control system coolin&#x67;**.**

By defaul&#x74;**,** it monitors CPU temperature using available CPU digital temperature sensors and maintains CPU temperature under contro&#x6C;**,** before hardware takes aggressive correction actio&#x6E;**.** If there is a skin temperature sensor in thermal sysf&#x73;**,** then it tries to keep skin temperature under 45&#x43;**.**

### cpupower-gui <a href="#toc171120212" id="toc171120212"></a>

[**cpupower-gui** ](https://aur.archlinux.org/packages/cpupower-gui/)is a graphical utility designed to assist with CPU frequency scalin&#x67;**.** The GUI is based on[ **GTK** ](https://wiki.archlinux.org/title/GTK)and is meant to provide the same options as *cpupower***.** *cpupowe&#x72;**-**&#x67;ui* can change the maximu&#x6D;**/**&#x6D;inimum CPU frequency and governor for each cor&#x65;**.**

Setting maximum and minimum frequencies

In some case&#x73;**,** it may be necessary to manually set maximum and minimum frequencie&#x73;**.**

To set the maximum clock frequency **(** is a clock frequency with unit&#x73;**:** GH&#x7A;**,** MH&#x7A;**):**

**#** cpupower frequenc&#x79;**-**&#x73;et **-**&#x75; *cloc&#x6B;**\_**&#x66;req*

To set the minimum clock frequenc&#x79;**:**

**#** cpupower frequenc&#x79;**-**&#x73;et **-**&#x64; *cloc&#x6B;**\_**&#x66;req*

To set the CPU to run at a specified frequenc&#x79;**:**

**#** cpupower frequenc&#x79;**-**&#x73;et **-**&#x66; *cloc&#x6B;**\_**&#x66;req*

### Changing to acpi-cpufreq CPU management driver <a href="#toc171120213" id="toc171120213"></a>

The idea here is to replace the inte&#x6C;**-**&#x70;state CPU power management driver with the acp&#x69;**-**&#x63;pufreq on&#x65;**.** This allows for better performance and slightly more efficient power use in some case&#x73;**,** as shown her&#x65;**.**

Disable inte&#x6C;**-**&#x70;state in grub config

To disable the default inte&#x6C;**-**&#x70;state drive&#x72;**,** you need to edit **/**&#x65;t&#x63;**/**&#x64;efaul&#x74;**/**&#x67;ru&#x62;**:** **#** also hides the splash screen for people like me that like to see log messages on boot instead of a progress ba&#x72;**.**

GRU&#x42;**\_**&#x43;MDLIN&#x45;**\_**&#x4C;INU&#x58;**\_**&#x44;EFAULT=**“**&#x71;uiet nosplash debug inte&#x6C;**\_**&#x70;state=disabl&#x65;**”**

After making our edit&#x73;**,** we need to refresh gru&#x62;**:**

**$**&#x73;udo updat&#x65;**-**&#x67;rub

et&#x63;**/**&#x64;efaul&#x74;**/**&#x67;rub

### BIOS frequency limitation <a href="#toc171120214" id="toc171120214"></a>

**/**&#x73;y&#x73;**/**&#x64;evice&#x73;**/**&#x73;yste&#x6D;**/**&#x63;p&#x75;**/**&#x63;pu&#x30;**/**&#x63;pufre&#x71;**/**&#x62;io&#x73;**\_**&#x6C;imit

Some CP&#x55;**/**&#x42;IOS configurations may have difficulties to scale to the maximum frequency or scale to higher frequencies at al&#x6C;**.** This is most likely caused by BIOS events telling the OS to limit the frequency resulting in set to a lower valu&#x65;**.**

Either you just made a specific Setting in the BIOS Setup Utilit&#x79;**,** **(**&#x46;requenc&#x79;**,** Thermal Managemen&#x74;**,** et&#x63;**.)** you can blame a bugg&#x79;**/**&#x6F;utdated BIOS or the BIOS might have a serious reason for throttling the CPU on its ow&#x6E;**.**

### Turn off CPU exploit mitigations <a href="#toc171120215" id="toc171120215"></a>

**Warning:** Do not apply this setting without considering the vulnerabilities it opens u&#x70;**.** See[ **this** ](https://phoronix.com/scan.php?page=news_item\&px=Linux-Improve-CPU-Spec-Switches)and[ **this** ](https://linuxreviews.org/HOWTO_make_Linux_run_blazing_fast_\(again\)_on_Intel_CPUs)for more informatio&#x6E;**.**

Turning off CPU exploit mitigations may improve performanc&#x65;**.** Use below[ **kernel parameter** ](https://wiki.archlinux.org/title/Kernel_parameter)to disable them al&#x6C;**:**

mitigations=off

### Virtual memory <a href="#toc171120216" id="toc171120216"></a>

There are several key parameters to tune the operation of the[ **virtual memory** ](https://en.wikipedia.org/wiki/virtual_memory)subsystem of the Linux kernel and the write out of dirty data to dis&#x6B;**.** See the official[ **Linux kernel documentation** ](https://docs.kernel.org/admin-guide/sysctl/vm.html)for more informatio&#x6E;**.** For exampl&#x65;**:**

Contain&#x73;**,** as a percentage of total available memory that contains free pages and reclaimable page&#x73;**,** the number of pages at which a process which is generating disk writes will itself start writing out dirty dat&#x61;**.**

|   | v&#x6D;**.**&#x64;irt&#x79;**\_**&#x62;ackgroun&#x64;**\_**&#x72;atio = 5 |   |
| - | ------------------------------------------------------------------------- | - |

Contain&#x73;**,** as a percentage of total available memory that contains free pages and reclaimable page&#x73;**,** the number of pages at which the background kernel flusher threads will start writing out dirty dat&#x61;**.**

* Consensus is that setting to 1&#x30;**%** of RAM is a sane value if RAM is say 1 GB **(**&#x73;o 1&#x30;**%** is 100 M&#x42;**).** But if the machine has much more RA&#x4D;**,** say 16 GB **(**&#x31;&#x30;**%** is &#x31;**.**&#x36; G&#x42;**),** the percentage may be out of proportion as it becomes several seconds of writeback on spinning disk&#x73;**.** A more sane value in this case may be 3 **(**&#x33;**%** of 16 GB is approximately 491 M&#x42;**).**

v&#x6D;**.**&#x64;irt&#x79;**\_**&#x62;ackgroun&#x64;**\_**&#x72;atio

* Similarl&#x79;**,** setting to 5 may be just fine for small memory value&#x73;**,** but agai&#x6E;**,** consider and adjust accordingly for the amount of RAM on a particular syste&#x6D;**.**

### VFS cache <a href="#toc171120217" id="toc171120217"></a>

Decreasing the[ **virtual file system** ](https://docs.kernel.org/filesystems/vfs.html)**(**&#x56;F&#x53;**)** cache parameter value may improve system responsivenes&#x73;**:**

v&#x6D;**.**&#x76;f&#x73;**\_**&#x63;ach&#x65;**\_**&#x70;ressure = 50

The value controls the tendency of the kernel to reclaim the memory which is used for caching of directory and inode objects **(**&#x56;FS cach&#x65;**).** Lowering it from the default value of 100 makes the kernel less inclined to reclaim VFS cache **(**&#x64;o not set it to &#x30;**,** this may produce ou&#x74;**-**&#x6F;&#x66;**-**&#x6D;emory condition&#x73;**).**

All the configs are set in the **/**&#x65;t&#x63;**/**&#x73;ysct&#x6C;**.**&#x63;onf

### Linux kernel configuration <a href="#toc171120218" id="toc171120218"></a>

You can use any of three basic methods to configure a Linux kerne&#x6C;**.** Chances are that you will have the opportunity to try all of them eventuall&#x79;**.** The methods are

**• Modifying tunable (dynamic) kernel configuration parameters**

* Building a kernel from scratch **(**&#x62;y compiling it from the source cod&#x65;**,** possibly with modifications and addition&#x73;**)**
* Loading new drivers and modules into an existing kernel on the fly These procedures are used in different situation&#x73;**,** so learning which approaches are needed for which tasks is half the battl&#x65;**.** Modifying tunable parameters is the easiest and most common kernel twea&#x6B;**,** whereas building a kernel from source code is the hardest and least often require&#x64;**.** Fortunatel&#x79;**,** all these approaches become second nature with a little practic&#x65;**.**

Tuning Linux kernel parameters

Many modules and drivers in the kernel were designed with the knowledge that one size does not fit al&#x6C;**.** To increase flexibilit&#x79;**,** special hooks allow parameters such as an internal tabl&#x65;**’**&#x73; size or the kerne&#x6C;**’**&#x73; behavior in a particular circumstance to be adjusted on the fly by the system administrato&#x72;**.** These hooks are accessible through an extensive kerne&#x6C;**-**&#x74;&#x6F;**-**&#x75;serland interface represented by files in the **/proc** filesystem **(**&#x61;ka procf&#x73;**).** In some case&#x73;**,** a large use&#x72;**-**&#x6C;evel application **(**&#x65;specially an infrastructure application such as a databas&#x65;**)** might require a sysadmin to adjust kernel parameters to accommodate its need&#x73;**.**

### To avoid duplicate in sysctl.conf <a href="#toc171120219" id="toc171120219"></a>

**#**&#x63;at **/**&#x65;t&#x63;**/**&#x73;ysct&#x6C;**.**&#x63;onf|grep **-**&#x76; ^**#**|grep **-**&#x76; ^**$**|awk **-**&#x46;**”**=**“** **‘**{print **$**&#x31;}**’**|uniq **-**&#x63;|awk **‘**{print **$**&#x31;}**’**|grep **-**&#x76; 1

### Logical Volume Manager (LVM) <a href="#toc171120220" id="toc171120220"></a>

it is a device mapper framework that provides logical volume management for the Linux kerne&#x6C;**.** Most modern Linux distributions are LV&#x4D;**-**&#x61;ware to the point of being able to have their root file systems on a logical volum&#x65;**.** The lvm monitor service is disabled by defaul&#x74;**.**

**#** systemctl status lvm&#x32;**-**&#x6D;onitor

Predato&#x72;**-**&#x4F;S sollution was to reduce the timeou&#x74;**,** and to do so without messing with the base installed networkin&#x67;**.**&#x73;ervices systemd fil&#x65;**.** This will persist during updates in any packag&#x65;**.**

**hugepages** in **/**&#x65;t&#x63;**/**&#x73;ysct&#x6C;**.**&#x63;onf fil&#x65;**.**

v&#x6D;**.**&#x6E;&#x72;**\_**&#x68;ugepages = 126 126 pages x 2 MB = 252 MB

**$**&#x63;at **/**&#x73;y&#x73;**/**&#x6B;erne&#x6C;**/**&#x6D;&#x6D;**/**&#x74;ransparen&#x74;**\_**&#x68;ugepag&#x65;**/**

**Motd**

motd **-** message of the day

The welcome message shown to a user upon the terminal login whether it is via remote SSH login or directly via TTY or terminal is a part of **motd** also known as **“M**essage **O**f

**T**

he

**D**

ay

**”**

daemon

**.**

The

**mot**

**d**

message can by customized to fit

individual needs of

each user or administrator by modifying the

**/**

**etc**

**/**

**mot**

**d**

file or script within

the

**/**

**etc**

**/**

**update**

**-**

**motd**

**.**

**d**

directory

**.**

Modifying the **/etc/motd** file is fast and effective way on how to quickly change the welcome messag&#x65;**.** Howeve&#x72;**,** for more elaborate configuration it is recommend to customize the MOTD via scripts located within the **/etc/update-motd.d** director&#x79;**.**

**/**&#x65;t&#x63;**/**&#x64;efaul&#x74;**/**&#x6D;ot&#x64;**-**&#x6E;ews

**/**&#x76;a&#x72;**/**&#x63;ach&#x65;**/**&#x6D;ot&#x64;**-**&#x6E;ews

**/**&#x65;t&#x63;**/**&#x75;pdat&#x65;**-**&#x6D;ot&#x64;**.**&#x64;**/\***

### Configuration Directories <a href="#toc171120221" id="toc171120221"></a>

The default configuration is set during compilatio&#x6E;**,** so configuration is only needed when it is necessary to deviate from those default&#x73;**.** Initiall&#x79;**,** the main configuration file in **/**&#x65;t&#x63;**/**&#x73;ystem&#x64;**/** contains commented out entries showing the defaults as a guide to the administrato&#x72;**.** Local overrides can be created by editing this file or by creating dro&#x70;**-**&#x69;n&#x73;**,** as described belo&#x77;**.** Using dro&#x70;**-**&#x69;ns for local configuration is recommended over modifications to the main configuration fil&#x65;**.**

In addition to the **“**&#x6D;ai&#x6E;**”** configuration fil&#x65;**,** dro&#x70;**-**&#x69;n configuration snippets are read from **/**&#x75;s&#x72;**/**&#x6C;i&#x62;**/**&#x73;ystem&#x64;**/\*.**&#x63;on&#x66;**.**&#x64;**/,** **/**&#x75;s&#x72;**/**&#x6C;oca&#x6C;**/**&#x6C;i&#x62;**/**&#x73;ystem&#x64;**/\*.**&#x63;on&#x66;**.**&#x64;**/,** and **/**&#x65;t&#x63;**/**&#x73;ystem&#x64;**/\*.**&#x63;on&#x66;**.**&#x64;**/.** Those dro&#x70;**-**&#x69;ns have higher precedence and override the main configuration fil&#x65;**.** Files in the **\*.**&#x63;on&#x66;**.**&#x64;**/** configuration subdirectories are sorted by their filename in lexicographic orde&#x72;**,** regardless of in which of the subdirectories they resid&#x65;**.** When multiple files specify the same optio&#x6E;**,** for options which accept just a single valu&#x65;**,** the entry in the file sorted last takes precedenc&#x65;**,** and for options which accept a list of value&#x73;**,** entries are collected as they occur in the sorted file&#x73;**.**

When packages need to customize the configuratio&#x6E;**,** they can install dro&#x70;**-**&#x69;ns under **/**&#x75;s&#x72;**/.** Files in **/**&#x65;t&#x63;**/** are reserved for the local administrato&#x72;**,** who may use this logic to override the configuration files installed by vendor package&#x73;**.** Dro&#x70;**-**&#x69;ns have to be used to override package dro&#x70;**-**&#x69;n&#x73;**,** since the main configuration file has lower precedenc&#x65;**.** It is recommended to prefix all filenames in those subdirectories with a tw&#x6F;**-**&#x64;igit number and a das&#x68;**,** to simplify the ordering of the file&#x73;**.**

To disable a configuration file supplied by the vendo&#x72;**,** the recommended way is to place a symlink to **/**&#x64;e&#x76;**/**&#x6E;ull in the configuration directory in **/**&#x65;t&#x63;**/,** with the same filename as the vendor configuration fil&#x65;**.**

**/etc/systemd/system.conf**

DefaultTimeoutStartSec=10s DefaultTimeoutStopSec=7s The&#x6E;**:**

**$**&#x73;udo systemctl daemo&#x6E;**-**&#x72;eload

### OS Prober <a href="#toc171120222" id="toc171120222"></a>

### What is OS Prober? What is issue with new release? <a href="#toc171120223" id="toc171120223"></a>

If you are mult&#x69;**-**&#x62;ooting with other Linuxe&#x73;**,** and Window&#x73;**,** you might find an issu&#x65;**,** when you update or upgrade Debian stable **(**&#x6D;aybe with other Linuxes to&#x6F;**)** sometime no&#x77;**,** i&#x74;**’**&#x64; stop **“**&#x73;eein&#x67;**”** other distros and Window&#x73;**.** The issue here is in the GRUB &#x32;**.**&#x30;6 it is disabled for O&#x53;**-**&#x64;etecting feature securit&#x79;**.**

What file to edit?

You need to edit the Grub configuration file which is located o&#x6E;**:**

sudo nano **/**&#x65;t&#x63;**/**&#x64;efaul&#x74;**/**&#x67;rub

Make sure that you are a root or root privileged user who can edi&#x74;**.**

To disable the OS Probe&#x72;**,** use the following comman&#x64;**.**

GRU&#x42;**\_**&#x44;ISABL&#x45;**\_**&#x4F;&#x53;**\_**&#x50;ROBER=true

To enable the OS Probe&#x72;**,** use the following comman&#x64;**.**

GRU&#x42;**\_**&#x44;ISABL&#x45;**\_**&#x4F;&#x53;**\_**&#x50;ROBER=false

Once you have set the instruction you can save and exit the fil&#x65;**.**

Now just update the Grub so it can take effect&#x73;**.**

sudo updat&#x65;**-**&#x67;rub

This is i&#x74;**,** just reboot **(**&#x72;estar&#x74;**)** the system and check i&#x74;**.**

GRU&#x42;**\_**&#x44;ISABL&#x45;**\_**&#x4F;&#x53;**\_**&#x50;ROBER=false

### Secure Boot <a href="#toc171120224" id="toc171120224"></a>

To check whether your system has Secure Boot enabled or disable&#x64;**,** typ&#x65;**:** **/**&#x75;s&#x72;**/**&#x62;i&#x6E;**/**&#x6D;okutil **--**&#x73;&#x62;**-**&#x73;tate

**/**&#x75;s&#x72;**/**&#x62;i&#x6E;**/**&#x6D;okutil **--**&#x64;isabl&#x65;**-**&#x76;alidation

### How to Bug Report <a href="#toc171120225" id="toc171120225"></a>

There is issues on github page to track the bugs or send an issue of Predato&#x72;**-**&#x4F;&#x53;**.**

Please write any bug in the following link:

http&#x73;**://**&#x67;ithu&#x62;**.**&#x63;o&#x6D;**/**&#x68;osseinseilan&#x69;**/**&#x50;redato&#x72;**-**&#x4F;&#x53;**/**&#x69;ssue&#x73;**/**

There is a sctrip on emergency mode to troubleshooting your syste&#x6D;**.**
