Reset Debian root Password

by jz on 2013-11-28

So I had an issue with Debian 7 “Wheezy” on one of my boxes this week. The root password stopped working. It was fine for months and had never been changed since install but then is started giving me the error “su: Authentication failure” when I tried to use the su command. It also wouldn’t let me log in with root saying the password was wrong. I haven’t been able to replicate the issue so no bug report has been filed, but in the event it happens to someone else this is evidence you’re not alone.

Luckily if you forget your root password in Debian or it gets corrupted you can easily reset it.

Boot your machine, and when you get to the grub menu select the first entry which will be something like Debian GNU/Linux, with Linux 3.2.0-4-amd64 and press e on your keyboard.

Find the line that says linux /boot/vmlinuz-3.2.0-4-amd64 and add a space and init=/bin/bash right after it. Then Press CTRL+X or F10 to boot.

Once it boots type mount -rw -o remount / press enter, followed by the passwd command to change the root password. After that you can restart the machine and everything should be back to normal.

Also you my want to add a user to the sudoers file so you don’t have to use the root account for administrative tasks. To do that just use the following commands (Substitute ‘jz’ for your username):


su
adduser jz sudo

After you log out and back in again you will be able to use sudo to execute commands.

1 Comment

Einstein’s Riddle

by jz on 2013-10-27

About a decade ago I came across this riddle purportedly created by Albert Einstein and only solvable by the most intelligent 2% of the population. Back then it took me over an hour to solve it using a scrap of paper and a pencil.

Recently I crossed paths with it again and took a more modern approach using a spreadsheet, and solved it in about 10 minutes. Have a try, the solution is below.


There are 5 houses in five different colours.
In each house lives a person with a different nationality.
These five owners drink a certain type of beverage, smoke a certain brand of cigar and keep a certain pet.
No owners have the same pet, smoke the same brand of cigar or drink the same beverage.
The question is: Who owns the fish?

  • The Brit lives in the Red house.
  • The Swede keeps dogs as pets.
  • The Dane drinks tea.
  • The Green house is next to, and on the left of the White house.
  • The owner of the Green house drinks coffee.
  • The person who smokes Pall Mall rears birds.
  • The owner of the Yellow house smokes Dunhill.
  • The man living in the center house drinks milk.
  • The Norwegian lives in the first house.
  • The man who smokes Blends lives next to the man who keeps cats.
  • The man who keeps horses lives next to the man who smokes Dunhill.
  • The man who smokes Blue Master drinks beer.
  • The German smokes Prince.
  • The Norwegian lives next to the Blue house.
  • The man who smokes Blends has a neighbour who drinks water.

Look below for both the answer and the template I used to solve it.
Einstein's Riddle Spreadsheet
The answer is the German owns the fish.

It’s hard to imagine that someone who approaches the problem systematically to keep track of the various elements and their relationship to each other would not solve this problem given enough time; even if it be by trial and error.
There does not seem to be any definitive evidence that Einstein created this riddle, however the following quote likely applies nonetheless:

“It’s not that I’m so smart, it’s just that I stay with problems longer.” — Albert Einstein

No Comments

Quickly remove double file extensions in bash

by jz on 2013-10-23

If you have files you batch converted from PNG to JPEG that now have the name file.png.jpg and you want to change that to file.jpg do the following:
for i in *.png.jpg; do mv -n "${i}" "${i%png.jpg}jpg"; done

If you converted your FLAC to Opus after reading this post you can remove the redundant extension.
for i in *.flac.opus; do mv -n "${i}" "${i%flac.opus}opus&"; done

No Comments

Convert FLAC files to Opus

by jz on 2013-10-22

If you have a large library of FLAC encoded music and want to put it on a device with limited storage like an Android tablet or phone, Opus is a great choice. Just make sure you have a player like VLC that can have support for the codec.

To convert FLAC files to Opus you will need opus-tools installed. Then you can use the opusenc program.

for i in *.flac; do opusenc --bitrate 256 "$i" "$i.opus"; done

You can experiment with the bit rate if you like, 256 produces a quality that is probably indistinguishable from the FLAC file for most people.

