Facebook Twitter Instagram Pinterest YouTube
    Trending
    • Elecrow Meteor IPS Touchscreen with RGB LEDs
    • Pi Pico Pinout Display on the Command Line
    • How to Add a Raspberry Pi Pico Reset Button
    • Pi Pico Onboard LED
    • Pi Pico W Pinout and Power Pins
    • CrowPi L Raspberry Pi Laptop and Learning Platform
    • Pi Pico W Launched
    • Add Kodi to RetroPie Menu
    Facebook Twitter Instagram Pinterest YouTube RSS
    Raspberry Pi SpyRaspberry Pi Spy
    • Home
    • Categories
      • General
      • Hardware
      • Programming
      • Python
      • Software
      • Tutorials & Help
    • BerryClip
      • BerryClip Instructions
      • BerryClip Plus Instructions
      • Videos & Reviews
    • Buy
      • Buy Pi
      • Buy Pi Accessories
      • Buy Books
    • Tools
      • Ultimate Raspberry Pi Alexa Skill
      • Pi Power Estimator App
      • Pi-Lite 14×9 LED Matrix Sprite Editor
      • RPiREF Pin-out Reference App
      • Simple Ohm’s Law Calculator
      • Web Sites & Links
    • Tutorials & Help
        Featured
        November 9, 20200

        Raspberry Pi Temperature Monitoring

        Recent
        December 23, 2022

        How to Add a Raspberry Pi Pico Reset Button

        November 20, 2022

        Pi Pico Onboard LED

        May 6, 2022

        Add Kodi to RetroPie Menu

      1. Contact Us
      2. Site Map
      Raspberry Pi SpyRaspberry Pi Spy
      You are at:Home»Tutorials & Help»How to Change the Raspberry Pi Hostname
      Raspberry Pi Blueprint

      How to Change the Raspberry Pi Hostname

      2
      By Matt on May 27, 2012 Tutorials & Help

      By default the Raspberry Pi has its hostname set to “raspberrypi”. This appears as part of the command prompt when you open a terminal window. It only takes a few minutes and you’ve got a choice of two methods.

      I sometimes change the hostname so that when I list devices on my home network I can easily identify any Raspberry Pis I’ve got connected amongst all the phones, tablets and PCs.

      Method 1 – Using raspi-config

      From the command line (or terminal if you are using the desktop) type :

      sudo raspi-config

      From the menu select “Hostname”.

      Read the notes and select “OK”.

      Enter your required hostname and select “OK”.

      Select “Finish”.

      When prompted to reboot select “Yes”.

      Your Pi will reboot and will now have your new hostname.

      Method 2 – Editing Files Manually

      From the command line (or terminal if you are using the desktop) type :

      sudo nano /etc/hostname

      followed by ENTER. Type the hostname you require and using the menu save the file and exit.

      Then type :

      sudo nano /etc/hosts

      followed by ENTER. Replace all instances of the old hostname (e.g. “raspberrypi”) with the new hostname that you entered above. As an example I changed my hostname to “pi2” so my file looks like this :

      127.0.0.1 localhost
      ::1 localhost ip6-localhost ip6-loopback
      fe00::0 ip6-localnet
      ff00::0 ip6-mcastprefix
      ff02::1 ip6-allnodes
      ff02::2 ip6-allrouters
      
      127.0.1.1 pi2

      Save the file. Then you can either reboot by typing :

      sudo reboot

      followed by ENTER or simply restart the hostname process by typing :

      sudo /etc/init.d/hostname.sh start

      followed by ENTER.


      The hostname as been changed. You new hostname will now be visible in the command prompt when you open a new terminal window.

      Please ensure you choose a hostname that only contains upper and lower case letters, numbers and the “-” character.

      Share. Facebook Twitter Pinterest LinkedIn Tumblr Email
      Previous ArticleRaspberry Pi Cables & Connectors
      Next Article Send Text and HTML Email Using Python on the Raspberry Pi

      Related Posts

      How to Add a Raspberry Pi Pico Reset Button

      Pi Pico Onboard LED

      Add Kodi to RetroPie Menu

      2 Comments

      1. Andy on May 31, 2012 8:30 pm

        Just a note: a hostname can also have numbers (0-9) in it as well as letters (uppercase and lowercase) and the dash “-” character. So “Host-01”, “host-01” and “host01” are all valid for example.

        Reply
        • Matt on May 31, 2012 9:03 pm

          Thanks for the update. I’ll modify my text.

          Reply

      Leave A Reply Cancel Reply

      This site uses Akismet to reduce spam. Learn how your comment data is processed.

      Recent Posts
      March 13, 2023

      Elecrow Meteor IPS Touchscreen with RGB LEDs

      December 26, 2022

      Pi Pico Pinout Display on the Command Line

      December 23, 2022

      How to Add a Raspberry Pi Pico Reset Button

      November 20, 2022

      Pi Pico Onboard LED

      November 14, 2022

      Pi Pico W Pinout and Power Pins

      Categories
      • 1-wire
      • 3D Printing
      • Add-ons
      • BBC Micro:bit
      • BerryClip
      • Books
      • Camera Module
      • Cases
      • Events
      • General
      • Hardware
      • I2C
      • Infographics
      • Interfaces
      • Minecraft
      • Model A+
      • Model B+
      • News
      • Pi Models
      • Pi Pico
      • Pi Zero
      • Power
      • Programming
      • Python
      • Raspberry Pi OS
      • Raspbian
      • RetroGaming
      • Robotics
      • Sensors
      • Software
      • SPI
      • Tutorials & Help
      Tags
      Arduino audio battery berryclip Birthday bluetooth cambridge camera CamJam DigiMakers display games GPIO I2C interface Kickstarter Kodi LCD LED Linux media Minecraft Model A motionEyeOS PCB photography photos Pi-Lite Pi Pico power python Raspberry Jam Raspberry Pi Bootcamp raspbian Retrogaming retroPie screen SD card security sensor SPI SSH temperature ultrasonic video
      Raspberry PI Related
      • Adafruit Blog
      • Average Maker
      • Official RaspBerry Pi Site
      • Raspberry Pi Pod
      • RasPi.tv
      • RaspTut
      • Stuff About Code
      Tech Resources
      • MattsBits – Pi Resources
      • Microbit Spy
      • Technology Spy
      Archives
      About

      Unofficial site devoted to the Raspberry Pi credit card sized computer offering tutorials, guides, resources,scripts and downloads. We hope to help everyone get the most out of their Pi by providing clear, simple articles on configuring, programming and operating it.

      Popular Posts
      September 19, 2014

      Top 5 Reasons The Raspberry Pi Sucks

      July 27, 2012

      16×2 LCD Module Control Using Python

      October 20, 2013

      Analogue Sensors On The Raspberry Pi Using An MCP3008

      Recent Posts
      March 13, 2023

      Elecrow Meteor IPS Touchscreen with RGB LEDs

      December 26, 2022

      Pi Pico Pinout Display on the Command Line

      December 23, 2022

      How to Add a Raspberry Pi Pico Reset Button

      Facebook Twitter Instagram Pinterest YouTube RSS

      Entries RSS | Comments RSS

      This site is not associated with the official Raspberrypi.org site or the Raspberry Pi Foundation. Raspberry Pi is a trademark of the Raspberry Pi Foundation.

      Copyright © 2022 - All Rights Reserved - Matt Hawkins

      mastodon.social@RPiSpy

      Type above and press Enter to search. Press Esc to cancel.