Page cover image

raspi-config tool from the command line

Using raspi-config from the Command Line

raspi-config is a powerful configuration tool for Raspberry Pi that allows you to easily customize various settings. While it provides an interactive menu-driven interface, it can also be used non-interactively from the command line. This tutorial will guide you through using raspi-config from the CLI.

Basic Syntax

To use raspi-config from the command line, you need to use the following syntax:

sudo raspi-config nonint <command> <arguments>

Note that you need to use sudo because modifying system settings requires root privileges.

Examples

Here are some examples of commonly used raspi-config commands from the CLI:

Change the Hostname

To set the hostname of your Raspberry Pi, use the following command:

sudo raspi-config nonint do_hostname <hostname>

Replace <hostname> with the desired hostname for your Raspberry Pi.

Example:

sudo raspi-config nonint do_hostname mypi

Enable/Disable SSH

To enable or disable SSH access on your Raspberry Pi, use the following command:

sudo raspi-config nonint do_ssh <0/1>
  • Use 0 to enable SSH

  • Use 1 to disable SSH

Example:

sudo raspi-config nonint do_ssh 0

Change the Time Zone

To set the time zone on your Raspberry Pi, use the following command:

sudo raspi-config nonint do_change_timezone <timezone>

Replace <timezone> with the desired time zone.

Example:

sudo raspi-config nonint do_change_timezone America/New_York

Change the Locale

To set the locale on your Raspberry Pi, use the following command:

Copy codesudo raspi-config nonint do_change_locale <locale>

Replace <locale> with the desired locale.

Example:

sudo raspi-config nonint do_change_locale en_US.UTF-8

Enable/Disable VNC

To enable or disable the VNC server on your Raspberry Pi, use the following command:

sudo raspi-config nonint do_vnc <0/1>
  • Use 0 to enable VNC

  • Use 1 to disable VNC

Example:

sudo raspi-config nonint do_vnc 0

Expand Filesystem

To expand the filesystem to fill the entire SD card, use the following command:

sudo raspi-config nonint do_expand_rootfs

Note that this command will immediately start the partition expansion process without any confirmation.

Conclusion

Using raspi-config from the command line provides a convenient way to automate the configuration of your Raspberry Pi. By using the nonint option and the appropriate commands, you can easily modify various settings without the need for an interactive menu.

Remember to always use sudo when running raspi-config commands, as they require root privileges to modify system settings.

For a complete list of available commands and their usage, you can refer to the raspi-config documentation or run raspi-config with the --help option.

I hope this tutorial helps you effectively use raspi-config from the command line on your Raspberry Pi!

Last updated

Was this helpful?