A few useful Linux tricks
Run a job on your lab machine from home
- Connect to the virtual private network.
- SSH into your lab machine (ssh email@example.com).
- Start a new tmux session (tmux new).
- Run your job.
- If you want to, you can rename the session (Ctrl-b $).
- Disconnect from tmux (Ctrl-b d), where there is no space between Ctrl-b and d.
- Disconnect from SSH (exit).
- Take a nap while the job runs.
- SSH back into your lab machine (ssh firstname.lastname@example.org).
- Attach to the latest tmux session (tmux a).
- If this is not the session you wanted, choose the right session (Ctrl-b s).
- Look at your results.
- If needed, you can scroll up (Ctrl-b PgUp), then press q to quit from scroll mode.
- Exit your tmux session (exit).
- Exit from ssh (exit).
Remove the guest account
- Edit /etc/lightdm/lightdm.conf
- Add this:
Root a machine to which you have physical access
- Make a startup thumb drive with your favorite flavor of Linux.
- 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:
sudo mount /dev/sda3 /mnt/rootme
- Mount the folders that the OS needs to operate properly with the new root. Debian-based instructions:
sudo mount --bind /dev dev/
sudo mount --bind /proc proc/
sudo mount --bind /sys sys/
Red hat-based instructions:
mount -t proc proc proc/
mount -t sysfs sys sys/
mount -o bind /dev dev/
- Make the other drive the new root:
sudo chroot /mnt/rootme /bin/bash
- adduser iownu
- add iownu to the list of sudoers, or accounts with admin privileges
- 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.)
- 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.)
- Boot from your thumb drive. use pwdump to obtain the password hashes for all the accounts on the system.
- 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
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