Home>Article>Operation and Maintenance> How to restore linux tmp files?
The
/tmp directory mainly contains temporarily needed files, which are used by different programs to create lock files and temporarily store data. Many of these files are important to currently running programs, and deleting them may cause your system to crash.
On all Linux systems, the contents of the /tmp directory are deleted (cleared) at boot time or when the local system is shut down. This is a standard procedure in system administration to reduce the storage space used (usually on a disk drive).
Important Tip: Do not delete files from the /tmp directory unless you know exactly what you are doing! In a multi-user system, this may delete active files, thus interrupting the user activities (through the programs they are using).
What if you accidentally delete the /tmp directory?
In this article, we will introduce how to restore (re-create) the /tmp directory after deleting it.
There are a few things to note before running the command below.
1./tmp must belong to the root user.
2. Set appropriate permissions to allow all users to use this directory (make it public).
$ sudo mkdir /tmp $ sudo chmod 1777 /tmp
Alternatively, run this command.
$ sudo mkdir -m 1777 /tmp
Now run the following command to check the permissions of the directory.
$ ls -ld /tmp
Recover deleted /tmp directory in Linux
The permission set here means that everyone (owner, group and others) Files in the directory can be read, written, and accessed, and the t (sticky bit) indicates that the file can only be deleted by the owner.
Note: Once the /tmp directory shown above is restored, it is recommended to restart the system to ensure that all programs can run normally.
The above is the detailed content of How to restore linux tmp files?. For more information, please follow other related articles on the PHP Chinese website!