How can I remove all strings from tar file in Linux?

I created a tar.gz file using tar -cf file_1.tar command. But, when I use strings file_1.tar, I see:

file
0000644
0001750
0001750
00000000000
014545
ustar  
arian
arian

How can I remove them?


Solution 1:

strings represents any plain text within the binary file, you should encrypt your tar file to hide its contents.

You can either use GPG with tar directly, like in this answer.

Encrypt:

tar czvpf - file1.txt file2.pdf file3.jpg \
 | gpg --symmetric --cipher-algo aes256 -o myarchive.tar.gz

Decrypt:

gpg -d myarchive.tar.gz.gpg | tar xzvf -

Or you might want to consider storing your tar file using p7zip, which could be useful for compatibility with other operating systems using p7zip or 7-Zip. The reason you recompress the tar file is to preserve the unix permissions that ZIP files don't have compatibility for.

Install it first

sudo apt install p7zip-full

Encrypt:

7z a -p -mx=0 -mhe -t7z test.7z test.tar

When you run the encrypt command a prompt will ask you for the password you want to use.

Decrypt:

7z x test.7z

For more info on what these switches mean, see this guide.