Reset lost root password on Ubuntu 16.04 Xenial Xerus Linux

Reboot to Grub Menu

Press SHIFT after you start your computer until GRUB’s menu appears:



Edit Grub Menu

Once you reboot to Grub menu, select the first menu item or the menu item you normally use to boot your Ubuntu system and press e to edit:

Once in the Grub’s boot menu edit mode use navigation arrows to locate a line starting with linux and edit it to include or append read-write mode rw and init=/bin/bash.


Once ready press CTRL+x or F10 to boot.


Reseting root’s password

root@(none):/# mount | grep -w /

root@(none):/# passwd

Reboot System

Reboot your system using the following command:

root@(none):/# exec /sbin/init

Get Environment varibales in java

import java.util.Map;

public class TestDemo {

public static void main(String[] args) {

String user = System.getProperty(“”) ;  /*getting username using System.getProperty in Java */
System.out.println(“Username using system property: ”  + user);

String userWindows = System.getenv(“USERNAME”); /* getting username as environment variable in java, only works in windows */
System.out.println(“Username using environment variable in windows : ”  + userWindows);

//name and value of all environment variable in Java  program
Map<String, String> env = System.getenv();
for (String envName : env.keySet()) {
System.out.format(“%s=%s%n”, envName, env.get(envName));