Posted: . At: 3:40 PM. This was 2 years ago. Post ID: 16541
Page permalink. WordPress uses cookies, or tiny pieces of information stored on your computer, to verify who you are. There are cookies for logged in users and for commenters.
These cookies expire two weeks after they are set.


Some very interesting and evil shell tricks.


It is possible to create a file with a blank filename in the standard Linux shell. To do this, type this command out.

jason@jason-Lenovo-H50-55:~$ strace touch '​‏'

Then in between the single quotes, press Control-Shift-U and then type 200f and press ENTER, this creates a file with a blank file name.

-rw-rw-r--  1 jason jason    0 Aug 25 14:44 ​‏
-rw-rw-r--  1 jason jason    0 Aug 25 13:00 ​.​
drwxr-xr-x 24 jason jason 4.0K Aug 25 14:44 .
drwxr-xr-x  4 root  root  4.0K Aug 23 10:10 ..

As you can see in the directory listing above, this created a file with a blank file name. But it is easy to delete this file, just use the command below.

Use the command ls -li to list files including the inode value.

jason@jason-Lenovo-H50-55:~$ ls -hulai
total 19M
55838358 -rw-rw-r--  1 jason jason    0 Aug 25 14:44 ​‏
55838354 -rw-rw-r--  1 jason jason    0 Aug 25 13:00 ​.​
55838274 drwxr-xr-x 24 jason jason 4.0K Aug 25 14:44 .
55836673 drwxr-xr-x  4 root  root  4.0K Aug 23 10:10 ..
55838278 -rw-rw-r--  1 jason jason  16M Sep 15  2020 annex.Altis.pbo
55838352 -rw-------  1 jason jason  14K Aug 25 10:32 .bash_history
55838277 -rw-r--r--  1 jason jason  220 Aug 22 19:38 .bash_logout
55838284 -rw-r--r--  1 jason jason 3.8K Aug 24 12:28 .bashrc

Then you may use the inode value to delete this file.

jason@jason-Lenovo-H50-55:~$ find . -inum 55838358 -exec rm -i {} \;
rm: remove regular empty file './​‏'? y

I don’t think you can create a file that does not have an inode value, so it is always possible to delete a file irrespective of the filename. But you can not create a file with a / in the filename, there are protections to prevent this.


Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.