While the raspi-config script makes for convenient setup on first boot, one of the reasons I have a Raspberry Pi is to help me learn what goes on behind the menu on my computers.

I would like to see the raspi-config script, and understand how it works. I found a partial script online, but it (apparently) only includes the portions which just edit the config.txt file, and I am interested in knowing what else it affects, and how.

I would like to see the full text for the raspi-script, and as yet have not found in in my file system. Can someone offer the location?

For the moment, I don't want explanation of how it does what it does. I want to try to figure it out myself. (Although that may be a later question.)

  • All of these answers were correct, and helpful. I chose Steve's because I learned the most from it/him. – zenbike Jul 28 '12 at 10:59

Both of the other answers are correct and will let you view and study how the file works. However, with the idea of teaching you to fish rather than give you a fish, if you do the following it will help you find any file on your system.

sudo find / -name 'raspi-config'

Breaking it Down:

sudo tells the system to run this command with root privileges - this prevents lots of errors cluttering the system from directories that your regular user (pi) can't access.

find the name of the Linux command to find files and directories.

/ tells the find command to search the root of the filesystem and all its sub-directories.

-name tells the find command to search by the file name.

'raspi-config' this is the file name you are searching for.

to find a different file just replace the raspi-config with the name of the file you are looking for. There are many other options for the find command and you can find all of the details for most linux commands by typing

man find

on the command line.

Man is short for manual, and prints the manual page (help page) for the Linux command that follows it.

| improve this answer | |
  • Dude, we can teach people how to fish once this site is graduated. =P – user46 Jul 28 '12 at 6:08
  • 4
    I like this mentality. Learning is why we're in to Pi. :) – zenbike Jul 28 '12 at 7:56
  • 1
    Look at mlocate rather than find. It will be much faster at this type of operation. – Jivings Jul 28 '12 at 9:37
  • Look at which down below. – user7624 Jun 2 '13 at 17:29

The full path of the raspi-config file is /usr/bin/raspi-config:

pi@raspberrypi ~ $ which raspi-config
| improve this answer | |
  • 1
    which is a better answer than using find as it tells you which file is being called. find will both take longer and could turn up any number of files with the name you're searching for. – Oli Aug 23 '12 at 22:49

While I can't tell you exactly where to find raspi-config on your filesystem, the source for it is hosted on GitHub.

It's a tool created by asb who also appears to be a moderator on the official Raspberry Pi forums. You can find the source at asb/raspi-config.

Edit: This is the full code, here, as well, drawn from the git repo linked above:

# Part of raspi-config http://github.com/asb/raspi-config
# See LICENSE file for copyright and license details

if [ $(id -u) -ne 0 ]; then
  printf "Script must be run as root. Try 'sudo raspi-config'\n"
  exit 1


