Secure Remove Instead of Remove

srm is a multi-pass overwrite and secure delete tool designed to be backward compatible with rm. The tool is already present on OSX.

mv /bin/rm /usr/bin/rm.insecure
ln -sf /usr/bin/srm /bin/rm

Moving files is not sufficient. The best way to make sure that a file is deleted is to copy the file and then wipe the old copy. It should be noted that deletion operations will take much longer and may impose stress on other software. For a better solution, please see the system-wide secure remove page.

Wipe Free Space

Virtual images can be shrunk by first zeroing out the free space available:

bcwipe -mz -F -S -v /

and then by using a compression format such as qcow2 supported by qemu:

qemu-img convert -O qcow2 image.raw image.qcow2

Use S.M.A.R.T. To run a Hard-Drive Test

To schedule a test, issue:

smartctl -t short /dev/sda

where /dev/sda is the device to run the test on.

The process takes a few minutes, after which you can issue:

smartctl -l selftest /dev/sda

to check the results.

The results will display, something like the following:

# 1  Short offline       Completed without error       00%     11482         -

in case the tested completed without errors, or:

# 1 Short offline Completed: read failure 90% 23678 200910

to indicate failures.

Show File Encoding

To determine the encoding of the file document.txt, issue:

file -bi document.txt

Change File Encoding

To convert a file input.txt from ASCII to a new file output.txt with UTF-8 encoding, issue:

iconv -f ascii -t utf8 input.txt > output.txt

since UTF-8 contains characters that cannot be encoded with ASCII, the reverse command will generate errors:

iconv -f utf8 -t ascii ouput.txt > input.txt

unless we add the -c flag that strips non-ASCII characters:

iconv -c -f utf8 -t ascii ouput.txt > input.txt

Generate Unsalted MD5 Password Hash

You can generate an MD5 password using md5sum and echo -n:

echo -n "mypassword" | md5sum

where mypassword is the password to hash.

List Folder Contents with Octal Permissions

Using awk:

ls -l file | awk '{k=0;for(i=0;i<=8;i++)k+=((substr($1,i+2,1)~/[rwx]/) *2^(8-i));if(k)printf("%0o ",k);print}'

where file is a file to query.

Find Large Files

The following command uses du to report the size of folders for the entire system while reporting folders containing over 1GB of data:

du -h / | grep ^[0-9.]*G | sort -rn

The same can be achieved in order to find folders over 100MB:

du -h / | grep ^[1-9][0-9][0-9][0-9.]*M | sort -rn

Determine if Operating System is 32 or 64 bits

The command:

getconf LONG_BIT

will print 32 or 64 depending on whether it is a 32 or 64 bit machine.

Find Last Modified Files

This can be accomplished using find:

find . -mtime -5

which will find the files that were modified since 5 days ago.


fuss/unix.txt ยท Last modified: 2022/04/19 08:28 by 127.0.0.1

Access website using Tor Access website using i2p Wizardry and Steamworks PGP Key


For the contact, copyright, license, warranty and privacy terms for the usage of this website please see the contact, license, privacy, copyright.