The resulting files will be in the format file.flac.opus, if you would like to strip away the double file extension see this post.

1 Comment

Generate one-time passwords with oathtool

by jz on 2013-10-12

If you’re in a pinch and need to generate a one-time password for use with a two factor authentication system oathtool is a good solution. Of course you will still need access to the secret key, and you should take extra precautions not to leak it. This is mainly a good solution for if you can’t generate a code on your device, such as an Android phone because it is lost or damaged.

oathtool --base32 --totp "JZBZTARJZ7WX5FIMGTAKOTDN"

No Comments

Recompress your FLAC music to save space

by jz on 2013-10-12

To maximize the compression used by flac do the following…

for i in *.flac; do flac "$i" --best --force; done

This will go through each flac file in a directory and recompress it using the “best” setting (equal to 8). This can save you a significant amount of space if some of your files were not compressed using the highest setting.

No Comments

Create a QR code with Wi-Fi credentials

by jz on 2013-10-10

If you want a simple way to transmit Wi-Fi credentials to people using Android devices consider creating QR codes embedded with the data.

qrencode "WIFI:S:MyAccessPointName;T:WPA;P:ThisIsThePassword;;" -o MyAccessPointName.png

WIFI:S:MyAccessPointName;	This is the SSID of the Access Point
T:WPA;				Here we specify the encryption type
P:ThisIsThePassword;;		Password, also an extra semicolon

The output will be a QR code PNG image that you can scan with most bar code scanners on Android and automatically add the credentials to your device and connect to the network without having to type anything in.

This makes using secure passwords much more convenient.

No Comments

Use pwgen to generate strong passwords

by jz on 2013-10-04

If you use Linux I strongly recommend the use of pwgen for generating passwords.

The command below will tell pwgen to make a list of passwords 18 characters long using “secure” mode [-s] for random passwords and not use any capital letters in the generated passwords [-A] to make them easier to enter manually.
pwgen -sA 18

Which gives the output:

og7ekxotv29ngwfw4e a3pdbu8pz2w9hop6ar ok5fz331pm4typr75s jnxcs589zwahe2e8cj
nsil47d9wh065m3f5y 7v91dxe4mml93b6ts2 u50hc2nq0lhwp18baq 4apkk3jjv5t2nrdtr8
jsdyyd2jcz48x4d65w 4h1jy5fqsm8p2h1263 yz557agf3oxbu7015x dw9dfooac84uic9ts4
klbdro59qoe92x6zgs bgozodog77iwzx5z1f zr3vseerl56f1qkrxx 7jk3xrqwk3d9d64rv8
n12zxs3mu3o7v4emim enmjc4txrsri4bjyn9 02r9m5stu9hwgr5ain cv5pcr4ugjbpkn5vzt
gcbhvmzzdsm7n7g3jo b5ju2h5fpl6jmcupji iihpcvfx86ygqsi9fb sm7hygzko807ohetbq
o9e14kipcracdqufs4 5yle687acygw6znc1o pnxc1ygpk3rs8p29nn z94ucsky7v2lr18p1q
drh3xp2p512d7pcv1d 4ecajs4st8u580xi3k vnapyvwcqu3s0i0l2m 5o0l4lgm7k8vos8fyh
i62e87xfkkiv8857l4 175vlv02rixlrdbhfe gcf72gx3sdrr6dsn24 mz19nj5hy3rp5fark9
ldwyqyr5ulqldl6et5 3kmosx9450amcovn9o zm3pewr37w40jdjnhz 40zp1vdtezcsba3b0p
l537hlp3krn1k3glzx iihrt7rloexgpqtf75 2382a7vrok4e9rimbn x5sdvagr9iubh5hkox
kvkabzsw3wv8zgks1j iyo7ey8y52w16wd5o5 qjejuu69trzixciabt 8db29yokm2pok32l6l
yw6r2jikztdo00sdbk v5xp76987pmkqkmvtd daqc4lxjl7t0ughsum 2plrja8m8fv6cscyki
vc587i260luxa5pduy 4iayysx2sdqb2v0y6s fxj7xn3gequge8xcox 5fjpovlajm3fez6n7t
g6p8napgw59s6mc9qe rk10navjooxdlmy2ft vcz6i86yj7ra6ctpvc ul1v5iznhk1hat8com
e5is647ohuz0rkuq04 te55lrt39hrc5x8wkz mqeqebh4z64h38ezge lsicsf96yytfx01rp0
h8jh45u76410xiai77 s8ebb7z1h4asuquego fk3bjhlekg4r63wk10 itsymiahkayuqepr2k
n3oi4ug6g4wpro8blj 8vogx5kvn9u87y30ov hc2a2vi68yvasigjjd zeytp5g9u7wg0cprt8
ekfg47dem721gof7e6 w8wuq3cdpoo0aub1f1 8rtydclatde13pfqhb iehzynsjdgw9hddcxt
etz0t088v9061i9f3c 926gkezls7bjemmrcg lmh4j9zgcltg2elz4w 0rg0jnj8od1txyme7q

