Raspberry Pi und Linux - Basiswissen - Teil 2

in the first part I presented the Raspberry Pi, Raspberry Pi OS and a little Linux. The whole thing was rounded off with an OLED display showed us the most important information from the PI. I have initiated Linux or formerly Raspbian with that it is not a Windows and much easy for the Windows user is unfamiliar when you start a Raspberry Pi with Linux for the first time.

In today's contribution, the topic Linux, in this case by Raspberry Pi OS, will be further deepened and important commands are explained. At the same time I want to explain to them the structure of Linux (where I will make this very superficial at this point, as these topics and everything belongs to all books fills. If you have more interest in it, I personally recommend a look into the book Raspberry Pi manual for beginners but also Linux: The comprehensive manual) And we install a Apache web server.

What is Linux

In the first part I have already roughly addressed this question. Linux, a UNIX-like operating system, is a free system, according to the General Public License, short GPL. However, in this case, it is not only easy for free, but that you can view, copy or compile the complete source code of Linux. Theoretically, as a developer, they can even contribute to improvements to Linux. This is already a significant difference to Windows or Macos, as the company's outcomes the source code of the operating system, short OS for operating system, does not make freely publicly available.

Basically, in paragraph I used a wrong termologist, as is often the case with Linux. Basically Linux is not the operating system, but only refers to the kernel. The kernel is to help you access the core system from the operating system and provides all elementary functions available. Essentially, the storage and processor management and the control of the hardware are. Based on the kernel, the operating system is then set with e.g. graphic surface. Interesting is that Linux can be found almost everywhere. Each larger company uses Linux server, Android based on Linux and many embedded devices run with Linux. Even with the current supercomputers, the proportion of Linux is over 90% when involving all the distributions, see https://top500.org/statistics/list/What is not the case in the consumer area.

If you look at the global distribution of operating systems in the consumer area, Linux is a share of 1.3%, a right lean representative at the end user, see https://de.statista.com. You could now start with the arguments that an enabled Windows version is preinstalled on almost every new laptop and an Apple device already has MacOS, or how complicated the manufacturers make (skills) to change to another system . But I do not want to start with this discussion. However, it is to be able to install a Linux-based operating system with high probability to your PC or laptop.

Let's get to speak hardware support at this point. A finished PC or laptop has various built hardware, hard drive, CPU, sound or graphics card, (W) LAN and other PCI Express cards, if necessary. All this supports Linux without any problems, even though it is often claimed that Linux would be far behind Windows in terms of compatibility. In fact, Linux supports as many hardware components, like no other system! This is the reason why e.g. Android or our popular Raspberry Pi, used Linux kernel.

If Linux is not the operating system, what then?

At the beginning I had tried to clearly distinguish what is the Linux kernel and what the operating system. The kernel represents the basis for all so-called distributions. A distribution uses the Linux kernel, various commands for the shell, a graphical user interface, various software packages and packs all this to an installation medium. In the Raspberry Pi, this is the standard operating system Raspberry Pi OS, which is also copied as an image file to an SD card, or since the Raspberry Pi 3 also, is copied to a USB mass storage. Raspberry Pi OS, see Figure 1, is a slim distribution that requires a few system resources. This is your operating system from the basic principle.

Figure 1: Desktop view of Raspberry Pi OS

Figure 1: Desktop view of Raspberry Pi OS

Raspberry Pi OS needs in the Lite version, so without a graphical surface, just 400MB of storage space, on the other hand, Full- Version of Raspberry Pi OS 2.8GB. The memory difference of both versions is that in the Full- Version Many (supposedly) useful programs are directly available. the Lite- Version actually provides only the most basic functions available. Extras, such as a web server, or a remote desktop server (only graphic interface only), must be additionally installed.

The completeness should be mentioned again at this point that Raspberry Pi OS as the basis the distribution Debian uses. Therefore, the original name "Raspbian". Personally, I like Debian very much for my web server and Raspberry Pi OS for my many Raspberry Pi's. But these are not all distributions. Should be mentioned here too Ubuntu or Linux Mint. A complete overview of all known distributions can be found at Liupix.de.

