Date: 2011mar8
OS: Linux
Q. Linux: What permissions should the /tmp folder have and how do I set it?
A. On a properly set up system
ls -ld /tmp /var/tmp
will yield
drwxrwxrwt. 13 root root 40960 Mar 8 11:47 /tmp/
drwxrwxrwt. 2 root root 4096 Mar 8 01:11 /var/tmp/
If your folders (directories) don't have these permissions, correct them like
this:
chmod a+rwxt /tmp /var/tmp
The t is a special flag for temporary folders. Chmod's man page says:
The restricted deletion flag or sticky bit is a single bit, whose
interpretation depends on the file type. For directories, it prevents
unprivileged users from removing or renaming a file in the directory
unless they own the file or the directory; this is called the
restricted deletion flag for the directory, and is commonly found on
world-writable directories like /tmp. For regular files on some older
systems, the bit saves the program's text image on the swap device so
it will load more quickly when run; this is called the sticky bit.