Published On: October 13, 2012|Categories: Linux|Tags: , |

Most of the ROMs (except CM) whether it be stock or any, don’t have a setting to change the host name of your Android device. Read on to know how to change it.

When you have a common wifi network between your desktop and mobile, it rather makes sense to have a proper host name for your phone instead of accessing it every time by the IP address. This is typically useful if you want to control your phone from your control using AirDroid for example. Chat using Texts. While most routers have an option to set host name for a specific MAC ID, but on some networks you might not have control, for example your office network.

The process is very simple, but you need a rooted device. If you have not rooted it yet, check XDA forums. I can’t help you in that. Also, you would need the Android SDK (mainly adb and the device drivers for your phone).

  • Turn on USB Debugging in developer options.

android_usb_debugging

  • Connect it to your computer
  • Open terminal
  • Run adb pull /system/build.prop
  • Now edit build.prop (saved in the directory you executed the command) and add the following line:
  • Run adb push build.prop /sdcard (or /mnt/sdcard, if it fails).
  • Run adb shell and type the following commands:
  • Run adb reboot.
  • Enjoy

31 Comments

  1. fabiofava December 29, 2019 at 8:23 AM - Reply

    Your Hollyness! I’ve been looking for this since a long! Thanks! Any clue to change it on a new Android 9 Phone (Moto G8 Plus) without having to unlock bootloader? I don’t want to lose warranty but having no name on the DCHP Lease it’s not cool. Cheers!

    • nilesh December 29, 2019 at 8:26 AM

      A lot has changed in android since I wrote this article nearly 7 years ago… So I don’t know if this even works now.

      Some devices these days let you set the hostname sent to DHCP in About section..

      It might be just easier to bind the mac address to hostname in the DHCP server if have a DHCP server with editable configuration.

    • fabiofava January 29, 2020 at 12:50 AM

      Still works for Lollipop and Marshmellow! Cheers!

  2. BWNstudios January 11, 2019 at 12:00 PM - Reply

    Very Nice article. it helps a lot.

  3. restpeace September 3, 2015 at 12:59 AM - Reply

    Work fine on my Acer E2 Duo

  4. Mikel May 12, 2015 at 7:50 AM - Reply

    Tres Bien!

  5. Georgi Vidinski June 5, 2014 at 1:00 AM - Reply

    Very useful article!

  6. tyl85 June 4, 2014 at 6:16 PM - Reply

    Worked on XPERIA Z1 , CHINA TABLET A13 (rom MAXPAN 713) (used totalcommander with root privileges to copy/edit buildprop file without adb)

    • S7eele October 7, 2014 at 10:07 AM

      Am trying to figure out whether I really need adb at all with a rooted device, busybox, superuser and a file editor and terminal emulator. I might need to hook up a usb keyboard but with that I should be good to go editing everything locally, right?

      Well, seeing your response above gives me hope that it is as I think it should be and I can edit things like the hosts file locally, on the Ouya.

    • nilesh October 7, 2014 at 10:17 AM

      You need at least root if the ROM provided by OEM does not support it directly. Try enabling developer mode, it’s sometimes present there (at least it is there on CM based ROMs).

  7. Andrew January 19, 2014 at 11:21 AM - Reply

    You need to edit th adb push command to /mnt/sdcard/

    You left off the last slash.

    • nilesh January 23, 2014 at 7:52 AM

      Differs from phone to phone. Some phones mount sdcard at /mnt/sdcard and create a link to it at /sdcard. While some mount directly at /sdcard.

  8. Shankar Valleru September 2, 2013 at 4:37 PM - Reply

    Install the BuildProp Editor app and add the net.hostname key-value pair, It’s way easier and fast !

    • nilesh September 2, 2013 at 5:07 PM

      Yeah, that is one way and better too. I did not know about the editor when I wrote this

  9. danielmilloy May 24, 2013 at 1:49 AM - Reply

    Excellent. I used the Build Prop Editor app from JRummy (https://play.google.com/store/apps/details?id=com.jrummy.apps.build.prop.editor) and I added the property painlessly to my build.prop on AHRD ROM. Rebooted, and voila!

  10. setpropers May 7, 2013 at 4:22 PM - Reply

    Adb shell
    $ su
    # setprop net.hostname DESIRED.HOST.NAME

    • tyl85 June 4, 2014 at 6:30 PM

      it works, but you have to do this on each reboot

  11. Guest April 14, 2013 at 7:20 AM - Reply

    Alternatively, you can use this once you’ve edited the build.prop file
    adb root (this restarts adbd as root)
    adb remount (this makes reading/writing from the /system area possible)
    adb push build.prop /system/build.prop

  12. Browner87 April 2, 2013 at 6:42 PM - Reply

    Thank you for this. I knew it had to be in a config somewhere. My Nexus 4 was already rooted so i just downloaded a terminal app, granted it sudo rights with SuperSu, mounted as writable, made a backup copy of the file, added that line to the end (without the angle brackets) in vi, then saved and re-mounted and rebooted my phone and it worked perfect. Thanks a ton for the writeup! Although i might not suggest this to newbies to programming. If your phone “won’t boot” then you must likely made a simple mistake. But if you didn’t backup the file and you don’t know how to restore it from a terminal in fast-boot mode, then you could be toast.

  13. Eleazar December 14, 2012 at 5:13 AM - Reply

    also messed up my phone… T989 with ICS… won’t boot. What has this been tested on?

    • nilesh December 14, 2012 at 5:19 AM

      It works on both my Sony devices: Xperia S and Xperia Mini Pro. Both the stock ROMs.

    • Eleazar December 14, 2012 at 5:28 AM

      hmm, i edited it with wordpad, and i think it changed the line breaks… maybe thats it?

    • nilesh December 14, 2012 at 5:34 AM

      Quite likely.

  14. Jeffrey Thompson December 10, 2012 at 7:15 PM - Reply

    Hey, thanks for the tips. I recently found a more detailed tutorial for this a while back:http://blog.burrowsapps.com/2011/09/android-change-hostname.html.

    Shows you how to use SQLite3.

    • nilesh December 11, 2012 at 1:58 AM

      I’d definitely come across that when I searched around, but it seemed too complex.

      The build.prop trick works great on most roms.

  15. Devian50 October 14, 2012 at 6:37 AM - Reply

    This fucked up my phone. It wouldn’t be able to get past the company branding of my carrier. >.> Thanks a lot. replacing the original build.prop won’t fix shit either.

    • nilesh October 14, 2012 at 6:43 AM

      Ouch. The simplest solution for you now would be to get your phone’s ftf from xda and flash it. You would need titanium backup for backup and restore your data.

      But the funniest part is how it didn’t work for you. I did this on two phones of mine and it worked for me.

      If you have CWMR (or any other recovery), try wiping dalvik cache and reboot. It should solve the problem.

    • Isaac Parker April 14, 2013 at 7:06 AM

      Perhaps this had to do with the end line character? I’m just brainstorming here but if this is done on a Windows machine perhaps this^ build.prop had incompatible characters?
      EDIT: Looks like someone mentioned this further down in the comments

    • nilesh April 14, 2013 at 7:16 AM

      Possibly. Windows adds rn at the end of lines, while Linux uses just n. And most of the times, they’re not compatible with each other.

    • Joe Kemp August 21, 2013 at 2:27 AM

      I had the same problem as you. The issue turned out to be caused by the permissions on the file I pushed. it should be -rw-r–r– not -rw-rw-r–

  16. Michael Mol October 13, 2012 at 6:16 PM - Reply

    Excellent.

Comments

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