Raspberry Pi

How Can I Learn Linux on Raspberry Pi

Raspberry Pi device is a low-powered mini-computer that allows you to run different lightweight Linux operating systems like Ubuntu, Kali Linux, DietPi, and more. The Linux operating systems are widely used nowadays because they are fast, stable, and have strong support for network functionality, providing users the freedom to do server and client-related tasks with ease. Another useful advantage of Linux is that they are free to use and most of the applications come under GNU (General Public License).

If you have recently purchased a Raspberry Pi device and want to learn Linux on it, you would probably need to install a Linux OS preferably Raspberry Pi OS on your device. You can follow this article that provides you with enough guidelines to start learning Linux on Raspberry Pi.

How to Learn Linux on Raspberry Pi

Unlike Windows, the Linux system is a completely different environment, and you cannot install packages or applications directly from the GUI. You must need terminal commands to install a specific application or software on your Linux system. Same is true for Raspberry Pi OS, where you have to do most of your tasks on the terminal. So, if you want to learn Linux on Raspberry Pi, you must learn some useful commands that you can run on your Raspberry Pi terminal to perform a specific task.

You can open the terminal on the Linux system easily from the desktop:


 

After opening the Linux terminal, it’s now time to learn some commands that you will mostly use whenever you work on any Linux system.

1: List Files

The ls command is useful on the Raspberry Pi system to get the list of files inside the directory. When this command is run on a newly opened terminal it displays the list of files present in the home directory:

$ ls

 

2: Open a Directory

This command is used to open a specific directory inside the terminal. This cd command is applicable to move to the root directory whereas the cd ..” command is used to go to the previous directory.

To move to a specific directory, you must specify the directory path using the following syntax.

$ cd /home/pi/<directory_name>

 

If you want to stick yourself to a specific directory, you can use the following command:

$ cd cd ~

 

3: Make a Directory

The mkdir command is used if you want to make a directory on Linux system. You have to specify the directory name so that the command can create the directory at a given location:

$ mkdir <folder_name>

 

4: Create a Document

To open a document on a Linux system, you can use the pre-built nano editor that allows you to open, create and edit files on your system. To open a document on your system, follow the below-mentioned command:

$ nano <file_name>

 
Note: In the below output I have created a file with the name dummy file, You can replace it with any name you like.


 

To save this file, use CTRL+X, add Y, and press enter.

5: Remove a File or Directory

The rm command is used on the Linux system to remove the file or directory. You can apply the same command on your Raspberry Pi terminal for removing the file or directory from your system.

$ rm <file_name>

 

For removing the directories on Raspberry Pi, you can follow here to find different ways.

6: Copy Files

Although you can copy files on Linux system easily from GUI, but most of the time you may need to stay on the terminal and copy the files to other places through command. So, the cp command is used for this purpose that allows Linux users to copy files to any location they want through the following syntax:

$ sudo cp <file_name> <file_location>

 
Note:  /bin is the directory where we have copied the dummyfile, you can also use other directories paths.

7: Make a File Executable

In Linux system, you won’t be able to execute some files because of the security issue and to make them executable, you must use the chmod command. This command is used by Linux users to allow them permission to execute the file on the system. You can follow the below-mentioned syntax to make the file executable on your system:

$ sudo chmod a+x <filename>

 

8: Install Packages from Linux Repository

The Linux systems have built-in repositories that allow users to install packages or software directly on their systems. The same case applies to Raspberry Pi OS as well which has its official repositories where you can run the Linux command to install packages on your system. You can install, update, uninstall or upgrade the packages on your Linux system easily using the following syntax:

$ sudo apt install <package_name>

 
Remember that you must replace the <package_name> with the name of the app/package you need to install on your system.


Note: During the installation process you will be asked for permission to install then press y for Yes or n for No.

To upgrade the package, apt command can be used by following the below syntax:

$ sudo apt upgrade <package_name>

 

To remove the package from Linux repository, you can use the following syntax:

$ sudo apt remove <package_name>

 

9: Switch to a New User

If you want to switch user on your Linux system, you can do it easily from the following command.

$ sudo su <username>

 

10: Change Password

The passwd command is used to change the password of the user. After typing the below command insert the new password.

$ sudo passwd <username>

 

11: Add a New User

The adduser command is used to add multiple users for your Linux-based Raspberry Pi system:

 $ sudo adduser <username>

 

12: Printing a String on Terminal

You can use the “echo” command to print a string on the terminal. The string could be a text you want to appear on your Raspberry Pi terminal.

$ echo <string>

 

How To Shut Down the System?

As you have learned some Linux system basics, now it’s time to learn how to shut down your system. To shut down the system, you can access the shutdown option from the Application menu present at the top left of your desktop interface:


If you want to shut down your Raspberry Pi from the terminal, you can read our guide here.

That’s it for this guide!

Conclusion

Raspberry Pi comes with its own OS called Raspberry Pi OS which is Linux based. So, Raspberry Pi makes it feasible for its users to learn Linux easily. In the article, we have discussed the basic commands that you must remember because they are mostly used whenever you execute a task on your Linux system. These commands are extremely useful for a beginner, who wants to learn Linux on Raspberry Pi.

About the author

Zahra Zamir

An Electronics graduate who loves to learn and share the knowledge, my passion for my field has helped me grasp complex electronics concepts and now I am here to share them with others.