Command Line, Linux




grep without filenames

I needed to grep a directory, and sub directories, and not displaying the filenames in the output. This is when the man page came to the rescue. man grep | grep filename Output -H, --with-filename -h, --no-filename There we go, -h, --no-filename, is what I needed. Example with output to a …



How to check cp progress after cp has started

First, the easier way to do this is to use rsync in the first place. rsync -avh --progress sourceDirectory destinationDirectory However, sometime you think cp will be quick and you already kicked it off. Here is a quick way to check the progress of a copy command after you've already …



Ubuntu Command line Display Driver Change

Recently upgraded to 15.10 and that looked okay at first. However, the displa driver that it installed, NVIDIA, was causing issues. So I defaulted back to the open source driver and reboot. MISTAKE! Ended up causing the system to crash and couldn't do anything about it. I rebooted into …



How to find large volumes on linux

Running linux machines sometimes it's needed to figure out what is taking up a large amount of room on a server. Here's an easy way to investigate large directories. du -h <dir> | grep '\[0-9:::.\]+G'



7z file encryption with password

Previously I've transferred file with a pgp key, but this is an ok alternative. 7za a -tzip -psuperSecurePassword -mem=AES256 filename.zip file.doc file1.doc file2.doc You can also checkout the easier and more supported zip method.



Password protect a zip file

Sometime a simple encrypt with a password is needed. This isn't the most secure method (7z provides more secure methods), but is better than nothing. I simple way to do it is to create a zip password protected with all the files. zip --password yourpassword filename.zip file.doc file1 …



How to set a password on pdf in Ubuntu

This one is super simple. sudo apt-get install pdftk pdftk input-file.pdf output output-file.pdf userpw mysupersecretpassword



Move files while preserving timestamps

A quick way to move files in linux while keeping their timestamps. In short mv doesn't support this. The work around is to copy instead. cp -p -r -l source/date target/ rm -rf source/data



Convert pdf to png easily

I need to quickly convert odfs to image for both online processing and one off processing. Luckily imagemagick had me covered for both. First install imagemagick: sudo apt-get install imagemagick Then use the convert function to do the work: convert example.pdf example.png This will append ## to the file …



How to do decrypt a pgp message

After sending my public pgp key and getting an encoded message back. I need to decrypt a pgp message. I made a pgp file by opening a text editor and saving it as "mypgpfile.pgp" gpg -o output.txt mypgpfile.pgp The breakdown: gpg - the command to encode/decode pgp …