Posted: . At: 11:49 PM. This was 7 years ago. Post ID: 3123
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.

Removing and creating files on UNIX/Linux and using the shred command.

The shred command on Linux is the perfect way to remove files securely from your Linux system. With a large amount of iterations, it will ensure that it is very difficult to get the data back. the -u parameter will delete the file after the overwriting process.

neo@deusexmachina:~$ shred -n 20 -u gegl-0.2.0.tar.bz2

To create a file on Linux, the touch command may be used. if you type touch myfile.txt it will create an empty file that you may then fill with text. Or this command: echo ” > myfile.txt. below is the most hackish way to create an empty file that you may then fill with text. Reading from /dev/null for once…

neo@deusexmachina:~/Desktop$ dd if=/dev/null bs=1 of=myfile.txt
0+0 records in
0+0 records out
0 bytes (0 B) copied, 1.2069e-05 s, 0.0 kB/s
neo@deusexmachina:~/Desktop$ ls myfile.txt 
-rw-r--r-- 1 neo neo 0  12-04-12 09:15 pm myfile.txt

That is why Linux is so cool, the fact that everything under /proc and /dev is a file and can be manipulated as a file can. That is one of the main strengths of a UNIX and Linux operating system. And the Macintosh operating system as well, because that runs on top of the Darwin UNIX OS.

Of course the rm command on UNIX/Linux is easy to use, the rm –no-preserve-root -rf / command is famous for being the one command you do not want to execute as the root user. But the rm -f command is perfect for removing files. Just be cautious when using the rm -rf command and double check the command you have typed and use the pwd command to see where you are before executing it.

Another way to create an empty file is this.

ubuntu ~ $ >foo.txt

This is the simplest way possible to create a file on Linux.

Then it may be erased very easily.

ubuntu ~ $ shred -n 20 -u foo.txt

Shows how easy the shell can be when you know a few tricks, makes Linux fun.

1 thought on “Removing and creating files on UNIX/Linux and using the shred command.”

Leave a Comment

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