RaspberryPi Commands - NicoHood/NicoHood.github.io GitHub Wiki

Debian

Username: pi
Password: raspberry
Hostname: raspberrypi

Update

sudo apt-get update
sudo apt-get dist-upgrade

# Normally not required!
BRANCH=next sudo rpi-update
sudo apt-get autoremove

Change passwords

sudo passwd pi

# Use a password for entering sudo
sudo visudo

# Comment out the line:
pi ALL=(ALL) NOPASSWD: ALL

Tools

sudo apt-get install gnome-system-monitor gnome-disk-utility htop iceweasel screen

Edit rpi config

sudo nano /boot/config.txt
# See /boot/overlays/README for all available options

[pi0]
# USB OTG driver
#dtoverlay=dwc2

[pi1]
# Overclocking Turbo
arm_freq=1000
core_freq=500
sdram_freq=500
over_voltage=6
temp_limit=70

[pi2]

[pi3]

[all]
# General display setting
disable_overscan=1
hdmi_force_hotplug=1
disable_splash=1

# A higher color depth only increases the gpu mem by 4mb, also for kodi
# But the desktop backgrounds and web pages will look way better
# sudo /opt/vc/bin/vcdbg reloc
framebuffer_depth=32
framebuffer_ignore_alpha=1

# Allocate more gpu mem for kodi
gpu_mem=128

# Load audio
dtparam=audio=on

# Get the monitor setting via
# tvservice -n
# /opt/vc/bin/tvservice -n
[EDID=ACR-M230HDL]
# DVI Monitor Mode
hdmi_drive=1

# Cinch setting
#sdtv_mode=2
#sdtv_aspect=3
#disable_overscan=0
#overscan_left=10
#overscan_right=10
#overscan_top=0
#overscan_bottom=0

[EDID=SAM-SAMSUNG]
hdmi_drive=2

Restart HDMI

tvservice -o
tvservice -p
fbset -depth 8
fbset -depth 16
xrefresh

Fix mouse lagg

sudo nano /boot/cmdline.txt

# Add:
usbhid.mousepoll=0

# One line command
echo "usbhid.mousepoll=0" | sudo tee -a /boot/cmdline.txt

Hardware Random Number Generator

# The extra kernel module is no longer required
sudo apt-get install rng-tools
sudo reboot

# Test rng (should output a lot random chars continuously)
 </dev/random tr -dc "a-zA-Z0-9"

Autostart

sudo nano /etc/rc.local

Show available versions

apt-cache policy <package name>
apt-cache madison <package name>

Upgrade to Jessie

sed -i 's/wheezy/jessie/' /etc/apt/sources.list
apt-get update
apt-get dist-upgrade -y

Temperature/CPU speed

cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq
700000

cat /sys/class/thermal/thermal_zone0/temp
55148
vcgencmd measure_temp
temp=76.3'C

Clear SD-Card under Windows

diskpart
list disk
select disk X
clean

Play Audio test file

aplay /usr/share/sounds/alsa/Front_Center.wav
aplay /usr/share/sounds/alsa/Front_Center.wav -D sysdefault:CARD=1

X11 Forwarding

# This will open the whole xsession on tty 2 or tty8
sudo xinit -- :1 &
DISPLAY=:1 ssh -X [email protected] lxsession

Stream Music from one device to another

Works in both directions. Don't use Multicast/RTP. No restart required.

# Both
sudo apt-get install pavucontrol paprefs pulseaudio
sudo pacman -S pavucontrol paprefs pulseaudio pulseaudio-zeroconf
# Remove the volume panel of the lxde desktop as it will make the pulseaudio daemon not work.

# Receiver
paprefs
Enable network access to local sound devices (check all suboptions)

# Sender
paprefs
Make discoverable PulseAudio network sound devices locally available
pavucontrol
# Wait for the Receiver to show up
Select receiver output as Output (You might only be able to set it as fallback)
# Test config
aplay /usr/share/sounds/alsa/Front_Center.wav
# Kodi
Settings->System->Audio->Audio output device->ALSA
Settings->System->Audio->Output configuration->Fixed

# As alternative if videos lagg too much you can use RTP sender/receiver
# This will not work with a bridged wlan to ethernet as multicast is routed to wlan then.

Open RTP stream with vlc:
tcpdump # Check which ip and port the stream is sent on
vlc rtp://@224.0.0.56:46574

Open RTP stream with kodi:
tcpdump # Check which ip and port the stream is sent on
Create a file pulseaudio.strm with the content:
rtp://@224.0.0.56:46574
http://kodi.wiki/view/Internet_video_and_audio_streams

Optional Infos (not essentially required)

Use HW Serial

# HW Serial is enabled by default, open it with a tool on the host
screen /dev/ttyUSB0 115200

# To make the terminal fit to your screen you can use xterm
sudo apt-get install xterm
resize

# Or manually resize the screen
stty rows 50 cols 132

# To add colors set the TERM variable
# You can also put this into ~/.bashrc
TERM=linux
export TERM

Resize Filesystem

sudo fdisk /dev/mmcblk0
p, d, 2, n, p, 2, enter, enter, w
sudo reboot
sudo resize2fs /dev/mmcblk0p2

NFS (not working correct after reboot)

# Server:
sudo apt-get install nfs-common nfs-kernel-server
sudo mkdir -p /srv/nfs4/
sudo chmod 777 /srv/nfs4/ 
sudo nano /etc/exports 
/srv/nfs4/ 192.168.178.0/24(rw,sync,no_subtree_check)
sudo systemctl start rpcbind.service
sudo systemctl enable rpcbind.service
sudo exportfs
sudo systemctl restart nfs-kernel-server
sudo systemctl status nfs-kernel-server

# Client:
sudo mount raspberrypi.local:/srv/nfs4 /mnt
sudo umount /mnt

SMB Share

sudo apt-get install samba samba-common-bin
sudo nano /etc/samba/smb.conf
sudo smbpasswd -a pi
/etc/samba/smb.conf
[pi]
path = /home/pi
writeable = yes
guest ok  = no

Links

⚠️ **GitHub.com Fallback** ⚠️