We are supported by readers, when you click & purchase through links on our site we earn affiliate commission. Learn more.

FAQ: Shell helper

Shell refers to a traditional user interface. Users can type commands in the input line. We will show you a selection of commands.

How do I find out the name of the distribution and the version of the Linux system I am using?

All common distributions such as Arch Linux, Debian, Fedora, openSUSE or Ubuntu store information on the system and version in a standardized form in the file / etc / os-release. You can display their content with the cat command:

cat /etc/os-release

The output of the file provides a list of keywords such as NAME, VERSION or ID. Behind NAME is the general name of the distribution (“Fedora”), VERSION gives the number and name of the edition. In a rolling release distribution such as Arch Linux, this information is in principle missing. If in doubt, follow up PRETTY_NAME Look out that contains all relevant information in a form that is legible for the user.

Basic information such as the name occurs in all systems, but all entries are optional. In addition, distributions can add their own value pairs.

You can also read the os-release file into your own scripts in order to carry out different actions depending on the distribution or version.

More from c't magazine

I want to unmount a volume, but something is preventing it. How do I find out which process is still accessing the volume?

The call of lsof /dev/sda1 lists all open files for the device path / dev / sda1: You can also use the path in which the data carrier is mounted. The following example shows lsof the processes accessing the mount point / media / cttest / STICK:

lsof +f -- /media/cttest/STICK

The option +f shows lsof to abort if the path is not the root of a filesystem. This avoids errors if you accidentally specify a subdirectory. The double hyphens are necessary so that the path is not interpreted as a parameter.

If you want to terminate the process or processes that are blocking the unmounting, you can do so without any detours fuser:

fuser -kivm -TERM /media/cttest/STICK

The option -k stands for “kill” and -i for “interactive”, whereby fuser asks again before shooting. Shows additional information about the processes -v on, whereas -m fuser reports that the path refers to a mount point. Usually goes fuser from a single file (fuser ~/Datei.txt).

I want to know which files are taking up a lot of space on my disk. The command du shows me the file sizes, but only as a static list. Is there also an interactive command line tool?

Install the tool ncdu via the package of the same name, for example with sudo apt install ncdu. It’s the Ncurses variant of du. Start ncduto view the size of files in the current directory. Sorted by default ncdu the files according to size and visualizes the memory consumption with a bar graph. You can delete a selected file with d. The help shows further commands with ? at; with q Finish ncdu.

How can I find out if my desktop environment is running in Wayland mode or with X11?

First, open a terminal program like Gnome Terminal or Console and try setting the environment variable XDG_SESSION_TYPE read out. If the variable has been set, echo $XDG_SESSION_TYPE either “x11” or “wayland” back. If the answer is only an empty line, the variable is not set. In this case, use the command loginctl, which lists all active user sessions. Then look for your session number in the “SESSION” column and call loginctl again with the parameter show-session and the session number on:

loginctl show-session 2 | grep Type

With grep Type the appropriate line is filtered out immediately, otherwise you would have to fish it out of the output yourself.

There is a proprietary and a free driver for my graphics card. How do I find out which graphics card driver is being used?

To do this, install the program inxithat collects and clearly prepares existing hardware information. Under Debian and Ubuntu the command is to do this sudo apt install inxi. Then call inxi with the switch -G to display information about the graphics card only:

inxi -G -xxx

The output contains compact information about the hardware as well as the available and used drivers. With -xxx assign inxi to provide particularly detailed information.

The Perl script inxi collects system information and prepares it in an attractive manner.

How do I display the IP addresses of my network interfaces?

Use the command for this ip. Provides a brief overview of the status of all detected network devices and their IP addresses

ip -brief address

You can also call it with ip -br a abbreviate. With the additional option -c before address or a the tool highlights the different data in color, which makes it easier to read.

My computer starts via UEFI, but can also boot in the classic way. How can I check which method my system started up with?

On modern Linux systems with systemd, the following command displays information about the system:

bootctl status

If a legacy BIOS or the CSM (Compatibility Support Module) of the UEFI firmware started your computer in a classic way, reports bootctl “Not booted with EFI”. The command line tool is part of systemd boot, an alternative to the popular GRUB boot loader.

If the system is booted with UEFI, there are bootctl Information about the boot entries in the UEFI firmware and also whether Secure Boot is switched on. Call the command with sudo or root rights on, can bootctl access the EFI system partition and view additional information.

To open the BIOS setup, I have to press a certain key shortly after the computer starts. How can I restart the computer from my Linux system so that it calls up the UEFI BIOS setup by itself?

Systemd provides a practical function for this, but it restarts the computer without further inquiry. You should therefore first save any data that has not been backed up. Then call systemctl as follows:

systemctl reboot --firmware-setup

I have multiple operating systems on my computer with UEFI BIOS. When I try to start another system, I often miss the boot menu. Can I instruct my Linux system to boot into one of the other systems once?

To do this, give first efibootmgr in the terminal that lists all boot entries. Each entry is provided with an identifier (Boot0001, Boot0002, …). Find the ID of the system you want, using only the number without leading zeros. Then call with sudo or root rights efibootmgr again and pass the selected value. For Boot0002 the command looks like this:

sudo efibootmgr --bootnext 2

Then restart the computer.

If you want to change the order permanently, use the option --bootorder and enter the numbers in the order you want, separated by commas: efibootmgr --bootorder 4.1.2.

I know the documentation in the man pages, but it is often too detailed to quickly look up the syntax of a command. Is there an overview that only explains the most important calls of a command in an understandable way?

The “tldr Pages” project has created a kind of cheat sheet with examples that can be used every day for many commands from the man pages. The pages stored on GitHub are called up with a command line client, of which there are several implementations. Depending on the distribution, install the tldr or tealdeer package. After the installation, then call tldr followed by the command you want to know more about:

tldr ls

Usually the examples are explained in English; newer versions of the tldr clients also show the help in German, if available. To do this, install the Node.js client from tldr via NPM or download the binary file from GitHub.

You can even get help for tools or their variants on other Unix systems like Solaris, macOS, or even Windows. How to do that shows tldr tldr.

Instead of being exhausted, tldr only shows a handful of practical examples for the command you are looking for.

In c’t 23/21 you will learn about the hackers’ tricks. With the right tools you can crack forgotten passwords, find security gaps in your network and decrypt Word documents. We also analyze what makes WordPress so unique and help you get started and find suitable themes and plug-ins. You can find c’t 23/21 from October 22nd in Heise shop and at the well-stocked newspaper kiosk.


To home page