Tag: system administration

What is the difference between Suspend and Hibernate in Linux. Why is the Hibernation button missing?

When shutting down Linux, instead of completely shutting down the computer, you can select Suspend or Hibernate. These modes are also offered when configuring the behavior of the computer during inactivity (to save power), when the laptop battery is low, and when configuring the behavior after closing the lid of the laptop.

Suspend means stopping all applications and puts the computer into low power mode. When you turn on the computer, it returns to the same state that it was before Suspend. The difference from Hibernate is that the computer turns on faster, although it continues to consume energy. That is, the data remains in RAM, but the computer goes into a low power mode, similar to shutting down. In this state, the battery is consumed very slowly. When turned on, the computer wakes up very quickly. But if the battery is completely discharged before turning on, then the current data from the RAM will be lost)

Hibernate means writing the current state of the computer and RAM to the hard disk and turning off the computer. When you turn on the computer, it returns to the same state that it was before Hibernate. The difference from Suspend is that the computer completely stops consuming power and cannot lose data due to the fact that the battery is dead. But in Hibernate mode, the computer takes a little longer to turn on than when exiting the Suspend state. That is, the Hibernate mode means saving all data from RAM to disk and turning off the computer. The next time you turn on the data from the disk will be loaded into RAM and the computer will be able to continue from the same point that it stopped before sleep

That is, if the computer is often idle and you need to turn it on very quickly, then select the Suspend mode for this. If you expect the computer to be turned off for a long time, then select Hibernate.

Why is there no Hibernate mode in Linux?

In the following screenshot, you can see that when you turn off the computer, there is no option to select Hibernate. This is due to the fact that there is no Swap partition (Swap file) on the specified system, or it is of insufficient size.

In order for the Hibernate option to appear, you need to create a Swap file or increase its size, making it equal to or larger than the computer's RAM.

The created swap partition can be used not only to store some information from RAM while the computer is running, it can also be used in Hibernate mode. When adding this mode, an additional option will appear in the shutdown menu – Hibernate. If you select it, then the current state of the RAM will be written to the swap partition. The next time you turn on the computer, it reads the information from the swap file and restores the state of the computer. That is, those programs that were opened will be reopened and their result will be saved.

In modern Linux, hibernation (sleep) should be enabled automatically when a partition or swap file is added to the system.

For information on how to create a swap file in various distributions, see the articles:

Where NetworkManager stores settings (SOLVED)

NetworkManager Configuration Files

NetworkManager supports various plug-ins that can define new locations for storing configuration information.

The main configuration file for NetworkManager, which is usually changed, is /etc/NetworkManager/NetworkManager.conf. You can view its contents with the following command:

cat /etc/NetworkManager/NetworkManager.conf

In addition to this file, NetworkManager settings can be saved in the /etc/NetworkManager/conf.d and /usr/lib/NetworkManager/conf.d directories.

For a list of all NetworkManager settings, taking into account all configuration files, run the command:

NetworkManager --print-config

Where NetworkManager stores network connection settings

NetworkManager stores the settings for each connection in separate text files with the .nmconnection extension. A typical storage location for configuration files is /var/run/NetworkManager/system-connections. In addition to it, files with connections can be located in other places defined by NetworkManager plugins, for example, settings for network connections via Bluetooth can be stored in the /etc/NetworkManager/NetworkManager.conf folder. The NetworkManager configuration file is /etc/NetworkManager/NetworkManager.conf. Besides these main locations, there may be other paths that are specific to Linux distributions.

To list all network connections and the location of their configuration files, run the command:

nmcli -f NAME,DEVICE,FILENAME connection show

All NetworkManager configuration files

So, the configuration files for NetworkManager are as follows:

  • /etc/NetworkManager/NetworkManager.conf – main configuration file
  • /etc/NetworkManager/conf.d – directory with configuration files
  • /usr/lib/NetworkManager/conf.d – system directory with configuration files (for example, file /usr/lib/NetworkManager/conf.d/20-connectivity.conf)
  • /var/lib/NetworkManager/NetworkManager-intern.conf – internal configuration file. This file is written and read by NetworkManager, and its configuration values are merged with the configuration from NetworkManager.conf. Changes made to this file will be overwritten
  • /var/lib/NetworkManager/NetworkManager.state – file with a set of states
  • /etc/NetworkManager/system-connections/ – directory where wired and wireless connections are stored
  • /var/run/NetworkManager/system-connections/ – directory with some types of connections, for example, Internet via Bluetooth modem
  • /var/lib/NetworkManager/
  • /etc/NetworkManager/dispatcher.d/
  • /etc/NetworkManager/dnsmasq.d/
  • /etc/NetworkManager/dnsmasq-shared.d/

