When you first get in touch with the Linux world as a Windows user, the frustration usually does not wait long.
Especially working with the console is unfamiliar and almost impossible without knowing the right commands. Also, the file system or folder structure differs greatly from Windows.
In order to facilitate the entry into the Linux world, I have tried to summarize the most important information, functions and commands.
Hints for our lovely english readers: Basically, many of the articles on Nerdiy.de are translations from the original german articles. Therefore, it may happen here and there that some illustrations are not available in english and that some translations are weird/strange/full of mistakes or generally totaly wrong. So if you find some obvious (or also not obvious) mistakes don't hesitate to leave us a hint about that in the comment section.
Also please don't get confused, that instead of a "dot" often a "comma" is used as decimal separator. 🙂
- 1 Commands in the console
- 2 Working in the console
- 3 File and folder operations
- 3.1 Show current path
- 3.2 Display directory tree
- 3.3 List folder contents
- 3.4 Create folder
- 3.5 Delete folder (including content)
- 3.6 Delete file
- 3.7 Change folder
- 3.8 Copy files
- 3.9 Move multiple files or a file to another folder
- 3.10 Rename file
- 3.11 Download file
- 3.12 Unzip zip file with password
- 3.13 Extract rar file with password
- 3.14 Unzip zip file to destination folder
- 3.15 Pack folder in zip file
- 3.16 Secure deletion of data
- 4 Installation of and working with packages
- 5 RaspberryPi-specific commands
- 6 network
- 7 Netzwerk
- 8 Miscellaneous
- 8.1 Change the password of a user
- 8.2 Show free space
- 8.3 List all installed USB devices
- 8.4 Show all partitions
- 8.5 Show detailed information
- 8.6 Force validation of the file system
- 8.7 Show Serialby ID
- 8.8 Show all serial ports
- 8.9 Check other computers for presence in the network
- 8.10 Show running processes
- 8.11 Termination of a process identified by the process ID
- 8.12 Output of processor utilization
- 8.13 Specify the runtime and load of the computer
- 8.14 Show current user
- 8.15 View the location of a program
- 9 Folder Structure – Which folder contains which files?
I know the following hints are always a bit annoying and seem unnecessary. But unfortunately, many people who knew it "better" from carelessness lost their eyes, fingers or other things or hurt themselves. In comparison, a loss of data is almost not worth mentioning, but even these can be really annoying. Therefore, please take five minutes to read the safety instructions. Even the coolest project is worth no injury or other annoyance. https://www.nerdiy.de/en/sicherheitshinweise/
The links to online shops listed here are so-called affiliate links. If you click on such an affiliate link and shop via this link, Nerdiy.de receives a commission from the online shop or provider concerned. The price doesn't change for you. If you do your purchases via these links, you will support Nerdiy.de in being able to offer further useful projects in the future. 🙂
To learn how to rightfully find yourself in the Linux world, it’s best to deal with it directly. “Learning by doing” so to speak. Do not be afraid to break something. The worst thing that could happen is that you have to reinstall Raspian.
How to do that and how you generally configured a working RaspberryPI I described in the following articles:
RaspberryPi – Setting up for Nerdiys
RaspberryPI – The First Configuration
RaspberryPi – Control the RaspberryPi via SSH
In the following list you will find all the parts you need to implement this article.
Commands in the console
The console under Linux is twofold. On the one hand, you can use it to navigate through the folder structure of the RasPi and thus change the respective directory in which you are currently “located”.
I (and possibly others too) call this directory working directory, because it is always the directory in which the currently running commands are executed and access files.
For example, if you create a folder, it will be created in the current working directory (without further details).
Paths are either (relatively) given from the working directory or absolutely from the root directory (ie the highest folder level).
On the other hand, the console is also command prompt. So commands can be entered and executed in it.
Finally, it is the commands that allow you to navigate through the folder structure.
The form of the entered commands is almost always the same.
Usually it is:
COMMANDNAME -PARAMATER PATH
This means that a command always consists of the command name, any parameters and, if necessary, path information.
Parameters are different letters that influence the behavior of the command. These are different for each command. A complete list of parameters and general help can be found for each command by specifying the command name and the –help parameter.
(Note that you must enter two dashes before the “help”)
Ttake a look at all possible parameters and a few examples of the “cp” command.
So if you forget how a command works or forget a parameter you have an integrated documentation at hand here.
Working in the console
Last entered command display
Arrow key up/down
By pressing the up arrow key you can see your last command entered.
If you want to execute a selected one again, just press the Enter key.
If you want to edit it again, you can use the arrow keys to navigate left and right through the command.
Delete terminal output
This command clears the current console session and displays a “fresh” prompt.
Complete the path entries
The tabulator key automatically completes path information.
For example, if you just want to switch from the current folder to the next folder named “NextFolderWithFastFamilyLongName”, just type the following command:
and then press the tab key.
Linux then completes “next” automatically to “NextFolderWithFastlyLongName”.
If, in addition to the folder “NextFolderWithFastlyLongName” it also happens to have a similar sounding folder (eg “nextfolderwithshortname”) in the current directory, the folder name will only be completed as far as the two folder names are different. In this case only until “nextfolderwith”. However, if you then enter a letter of the desired folder, the completion can be performed again.
For example, typing “nextfolderfolderwithf” and then pressing the tab key will tell Linux that the folder “NextfolderWithFastlyLongName” must be meant and completes the name accordingly.
So you save a lot of typing. This path completion works in nearly every command.
Stop execution of commands
The key combination CTRL+C can be used to terminate currently running processes.
File and folder operations
Show current path
This command shows you the current absolute (ie complete, outgoing root) path to the directory you are currently in.
Display directory tree
This command displays the folder structure in the current directory.
As the name (tree = tree) suggests, the current folder structure is shown starting from the working directory. That is, the subfolders in folders are represented as the branches of a tree starting from the root. This is easiest to understand by just trying it out. 🙂
List folder contents
This command shows you the complete contents of the current directory (including hidden files). But in most cases, a simple:
mkdir new folder
This command creates a new folder in the current directory with the given name (in this case “newfolder”).
Delete folder (including content)
rm -R new folder
This command deletes the specified folder (in this case, “new folder”) and all files contained in it without asking or warning again.
This command deletes the specified file (in this case, the file to be deleted). in the current directory.
This command changes the directory to the specified directory.
With this command you change to the next higher folder level.
This can also be linked. For example, if you want to go up a folder level from the current folder and go directly to another folder, you can do this with the following command:
With the following command you can switch directly to your home directory:
cp "filename" "destination"
This command copies the file “filename” to “destination”. In this way you can also rename files directly.
cp coolTexttfile.txt stillCoolerTextfile.txt
For example, this will cause the “coolTextfile.txt” to be copied to the current folder again. The copied file will be called “evenMoreCoolerTextfile.txt”.
Of course, path information can also be incorporated in the copying processes.
For example, the following command copies the file “coolTextfile.txt” into the subfolder “coolFolder”.
cp coolTexttfile.txt coolFolder/coolTexttfile.txt
Move multiple files or a file to another folder
mv -t destinationfolder file1 file2 file3
mv currentfilename desiredfilename
This command is actually a file move (mv = move). Since you can also specify a new name when moving files, this command is also perfect for renaming files.
This command allows you to download files to the current directory.
For this, only the link to the file you want to download behind “wget” must be specified.
Unzip zip file with password
unzip -P PASSWORD 'zipFile.zip'
This command unpacks the password-protected file “zipFile.zip” with the password “PASSWORD” in the current directory. If you want to know what Zip files are, I described this in this article:
Extract rar file with password
unrar e -p PASSWORD 'rarFile.rar'
This command unpacks the password-protected file “rarFile.zip” with the password “PASSWORD” into the current directory. If you want to know what Rar files are, I described this in this article:
Unzip zip file to destination folder
unzip zipfile.zip -d TARGET
This command unpacks the “zipFile.zip” file into the directory specified with DESTINATION.
Pack folder in zip file
zip -r filename.zip FOLDER NAME
Secure deletion of data
shred -fuz for fileToShredForever
This command not only deletes files, it also overwrites the space of the deleted file. As a result, the deleted files can not be recovered even by forensic means. The command works with the Gutmann method.
Installation of and working with packages
Update program packages
sudo apt-get update && sudo apt-get upgrade
These are actually two commands that are linked by the “&&”.
The “&&” in this case means that first the first command and then the second command is executed.
sudo apt-get update
… updates the package list of the “Advanced Packaging Tool” (apt). This tool manages different software packages. Updating the package list therefore downloads the current table of contents of the available software packages.
sudo apt-get upgrade
… then compares the packages already installed on your system with the packages available in the table of contents. If one of the available packages is newer than the package installed on your system, it automatically installs the new version of the package
sudo apt-get install PACKETNAME
This command uses the “Advanced Packaging Tool” to install the package specified with “PACKETNAME” and all other necessary packages needed to run this package.
Delete unnecessary programs/packages
sudo apt-get autoremove PACKETNAME
This command is also part of the “Advanced Packaging Tool” and can be executed with and without package name. Without a package name, ie “sudo apt-get autoremove”, this command uninstalls all packages that are no longer used because they were only installed as a prerequisite for another package that no longer exists.
Package name, for example “sudo apt-get autoremove RANDOM_PACKET_NAME” uninstalls the specified package and all prerequisites installed during the installation of this package.
Update firmware and kernel of the RasPi
This command updates the kernel and important system files of the RasPi. According to the motto “Never touch a running system”, this should only be done if important security updates are available or something is not working as it should.
This command safely shuts down the RasPi and restarts it directly. This is perfect for testing if installed software starts automatically after a reboot.
Shut down RasPi safely and immediately
sudo shutdown -h -P now
or the abbreviation (specific for the RaspberryPi)
After running the shutdown command, wait a few more seconds. Just as with Windows systems, it takes a moment for the system to complete all programs / processes. At the same time all possible writing processes are terminated.
This is also the reason why you should always shut down the RasPi properly. If this is currently saving a file to a memory and is then disconnected from the power, the storage process is interrupted. This leads to the fact that any partially written files can not be read anymore.
If this file happens to be an important file for the system, the RasPi may not start correctly the next time.
If the RasPi is completely shut down you will recognize that the green LED is no longer blinking and only the red LED is lit.
If you should still pull the plug without having shut down the RasPi before you do not need to burst into tears immediately: Mostly it’s fine, but just mostly. 🙂
Execute commands as root
sudo = Super User Do
This command can be set before any command and causes this command to execute as if the superUser “root” were executing it. For example, as a normal user, you could execute commands that would be used to access files that you, as a normal user, do not actually have access to.
To be able to use sudo you have to be entitled to do so. This is determined in the file /etc/sudoers.
Log off from the console
This command terminates the connection to the RasPi and closes the console.
Show RasPi CPU temperature
echo $ ((`cat/sys/class/thermal/thermal_zone0/temp`/1000))
This command gives you the current temperature of the CPU.
Show RasPi GPU temperature
/opt/vc/bin/vcgencmd measure_temp | cut -c6-9
This command gives you the current temperature of the GPU.
IP address or network configuration Display
This command displays information about your network connection. So you can also check which IP address your RasPi has.
List open ports and existing network connections
netstat –tcp –listening –programs –numeric
This command displays all currently open ports and network connections as well as various information about them
IP-Adresse bzw. Netzwerkkonfiguration Anzeigen
Dieser Befehl zeigt euch Informationen zu eurer Netzwerkverbindung an. So könnt ihr auch prüfen welche IP-Adresse euer RasPi hat.
Offene Ports und bestehende Netzwerkverbindungen auflisten
netstat --tcp --listening --programs --numeric
Dieser Befehl zeigt euch alle aktuell geöffneten Ports und Netzwerkverbindungen sowie verschiedene Informationen dazu an
Change the password of a user
This command allows you to change the password of the user specified as “userName”. In addition, various change and lock intervals can be defined.
Show free space
This command shows you how much space is still available on your disks.
List all installed USB devices
This command gives you all currently installed USB devices.
Show all partitions
This command gives you all currently installed partitions.
Show detailed information
sudo fdisk -l
With this command you can get detailed information about your partitions.
Force validation of the file system
sudo shutdown -rF now
The file system of the RasPI is normally only checked after every 30th restart. With this command you enforce an immediate check and (if necessary) repair of the file system.
Show Serialby ID
ls -l /dev/serial/by-id
This command displays the ID’s of any existing USB to serial adapters. So you can connect serial ports instead of using e.g. / dev / ttyUSB0 address directly via the ID of the USB device.
This has the advantage that the access via the ID is always unique and the ID does not change even after a restart of the RasPi. If you only access a USB-to-serial adapter via / dev / ttyUSB0, it may happen that it can no longer be reached under / dev / ttyUSB0 after a restart, but maybe under / dev / ttyUSB1.
To avoid this problem, it is advisable to address the serial interface via the ID of the USB-serial adapter.
Show all serial ports
ls/dev/tty* or dmesg | grep tty
This command will show you all possible serial ports of the system.
Check other computers for presence in the network
ping *network address*
Use the ping command to check for the presence of other network participants.
This can be a computer on the local network but also on the Internet.
“Network address” is replaced by the IP address or the domain name of the computer whose presence you want to check.
Show running processes
The command “ps” shows you all currently running processes including the ID and a few other information such as utilization, etc.
Termination of a process identified by the process ID
This command terminates the process with the process ID “processID”.
Output of processor utilization
This command will show you the current utilization of the CPU.
Specify the runtime and load of the computer
By “uptime” you can see the time that has passed since the launch of the RasPI.
Show current user
This command displays the name of the currently logged-in user.
View the location of a program
This command displays the location of the prametered program (in this case) “ls”.
Folder Structure – Which folder contains which files?
Under Linux, the folder structure is slightly different than in Windows but still logical. If you break down the abbreviations, the rest is almost self-explanatory.
“bin” = binaries: executable files so programs
“sbin” = system binaries: executable system files ie system programs
These two folders contain only files that are important for the system.
User-installed programs are written in /usr/bin and /usr/sbin.
The files in these folders may also be executed by normal users.
The in “bin” and “sbin”, however, mostly only by users with administrator rights.
“boot”: contains important files for booting.
“dev” = devices: This folder contains all device files. These can be used to address different hardware interfaces. For example, USB and serial interfaces.
“lib” = libraries: Contains important libraries that are necessary for some programs.
“Lost + found”: If files or file fragments are found during the repair of a data carrier, they are moved or saved to this folder.
“mnt” = mount: Contains all temporarily mounted (= mounted) data carriers such as USB sticks.
“opt” = optional: Contains all manually installed programs that require their own libraries.
“proc” = processes: Contains interfaces to the loaded kernel and its procedures.
“root” = root: This is the user directory of the super-user root. It is the only user directory that is not in the home directory.
“home”: This is the default user folder where every user automatically gets a subfolder. User files can then be stored in this folder. Each user may create files or folders in their own home folder.
“etc” = et cetera: Default memory location for system-wide configuration files.
Examples and explanations
I find the page tldr.ostera.io very practical
Here you can enter the command you want to use in a search mask and you will automatically be shown further explanations and examples.
I hope this information helps you to make the first entry into the Linux/RaspberryPI world a little easier. If you do not have or you have other criticisms or questions please let me know. You can simply use the comment function under the article. 🙂
I hope everything worked as described. If not or you have any other questions or suggestions, please let me know in the comments. Also, ideas for new projects are always welcome. 🙂
P.S. Many of these projects - especially the hardware projects - cost a lot of time and money. Of course I do this because I enjoy it, but if you appreciate it that I share these information with you, I would be happy about a small donation to the coffee box. 🙂