Myths and statements about Linux

In the first part I have already informed about a great myth, but there are still a few more. I want to realize that Linux is nothing bad, summarize the most common myths and even refute.

(1) Linux, or their distributions, are just something for IT nerds

This statement is relatively common and applies to one, but not at the other. The different distributions are made for different persons. There are distributions, such as Raspberry Pi OS, which give a slight start to a beginner, but also distributions, e.g. Arch Linux, which are more of something for advanced who knows what they do (need)

(2) Linux can only be operated via terminal and cumbersome

Again, a clear Jain again. Many distributions, as well as Raspberry Pi OS, offer the possibility to use them only with terminal, or to give a graphical surface to the user. Many operations are to be carried out with the console faster than on the graphical surface and some operations are only exclusively in the terminal.

(3) Linux does not offer me what Windows offers me

This myth or statement often found in forums where it comes to the topic of Linux vs. Windows. Yes there are a lot of software that one probably only on Windows and. MacOS still running. A good representative is because Adobe Photoshop or Lightroom with, for example. But under Linux there is for high evenly matched software. Sometimes it is even possible to use known with the program WINE Windows software on Linux to get up and running.

(4) Linux, or their distributions are totally complicated

Since I reply times with the statement, each (operating) system which I do not know, is complicated. On Windows I need to familiarize myself accordingly so that I can safely handle it.

(5) Linux, and their distributions are complicated to install

Depending on the Linux distribution, this statement may be true. As bad as it was 15 - was 20 years ago, it is now no more, many suppliers of distributions have ready a similar installer, as with Windows. Nevertheless, there are Linux distributions because it looks different and the end user should previously complicated to assemble its operating system. But this depends largely on which Linux distribution you want to use. but in many cases there are special forums that help one there.

(6) For Linux, there is no malicious software

Since I have unfortunately disagree. Linux, or their distributions remain of malicious software, known as Malware, not spared. but in fact it is much more complicated to place Linux malware on a computer, for example, than in Windows. I know that now is a dangerous statement that I meet here, but the reason is also the right system of Linux. In addition, it is worth only conditionally for attackers to program Linux malware, as the market share of Windows in the consumer sector is significantly higher and the damage is thus enormous.

(7) Without terminal I can not use 100% Linux distributions and their

Yes, this statement I can only agree. Deal of configuration work, for example, a Web server, I can do via the terminal with configuration work. For this I must as an end user, but also know what I do. A beginner is not immediate plans to establish generally a web server and print server, or perform other complicated configurations. Raspberry Pi OS is secure in the sense as long as the Raspberry Pi is not accessible from the Internet. But here, this scenario is more likely to have an experienced user.

I could make here still on forever, but I think the most common statements or myths have can I clarify. Basically was but said: You are not afraid of Linux, but experiment with it! Everyone (mis) success is a learning goal and you become more familiar with Linux or a Linux distribution.

Drives and folders on Linux

The title says it probably. not directly, but now the portion in which I refer to the structure of Linux compared to Windows follows. When I open Windows Explorer, as shown in Figure 2, you can directly see the different drives. no matter whether connected a new USB hard drive or SD card, Windows presents this always as a drive. Also DVD or CD drives get a drive letter Windows assigned.

Figure 2: Windows Explorer with drives

Figure 2: Windows Explorer with drives

A drive is a complete or partitioned hard drive on Windows, which is assigned a drive letter. Classic is the operating system Windows on the C partition. On all hard disks programs can be installed or data stored, edited or deleted. Of course, you can also create, edit or delete folders and subfolders as they like. The completeness must of course be mentioned that these operations only work if the appropriate permissions are present. With a normal home computer, this is usually the case. For Windows to recognize the corresponding drives, the file systems come NTFS, FAT32 or exfat for use. The former has now been the default file system since Windows XP.