do_info() {
  whiptail --msgbox "\
This tool provides a straight-forward way of doing initial 
configuration of the Raspberry Pi. Although it can be run 
at any time, some of the options may have difficulties if 
you have heavily customised your installation.\
" 20 70 1

do_expand_rootfs() {
  # Get the starting offset of the root partition
  PART_START=$(parted /dev/mmcblk0 -ms unit s p | grep "^2" | cut -f 2 -d:)
  [ "$PART_START" ] || return 1
  # Return value will likely be error for fdisk as it fails to reload the 
  # partition table because the root fs is mounted
  fdisk /dev/mmcblk0 <<EOF


  # now set up an init.d script
cat <<\EOF > /etc/init.d/resize2fs_once &&
# Provides:          resize2fs_once
# Required-Start:
# Required-Stop:
# Default-Start: 2 3 4 5 S
# Default-Stop:
# Short-Description: Resize the root filesystem to fill partition
# Description:

. /lib/lsb/init-functions

case "$1" in
    log_daemon_msg "Starting resize2fs_once" &&
    resize2fs /dev/mmcblk0p2 &&
    rm /etc/init.d/resize2fs_once &&
    update-rc.d resize2fs_once remove &&
    log_end_msg $?
    echo "Usage: $0 start" >&2
    exit 3
  chmod +x /etc/init.d/resize2fs_once &&
  update-rc.d resize2fs_once defaults &&
  whiptail --msgbox "Root partition has been resized.\n\
The filesystem will be enlarged upon the next reboot" 20 60 2

set_config_var() {
  lua - "$1" "$2" "$3" <<EOF > "$3.bak"
local key=assert(arg[1])
local value=assert(arg[2])
local fn=assert(arg[3])
local file=assert(io.open(fn))
local made_change=false
for line in file:lines() do
  if line:match("^#?%s*"..key.."=.*$") then

if not made_change then
mv "$3.bak" "$3"

# $1 is 0 to disable overscan, 1 to disable it
set_overscan() {
  # Stop if /boot is not a mountpoint
  if ! mountpoint -q /boot; then
    return 1

  [ -e /boot/config.txt ] || touch /boot/config.txt

  if [ "$1" -eq 0 ]; then # disable overscan
    sed /boot/config.txt -i -e "s/^overscan_/#overscan_/"
    set_config_var disable_overscan 1 /boot/config.txt
  else # enable overscan
    set_config_var disable_overscan 0 /boot/config.txt

do_overscan() {
  whiptail --yesno "What would you like to do with overscan" 20 60 2 \
    --yes-button Disable --no-button Enable 
  if [ $RET -eq 0 ] || [ $RET -eq 1 ]; then
    set_overscan $RET;
    return 1

do_change_pass() {
  whiptail --msgbox "You will now be asked to enter a new password for the pi user" 20 60 1
  passwd pi &&
  whiptail --msgbox "Password changed successfully" 20 60 1

do_configure_keyboard() {
  dpkg-reconfigure keyboard-configuration &&
  printf "Reloading keymap. This may take a short while\n" &&
  invoke-rc.d keyboard-setup start

do_change_locale() {
  dpkg-reconfigure locales

do_change_timezone() {
  dpkg-reconfigure tzdata

do_memory_split() {
  # Stop if /boot is not a mountpoint
  if ! mountpoint -q /boot; then
    return 1
  MEMSPLIT=$(whiptail --menu "Set memory split" 20 60 10 \
    "224" "224MiB for ARM, 32MiB for VideoCore" \
    "192" "192MiB for ARM, 64MiB for VideoCore" \
    "128" "128MiB for ARM, 128MiB for VideoCore" \
    3>&1 1>&2 2>&3)
  if [ $? -eq 0 ]; then
    cp -a /boot/arm${MEMSPLIT}_start.elf /boot/start.elf

do_ssh() {
  if [ -e /var/log/regen_ssh_keys.log ] && ! grep -q "^finished" /var/log/regen_ssh_keys.log; then
    whiptail --msgbox "Initial ssh key generation still running. Please wait and try again." 20 60 2
    return 1
  whiptail --yesno "Would you like the SSH server enabled or disabled?" 20 60 2 \
    --yes-button Enable --no-button Disable 
  if [ $RET -eq 0 ]; then
    update-rc.d ssh enable &&
    invoke-rc.d ssh start &&
    whiptail --msgbox "SSH server enabled" 20 60 1
  elif [ $RET -eq 1 ]; then
    update-rc.d ssh disable &&
    whiptail --msgbox "SSH server disabled" 20 60 1
    return $RET

do_boot_behaviour() {
  whiptail --yesno "Should we boot straight to desktop?" 20 60 2
  if [ $RET -eq 0 ]; then # yes
    update-rc.d lightdm enable 2
    sed /etc/lightdm/lightdm.conf -i -e "s/^#autologin-user=.*/autologin-user=pi/"
  elif [ $RET -eq 1 ]; then # no
    update-rc.d lightdm disable 2
  else # user hit escape
    return 1

do_update() {
  apt-get update &&
  apt-get install raspi-config &&
  printf "To start raspi-config again, do 'sudo raspi-config'. Now exiting\n"
  exit 0

do_finish() {
  if [ -e /etc/profile.d/raspi-config.sh ]; then
    rm -f /etc/profile.d/raspi-config.sh
    sed -i /etc/inittab \
      -e "s/^#\(.*\)#\s*RPICFG_TO_ENABLE\s*/\1/" \
      -e "/#\s*RPICFG_TO_DISABLE/d"
    telinit q
  if [ $ASK_TO_REBOOT -eq 1 ]; then
    whiptail --yesno "Would you like to reboot now?" 20 60 2
    if [ $? -eq 0 ]; then # yes
  exit 0

while true; do
  FUN=$(whiptail --menu "Raspi-config" 20 80 12 --cancel-button Finish --ok-button Select \
    "info" "Information about this tool" \
    "expand_rootfs" "Expand root partition to fill SD card" \
    "overscan" "Change overscan" \
    "configure_keyboard" "Set keyboard layout" \
    "change_pass" "Change password for 'pi' user" \
    "change_locale" "Set locale" \
    "change_timezone" "Set timezone" \
    "memory_split" "Change memory split" \
    "ssh" "Enable or disable ssh server" \
    "boot_behaviour" "Start desktop on boot?" \
    "update" "Try to upgrade raspi-config" \
    3>&1 1>&2 2>&3)
  if [ $RET -eq 1 ]; then
  elif [ $RET -eq 0 ]; then
    "do_$FUN" || whiptail --msgbox "There was an error running do_$FUN" 20 60 1
    exit 1
| improve this answer | |

Using sudo find / -name 'raspi-config!' is unnecessary. It searches the whole file system, and continues even after it finds a match. It's completely the wrong tool for the job.

Just use which raspi-config. It's more efficient.

| improve this answer | |
  • 2
    The commentary here re: the answer by @Steve Robillard is unnecessary and rude. Please keep your answer limited to what you can contribute, rather than denigrating other's efforts. After all, i did learn what I needed from him. – zenbike Jun 15 '13 at 17:05
  • 1
    Welcome to Stack Exchange John. I guess from your username that you are looking to troll. However, such behaviour is not welcome here. – Jivings Jun 16 '13 at 22:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.