LinuxShellSite

The shell is the central control element in Linux systems and allows users to enter and execute commands in plain text. This type of interaction is extremely efficient, flexible and in many cases the only way to make in-depth system interventions for many tasks. While modern desktop environments provide graphical user interfaces, the shell is often the means of choice in system administration and software development.

What is a shell anyway?

A shell is basically a program that receives commands, interprets them, and outputs the result. In Linux, the most popular and widely used shell is Bash (Bourne Again Shell). However, there are also other shell variants such as Zsh, Fish or Dash, some of which offer advanced or specialized functions.


Shell Commands

ALLGEMEIN | SHELL im Überblick
ALLGEMEIN | die wichtigsten Befehle
ALLGEMEIN | Setup, Update, Uninstall
ALLGEMEIN | User & Group Verwaltung
ALLGEMEIN | Dateiberechtigungen
ALLGEMEIN | Filesystem
ALLGEMEIN | Prozesse
ALLGEMEIN | Backup & Recovery
ALLGEMEIN | Logs und Fehlersuche
ALLGEMEIN | Systeminformationen
EDITOR | vim / vi & nano
NETWORK | NETPLANS

Path Structures and Navigation

Unlike Windows, Linux does not know drive letters. The top level of the file system is the root directory (/). To find your way around, the following directories are important:

  • / – Root directory, root of the file system
  • /home – Default directory for users
  • /etc – system configuration files
  • /var – Variable data (logs, temporary files)
  • /bin, /usr/bin – System Utilities and Applications
  • /lib, /usr/lib – System Libraries

For example, to switch to the directory /etc , use cd /etc. For a quick switch back to the home directory, a cd ~.

Pipes and Redirects

One of the most powerful concepts of the Linux shell is the piping of commands and the targeted redirection of inputs and outputs.

  • Pipes(|) pass the output of the first command to the input stream of the next command:copyls -l | grep '.txt' bashCodeHere lists ls -l all entries and grep filters only by rows with .txt.
  • Redirects are used to redirect outputs to files or use files as inputs:
    • > overwrites a file with the output copy codels -l > output.txt
    • >> appends to an existing file anbash copy codeecho "Neuer Eintrag" >> datei.txt
    • < uses a file as an input bash code copywc -l < datei.txt

Shell Scripts

Shell scripts are simple text files that contain commands in the order in which they are executed. They enable the automation of recurring tasks. Example of a simple script:

Copy bashCode#!/bin/bash
echo "Hallo, Welt!"
  1. Create a file, e.g. test.sh
  2. Make script executable: chmod +x test.sh
  3. Run with ./test.sh

Useful tips to get you started

  1. Tab completion
    Use the Tab key to autocomplete file names or commands.
  2. Troubleshooting with history
    You can view your past commands via history . This makes it possible to uncover sources of error more quickly or to quickly re-execute frequently used commands.
  3. Structure of an alias
    Aliases can be used to shorten complicated or long commands. For example, a often used can be used by copying the ls -la bashCode in the ~/.bashrc alias ll='ls -la'
  4. Explore More Shells
    Each shell has its own special features. While Bash is the standard, Zsh, for example, offers many convenience features such as auto-completion, syntax highlighting , and correction suggestions.

further links


Linux-Community.deProvides articles, tips and tricks about Linux and the shell.
Ubuntuusers WikiA comprehensive wiki page dedicated to Ubuntu and the basic shell commands.
shellscript.shLarge collection of shell scripting examples and explanations of common commands.