Linux, or in the further course, I use Raspberry Pi OS as a reference, here is another way. From the principle Linux can read all file systems, where an additional package must be installed for NTFS, since the kernel 5.15, the file system is also available directly. To boot Linux, it needs a boot partition in VFAT format or FAT32 and at least one further partition, which is suspended as the root partition "/".

If you type in the terminal of Raspberry Pi OS code 1 and confirm with Enter, you will see a similar issue as shown in Figure 3.

 sudo Cat / etc / fstab

Code 1: Show fstab

Figure 3: Issue from Fstab

Figure 3: Issue from Fstab

The second line is the boot partition that is mounted in the path / boot. Immediately afterwards you will see the Ext4 partition the "/" in the root directory. Apart from the Partuuid, this is the same for every Raspberry Pi OS and many Linux distributions. But now the difference to Windows! Linux does not use the drive structure of Windows, but you need to mount hard drives in paths (hanging). Sounds more complicated than it's! Raspberry Pi OS automatically takes this mount from external memory for you if you e.g. connect a USB stick, see Figure 4.

Figure 4: USB stick connected to Raspberry Pi

Figure 4: USB stick connected to Raspberry Pi

For them, it looks like just a new drive, similar to Windows, has been recognized and now available as a user. In fact, however, a bit more happens in the background. First "Raspberry Pi OS recognizes that a new memory has been plugged in. Since it is a mass storage, a new folder under the path / media / pi named "Disk 8,1GB" is created and subsequently the drive / dev / sdb1 or the corresponding UUID is mounted. Following a few permissions and the user "Pi" can be accessed on the USB stick. This happens everything in the background, many beginner-friendly Linux distributions make it similar, but there are also distributions, because you have to manually perform these processes.

You will probably be surprised now / dev / sdb1 should be and why / Media / Pi A folder was created, but I want to explain now.

Let's get back to Figure 3, where the Ext4 partition is hooked into the root directory "/". Basically, the hard disk partition is given as a root. Imagine that like a tree. The base is the root with the tree trunk. After that, the branches that are the different folders and subfolders here and last the leaves on each branch, which are the files. The root or root directory "/" usually has the directories described in Table 1.

directory

Explanation

/am

Contains indispensable programs for Linux (amAries), which must be available for system startup. These programs can be used by all users. Subfolders are not allowed.

/boat

Contains files needed to boot.

/ Boot / grub contains files for the boot loader GRUB 2

/ Boot / efi contains EFI programs

/ dev

The device directory (DEVice) responsive all the hardware components in operation. Must be present at boot time.

/Etc

Folder that all changeable configuration files included. Previously Etcetera (everything else) later editable text Ccalled onfiguration.

/ home

The directory where each user created a separate own directory has. Corresponds in Windows "My Documents" folder

/ lib

Contains essential libraries (libraries), which are needed for system startup

/ Lost + found

Files or file fragments that are left over when trying to repair a defective file system.

/ media

Is usually the directory that serves as mount points for mass storage such as USB sticks or external hard drives.

/ mnt

Of the mountFolder is (mounted) for temporarily suspended memory. If a memory hung here, this will not appear on the desktop, as in / media.

/ opt

Of the Optional folder is intended for the manual installation of programs that bring their own libraries and are not available through the package manager of the distribution

/ proc

Serves as an interface to existing programs (processes)

/ root

The home directory of the root-User.

/run

There are files that saves the state of the system in this folder. run / var / to find earlier

/ sbin

Does System Tools (system amaries) must be present at boot time. Includes System programs that are allowed to run only the system admin, or a user with superuser privileges.

/ svr

The folder of the data for services (services) contains

/ sys

The folder syssystem mainly includes kernel interfaces

/ tmp

folder temporäre files and folders. Is emptied completely when booting

/ usr

Under USer System tools, libraries and installed programs are stored

/ var

That Variable directory contains files and folders that can be changed by the various programs. As an example, the log files are in / var / log where each system program logs can create.

Table 1: directory structure of Linux

