Raspberry Pi For N00bs – Linux Basics

After installing a Linux distribution as explained in my article “Raspberry Pi for n00bs – Installation“, it is time to change some basic settings. This article covers everything you need to know to get your system ready to use. I only run my Raspberries “headless”, without a monitor/TV. Saves an expensive gold-plated HDMI cable and all the cool kids do it 🙂

Connect to your Raspberry Pi

Before you can unleash the power of Linux, you have to connect to your precious Raspberry. Provided that you have activated SSH in the raspi-config tool and the Raspberry is powered and connected to your LAN, you can use a tool like Putty to open a connection. That is, if you are using Windows. Linux users can just use a Terminal, ssh is usually already installed. Either way, you need to know the IP address or the host name, which is “raspberrypi” by default.

Putty

As you can see in the screenshot, just put in the host name and click “Open”. A Terminal window will open and you can log in. The default username is “pi”, the default password is “raspberry” (i´ve already renamed mine to “raspi1”):

Putty SSH

Change Hostname and Password

You should change the default password asap, and probably your hostname too, especially if you plan to run more than one Raspberry in the same LAN. Use the following commands to change both:

For some commands you will need to use “sudo“, which runs a command in the context of another user (the root). “sudo” stands for “substitute user and do“. If you want to know more, the internet is full of excellent explanations for “su” and “sudo”.

I am using the editor “nano“. The commands are visible at the bottom, CTRL+O for saving the file, CTRL+X for closing it.

Change IP

By default, your Raspberry Pi should get his IP address with DHCP, while it is always better (and faster) to use a static one. We are going to need sudo for this one again:

address” is the most important value in the file, gateway and nameserver will most likely be the IP of your router. “netmask” will be 255.255.255.0 in most cases, so don´t worry about that.

There is one problem: stopping the network device means that you cannot access your Raspberry anymore. I have used a WLAN stick while i set up my static IP for the LAN, that is why i was able to use “ifdown” and “ifup“. You can just call “sudo reboot” instead.

Fun with apt-get

apt-get” (Advanced Packaging Tool) is where the installation magic happens. For example, if you would want to install “nano”, you would type the following command:

The parameter “-s” means that it will only simulate the installation. It is good practice to call apt-get with the “clean” parameter after every installation, it removes downloaded installation packages.

Of course you can also deinstall packages with apt-get, or download packages without installation:

Headless Linux

Now you are ready to go headless for real. You do not need to know all the packages, just use the following command to remove the graphical user interface completely. Be advised that it may take some time:

The parameter “-y” means that every question that comes up in the process will get answered with “yes”. “autoremove” removes all unused dependencies.

Keep it up to date

You can easily keep your Raspberry on track with apt-get:

You can also use “upgrade” instead of “dist-upgrade”. The first one only upgrades existing packages, while “dist-upgrade” installs new packages or deletes old ones too. I am not sure if the comparison fits, but i would say that “upgrade” is like a patch in Windows, while “dist-upgrade” is an upgrade from one full Windows version to another.

Of course you don´t want to enter all those commands for the upgrade. Putty comes with a command line tool called “plink.exe”, which is perfect for a small batch file (“update_pi.bat”) to keep your Raspberry up to date:

Even the login is included, so be careful where to place that file 😉

Sky is the limit

Here are some more Linux commands you may need:

I am no Linux king, so if you have any suggestions, please feel free to comment and stay tuned for more Raspberry Pi stuff 🙂

5 thoughts on “Raspberry Pi For N00bs – Linux Basics

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.