How to clear /tmp manually?

0162

To clear the /tmp directory manually, you can use the following commands in the terminal. Make sure you have the necessary permissions to delete files in this directory.

  1. Open a terminal.

  2. Use the rm command to remove files and directories. Here are a few examples:

    • To remove all files in /tmp:

      sudo rm -rf /tmp/*
    • To remove files older than a certain number of days (e.g., 7 days):

      sudo find /tmp -type f -mtime +7 -exec rm {} \;
    • To remove empty directories in /tmp:

      sudo find /tmp -type d -empty -exec rmdir {} \;
  3. Verify the contents of /tmp after clearing:

    ls -la /tmp

Note: Be cautious when using the rm -rf command, as it will permanently delete files without confirmation. Always double-check the command before executing it.

0 Comments

no data
Be the first to share your comment!