The last question is probably. nor why the USB flash drive folder under the / dev as sdb1 is registered. I would like to just to an article by debian.org linkWho have very close and understandable summarized.

Programs on the Raspberry Pi (de-) install

Almost every distribution has to bring its own package manager, which makes it possible for the user software (de-) install or the system up to date, see figure 5.

Figure 5: Graphic package manager from Raspberry Pi OS

Figure 5: Graphic package manager from Raspberry Pi OS

You can install as the popular HTTP server Apache. In the search, enter the channels to be searched, or the library you require can search for it and on the selection and OK the package will be installed in theory, see figure 6.

Figure 6: Install the Apache HTTP Server

Figure 6: Install the Apache HTTP Server

To be honest, I do not like this option, because each package manager so has its individual character. Much better, even on terms with the dependencies, installing packages using the apt package manager from the console is out. You know the situation already out of our eBooks on how to keep as the Raspberry Pi OS up to date.

Open the console and enter the commands in Code 2:

 sudo update && apt sudo apt dist-upgrade -y && sudo apt autoremove

Update Raspberry Pi OS and programs from the Pi code: 2

The "sudo" is the command that we want to execute the follow-up command with system administrator rights. One of the most funniest memes, which explains the command "sudo" very well, shows Figure 7.

Figure 7: Meme Sudo Sandwich, Source Devrant.com

Figure 7: Meme Sudo Sandwich, Source Devrant.com

Without the command sudo In the beginning, Raspberry Pi OS would react as well as the right stick figure and execution of the command refuse. At the same time, you should not have sudo rights, the system administrator will be informed about an "illegal" attempt. Where Raspberry Pi OS WhiteWho has these rights and who is not, is once in which group is the user, see Figure 8.

Figure 8: Show groups to which User Pi belongs

Figure 8: Show groups to which User Pi belongs

You see clearly that the user pi Among other things, the group sudo belong to. With it pi Ever system admin rights and may also execute the corresponding commands. In the theory, every user must still have to enter a password, which is in the file / etc / sudoers, see Figure 9.

Figure 9: Content of / etc / Sudoers

Figure 9: Content of / etc / Sudoers

But that's just part of this file. In addition, there is the directory /etc/sudoers.d, see Figure 10, which includes subsequent files.

Figure 10: Content of path /etc/sudoers.d

Figure 10: Content of path /etc/sudoers.d

Interesting here is the file 010_pi-nopasswd, see Figure 11, which is just from / etc / sudoers Included and then the corresponding rights are read. It's determined that pi Do not enter a password when commands with sudo to be performed.

Figure 11: Contents of 010_PI-Nopasswd

Figure 11: Contents of 010_PI-Nopasswd

But let's get back to the installation of the Apache web server via the command line. To install the Apache web server with all dependencies, it is sufficient with the command from code 3:

 sudo Apt Install Apache2

Code 3: Command for installing the Apache web server

Immediately after this command, it is checked whether Apache has already been installed and if not, which dependencies are still missing, see Figure 12.

Figure 12: Install Apache Web Server with all dependencies

Figure 12: Install Apache Web Server with all dependencies

Confirm the last message with an ENTER and Apache With all the necessary packages are downloaded and installed on your current Raspberry PI OS. Depending on the PI and Internet management, this process can take a bit. But since it is relatively small packages, it should not take too long. Immediately thereafter, in a browser, you can open the address 127.0.0.1 on the Raspberry Pi or the IP address of your PI on another PC and see the Default page of Apache, see Figure 14.

Figure 13: Default page of Apache page

Figure 13: Default page of Apache page

Thus, you have your own web server in your network, which is completely unsecured and therefore not be accessible via the Internet. Apache or Nginx are in most cases the first choice for a small own web server. Whether it's about its own NextCloud or a WordPress page. Especially for most web services, there are good (English-speaking) tutorials how to install them on a PI.

Interesting projects for you could be:

