The touch command ordinarily does not allow the user to create files with a filename like –rf, but if you want to really annoy someone then you may use this command to create one.
homer@debian:~$ touch -- '--rf ' |
And now you have a file named –rf.
-rw-r--r-- 1 homer homer 0 Jun 28 16:26 -rf |
This file cannot be easily deleted, the –rf is interpreted by rm as a command parameter.
Therefore, this trick is necessary to delete this file.
homer@debian:~/test$ rm -- -rf |
The --
parameter to rm signifies the end of command line parameters to the rm command. This allows you to delete this file. Below is another example.
homer@debian:~/test$ ls -hula total 24K -rw-r--r-- 1 homer homer 0 Jun 28 16:26 -- drwxr-xr-x 2 homer homer 4.0K Jun 28 18:07 . drwxr-xr-x 24 homer homer 4.0K Jun 28 17:59 .. -rw-r--r-- 1 homer homer 10K Jun 28 16:21 archive.tar -rw-r--r-- 1 homer homer 0 Jun 28 16:17 --checkpoint=1 -rw-r--r-- 1 homer homer 0 Jun 28 16:17 --checkpoint-action=exec=sh -rw-r--r-- 1 homer homer 0 Jun 28 16:26 -f -rw-r--r-- 1 homer homer 0 Jun 28 18:07 --rf -rwsr-sr-x 1 homer homer 26 Jun 28 16:21 shell.sh |
Use this command to delete this file.
homer@debian:~/test$ rm -- --rf |
This is very easy, you cannot create a file named .
though. But give this a try yourself and see how you go!