> For the complete documentation index, see [llms.txt](https://education.raspberrypiaustralia.online/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://education.raspberrypiaustralia.online/using-the-command-line/raspberry-pi-commands.md).

# Raspberry Pi Commands

### <mark style="color:blue;">Basic Commands</mark>

<mark style="color:green;">Finding available devices</mark>

```bash
arp -a
```

This command <mark style="color:yellow;">lists all devices connected to the same network as your Raspberry Pi</mark>. It helps you identify the IP addresses and MAC addresses of the devices.

<mark style="color:green;">Connecting to the Raspberry Pi via SSH using the device name:</mark>

```bash
ssh pi@raspberrypi
```

This command establishes an SSH connection to your Raspberry Pi using its device name. By default, the username is "pi" and the device name is "raspberrypi".

<mark style="color:green;">Connecting to the Raspberry Pi via SSH using the IP address:</mark>

```bash
ssh pi@192.168.64.xxx
```

This command establishes an SSH connection to your Raspberry Pi using its IP address. Replace "192.168.64.xxx" with the actual IP address of your Raspberry Pi.

### <mark style="color:blue;">User Management</mark>

#### <mark style="color:green;">Adding a new user with a home directory</mark>

```bash
sudo useradd -m sven -G sudo
```

This command creates a new user named "sven" and assigns them to the "sudo" group, granting them administrative privileges. The "-m" flag creates a home directory for the user. User information is stored in the "/etc/passwd" file.

#### <mark style="color:green;">Setting a password for a user</mark>

```bash
sudo passwd sven
```

This command sets a password for the user "sven". The password is stored in an encrypted format in the "/etc/shadow" file.

### <mark style="color:blue;">System Information</mark>

#### <mark style="color:green;">Getting system information (e.g., IP address):</mark>

```bash
ifconfig
```

This command displays information about the network interfaces, including the IP address assigned to each interface.

<mark style="color:green;">Getting network information</mark>

```bash
iwconfig
```

This command provides information about the wireless network interfaces, including the connected Wi-Fi network and signal strength.

#### <mark style="color:green;">Getting the hostname</mark>

```
hostname
```

This command <mark style="color:yellow;">displays the hostname</mark> of your Raspberry Pi.

<mark style="color:green;">Getting the IP address associated with the hostname:</mark>

```bash
hostname -I
```

This command shows the IP address assigned to the hostname of your Raspberry Pi.

#### <mark style="color:green;">Checking for all connected USB devices</mark>

```bash
lsusb
```

This command <mark style="color:yellow;">lists all the USB devices currently connected to your Raspberry Pi.</mark>

### <mark style="color:blue;">System Configuration</mark>

#### <mark style="color:green;">Accessing the Raspberry Pi configuration tool:</mark>

```bash
sudo raspi-config
```

This command opens the Raspberry Pi configuration tool, which allows you to modify various system settings, such as enabling SSH, changing the password, and configuring the locale.

#### <mark style="color:green;">Starting the graphical user interface (GUI):</mark>

```
startx
```

This command starts the graphical user interface on your Raspberry Pi, if one is installed.

#### <mark style="color:green;">Rebooting the system</mark>

```
sudo reboot
```

This command reboots your Raspberry Pi.

<mark style="color:green;">Shutting down the system</mark>

```
sudo shutdown -h now
```

This command shuts down your Raspberry Pi immediately.

### <mark style="color:blue;">Web Server Setup</mark>

#### <mark style="color:green;">Updating the system</mark>

```
sudo apt-get update && sudo apt-get upgrade
```

This command updates the package list and upgrades the installed packages to their latest versions.

#### <mark style="color:green;">Installing the Apache web server and PHP:</mark>

```
sudo apt-get install apache2 php5
```

This command installs the Apache web server and PHP on your Raspberry Pi. It allows you to host web pages and run PHP scripts.

#### <mark style="color:green;">Installing MySQL</mark>

```bash
sudo apt-get install mysql-server mysql-client php5-mysql
```

This command installs the MySQL database server, client, and the necessary PHP extension for interacting with MySQL databases.

<mark style="color:green;">Restarting the Apache web server</mark>

```bash
sudo service apache2 restart
```

This command restarts the Apache web server to apply any configuration changes.

### <mark style="color:blue;">Audio Playback</mark>

#### <mark style="color:green;">Playing an audio file</mark>

```
omxplayer audio.mp3
```

This command plays an audio file named "audio.mp3" using the omxplayer, which is a command-line media player for the Raspberry Pi.

1. Adjusting the volume:
   * Press `+` to increase the volume.
   * Press `-` to decrease the volume.

### <mark style="color:blue;">Remote Control</mark>

Installing XRDP for remote desktop access

```bash
sudo apt-get install xrdp
```

This command <mark style="color:yellow;">installs the XRDP server, which allows you to access your Raspberry Pi's desktop environment remotely using the Remote Desktop Protocol (RDP).</mark>

#### <mark style="color:green;">Installing VNC server for remote access</mark>

```bash
sudo apt-get install tightvncserver
```

This command installs the VNC server, which enables remote access to your Raspberry Pi's desktop environment.

#### <mark style="color:green;">Starting the VNC server</mark>

```bash
tightvncserver
```

This command starts the VNC server on your Raspberry Pi.

* The Ethernet port for VNC is `5900`.
* The WLAN (Wi-Fi) port for VNC is `5901`.

### <mark style="color:blue;">File Sharing</mark>

#### <mark style="color:green;">Installing file sharing support</mark>

```bash
sudo apt-get install netatalk
```

This command installs the Netatalk package, which provides file sharing capabilities using the Apple Filing Protocol (AFP).

Connecting to the Raspberry Pi's file share from macOS:

* Open the "Connect to Server" dialog using the shortcut `⌘K`.
* Enter the following address: `afp://192.168.64.xxx`, replacing "192.168.64.xxx" with the actual IP address of your Raspberry Pi.

These are just a few examples of the many commands and configurations available on the Raspberry Pi.&#x20;

The Raspberry Pi offers a wide range of possibilities, and exploring the official documentation and community resources can help you discover more commands and features specific to your needs.

Remember to use commands with caution, especially those that require sudo privileges, as they can have significant impact on your system.&#x20;

It's always a good practice to understand the purpose and potential consequences of a command before executing it.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://education.raspberrypiaustralia.online/using-the-command-line/raspberry-pi-commands.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
