临时目录/tmp
Linux有两个公知的临时目录:/tmp与/var/tmp
这两个目录被用户用于存储临时性的文件,亦经常被读写用户存储临时性数据。
两个目录没有本质上的区别,最根本的区别仅仅是系统对其中文件清理的默认时间配置不一致。
/tmp 目录默认清理10天未用的文件,系统重启会清空目录。
/var/tmp 目录默认清理30天未用的文件。
CentOS 6系统在/etc/cron.daily/tmpwatch
[root@db01 ~]# cat /usr/lib/tmpfiles.d/tmp.conf # This file is part of systemd. # # systemd is free software; you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as published by # the Free Software Foundation; either version 2.1 of the License, or # (at your option) any later version. # See tmpfiles.d(5) for details # Clear tmp directories separately, to make them easier to override v /tmp 1777 root root 10d v /var/tmp 1777 root root 30d # Exclude namespace mountpoints created with PrivateTmp=yes x /tmp/systemd-private-%b-* X /tmp/systemd-private-%b-*/tmp x /var/tmp/systemd-private-%b-* X /var/tmp/systemd-private-%b-*/tmp
如果/tmp目录被误删除了也没事,重建就可以了
[root@db01 ~]# mkdir -p /tmp [root@db01 ~]# chmod a+rwx,o+t /tmp [root@db01 ~]# ls -ld /tmp drwxrwxrwt. 9 root root 4096 Jan 13 03:47 /tmp
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· Docker 太简单,K8s 太复杂?w7panel 让容器管理更轻松!