fchmod() Instead of chmod(), use fchmod() whenever possible Open file for reading use fchmod() close file fchown() and fchmod() are not necessary when you are in a directory where You are the only one with write permission, or The sticky bit is set Of course, it's always better to be safe than sorry What if the file permissions of the dir change? What if you use this code in a directory that isn't sticky/etc?