How to set system wide umask?

Both Debian and Ubuntu ship with pam_umask. This allows you to configure umask in /etc/login.defs and have them apply system-wide, regardless of how a user logs in. To enable it, you may need to add a line to /etc/pam.d/common-session reading session optional pam_umask.so or it may already be enabled. Then edit /etc/login.defs and change the … Read more

java set file permissions to 777 while creating a file object [duplicate]

Java SE 7 has java.nio.file.attribute.PosixFileAttributes which gives you fine grained control over read, write, and execute permissions for owner, group, and others. import java.nio.file.*; import java.nio.file.attribute.*; import java.util.Set; public class Test { public static void main(String[] args) throws Exception { Path path = Paths.get(“/tmp/test-file.txt”); if (!Files.exists(path)) Files.createFile(path); Set<PosixFilePermission> perms = Files.readAttributes(path,PosixFileAttributes.class).permissions(); System.out.format(“Permissions before: %s%n”, PosixFilePermissions.toString(perms)); … Read more