Lab homeEdit page

A few useful Linux tricks

Run a job on your lab machine from home

  1. Connect to the virtual private network.
  2. SSH into your lab machine (ssh
  3. Start a new tmux session (tmux new).
  4. Run your job.
  5. If you want to, you can rename the session (Ctrl-b $).
  6. Disconnect from tmux (Ctrl-b d), where there is no space between Ctrl-b and d.
  7. Disconnect from SSH (exit).
  8. Take a nap while the job runs.
  9. SSH back into your lab machine (ssh
  10. Attach to the latest tmux session (tmux a).
  11. If this is not the session you wanted, choose the right session (Ctrl-b s).
  12. Look at your results.
  13. If needed, you can scroll up (Ctrl-b PgUp), then press q to quit from scroll mode.
  14. Exit your tmux session (exit).
  15. Exit from ssh (exit).

Remove the guest account

  1. Edit /etc/lightdm/lightdm.conf
  2. Add this:


  • Scrape a website, save it to your machine:
    wget -np -krpL
  • Spider the department website, report broken links: (I think the wait time should be made smaller.)
    wget --spider -o wget.log -e robots=off --wait 1 -r -p

Root a machine to which you have physical access

  1. Make a startup thumb drive with your favorite flavor of Linux.
  2. Boot from the thumb drive. Mount the hard disk. Usually, you can do this by double-clicking on some icon, but here's a command:
    mkdir /mnt/rootme
    sudo mount /dev/sda3 /mnt/rootme
  3. Mount the folders that the OS needs to operate properly with the new root. Debian-based instructions:
    cd /mnt/rootme
    sudo mount --bind /dev dev/
    sudo mount --bind /proc proc/
    sudo mount --bind /sys sys/
    Red hat-based instructions:
    cd /mnt/rootme
    mount -t proc proc proc/
    mount -t sysfs sys sys/
    mount -o bind /dev dev/
  4. Make the other drive the new root:
  5. sudo chroot /mnt/rootme /bin/bash
  6. adduser iownu
  7. add iownu to the list of sudoers, or accounts with admin privileges
  8. reboot, and log in as iownu. Now, you own the machine.

If it is a Windows box, you can also easily obtain your neighbor's password. (Note: There are few situations where this is appropriate. I provide this information with vague details only so that you can understand how vulnerable Windows really is.)
  1. Download a version of pwdump that will work with the operating system on your thumb drive. (There are many versions available, and some come with their own startup disk and rainbow tables.)
  2. Boot from your thumb drive. use pwdump to obtain the password hashes for all the accounts on the system.
  3. Reverse the nthash. Windows uses an MD4 hash of your password in Unicode format. waffles_security can reverse these hashs, as can numerous other tools. Some of them use rainbow tables to make the process even faster. There are also GPU-optimized versions of MD4hash that make this process almost instantaneous for passwords of reasonable length. There are also cloud-based computing services that can do this in parallel for a very small fee.

Working with video

  • Convert all of the .jpg files in a folder to an AVI file:
    mencoder mf://*.jpg -mf w=800:h=600:fps=25:type=jpg -ovc\
    	lavc -lavcopts vcodec=mpeg4:mbd=2:trell -oac copy -o output.avi
  • generates a 320x240 sized thumbnail at the 4th second in the video:
    ffmpeg -itsoffset -4 -i test.avi -vcodec mjpeg\
    	-vframes 1 -an -f rawvideo -s 320x240 test.jpg
  • Save all frames from infile.avi as jpeg files:
    mplayer -vo jpeg file.avi
  • Save a frame from a video as a jpeg file every 5 seconds:
    mplayer -vo jpeg -sstep 5 file.avi