Jarkko's guides
You are here: Home » Linux » System administration

System administration

Shutting down & rebooting

To shut the computer down use:

sudo shutdown -h now

And to reboot:

sudo reboot

Boot loader

A bootloader loads an operating system kernel to boot up the OS when powering on the computer. The most commonly used boot loader for Linux is GRUB (GRand Unified Bootloader). Windows has its own boot loader called the Windows Boot Manager.

On modern PCs the BIOS has been replaced with UEFI. On those systems one or more boot loaders can be installed in the EFI System Partition (ESP) on your disk. It can hold both GRUB and the Windows Boot Manager.

Init system

After the kernel is loaded, the init system kicks in. Most Linux distributions use systemd. It manages service (also called daemons), which are processes that are constantly running in the background.

You can get a list with all running services with:

systemctl list-units --type service --state running

You can start/stop/restart a service with:

sudo service my_service start
sudo service my_service stop
sudo service my_service restart

You can add your own services by adding a .service file to /lib/systemd/system/ and then executing:

sudo systemctl enable my_new_service

This is a basic template for a custom .service file to run a script that is your home directory as a service:

[Unit]
Description=Your description here
After=default.target

[Service]
Type=simple
User=your_username_here
WorkingDirectory=~
ExecStart=command_to_run_here

[Install]
WantedBy=default.target

Kernel modules

Device drivers can be baked into the Linux kernel or be made available as a module. That is a choice when compiling the kernel. A module can be loaded and unloaded at run time. The modules are in /lib/modules/kernel_version.

Use lsmod to see which modules are loaded, insmod or modprobe (easier) to load a module and rmmod to unload a module. Modprobe figures out whether other modules are also needed. You can get more information about a module with modinfo module_name.

Device tree overlays

This is not relevant for running Linux on a PC, but it is used for Linux on the Raspberry Pi and other embedded systems. A Device Tree (DT) is supported by the kernel as a way to describe hardware. Because some embedded systems allow a lot of variation regarding connected hardware, there is a necessity to be flexible in how the device tree can be built up. A device tree overlay is a partial device tree. By bolting overlays onto the main device tree you can describe your particular extra/optional hardware. For the Raspberry Pi you use an overlay for so-called HATs (that you can mount on top of the Pi board) or to enable special pin functions (such as SPI) on the GPIO pins.

To show all available overlays:

dtoverlay --all

To get information about a particular overlay:

dtoverlay -h spi0-1cs

Overlays can be loaded and unloaded at run-time with dtoverlay. One limitation is that overlays that were loaded during boot-up cannot be unloaded at run-time. Example to load an overlay:

sudo dtoverlay spi0-1cs

In /boot/firmware/config.txt you can indicate what overlays to load during booting. You can e.g. add this overlay:

dtoverlay=spi0-1cs

Network

To configure your network refer to the documentation of your distribution. If you have a working local network with either WiFi or Ethernet with DHCP, then configuration should be simple.

You can see information about the configured network interfaces with ifconfig. You can check the configured hostname (that can be used to access the Linux machine in your local network) with hostname.

SSH

The Secure SHell (SSH) is the common method to log into a remote Linux machine to get access to a command line. It also supports file transfer (using the scp command or the SFTP protocol). OpenSSH is the standard program that is used as SSH client and server.

It is possible to log in with SSH without needing to enter a password. That can be achieved by creating a private/public key pair, e.g. using PuTTY. Look for guides online.

Windows file sharing

Windows uses the SMB protocol for file sharing. Support for SMB in Linux has been provided by the Samba software since the 1990s. An SMB client that was originally part of Samba is now included in the kernel, so that the mount command supports SMB shares. You need to use file system “cifs”. Example:

sudo mount -t cifs //machine_name/share_name /mnt/smb_share

In most graphical file managers you can access a Windows share as smb://machine_name/share.

As SMB server (to make files available to Windows machines) it seems that Samba is still the most widely used option. There is also a newer option: ksmbd, which is built into the kernel. It has better performance and has enough features for most use cases. It does lack some of the more advanced features in Samba.

To share files among Linux machines a better choice is NFS (network file system).

Logs

In /var/log you can find a number of log files from the kernel and services. The dmesg command shows the messages that came from the kernel during boot.

Listing devices

To list found USB devices:

lsusb -t -v

To list found PCI devices:

lspci

To list found drives:

lsblk

At

The “at” service can execute a command at a specified time. Simple example:

echo "Hello" | at now +5 minutes

Cron

Cron is a service that can execute commands at regular intervals, such as every day or week. It is useful for e.g. making a back-up or cleaning temporary files. Many distributions have subdirectories in /etc such as cron.daily and cron.weekly where you can add your own tasks. The overall configuration file is /etc/crontab.

Previous Next

ALL THE TOPICS ON THIS WEBSITE:

Linux

Raspberry Pi

Digital room correction

Web design

By Jarkko Huijts
Jarkko's guides

Table of Contents

Table of Contents

  • System administration
    • Shutting down & rebooting
    • Boot loader
    • Init system
    • Kernel modules
    • Device tree overlays
    • Network
    • SSH
    • Windows file sharing
    • Logs
    • Listing devices
    • At
    • Cron

LINUX

  • Intro
  • History
  • Open source
  • Distributions
  • Command line
  • Tool help
  • Remote access
  • Directory hierarchy
  • Basic commands
  • Viewing & editing files
  • Processes
  • GNU & other utilities
  • Users & permissions
  • Partitions & mounting
  • System administration
  • Software packages
  • Desktop environments
  • Scripting
  • Audio

AVAILABLE TOPICS

  • Linux
  • Raspberry Pi
  • Digital room correction
  • Web design