Bash – Purposely corrupt folder name

bashcorruption

I want to intentionally corrupt a folder name so I can test a script on it.

Currently the folders are named similar to :
37ee0500-52c0-4a18-861e-0084EF05FB

and are located in: /user/members/local/

I'd like to make it so the name is corrupt, so I can't cd into the folder, rename it or delete it.

Any ideas how I can do that ?

Thanks

Best Answer

Providing you're not running the tests as root I don't think you need to corrupt the filename do do these tests

  • Use chmod to remove execute permission, this will disable traverse so you can't cd into it.
  • use chattr to make the directory immutable. You won't be able to rename or delete it.

If you are using root

  • Don't do that.

If you think about it for a moment, if you corrupt the directory name, the reason why you can't interact with it is likely because you're passing the name incorrectly so you're actually trying to interact with the wrong entry. This leads to another possible solution ...