No Comments

Quickly serve files over HTTP with Python

by jz on 2013-10-03

If you ever need to serve a file up quickly using HTTP, say to transfer something that’s on your Linux desktop to your Android phone without the use of any cables or external storage, you can use the following technique:

Start a HTTP server on your desktop by navigating to the folder you want to share in the terminal and executing the following command.
python -m SimpleHTTPServer

You can now access your files by going to http://192.168.1.100:8000 or http://some-hostname:8000 using a web browser. Obviously substitute the IP address or hostname for that of your desktop.

If there is an index.html file, that will be served, otherwise you will get a directory listing of the working directory from which you executed the command.

No Comments

Download YouTube videos using youtube-dl

by jz on 2013-10-01

If you want to download a YouTube video for offline viewing here’s how to do it with the aptly named youtube-dl.

First install youtube-dl

sudo apt-get install youtube-dl

If it doesn’t happen to be available through your package repository you can install it through the Python PIP system

sudo pip install --upgrade youtube_dl

Now you can download videos with the following command. replacing the URL for that of the video you wish to download:

youtube-dl -f 37/22/18 https://www.youtube.com/watch?v=ViDEO

Which will attempt to download the video in the highest quality possible (1080p/720p/360p) in an mp4 container.
See the comparison of YouTube media encoding to better understand the options available.
Also the switch --prefer-free-formats will tell the program to try to download in free formats such as VP8 if they are available.

youtube-dl also supports downloading video from many other sites as well [see: youtube-dl --list-extractors] including:

1up.com				Hypem				ThisAV
3sat				ign.com				TrailerAddict
56.com				Ina				Tudou
8tracks				InfoQ				Tumblr
archive.org			Instagram			Tutv
ARD				Jukebox				ustream
arte.tv				justin.tv			Vbox7
AUEngine			Kankan				Veoh
Bandcamp			keek				Vevo
blip.tv				liveleak			video.google:search
blip.tv:user			Livestream			vimeo
Break				metacafe			vimeo:channel
Brightcove			mixcloud (CURRENTLY BROKEN)	Vine
canalplus.fr			MTV				wat.tv
CollegeHumor			MySpass				Weibo
ComedyCentral			myvideo				Wimp
CondeNast			NBA				WorldStarHipHop
Criterion			photobucket			XHamster
CSpan				plus.google			XNXX
dailymotion			Pornotube			XVideos
DailymotionPlaylist		RBMARadio			Yahoo
DepositFiles			RedTube				YouJizz
Dotsub				RingTV				Youku
eHow				Roxwel				YouPorn
Escapist			screen.yahoo:search		youtube
exfm				Sina				youtube:channel
facebook			soundcloud			youtube:favorites
Flickr				soundcloud:set			youtube:playlist
Freesound			Spiegel				youtube:recommended
FunnyOrDie			stanfordoc			youtube:search
GameSpot			Statigram			youtube:show
Gametrailers			Steam				youtube:subscriptions
generic				Teamcoco			youtube:user
HotNewHipHop			TED				youtube:watch_later
Howcast				TF1				ZDF
No Comments