# make a drive image
sudo bash -c "pv -EE /dev/sdX >my_disk.img"
# make a compressed drive image
sudo bash -c "pv -EE /dev/sdX | gzip >my_disk.img.gz"
Wednesday, May 17, 2017
Drive images with progress indication
Sunday, May 1, 2016
Ubuntu-Gnome 16.04 on Thinkpad x230
This is mostly for myself, but perhaps someone else might get some ideas from it..
Tuesday, April 26, 2016
Edit gnome settings with your favorite editor
Using the vipe command, we can read from stdin, edit the contents in the default editor and send it down the pipe.
Saturday, March 26, 2016
find files from a certain date range in linux
When you need to find a file from a specific range of dates, like a reciept that you know you saved but can't remember where.. You can use the find command along with some parameters to find files newer than a specific date, older or between two dates.
Bash one-liner to fix "Failed to fetch" error for chrome in ubuntu
See this page for details on how an why, but here's the error:
W: Failed to fetch http://dl.google.com/linux/chrome/deb/dists/stable/Release:
Unable to find expected entry 'main/binary-i386/Packages'
in Release file (Wrong sources.list entry or malformed file)
And this will fix it in one shot:
sudo sed -i 's?deb http://dl.google.com/linux/chrome/deb/ stable main?deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main?g' /etc/apt/sources.list.d/google-chrome.list
Saturday, March 12, 2016
Kill an ssh connection from the server side
So you don't like Bob today or maybe you want to test a failed connection.. Whatever your reason you need to kill the ssh connections for his user on your server.
Tuesday, January 26, 2016
Make better bash scripts for yourself (and others)
When you write a bash script, there's a few things you can do to make your life (and anyone else who uses it) a lot better. Here's a few of the things that I (try) to do when I write scripts to make it easier to use and less error prone.
Tuesday, October 14, 2014
Installing HL2270-DW on Ubuntu / elementary Linux
Download and install these packages:
#!/bin/bash wget --output-document=cupswrapperHL2270DW-2.0.4-2.i386.deb 'http://goo.gl/mw87o6' && wget --output-document=hl2270dwlpr-2.1.0-1.i386.deb 'http://goo.gl/8ixmvt' sudo dpkg -i cupswrapperHL2270DW-2.0.4-2.i386.deb hl2270dwlpr-2.1.0-1.i386.deb
Follow the instructions from the Archwiki Page:
- Open a web browser to http://localhost:631/
- Click the Administration tab then click the Add Printer button. The username is "root" and the password is the root password of the user's computer.
- Select IPP from the list.
- In the 'Connection' field, type ipp://THE_PRINTER_IP/ipp/port1
- In the next form, give the printer a unique name (no spaces and the name be must unique from any identical printers), and select "Brother" from the printer make field.
- Select "Brother HL2270DW for CUPS (en)" from the list of drivers (it is not in numerical order and is toward the bottom of the list).
- Configure the default options on the next page to your liking
Monday, October 13, 2014
Adjusting the system time in a VirtualBox Guest
#/bin/bash # First get the name of the vm you need to adjust: VBoxManage list vms # Then, adjust the time in milliseconds (neg nums go back in time): VBoxManage modifyvm $MY_VM --biossystemtimeoffset -32000000000 # about a year # To get it back on current time, just set it to zero: VBoxManage modifyvm $MY_VM --biossystemtimeoffset 0
Wednesday, October 1, 2014
Setting Up the AVR Toolchain for Linux for AVR Development
- Download the Atmel AVR Toolchain 3.4.x for Linux
- Extract it to either
/usr/local/avror~/local/avr#!/bin/bash mkdir -p ~/local/avr cd ~/local/avr tar zxvf ~/Downloads/avr8-gnu-toolchain-*.tar.gz mv avr8-gnu-toolchain-* avr
- Add the path to your
~/.profile:# add avr toolchain to path (search ~/local/avr then /usr/local/avr) if [ -d "$HOME/local/avr/bin" ] ; then PATH="$HOME/local/avr/bin:$PATH" fi if [ -d "/usr/local/avr/bin" ] ; then PATH="/usr/local/avr/bin:$PATH" fiThis will look for avr commands in your home first and then in/usr/local/avr, and only if they exist. - Now logout, login and then check to see if its working:
$ which avr-gcc
This should output/home/$USER/local/avr/bin/avr-gcc, or wherever you put it.
Thursday, September 25, 2008
Remote File Transfer, after Logout with rsync, ssh and disown
Enter Your Password
Hit ctrl-z to pause then type 'bg' to send process to background.
Find the pid of the rsync process with:
$ ps | grep rsync | cut -d' ' -f 1 > rsync.pid; cat rsync.pid;
disown `cat rsync.pid`
Now you can logout and the transfer will continue on. To kill the process, simply enter the following:
kill `cat rsync.pid`
To monitor progress, just type:
tail -f rsync.log
Tuesday, July 8, 2008
Local Files > Remote tar.gz with GnuTar and SSH
How to go from local files to remote compressed tarbal with no intermediate temp files in one command with tar and ssh.
So I'm getting ready to do a fresh upgrade/install to Ubuntu 8.04, the Hardy Heron, and I decide to back up my home folder to my file server. A quick ssh server df -h tells me that I have 443GB left on a 2.3TB array. It's barely enough, I need more HDs.
df -h on my computer shows that I'm using 85% of my /home patition. So there's probably not enough room to tar it localy and transfer to my server. I could just transfer all the files and folders to the server without taring, but hey, that's no fun :)The problem is that although rsync and scp both support compression during the transfer, everything comes out just like it went in. I did some googling to see if I could just pipe tar to rsync or scp, but didn't find anything helpful. However, I was reminded that you can pipe output from a local program to a remote program using ssh a la echo "Hello world" | ssh anotherhost.com 'cat > /tmp/1' (taken from here)
tar to pipe to ssh which then cats to a file on the remote server. Here's the basic process:- Tar the files, output to stdout:
tar cjv /home - Use ssh to connect to remote server:
ssh remotehost - Write the stream to a file with timestamp:
cat > home-`date +%Y.%m.%d-%H:%M:%S`.tar.gz
If we put all that together, we get the following:
tar cjv /home | ssh remotehost 'cat > home-`date +%Y.%m.%d-%H:%M:%S`.tar.gz'I hope this helps anybody unfortunate enough to stumble upon this blog.