Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
fuss:unix [2015/08/28 08:46]
office [Find Large Files]
fuss:unix [2017/02/22 18:30] (current)
Line 1: Line 1:
 +====== Secure Remove Instead of Remove ======
 +
 +[[http://​srm.sourceforge.net/​|srm]] is a multi-pass overwrite and secure delete tool designed to be backward compatible with ''​rm''​. The tool is already present on OSX.
 +
 +<code bash>
 +mv /bin/rm /​usr/​bin/​rm.insecure
 +ln -sf /​usr/​bin/​srm /bin/rm
 +</​code>​
 +
 +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:​system-wide_secure_remove|system-wide secure remove page]].
 +
 +====== Wipe Free Space ======
 +
 +Virtual images can be shrunk by first zeroing out the free space available:
 +<code bash>
 +bcwipe -mz -F -S -v /
 +</​code>​
 +and then by using a compression format such as [[https://​people.gnome.org/​~markmc/​qcow-image-format.html|qcow2]] supported by ''​qemu'':​
 +
 +<code bash>
 +qemu-img convert -O qcow2 image.raw image.qcow2
 +</​code>​
 +
 +====== Use S.M.A.R.T. To run a Hard-Drive Test ======
 +
 +To schedule a test, issue:
 +<code bash>
 +smartctl -t short /dev/sda
 +</​code>​
 +
 +where ''/​dev/​sda''​ is the device to run the test on.
 +
 +The process takes a few minutes, after which you can issue:
 +<code bash>
 +smartctl -l selftest /dev/sda
 +</​code>​
 +
 +to check the results.
 +
 +The results will display, something like the following:
 +<​code>​
 +# 1  Short offline ​      ​Completed without error       ​00% ​    ​11482 ​        -
 +
 +</​code>​
 +in case the tested completed without errors, or:
 +
 +<​code>​
 +# 1 Short offline Completed: read failure 90% 23678 200910
 +
 +</​code>​
 +
 +to indicate failures.
 +
 +====== Show File Encoding ======
 +
 +To determine the encoding of the file ''​document.txt'',​ issue:
 +
 +<code bash>
 +file -bi document.txt
 +</​code>​
 +
 +====== Change File Encoding ======
 +
 +To convert a file ''​input.txt''​ from ASCII to a new file ''​output.txt''​ with UTF-8 encoding, issue:
 +<code bash>
 +iconv -f ascii -t utf8 input.txt > output.txt
 +</​code>​
 +
 +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
 +</​code>​
 +unless we add the ''​-c''​ flag that strips non-ASCII characters:
 +<code bash>
 +iconv -c -f utf8 -t ascii ouput.txt > input.txt
 +</​code>​
 +
 +
 +
 +====== Generate Unsalted MD5 Password Hash ======
 +
 +You can generate an MD5 password using ''​md5sum''​ and ''​echo -n'':​
 +<code bash>
 +echo -n "​mypassword"​ | md5sum
 +</​code>​
 +where ''​mypassword''​ is the password to hash.
 +
 +====== List Folder Contents with Octal Permissions ======
 +
 +Using ''​awk'':​
 +
 +<code bash>
 +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}'​
 +</​code>​
 +
 +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:
 +<code bash>
 +du -h / | grep ^[0-9.]*G | sort -rn
 +</​code>​
 +
 +The same can be achieved in order to find folders over ''​100MB'':​
 +<code bash>
 +du -h / | grep ^[1-9][0-9][0-9][0-9.]*M | sort -rn
 +</​code>​
 +
 +====== Determine if Operating System is 32 or 64 bits ======
 +
 +The command:
 +<code bash>
 +getconf LONG_BIT
 +</​code>​
 +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'':​
 +<code bash>
 +find . -mtime -5
 +</​code>​
 +
 +which will find the files that were modified since 5 days ago.
  

fuss/unix.txt ยท Last modified: 2017/02/22 18:30 (external edit)

Access website using Tor Access website using i2p


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