Got hold of a Raspberry Pi but not entirely confident with Linux? While the main desktop is easy enough to use, at times you’ll need to rely on command line entry in the terminal. But if you’re new to the Raspbian operating system and Linux, this is easier said than done.
If you’re using a Raspberry Pi computer for a weekend project (perhaps a media center or a home server), then there is a good chance these useful Raspberry Pi command line instructions will save you some time.
Raspberry Pi Commands: You’re Using Linux
You’ve imaged your SD card and booted your Raspberry Pi, and running the Raspbian operating system, updated and configured to optimize your Raspberry Pi.
What you may not have realized is that despite the Windows-style icon-driven desktop, Raspbian is a Linux distribution. Several operating systems are available for Raspberry Pi, the vast majority of which are Linux.
This isn’t an attempt to get people using Linux by stealth! You can install Linux on a huge range if devices. Rather, the Raspberry Pi Foundation relies on Linux operating systems because of their open source origins and versatility. While you can use a Linux operating system without using the command line, this is where the real power lies.
Want total control over your Raspbian-powered Raspberry Pi? Begin by launching LX Terminal or booting to the command line.
5 Important Raspberry Pi Update Commands
We wouldn’t expect you to start using the command line without knowing how it works. Essentially, it is a method for instructing the computer to perform tasks, but without a mouse.
Look for the pi@raspberrypi $ prompt when you log in to the terminal. You can enter commands whenever this is displayed.
Probably the first thing you should learn to do from the command line is update your Raspberry Pi. If you’re using Raspbian, this is a case of using three or four commands, to update and upgrade the Pi’s sources and operating system:
- sudo apt-get update
- sudo apt-get upgrade
- sudo apt-get dist-upgrade
- sudo rpi-update
To save time, combine these into a single chained command:
- sudo apt-get update && sudo apt-get upgrade && sudo apt-get dist-upgrade && sudo rpi-update
5 Raspberry Pi Command Line Basics
With a mouse-driven GUI, you can easily switch directories and read their contents. However, you may prefer the flexibility of text-based commands.
- pwd shows you the current directory (print working directory).
- ls will list the contents of the directory.
- cd is used to change the directory. For example, cd edward with switch you to a child directory called “Edward” while cd.. returns focus to the parent directory.
- mkdir newdir will create a new directory, where “newdir” is the directory label. You can also create a succession of new directories with mkdir -p /home/edward/newdir1/newdir2, where both newdir1 and newdir2 are created, but this will only work with the -p
- clear presents a clean new screen, useful if your previous commands are cluttering things up.
You’ll easily pick up these command line basics. It’s useful to be able to navigate via the command line as some files and folders are invisible to the mouse-driven file manager.
10 Commands for Raspberry Pi Hardware Info
On a Windows PC or Mac you can easily find hardware information by looking in System Information or About This Mac. To find out about your Raspberry Pi’s hardware, enter the following:
- cat /proc/cpuinfo
This will output information about the device’s processor. For instance, where you see “BCM2708”, this indicates that Broadcom manufactured the chip.
Run these proc directory commands to uncover other hardware information.
- cat /proc/meminfo displays details about the Raspberry Pi’s memory.
- cat /proc/partitions reveals the size and number of partitions on your SD card or HDD.
- cat /proc/version shows you which version of the Pi you are using.
Use these commands to assess what your Raspberry Pi might be capable of. It doesn’t end there. Find further information using the vcgencmd series of commands:
- vcgencmd measure_temp reveals the CPU temperature (vital if you’re concerned about airflow).
- vcgencmd get_mem arm && vcgencmd get_mem gpu will reveal the memory split between the CPU and GPU, which can be adjusted in the config screen.
- free -o -h will display the available system memory.
- top d1 checks the load on your CPU, displaying details for all cores.
- df -h is a great way to quickly check the free disk space on your Raspberry Pi.
- uptime is a simple command that displays the Raspberry Pi’s load average.
3 Commands to Check Connected Devices
Just as you can list the contents of a directory with a single command, Linux lets you list devices connected to your computer.
- ls /dev/sda* displays a list of partitions on the SD card. For a Raspberry Pi with a HDD attached, substitute sda* with hda*.
- lsusb displays all attached USB devices. This is crucial for connecting a hard disk drive or other USB hardware that requires configuration.
If the item is listed here, you should be able to set it up.
- lsblk is another list command you can use. This displays information about all attached block devices (storage that reads and writes in blocks).
3 Commands to Shutdown and Restart Raspberry Pi
Perhaps the most important command line instruction is sudo. This single word instructs Linux-based systems that the following command is to be carried out with “super user” privilege. This is an advanced level of access like (but not the same as) administrator on Windows computers.
One of the most common commands for Raspbian users is sudo raspi-config. This opens the configuration screen for the operating system (there is also a desktop version found via main menu). The following three commands may prove useful:
- startx will start the Raspberry Pi GUI (graphic user environment) and return you to the default Raspbian desktop.
- sudo shutdown -h now will commence the shutdown process with immediate effect. Schedule a timed shutdown with the format: sudo shutdown -h 21:55
- sudo reboot is for restarting the Raspberry Pi from the command line.
Raspberry Pi Terminal Commands Are Power
For many people, command line access on any platform is intimidating.
The useful commands listed here are an attempt to give the Raspberry Pi newcomer the bare minimum to get started with the terminal, a small stepping stone to success with whichever Pi project they decide to start.
There’s an added bonus: learning these commands can set you on the road to using Linux, as the majority will work on any distribution! If you’re new to the Raspberry Pi, check out our article on Raspberry Pi basics everyone should know.
Read the full article: Raspberry Pi Terminal Commands: A Quick Guide for Raspberry Pi Users
Read Full Article
No comments:
Post a Comment