For about more than half the time, when I wake my ubuntu laptop from sleep, I will lose wifi. When I say lose, I mean I lose the
wlan0 interface completely.
Now this is a problem because I quite like having wifi and normally there seems to be no way to turn it back on from that little wifi menu from the top right corner.
After doing some googling, I found a crude yet simple solution. Restart the
network-manager service by running the following:
sudo service network-manager restart
Right before writing this article, I had to run that command and now it all works buttery smooth. Maybe there is a more permanent fix, I will keep an eye out for it and when I can find some time, will dig in to some logs somewhere to actually find the issue but for now, this is satisfactory (meh) to my current needs.
The other day I had to download a public cert from a web service’s host and store it in my java keystore so that it can be trusted. Here’s what I did:
openssl s_client -showcerts -connect www.manthanhd.com:443 < /dev/null 2>/dev/null| sed -n -e '/BEGIN\ CERTIFICATE/,/END\ CERTIFICATE/ p' > /tmp/www-manthanhd-com.cert
sudo keytool -import -file /tmp/www-manthanhd-com.cert -alias wwwmanthanhdcom -keystore /opt/java/jre/lib/security/cacerts -storepass changeit
The first line downloads the public cert from www.manthanhd.com and stores it in
Next, we’re using keytool to import that certificate into the Java cacert keystore. I am only using sudo here because Java is installed as root. If in your case its not, you can just use the keytool command without the sudo prefix.
Also, on my test box, the java keystore has the default java keystore password which is changeit. Make sure this matches whatever your keystore password is.
Last but not least, the alias that the cert is imported against is important because this is what you will have to use to later find it. In this case I’m just using the hostname without any punctuations. This way, I can easily find any cert I want for any host if I need it.
Thanks to Jamie Tanna (jvt.me) and Jack Gough (testingsyndicate.com) for their help on this.
Usually to edit crontab for a user, you login as that user and then run:
This usually opens up a text editor which then lets you edit the crontab. Once you are done, you save and quit, and this magically updates your crontab.
Today I was writing a script that needed to update crontab without any user interaction. After doing some digging, I found this neat way of updating my crontab;
(crontab -l ; echo "* 1 * * 1 /usr/bin/letsencrypt renew && service nginx restart")| crontab -
The above example is straight out of my shell script which renews my letsencrypt certificate and then restarts the nginx server.
Sometimes, I get errors like “address is already in use” but struggle to find out what’s using that port. This happens especially with loads of stuff running in background like docker, vagrant vms, local server instances, ssh tunnels etc.
Here’s an easy way to figure out whats running on a certain port:
netstat -vanp tcp | grep 8080
The second last column refers to the process using that port.
For example, running that on my mac:
➜ ~ netstat -vanp tcp | grep 8080
tcp4 0 0 *.8080 *.* LISTEN 65536 65536 5500 0
Indicates that process ID
5500 is using port
8080. Doing a process check on that tells me:
➜ ~ ps -ef | grep 5500
394661014 5500 5443 0 7:15am ?? 0:42.61 /Applications/VirtualBox.app/Contents/MacOS/VBoxHeadless --comment kitchen-awesomevm --startvm b459e3ea-566b-4184-a109-cf97338958aa --vrde config
Hope this helps!
Managing production passwords isn’t a trivial task. I was trying to deploy a containerized app the other day that had a database deployed with it. During the deployment, I was trying to find an easy way to set a secure password. I didn’t want anyone to know the password because I wanted only the application to know it and no one else. Also, the container was setup in a way that the database cannot be accessed from the outside world.
So instead of hard-coding the password, after doing some research, I used the following command: Continue reading