Raspberry Pi Command Line Interface (CLI)

Foreword
I am a fan of single board computers like the Raspberry Pi, I purchased a Revision 1.0 within the first months of the Pi's 2012 release so I ended up with the 256MB model that was quickly replaced with the Revision 2.0 the same year. I then proceeded to purchase a Model B+ Model 2 and a Model 3. All of which have served me well as project computers. Early on I used them as XBMC (Kodi) TV appliances and when I stopped using them for that purpose I moved them to various jobs around the place.
Now as I am tighter than a Gnats arse! I refuse to junk anything that still works and so all of these Pi's have been allocated new jobs, a web server, a BBS & IRC server, a development box and a music server. All of which are happily working away at their given tasks.
That said I keep hearing people talk about this and that Raspberry Pi being a desktop replacement. I refuse to agree with this unless you're desktop is 20 years old it's definitely not in that league but here is the caveat it can be as long as you don't want a graphical user interface. If you are happy working on the command line then you're in luck because it works beautifully as a terminal based computer.
Now to jump to the point of this article, my next job was to take an old Raspberry Pi B and make it a working usable computer from the command line. No GUI allowed. The specification of this specific Pi is:
- CPU Broadcom BCM2835 SOC Overclocked from 700MHz to 800MHz
- RAM 256MB RAM
- GPU Videocore 4 capable of Blu-ray quality H264 Playback.
- 2 x USB Ports
- 10/100 Ethernet
- HDMI, Composite Video, 3.5mm Audio Jack
- GPIO 26 pin header
I am not big on over clocking I see little point in spending hard earned cash on something I then reduce the life span off to gain very little. But as this specific overclock requires no over-volt then I am more comfortable with it.
Now I want you to understand this setup is not to impress, its job is to have a low powered device that doesn’t have to keep being charged up (Tablets and Phones), that has a constant connection to IRC, email, calendar, weather, and BBS those are the four main tasks, although I will point out some extra software installed on the computer that you may find useful if not interesting.
1. Install Raspberry Pi Imager
Linux
Debian / Raspberry Pi OS / Ubuntu
sudo apt update
sudo apt install rpi-imager
If your distribution does not include Raspberry Pi Imager in its software repositories, download the latest AppImage from the Raspberry Pi website.
Windows
- Download Raspberry Pi Imager.
- Run the installer.
- Start Raspberry Pi Imager.
macOS
- Download Raspberry Pi Imager.
- Open the downloaded
.dmgfile. - Drag Raspberry Pi Imager into the Applications folder.
- Launch Raspberry Pi Imager.
2. Write Raspberry Pi OS to the SD Card
- Insert your microSD card.
- Open Raspberry Pi Imager.
- Select Choose Device and choose your Raspberry Pi model.
- Select Choose OS.
-
Choose either:
-
Raspberry Pi OS Lite (32-bit)
or
- Raspberry Pi OS Lite (64-bit)
The 64-bit image is recommended for modern Raspberry Pi models with sufficient memory. The 32-bit image remains an excellent choice for older models such as the Pi Zero, Pi 1 and some Pi 2 systems.
- Select Choose Storage.
- Select your microSD card.
- Click Next.
3. (Optional) Configure Before Writing
Raspberry Pi Imager can configure your Raspberry Pi before it boots for the first time.
I recommend configuring:
- Username
- Password
- Hostname
- SSH
- Wi-Fi (if required)
- Time Zone
- Keyboard Layout
Doing this now can save time later.
4. Write the Card
Click Write.
Wait for:
- Writing
- Verification
Only remove the microSD card once verification has completed successfully.
5. First Boot
- Insert the microSD card into the Raspberry Pi.
- Connect:
- HDMI
- Keyboard
- Network (or Wi-Fi)
- Apply power.
Advanced Installation Using dd
This section is intended for users who prefer to write the operating system image manually from the command line.
1. Download the Image
Download the latest Raspberry Pi OS Lite image from the Raspberry Pi website.
2. Extract the Image
Linux
unxz *.img.xz
or
xz -d *.img.xz
3. Find Your SD Card
Before inserting the card, run:
lsblk
Insert the microSD card and run the command again:
lsblk
Identify the new device (for example, /dev/sdb).
Warning: Be absolutely certain you have identified the correct device. Writing to the wrong drive will permanently overwrite its contents.
4. Unmount Any Mounted Partitions
sudo umount /dev/sdb*
Replace sdb with the correct device for your system.
5. Write the Image
sudo dd if=raspios.img of=/dev/sdb bs=4M status=progress conv=fsync
When dd has finished, run:
sync
You can now safely remove the microSD card.
macOS
The process is almost identical.
Find the SD card:
diskutil list
Unmount it:
diskutil unmountDisk /dev/disk2
Write the image:
sudo dd if=raspios.img of=/dev/rdisk2 bs=4m
Using rdisk instead of disk is generally faster on macOS.
First Boot
If you configured Raspberry Pi Imager before writing the card, the system should boot directly to the login prompt.
If you skipped the operating system customisation, Raspberry Pi OS will guide you through the initial configuration before presenting the login prompt.
Once logged in, you have a working Command Line Interface (CLI).
The next stage is to update the operating system, configure a few settings and install the software that will turn your Raspberry Pi into a practical CLI workstation.
Optional: Raspberry Pi Configuration
Most users can skip this section if they configured Raspberry Pi Imager before writing the SD card.
To make changes later, run:
sudo raspi-config
Installing our toolkit
Aptitude
Install:
sudo apt install aptitude
A powerful package manager that provides a menu-driven interface and advanced dependency handling for installing, removing and updating software.
Midnight Commander
Install:
sudo apt install mc
A two-pane file manager that makes copying, moving, editing and organising files quick and easy from the command line.
Tmux
Install:
sudo apt install tmux
A terminal multiplexer that lets you create multiple terminal sessions, disconnect safely and reconnect later without losing your work.
Htop
Install:
sudo apt install htop
An interactive system monitor for viewing CPU, memory, processes and system load in real time.
Inxi
Install:
sudo apt install inxi
A comprehensive system information tool for displaying hardware, software and operating system details.
Curl
Install:
sudo apt install curl
A command-line tool for transferring data using HTTP, HTTPS, FTP and many other network protocols.
Wget
Install:
sudo apt install wget
A non-interactive download manager designed for retrieving files from web and FTP servers.
Rsync
Install:
sudo apt install rsync
A fast and efficient file synchronisation tool for copying files between directories, disks and remote computers.
Tree
Install:
sudo apt install tree
Displays directories in a clear tree-like structure, making it easy to visualise the layout of files and folders.
Mutt
Install:
sudo apt install mutt
A lightweight text-based email client for reading and sending email directly from the terminal.
WeeChat
Install:
sudo apt install weechat
A fast and extensible terminal-based IRC client for real-time online chat.
Newsboat
Install:
sudo apt install newsboat
A command-line RSS and Atom feed reader for following news, blogs and websites without a web browser.
Calcurse
Install:
sudo apt install calcurse
A text-based calendar and organiser for managing appointments, tasks and reminders from the terminal.
Lynx
Install:
sudo apt install lynx
A text-only web browser that allows you to browse websites entirely from the command line.
W3M
Install:
sudo apt install w3m
A lightweight terminal web browser with support for tables, frames and, in compatible terminals, inline images.
LFTP
Install:
sudo apt install lftp
A powerful file transfer client supporting FTP, FTPS, SFTP, HTTP, HTTPS and other network protocols.
OpenSSH Server
Install:
sudo apt install openssh-server
Provides secure remote access to your Raspberry Pi, allowing you to connect and administer it over a network using SSH.
Dig
Install:
sudo apt install dnsutils
A DNS lookup utility used to query domain names, troubleshoot DNS issues and inspect DNS records.
Traceroute
Install:
sudo apt install traceroute
Shows the network path taken by data packets to reach another computer, helping diagnose routing and connectivity problems.
MTR
Install:
sudo apt install mtr
Combines the features of ping and traceroute to provide real-time network diagnostics and performance monitoring.
Nmap (Optional)
Install:
sudo apt install nmap
A network discovery and security auditing tool used to identify devices, open ports and running services on your network.
Ncdu
Install:
sudo apt install ncdu
A fast and lightweight disk usage analyser that helps identify which files and directories are using your storage space.
Smartmontools
Install:
sudo apt install smartmontools
Provides tools for monitoring the health of storage devices using S.M.A.R.T. technology.
Hdparm
Install:
sudo apt install hdparm
A command-line utility for viewing and changing hard disk parameters and measuring disk performance.
Parted
Install:
sudo apt install parted
A powerful disk partition editor for creating, resizing and managing storage devices.
ZIP
Install:
sudo apt install zip
Creates ZIP archives for compressing and packaging files into a widely supported archive format.
Unzip
Install:
sudo apt install unzip
Extracts files from ZIP archives created on Linux, Windows and many other operating systems.
7-Zip
Install:
sudo apt install 7zip
Creates and extracts 7z archives while supporting many other common compressed file formats.
Gzip
Install:
sudo apt install gzip
A standard Linux compression utility commonly used for compressing individual files and creating compressed archives.
Bzip2
Install:
sudo apt install bzip2
A compression utility that typically provides better compression than gzip at the cost of slower processing.
XZ Utils
Install:
sudo apt install xz-utils
Command:
xz
A high-compression utility commonly used for Linux software packages, backups and source archives.
Unrar-free
Install:
sudo apt install unrar-free
Command:
unrar-free
Extracts files from RAR archives, allowing access to a format still encountered on the internet and in older archives.
Cabextract
Install:
sudo apt install cabextract
Command:
cabextract
Extracts Microsoft Cabinet (CAB) archives commonly found in older software and driver packages.
Git
Install:
sudo apt install git
A distributed version control system used to manage source code, scripts and document revisions.
Emacs (Optional)
Install:
sudo apt install emacs
Command:
emacs
A powerful and highly extensible text editor and working environment favoured by many developers and advanced users.
Vim (Optional)
Install:
sudo apt install vim
Command:
vim
A fast and powerful modal text editor based on the classic Unix editor Vi.
Telnet (Optional)
Install:
sudo apt install telnet
Command:
telnet
A legacy terminal client useful for testing network services and connecting to older systems. SSH should be used for secure remote access.
MOC (Music On Console) (Optional)
Install:
sudo apt install moc
Command:
mocp
A lightweight terminal-based music player that continues playing even after its interface has been closed.
FFmpeg (Optional)
Install:
sudo apt install ffmpeg
Command:
ffmpeg
A powerful multimedia toolkit for converting, recording, editing and processing audio and video files.
yt-dlp (Optional)
Install:
sudo apt install yt-dlp
Command:
yt-dlp
A versatile command-line media downloader capable of retrieving audio and video from many supported websites.
ImageMagick (Optional)
Install:
sudo apt install imagemagick
Command:
magick
A command-line image processing toolkit for converting, resizing, rotating and editing images individually or in batches.
Poppler Utils (Optional)
Install:
sudo apt install poppler-utils
Commands:
pdfinfo
pdftotext
pdfimages
pdfseparate
pdfunite
A collection of command-line tools for inspecting, extracting and manipulating PDF documents.
File
Install:
sudo apt install file
Command:
file
Identifies the true type of a file by examining its contents rather than relying on its filename or extension.
BC
Install:
sudo apt install bc
Command:
bc
A lightweight command-line calculator supporting arithmetic, variables and mathematical expressions.
Micro (Optional)
Install:
sudo apt install micro
Command:
micro
A modern, easy-to-use terminal text editor with familiar keyboard controls, mouse support and syntax highlighting.
JQ (Optional)
Install:
sudo apt install jq
Command:
jq
A command-line processor for reading, filtering and formatting JSON data.
Ripgrep (Optional)
Install:
sudo apt install ripgrep
Command:
rg
A fast text-search utility designed to quickly search through files and source code.
Screen (Optional)
Install:
sudo apt install screen
Command:
screen
A terminal multiplexer that allows long-running terminal sessions to continue after disconnecting from a remote system.
Minicom (Optional)
Install:
sudo apt install minicom
Command:
minicom
A serial communication program used for connecting to routers, embedded devices, microcontrollers and other serial consoles.
Netcat (Optional)
Install:
sudo apt install netcat-openbsd
Command:
nc
A versatile networking utility for testing connections, transferring data and troubleshooting network services.
Reboot And Realise
You can now for completion sake, reboot your install and realise it's potential.
sudo reboot
Enter your password and hit enter.
HAVE FUN, GOOD LUCK, DON'T DIE!