Format python code automatically using autopep8 on ubuntu 16.04


For single python file:
find . -name 'filename.py' -exec autopep8 --in-place '{}' \;

-------------------------------------------------------------

For multiple python file using .py as extention:
find . -name '*.py' -exec autopep8 --in-place '{}' \;

		
Advertisements

Translate rwx Permission in to Octal Format in Linux- (Chmod command user)


This command provides the list of files with the permission

$ stat -c ‘%n %a’ *

%n means filename and %a means octal form of permissions

 

Output:

<filename> 755

<filename> 777

 

You can use this command also to display regular form of permssions.

$ stat -c ‘%n %a’ *

Output

<filename>  -r-rwxr-xr-x

<filename> -rw-r–r–

 

 

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:

grub-menu

 

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(“user.name”) ;  /*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));
}

}

}