1

I am usong Sony Xperia Z3 6603 with latest available android. When using the Terminal Emulator, by default, the shown username@device is some random jibberish@D6603. Copy below:

u0_a218@6603

I have fiddled around with the hostnames, since one was localhost and the other one was the wi-fi random generated one. Its the one in net.hostname and the /proc/sys/kernel/hostname, i havent touched the /etc/hosts since i think it will break something. I havent touched either build.prop for the same reason, i dont really know what depends on the ro.product.device. $PS1 gives different output than the shown username.

The question is, which values are safe for editing, and which one should be edited for the shown username?

  • The username is the UID of the terminal emulator app (not something one can change); the hostname is the device codename defined in build.prop (changing it affects all apps that detect device identity according to it). – Andy Yan Sep 23 '17 at 12:08
  • Thanks, i couldn't find information for some reason. Also, after i rebooted, proc/sys/kernel/hostname returned to localhost for some reason. Does it require unlocked bootloader or something? And what is meant by affecting all apps? – ku4eto Sep 23 '17 at 12:15
  • @AndyYan I beg to differ. The info shown by the terminal, plus a couple of custom functions, is defined inside /system/etc/mkshrc). To edit it, you need root privileges. – Death Mask Salesman Sep 23 '17 at 20:32
  • Hmm, I didn't trace deep enough, just trying to tell where the defaults are from. Now that I've read further on that (a related SE question here), it's looking good for what OP actually intends to ask (you should probably post an answer). Just one additional question: how about differentiating between root an non-root? I don't have good Linux knowledge so I can't see which element in the default PS1 string corresponds to that. – Andy Yan Sep 24 '17 at 1:24
  • ` if (( USER_ID )); then PS1='$'; else PS1='#'; fi PS4='[$EPOCHREALTIME] '; PS1='${| local e=$? (( e )) && REPLY+="$e|" return $e }$USER@$HOSTNAME:${PWD:-?} '"$PS1 " ` Thats the content i think i will have to edit. Question is, is it save (wont corrupt anything) and will it persist after reboot (in case of locked bootloader). – ku4eto Sep 24 '17 at 9:22

Your Answer

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

Browse other questions tagged or ask your own question.