See also: How to remove Mobile broadband and Bluetooth connection in NetworkManager

Updating packages: whether to update the config file

Consider a situation when the package manager of your Linux distribution (Debian, Linux Mint, Ubuntu, Kali Linux) asks about updating the configuration file – what to do and how to get the latest version of the configuration file? Let’s figure it out.

With some updates of some packages, the structure of the configuration file changes. As a rule, the new file contains directives and settings that are necessary for the new version of the program, without which it cannot work.

Setting up a services is almost always changing configuration files. The end file can be the result of lengthy configuration work and many tests. This can take hours or even days.

Therefore, if it is necessary to update the configuration, a dilemma arises:

  • do not update the config, as a result of which the new version of a package will not work normally
  • update config and erase service configuration results

It is for this reason that the system asks you every time what needs to be done if the configuration file is updated with the program update?

An example of a message in which the package manager asks what to do with the new config file:

Configuration file '/etc/squid/squid.conf'
 ==> Modified (by you or by a script) since installation.
 ==> Package distributor has shipped an updated version.
   What would you like to do about it ?  Your options are:
    Y or I  : install the package maintainer's version
    N or O  : keep your currently-installed version
      D     : show the differences between the versions
      Z     : start a shell to examine the situation
 The default action is to keep your current version.
*** squid.conf (Y/I/N/O/D/Z) [default=N] ? 

The options are:

  • Y or I – install a new config file
  • N or O – save the currently used config file
  • D – show differences between versions
  • Z – open the shell to examine the situation

The default option is to save the current config file (N).

If in reality you have not used this program, or the settings made are of no value to you, then always agree to update the configuration file. If the settings made are important to you, then:

  • refuse to update the config file
  • make a backup copy of your config, update the config file to the new version, and then make the necessary settings in it

For some packages, like Tor, the config file is just a set of comments with no setting active – for such files (if you haven't changed them), the update is more of a formality.

How to view the new config file

Typically, system administrators and users save the current configuration file. But how do you view the new file? After all, it is quite possible that there are important changes in it.

One way to do this is to download the latest version of a package and see the configuration file for the latest version in that package.

Download the package with a command like:

apt download PACKAGE

For example, to download the squid package

apt download squid

Unpack the downloaded installation file with a command like:

ar x FILE.deb

For example:

ar x squid_5.1-2_amd64.deb

Now we need to unpack a file called data.tar.gz or data.tar.xz.

Look at the contents of the folder to find out the name of the file:

ls -l

If the file has a .tar.gz extension, then the command is as follows:

tar xzf data.tar.gz

If the file has the extension .tar.xz, then the command is as follows:

tar xf data.tar.xz

Let's check the contents of the current directory again in search of unpacked folders and files:

ls -l

Configuration files on the system are usually placed in the /etc/ directory, when you unpack the package, you will find this folder under the path ./etc/ (that is, in the current folder).

For example, the command to view the configuration file of the latest version of the squid package I am interested in:

gedit ./etc/squid/squid.conf

How to simulate package installation on Linux (How to create and install a dummy package)

Sometimes, when installing packages from source code, you may encounter the problem that the required dependency is missing from the system. Usually you need to solve this problem by installing the necessary dependencies from the standard repository, or by compiling them from source.

Sometimes the required package is present, but its version is not suitable, a similar example and solution is described in the article “How to install a package for which there is no dependency of the required version”.

But I ran into a situation where the required dependency is:

a) does not exist at all (the package was removed from the package repository)

b) functionality has been moved to another package that can be installed

Take a look at the following message:

Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
 detectiteasy : Depends: qt5-default but it is not installable
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

The program installed from source requires the qt5-default package. This package contains one single configuration file. The package itself was removed as unnecessary or due to the fact that its functionality was transferred to the qtchooser package that I installed. That is, from a practical point of view, the dependency is not needed, but I cannot update the system, because, as the package manager thinks, the dependencies are broken.

