This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | |||
fuss:unix [2015/12/20 20:18] – [Determine if Operating System is 32 or 64 bits] office | fuss:unix [2022/04/19 08:28] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Secure Remove Instead of Remove ====== | ||
+ | |||
+ | [[http:// | ||
+ | |||
+ | <code bash> | ||
+ | mv /bin/rm / | ||
+ | ln -sf / | ||
+ | </ | ||
+ | |||
+ | 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 [[unix: | ||
+ | |||
+ | ====== Wipe Free Space ====== | ||
+ | |||
+ | Virtual images can be shrunk by first zeroing out the free space available: | ||
+ | <code bash> | ||
+ | bcwipe -mz -F -S -v / | ||
+ | </ | ||
+ | and then by using a compression format such as [[https:// | ||
+ | |||
+ | <code bash> | ||
+ | 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: | ||
+ | <code bash> | ||
+ | smartctl -t short /dev/sda | ||
+ | </ | ||
+ | |||
+ | where ''/ | ||
+ | |||
+ | The process takes a few minutes, after which you can issue: | ||
+ | <code bash> | ||
+ | smartctl -l selftest /dev/sda | ||
+ | </ | ||
+ | |||
+ | to check the results. | ||
+ | |||
+ | The results will display, something like the following: | ||
+ | < | ||
+ | # 1 Short offline | ||
+ | |||
+ | </ | ||
+ | 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 '' | ||
+ | |||
+ | <code bash> | ||
+ | file -bi document.txt | ||
+ | </ | ||
+ | |||
+ | ====== Change File Encoding ====== | ||
+ | |||
+ | To convert a file '' | ||
+ | <code bash> | ||
+ | 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: | ||
+ | <code bash> | ||
+ | iconv -f utf8 -t ascii ouput.txt > input.txt | ||
+ | </ | ||
+ | unless we add the '' | ||
+ | <code bash> | ||
+ | iconv -c -f utf8 -t ascii ouput.txt > input.txt | ||
+ | </ | ||
+ | |||
+ | |||
+ | |||
+ | ====== Generate Unsalted MD5 Password Hash ====== | ||
+ | |||
+ | You can generate an MD5 password using '' | ||
+ | <code bash> | ||
+ | echo -n " | ||
+ | </ | ||
+ | where '' | ||
+ | |||
+ | ====== List Folder Contents with Octal Permissions ====== | ||
+ | |||
+ | Using '' | ||
+ | |||
+ | <code bash> | ||
+ | ls -l file | awk ' | ||
+ | </ | ||
+ | |||
+ | where '' | ||
+ | |||
+ | ====== Find Large Files ====== | ||
+ | |||
+ | The following command uses '' | ||
+ | <code bash> | ||
+ | du -h / | grep ^[0-9.]*G | sort -rn | ||
+ | </ | ||
+ | |||
+ | The same can be achieved in order to find folders over '' | ||
+ | <code bash> | ||
+ | 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: | ||
+ | <code bash> | ||
+ | getconf LONG_BIT | ||
+ | </ | ||
+ | will print '' | ||
+ | |||
+ | ====== Find Last Modified Files ====== | ||
+ | |||
+ | This can be accomplished using '' | ||
+ | <code bash> | ||
+ | find . -mtime -5 | ||
+ | </ | ||
+ | |||
+ | which will find the files that were modified since 5 days ago. | ||