Linux Delete Directory Compressed files

Source: Internet
Author: User
Tags rar tmp folder

"Project Requirements":

The Samba server shares the/tmp/folder, where anyone can write files, but prevents the following files from being written to:

  • rar,zip,tar,gz,7z file.

  • Windows Exe,com,bat executable file

You cannot write to the/tmp folder after you change the file name extension.

Using the shell to detect subfolders in/tmp/, the above files are immediately deleted.

"Solution ideas":

  1. The query file name contains RAR files, but cannot be probed after renaming to Doc.

  2. With the Linux file command, you can directly probe the file type, even if the change file name is detectable.

"Solution":

#!/bin/bashwhile:d ORM-RF $ (file $ (find/tmp/) | egrep "Archive | gzip | Tar | Windows | DOS "| Awk-f ': ' {print $} ') Sleep 1done

The script can be executed on the boot

This article is from "Knowledge change Fate technology Change Life" blog, please be sure to keep this source http://leoshi.blog.51cto.com/152597/1697574

Linux Delete Directory Compressed files

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.