The way out of this situation is to install a dummy package.

How to create and install a dummy package on Linux (Debian, Linux Mint, Kali Linux, Ubuntu)

There is a Debian package called equivs that can create fake packages. Install it by running

sudo apt install -y equivs

Due to unresolved dependencies, I was unable to install the equivs package on the problematic OS – I used another computer to help.

After installation, you create a “control” template file using the following command:

equivs-control FILE_NAME

For example:

equivs-control qt5-default

Alternative package name can be used like postfix-custom for postfix or something else.

Let's open the generated file for editing:

gedit qt5-default

An example of the content in my case:

### Commented entries have reasonable defaults.
### Uncomment to edit them.
# Source: <source package name; defaults to package name>
Section: misc
Priority: optional
# Homepage: <enter URL here; no default>
Standards-Version: 3.9.2

Package: <package name; defaults to equivs-dummy>
# Version: <enter version here; defaults to 1.0>
# Maintainer: Your Name <yourname@example.com>
# Pre-Depends: <comma-separated list of packages>
# Depends: <comma-separated list of packages>
# Recommends: <comma-separated list of packages>
# Suggests: <comma-separated list of packages>
# Provides: <comma-separated list of packages>
# Replaces: <comma-separated list of packages>
# Architecture: all
# Multi-Arch: <one of: foreign|same|allowed>
# Copyright: <copyright file; defaults to GPL2>
# Changelog: <changelog file; defaults to a generic changelog>
# Readme: <README.Debian file; defaults to a generic one>
# Extra-Files: <comma-separated list of additional files for the doc directory>
# Links: <pair of space-separated paths; First is path symlink points at, second is filename of link>
# Files: <pair of space-separated paths; First is file to include, second is destination>
#  <more pairs, if there's more than one file to include. Notice the starting space>
Description: <short description; defaults to some wise words> 
 long description and info
 second paragraph

The lines with comments indicate which defaults will be applied when creating the package – you can delete these lines or uncomment and specify your own value.

Also in the line “Package” enter the name of the package, I got it like this:

Section: misc
Priority: optional
Standards-Version: 5.15.2+dfsg-7
Version: 5.15.2
Package: qt5-default

The “Provides” line indicates that my package provides the capabilities offered by another package that one is trying to spoof.

Finally, after generating the template control file, use the equivs-build command to create a fake package like


In my case, this is:

equivs-build qt5-default

It will take a few seconds to build the package and then you can run

sudo dpkg -i PACKAGE_NAME*.deb

For example, in my case, after transferring the package to the problem system, the command is as follows:

sudo dpkg -i qt5-default_5.15.2_all.deb

After installing the package, the work of the package manager returned to normal – it is again possible to install and remove packages, update the system.

For advanced users, if your template control file has the “Requires” line, you can create metapackages to install a group of programs.

See also:

Linux PowerShell Basics (Beginner’s Guide)

PowerShell for Linux

In recent years, there has been a trend at Microsoft to cross-platform some of its products and open their source. Also Linux itself became part of Windows in the form of a subsystem. PowerShell, which was originally a Windows-only component, was released as open source and became cross-platform on August 18, 2016, available for Linux and Mac OS.

PowerShell is a task automation and configuration management system developed by Microsoft. It consists of a command interpreter (shell) and a scripting language built on the .NET Framework.

It offers full access to COM (Component Object Model) and WMI (Windows Management Instrumentation), thereby allowing system administrators to perform administrative tasks on both local and remote Windows systems, as well as WS-Management and CIM (Common Information Model), allowing you to administer remote Linux systems plus network devices.

Within this framework, administrative tasks are mostly performed by specific .NET classes called cmdlets (pronounced command-let). Similar to shell scripts in Linux, users can create scripts or executables by storing groups of cmdlets in files following specific rules. These scripts can be used as standalone utilities or command line tools.

How to install PowerShell on Linux

Installation on various Linux distributions is described in the official documentation “Installing PowerShell on Linux”.

But in the official documentation there is a lack of information about some distributions, to fill this gap, separate instructions were written:

Features of PowerShell on Linux

1. Command case is not important in PowerShell

In Windows, the case of commands and names of files and folders is not important – this is a big difference from Linux, where the case of both commands and files matters.