In fact, I use my Pi's for various projects. It would first be my DNS filter to block unnecessary advertising. At the same time, I have a PI as low-budget NAS, a PI as a 3D printer server and a work pi, which I use for Kali-Linux (hacking) and developer system. Many have a common feature that all use a SSD as mass storage, which are enlarged by an expansion card of my various housings via USB.

Commands you should know

Thus we come to the last part of this article, important commands you should know for the terminal. I have put together Table 2 for you.

command

description

cp

Copies a file, or with the attribute -r a folder to another location. Syntax is CP / Path / File / Path / Aim

MV

Moves a file, or with the attribute -r a folder to another location. Syntax MV / path / file / path / target / destination

chown

Changes the owner of a file or folder. Going outside the home directory only with Sudo rights and with attribute -r also recursively applicable to folders. Also goes to change the group. Syntax Chown Option User: Group File

chmod

Changes the access rights of files and folders for users and owners. Syntax Chmod Option Mode File / Directory [File / Directory 2, etc.

apt

Run from the package manager apt.

With Apt Install package, the package is installed with all dependencies

With APT PURGE package, the package will be uninstalled

With Apt Authoremove unnecessary packages are removed

With Apt Update, the package data is updated

With Apt Dist Upgrade all packages are updated

With APT AutoClean, all unneeded data is deleted from old packages

nano

Opens or lays a file with the text editor nano (AN). Syntax Nano / PAD / File

Files outside the user's home directory must be opened with system rights

Cat

Specifies the contents of a file in the terminal if the user has the required rights.

blkid

Lists all connected disks

DF

Displays the free memory of all the stored drives. Attribute -h the output is readable for people

Top

Lists the current processes from the system.

Clear

Deletes all entries from the terminal

CD

Switches to another directory

one

Opens the help file to the desired program.

syntax one program

LS

Lists all files and folders in the current directory. Attribute -a also displays hidden files and folders

to you

Like ls just not so colorful

Table 2: Important terminal commands for beginners

Of course there are many more commands in the Linux world. But I can not enumerate them all, so you can fill a book in the truest sense of the word. I recommend that you are interested in the book of Kofler Linux commanderference.

summary

In the two blog contributions, I have brought you the Raspberry Pi and Linux in the form of Raspberry Pi OS. A small project in the past blog post and here the web server are only smaller examples, which is possible with the Raspberry Pi so everything. There are both AZ-Delivery, as well as on other sites, various projects for you and other makers. In most cases, Python or C / C ++ is used as a fundamental programming language, so you should pay attention to these two languages. At the same time, you can also use the hardware offered AZ-Delivery for the Raspberry Pi. These and other commands are not only available under Raspberry Pi OS, but also on other Linux distributions. Especially the Raspberry Pi is a good game meadow to deal with the subject of Linux and hardware and software development.

Further projects for AZ-Delivery from me, see https://github.com/M3taKn1ght/Blog-Repo.

Projects for beginnersRaspberry pi

3 comments

Andreas Wolter

Andreas Wolter

@Wolfgang: wir haben die Idee in der Schublade, einen solchen Beitrag zu schreiben. Tests dazu haben wir bereits durchgeführt.

Wolfgang

Wolfgang

Hallo, alles klar und verständlich erklärt, ein tolles Handbuch.
Gibt es eigentlich auch eine Anleitung, einen Raspi 4 ohne SD-Karte zu betreiben, nur mit Stick oder SSD?
Danke auch an AZ für die vielen tollen Beiträge.

W.Herz

W.Herz

Danke für dieses tolle Tutorial. Da macht es gleich doppelt soviel Spaß sich mit dem Thema zu beschäftigen.
Super erklärt!

Leave a comment

All comments are moderated before being published

Recommended blog posts

  1. Install ESP32 now from the board manager
  2. Lüftersteuerung Raspberry Pi
  3. Arduino IDE - Programmieren für Einsteiger - Teil 1
  4. ESP32 - das Multitalent
  5. OTA - Over the Air - ESP programming via WLAN