cli

By Druss , 7 March, 2022

yt-dlp downloads the best available format by default. However, if you use something like

yt-dlp -F [video]

you might find that it's not necessarily downloading the format with the highest resolution. This might very well be because it is unable to handle the codec of the video format in question. To fix this, install FFmpeg.

However, this might result in the "best format" being in a codec that you don't want or your device cannot support. In my case, my TV can't handle newer codecs so I need to do something like this:

By Druss , 24 November, 2021
  1. Create a batch file named turnoff.bat on your desktop.
  2. Open it and add the following line
    powershell (Add-Type '[DllImport(\"user32.dll\")]^public static extern int PostMessage(int hWnd, int hMsg, int wParam, int lParam);' -Name a -Pas)::PostMessage(-1,0x0112,0xF170,2)
  3. Save the batch file.
  4. Run the file to turn off your screens.There will be a brief command-line window that pops up during execution.

Tested on Windows 10.

By Druss , 28 October, 2021

You sometimes want to check if a program that you've installed is doing anything funky. While you could install a full-blown packet analyser like WIreshark, sometimes, that is overkill. A quicker and handier option would be to just rely on good old netstat. Like so:

netstat -bn 10

as well as

netstat -bf 10

-b: displays the program name (executable)

-n: displays the IP address

-f: displays the resolved form of the IP address

10: indicates that the command should be repeated after 10 seconds

By Druss , 24 September, 2021

This is how you can send a message from the commandline using the mailx (mailutils) package.

$ mailx -s "Re: My mail subject" -r "" bar-recipient@example.com < contents.txt

Note, however, that I was unable to specify the sender's name. -r "Foo" and -r " (Foo)" did not work (and neither did the versions with the email addresses with the <> removed. What was sent instead was the username of the commandline account.

By Druss , 8 December, 2020

So, I've been facing some DNS issues with my Ubuntu box and needed to do some debugging. While I was certain that my router was assigning the Google DNS servers (8.8.8.8 and 8.8.4.4) via DHCP to my machine, I needed to make sure that they were actually being used. Usually, I would be able to tell by looking at the output of /etc/resolv.conf oslt. However what I found in resolv.conf was


nameserver 127.0.0.53
options edns0 trust-ad

Tags Old
By Druss , 11 March, 2019

Freeplane, a fork of the mind-mapping program, Freemind, works really well. Except for the fact that in my (K)Ubuntu installation, it sometimes hangs in the middle of editing a node. Once it becomes non-responsive, the only fix is to kill the process and restart the program. The version of Freeplane in Ubuntu 18.04 is 1.6.13. However, the current version (March 2019) of Freeplane is 1.7.7. So, it's highly possible that upgrading Freeplane to the latest version will fix this issue.

By Druss , 26 November, 2018

So I have a couple of routers connected to my network each linking to a different ISP. When an ISP goes down, I want to easily switch ISPs from the command line and these are the couple of lines I use to do so:


#!/bin/bash

sudo ip route del default

if [ $1 == 'isp1' ]
then
echo "Switching ISP to $1"
sudo ip route add default via 192.168.1.1
else
echo "Switch ISP to ISP2"
sudo ip route add default via 192.168.0.1
fi

All times are UTC. All content licensed under the Creative Commons Attribution-Noncommercial-Share Alike 3.0 License.