PowerShell inherits a feature from Windows – case is not important. Although this tutorial shows commands written in different case (for example, Get-Date), this is actually for better readability and it doesn't matter if you enter Get-Date, GET-DATE, get-date, or gET- dATE.

2. Some commands are missing

The set of commands in PowerShell depends on the available modules, that is, even on a Windows computer, if you install, for example, Active Directory, then new commands will appear in PowerShell.

The Linux version of PowerShell lacks some of the commands found in the standard Windows PowerShell, primarily when it comes to Windows-specific things.

3. Many aliases and abbreviations

You can see in the scripts and examples of PowerShell commands the unusual writing of commands – in PowerShell, abbreviated notation is allowed, and there are also many aliases, that is, the same action can be performed by commands written in different ways.

4. PowerShell versions

Please note that PowerShell 5 is currently preinstalled on Windows by default, and this shows the installation of the latest version of PowerShell 7. On Windows, you can also install PowerShell 7, but this version will not replace the preinstalled version – there will be 2 versions of PowerShell, moreover, when launched from the “Power user menu” (Win+x) will open PowerShell 5, and when you start Windows Terminal, PowerShell 7 will open.

5. Skipping option names

Some options are positional and when specifying their values, you can skip the option names – at first this may seem confusing.

How to use Powershell on Linux

In this section, we will have a short introduction to Powershell; where we will see how to start PowerShell, run some basic commands, see how to work with files, directories and processes. Later, you will learn how to list all available commands, show command help and aliases.

To start Powershell, enter:


You can check the Powershell version with the following command:


If you only need the version number, then use the following construction:

Get-Host | Select-Object Version

Running some basic Powershell commands on Linux.

Show current date:


Show computer uptime:


Show current working directory:


Working with files and directories in Powershell

1. Create a new empty file in two ways:

New-Item hackware.stuff



Then add content to it and view the content of the file.

Set-Content hackware.stuff -value "Делаем pwsh.ru - это весело!"
Get-Content hackware.stuff

2. Delete the file in PowerShell.

Remove-Item hackware.stuff
Get-Content hackware.stuff

3. Create a new directory.

Take a look at the following set of commands:

mkdir hackware-files
cd hackware-files

Sound familiar? Yes, as already mentioned, there are many aliases in PowerShell. The same actions can be performed with the following commands:

New-Item hackware-files -ItemType "directory"
Set-Location hackware-files
New-Item domains.list
Get-ChildItem -Name

In fact, the commands don't just do the same thing – they are identical.

4. To display a long list that displays detailed information about files and directories, including mode (file type), last modified time, enter:




To display the contents of a specific folder (in this case, the root of the file system), run:

Get-ChildItem /

Working with Processes in PowerShell

How to view all running processes in Linux using PowerShell:


To view detailed information about one or a group of running processes with a given name, specify the process name as an argument to the previous command as follows:

Get-Process httpd

The value of the units in the output is above:

  • NPM(K) – amount of non-paged memory that the process is using, in kilobytes.
  • PM(K) – amount of pageable memory that the process is using, in kilobytes.
  • WS(K) – size of the working set of the process, in kilobytes. The working set consists of the pages of memory that were recently referenced by the process.
  • CPU(s) – amount of processor time that the process has used on all processors, in seconds.
  • ID – process ID (PID).
  • ProcessName – name of the process.

To get all possible data about one or more processes use a command of the form (replace httpd with the name of the process you are interested in):

Get-Process httpd | Format-List *

To stop the process with ID 10500 use the command as shown below:

Get-Process -Id 10500 | Stop-Process

Getting Help in PowerShell

To learn more, get a list of all PowerShell commands for various tasks:


It is possible to filter the information displayed by the Get-Command command. Let's say you want to see PowerShell commands containing the word “Alias”, for this you need to run the following command:

Get-Command -Name *Alias

To display help about a command (cmdlet) use the following:


For example, to display help about the Get-Alias cmdlet:

Get-Help Get-Alias

To get the most complete help on Get-Command, do the following:

Get-Help Get-Command -Full

Aliases in PowerShell

To see all available command aliases, enter:


To get information about a specific alias, enter its name:

Get-Alias -Name pwd

PowerShell Command History

Last but not least, display the command history (a list of the commands you ran earlier) like this:


So this was an introduction to PowerShell on Linux. Of course, PowerShell can actually do much more than create files and show running processes.

Warning: apt-key is deprecated (SOLVED)

The apt-key command manages keys that are responsible for verifying the signature of application package repositories.

Now, whenever you use the apt-key command, you will receive the message:

Warning: apt-key is deprecated. Manage keyring files in trusted.gpg.d instead (see apt-key(8)).

It means that the apt-key program is now deprecated. Now we should use trusted.gpg.d to manage keyfiles. Translated into human language, now we have to add files ourselves to the /etc/apt/trusted.gpg.d/ folder.

This method will use the /etc/apt/trusted.gpg.d/ directory to store the public GPG key ring files. It has been available since early 2017.

If you look at the recommended man page (man apt-key), it says that this command and all its functions are deprecated.

There are two options for how you can proceed in this situation.

You can continue to use apt-key

Despite the assurances in the documentation, the apt-key program works as usual and performs all its functions.

At the same time, the apt-key command will not be removed for quite a long time, at least several years. It may not be removed at all for compatibility.

Therefore, basically, you can ignore the warning “apt-key is deprecated”.

How to add keys in a new way

The new “modern” version is poorly documented, let's try to fill this gap.

Now the keys need to be added with the following commands.

If a remote key file is added:

curl -s URL | sudo gpg --no-default-keyring --keyring gnupg-ring:/etc/apt/trusted.gpg.d/NAME.gpg --import

If a local key file is added:

cat URL.pub | sudo gpg --no-default-keyring --keyring gnupg-ring:/etc/apt/trusted.gpg.d/NAME.gpg --import

In these commands, you need to substitute:

  • URL - address of the .pub file
  • NAME - you can choose any file name
  • FILE - filename of the .pub file

Then be sure to run the following command to set the correct file permissions:

sudo chmod 644 /etc/apt/trusted.gpg.d/NAME.gpg

Example. If you already know the URL of the required public key, use wget or curl to download and import it. Remember to update the file permissions from 600 to 644.

curl -s https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo gpg --no-default-keyring --keyring gnupg-ring:/etc/apt/trusted.gpg.d/earth.gpg --import
sudo chmod 644 /etc/apt/trusted.gpg.d/earth.gpg

Alternatively, you can get the key from the keyserver:

sudo gpg --no-default-keyring --keyring gnupg-ring:/etc/apt/trusted.gpg.d/rabbit.gpg --keyserver keyserver.ubuntu.com --recv 6B73A36E6026DFCA
sudo chmod 644 /etc/apt/trusted.gpg.d/rabbit.gpg

How to view information about installed keys

To view information about the installed key, run a command of the form:

gpg --list-keys --keyring /etc/apt/trusted.gpg.d/FILE.gpg

For instance:

gpg --list-keys --keyring /etc/apt/trusted.gpg.d/earth.gpg

As said, the old command also works:

apt-key list

How to remove a key added by a new method

If you need a command analogue:

sudo apt-key del 7D8D08F6

Now, to remove the key, simply delete the file with commands like:

cd /etc/apt/trusted.gpg.d/
sudo rm NAME.gpg

But “apt-key del” also works.

How to remove a key added with apt-key add

If you want to delete individual keys, then use a command like this:

sudo apt-key del KEY_ID

To find out the KEY_ID, run the command

apt-key list

find the key you want, for example:

pub   rsa4096 2016-04-12 [SC]
      EB4C 1BFD 4F04 2F6D DDCC  EC91 7721 F63B D38B 4796
uid         [ неизвестно ] Google Inc. (Linux Packages Signing Authority) <linux-packages-keymaster@google.com>
sub   rsa4096 2019-07-22 [S] [   годен до: 2022-07-21]

Look at the sequence of numbers and letters in the pub field - this is a hash. In this example, we are interested in the line

      EB4C 1BFD 4F04 2F6D DDCC  EC91 7721 F63B D38B 4796

To delete this key, you need to run the command (note that spaces have been removed from the hash):

sudo apt-key del EB4C1BFD4F042F6DDDCCEC917721F63BD38B4796

How to remove all keys added with apt-key add

Just delete the /etc/apt/trusted.gpg file:

sudo rm /etc/apt/trusted.gpg