Technical information I have found useful
Topics
Private DNS Resolver, 1.1.1.1
DNS encrypt proxy with adblocker for Linux, www.cyberciti.biz
arp -v
- find connected hostsnmap -sP 192.168.0.1/24
- reverse DNS lookupsudo nmap -sn 192.168.0.1/24
- fast scansudo nmap -v -A 192.168.0.1/24
- deep scannmap --script smb-os-discovery -p 443 192.168.0.1/24
- find SMB (disk sharing) connected hosts, change port for other (e.g. 80 instead of 443)for IP in `arp -v | grep ^192 | awk '{print $1}'`; do nmblookup -A $IP ; done
- this shell command I wrote will get Network info (name and group) of all servers using arp and nmblookupiftop
- clearly shows traffic to and from an ip addresses and the traffic ratenload
- different layout to iftop, less infonethogs
- view based on the program using the device and traffic levels through itcurl wttr.in
I used to use the Settings / Save Open Pages option, but Tab Groups lets you do multiple different sets. A colleague, Neil Fisk, wrote the following excellent instructions to help me set these up.
Chrome has a feature called Tab Groups. This is where you can group tabs together according to requirements. I would suggest this is what you're looking to do. Below is a guide to setting them up so that you can recall them whenever you start Chrome for the first time.
Open all of the sites that you want to have open when you start Chrome. Right-click the first tab and select "Add to tab group". Give the group a name (i.e. Startup).
Now, right click on each of the remaining tabs and add them to the group you've just created.
Once done, all of your startup tabs are grouped together. Make sure you don't have any other tabs open which you don't want included in the group. Then, click the vertical three dots “more” menu at the top-right of the Chrome browser and hover over “Bookmarks”. From there, you’ll see a “Bookmark all tabs” option.
Once the dialog box appears and asks you where you’d like to save all of these tabs collectively, just choose the Bookmark bar for now. Here’s the important part – whatever you do, don’t click the “New folder” button on the bottom-left. All of these grouped tabs will automatically be placed into a Bookmark folder by the name of the Tab Group they came from, so all you’ll need to do is to fill out the parent folder name found in the “Name” text box of the pop-up dialog.
Now, just finish up by clicking the Save button on the pop-up dialog, and then you’ll see that it has been added to the Bookmarks bar, or wherever you’ve saved it to. You are now free to right-click a Tab Group and select “Close group” to free up your workspace without fear of losing anything.
To recall your tabs as the same group, you can right-click the Bookmark folder on your bar or in the Bookmark Manager (Ctrl+Shift+O) and choose the “Open all in new tab group”. Immediately upon doing so, you’ll see your Tab Group reappear with the same name, color, and tabs that you last left off with.
https://www.youtube.com/watch?v=Zx2xYWrFKR8&t=875s
If there is a song you like, but only the video is out, then use the youtube-dl to download the audio elements, e.g.
youtube-dl -k https://www.youtube.com/watch?v=AWhHUaEfecc
then, look for the file(s) downloaded and convert for your MP3 player
ffmpeg -i thevideo.mkv -ab 320k thevideo_audiotracks.mp3
Or only using youtube-dl to get an mp3. Also shown is how to use ffmpeg to skip the beginning (in the example 4.1 seconds),
youtube-dl -x --audio-format mp3 --audio-quality 320k https://www.youtube.com/watch?v=AWhHUaEfecc
ffmpeg -i youtube.mp3 -ab 320k -ss 00:00:04.100 skipped_song.mp3
or
yt-dlp -x --audio-format mp3 --audio-quality 320k https://www.youtube.com/watch?v=HR36AQVZ10k
If there is a video where there is a high quality video but has no sound in that format, you need to
combine the video with one of the other audio streams. I wrote a small script to enable this, see youtubedlb.sh (download)
Examples:
./youtubedlb.sh https://www.youtube.com/watch?v=EDwb9jOVRtU
./youtubedlb.sh -m https://www.youtube.com/watch?v=EDwb9jOVRtU
using yt-dlp, to force a specific format, e.g. mp4 with the best quality video and audio
yt-dlp -f "bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best" https://www.youtube.com/watch?v=rRaVGKk4k6k
If you need to change the meta data in the mp3 files my fav tool is id3v2
.
Examples:
id3v2 --TPE2 "Various Artists" *.mp3
To change all the artist in all tracks to "Various Artist"
A very powerful (and dangerous) tool, xdotool allows you to simulate mouse and keyboard presses.
You might need to install with sudo apt-get install xdotool
The cursor MUST BE EXACTLY where you need it when the clicking starts and all the time it continues.
Examples:
xdotool click --repeat 100 --delay 18 1
To click every 30 seconds for 1 hour, with 5 seconds delay before the cycle starts so you can get the mouse in place
sleep 5 ; xdotool click --repeat 120 --delay 30000 1
while : ; do AF=`ls -rt | tail -1`; tail -20 $AF; sleep 2 ; done
find /mnt/mydrive/start.point -type f -print0 | xargs -0 du -h | sort -rh | head -n 10
pactl list short sources
ffmpeg -video_size 1920x1200 -framerate 30 -f x11grab -i :0.0 -f pulse -i alsa_output.pci-0000_00_1b.0.analog-stereo.monitor -c:v libx264 -preset ultrafast -c:a aac output.mp4
ffmpeg -i output.mp4 -ss 00:00:31 -c copy trimmed_output.mp4
mv trimmed_output.mp4 chatgpt-song.mp4
ffmpeg -i chatgpt-song.mp4 -vn -acodec mp3 chatgpt-song.mp3
If you're wondering about the naming, I just had to have a local copy of the excellent post of the ChatGPT song created
by the Head of AI at Moonpig that was posted on LinkedIn , but they do not allow downloading.
Why would you need split videos into smaller chunks? Recently I got the full set of Star Wars movies (again, now I have VHS, DVD and 4KBlueRay disks), and
I have a 4K TV which can read off a memory stick, so the logical solution is to put all the movies onto a 128GB memory stick plugged into the TV for instant,
emergency access ... but a 4K movies is about 8GB and FAT32 formatted drives (which my TV supports and most memory sticks tend to be preformatted to) can only take 4GB as an upper file size limit,
so you need to split the big 4K movie file into chunks. Using ffmpeg makes it simple, with no affect on the original quality, and can handle multiple file types such as mp4 and mkv files,
as shown below.
ffmpeg -i ORIGINALFILE.mp4 -acodec copy -vcodec copy -ss 0 -t 00:15:00 OUTFILE-1.mp4
ffmpeg -i ORIGINALFILE.mp4 -acodec copy -vcodec copy -ss 00:15:00 -t 00:15:00 OUTFILE-2.mp4
ffmpeg -i ORIGINALFILE.mp4 -acodec copy -vcodec copy -ss 00:30:00 -t 00:15:00 OUTFILE-3.mp4
To make life easy, use this python script (local copy here) so you can just use a chunks parameter,
so you do not have to worry about time points
python ffmpeg-split.py -f ORIGINALFILE.mkv -c 2
which will produce two chunks (from -c 2) named ORIGINALFILE.1-of-2.mkv and ORIGINALFILE.2-of-2.mkv
For further info see splitting an mp4 file
Additionally, you might want to remove hardcoded subs from mkv files as follows
ffmpeg -i originalvideo.mkv -vcodec copy -acodec copy -sn video-no-subs.mkv
I found some photos of a wedding we attended many years ago, the camera was an early digital one, only 3MP, but the video was quite good (but no sound). The photos taken were really not that good or sharp, but the video looked better, so it made sense to extract some photos directly from the video, though that would be even lower resolution, at least they would be sharper, ffmpeg to the rescue again.
Try varying the rate (-r) to extract more or less frames, the bigger the number, the more frames are extracted.
ffmpeg -i ../videofile.AVI -r 1.5 -q:v 1 -qmin 1 wedding-%3d.jpeg
Another example, starting at 36 mins and 6 seconds into the video, running to the end, the order of the options
is important for performance reasons
ffmpeg -ss 00:36:06 -i /mnt/amachine/adir/series/TheSeries/TheVideo.mp4 -r 2.5 -q:v 1 -qmin 1 image-%3d.jpeg
doexercise.sh is a useful little script I wrote to remind me to at least do some exercise, it is called via at or cron on a cycle. It will give you a prompt in a little window, and also create a popup which has a random selected exercise from https://musclewiki.org.
To schedule it on Linux, I use a crontab command of 10 10,11,12,13,14,15,16 * * 1,2,3,4,5 ./tools/doexercise.sh
(see download doexercise.sh), obviously change the path to where you
install and change the schedule, mine is weekdays, Mon-Fri, at 10mins past every hour from 10am to 4pm.
If you need an audio reminder to do something soon, try scheduling a little sound to be played when something is done or needs to be done thus
aplay ~/Downloads/mixkit-happy-bells-notification-937.wav
You can put a sleep or something before this, or sequence the command set with mycommand ; ffplay -nodisp -t 1 -autoexit notes.mp3 2>/dev/null
to make it happen once a command has finished.
Just in case you need to delete a file and ensure it cannot be read or recovered, the best way is to shred it, not just delete it, as they can be recovered, but to write to it many, many times, which makes it nearly impossible to recover (unless you have near infinite time or resources).
To shred one file just use shred myfile
, but to shred an entire directory tree of files do the following
find <base_directory> -type f -exec shred -u {} \;
or for a specific type of file, e.g. all .csv files
find <base_directory> -name "*.csv" -exec shred -u {} \;
To check your local release version lsb_release -a
To check the upstream release version (the base yours came from) cat /etc/upstream-release/lsb-release
Linux updates are amazing and are applied when your system is up and running, so no waiting at a blue screen, occasionally older stuff is left hanging around,
if you want to tidy this run the following sudo apt-get install --fix-broken
This will give a list of things you do not need anymore, then run the following command, which will also clean up any unnecessary used space in transient files,
expired backups, system images etc sudo apt autoremove
There is a really good guide on /boot
clean up at itsfoss.
If you want to copy or move a bunch of files around, but want to control the rate to limit the impact on your network, you can use rsync with bandwidth control.
The following will recursively (the -r) move (the --remove-source-files) files and directories (source dirs will be left empty but present), limiting the rate to 20kb/s (the --bwlimit)
rsync -rav --progress --bwlimit=20000 --remove-source-files /source_base/source_path/* /dest_base/dest_path
To do a faster move, where the file checksum is checked and only updated if different use the options -rcauv
I wrote a simple script to go through a destination, find and shrink larger mp4 files, see makevideosmaller.sh at Sample Code
sudo lshw -short -class display
xrandr --listactivemonitors
xrandr
cvt 1600 900
xrandr --newmode "1600x900_60.00" 118.25 1600 1696 1856 2112 900 903 908 934 -hsync +vsync
xrandr --addmode DVI-0 "1600x900_60.00"
xrandr --output DVI-0 --mode 1600x900_60.00
cvt 1920 1080
xrandr --newmode "1920x1080_60.00" 173.00 1920 2048 2248 2576 1080 1083 1088 1120 -hsync +vsync
xrandr --addmode DVI-0 "1920x1080_60.00"
xrandr --output DVI-0 --mode 1920x1080_60.00
fsck.ext4 -f -y -b 819200 -B 4096 /dev/sdd
code.neatdecisions.Detwinner
. Typical
use, to enable you to check local and remote drives, even mounted drives (need sudo to delete on these), do the following (once installed):
sudo -i /usr/bin/flatpak run --branch=stable --arch=x86_64 --command=detwinner com.neatdecisions.Detwinner
C:\Users\theod\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu20.04onWindows_79rhkp1fndgsc
wmic path SoftwareLicensingService get OA3xOriginalProductKey
How to convert a BitLocked Windows PC into a Dual boot Windows and Linux box
I gave up on Windows when we started using AWS at work and found that a Linux desktop worked much better for me, in every way. My kids however, are most interested in their games, which run best or only on Windows.
sc stop "SysMain" & sc config "SysMain" start=disabled
$loc = Get-ChildItem HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall
$names = $loc |foreach-object {Get-ItemProperty $_.PsPath}
foreach ($name in $names) { Write-Host $name.Displayname }
The command echo $loc
can be used to get full info
MAX=4 ; for i in $( seq $MAX ); do
FILE=image${i}.jpg
curl 'https://thispersondoesnotexist.com/image' -H 'authority: thispersondoesnotexist.com' -H 'pragma: no-cache' -H 'cache-control: no-cache' -H 'upgrade-insecure-requests: 1' -H 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.80 Safari/537.36' -H 'accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3' -H 'referer: https://thispersondoesnotexist.com/' -H 'accept-encoding: gzip, deflate, br' -H 'accept-language: en-US,en;q=0.9' --compressed -o $FILE
sleep 1
done
As at the end of movies, I need to state that any address which resembles a real address is purely coincidental.
pygmentize -f html -l sh -O style=default -O noclasses=True -o make_address.sh.html make_address.sh
In addition to the document generation above, which produce HTML pages, these can be converted into PDF and other formats using tooling such as:
date | md5sum
openssl rand -base64 32
tr -cd '[:alnum:]' < /dev/urandom | fold -w30 | head -n1
UUID=$(uuidgen)
if [ ! -n "$UUID" ]
then
UUID=`cat /proc/sys/kernel/random/uuid`
fi
if [ ! -n "$UUID" ]
then
UUID=`python -c 'import uuid; print(str(uuid.uuid4()))'`
fi
if [ ! -n "$UUID" ]
then
UUID=`apg -a 1 -M nl -m32 -n 1 -E ghijklmnopqrstuvwxyz | sed -r -e 's/^.{20}/&-/' | sed -r -e 's/^.{16}/&-/' | sed -r -e 's/^.{12}/&-/' | sed -r -e 's/^.{8}/&-/'`
fi
printf "1" ; for A in `seq 1 3003`; do printf 0 ; done ; printf "\n"
Google provide an amazing collection of free to use fonts at Google Fonts, where you can try out different phrases to see what the typeset looks like. If you like them, you can easily include in your code thus,
In your html page, in the head section put the following syntax (Google even provides there when you click the Select the style option), for example to use the Noto Sans JP font
<link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@300&display=swap" rel="stylesheet">
OR
<style>
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@300&display=swap');
</style>
In your css definition
h1 {
font-family: 'Noto Sans JP', sans-serif;
}
See how to use Google Fonts for more info.
Or you could download a TFF or WOFF file and put that in your path and use that as follows (from FontSpace)
... in the style section ....
@font-face {
font-family: 'TrekFont';
src: url('font/FinalFrontierOldStyle-8Pg.woff') format('woff'), /* Chrome 6+, Firefox 3.6+, IE 9+, Safari 5.1+ */
url('font/FinalFrontierOldStyle-8Pg.ttf') format('truetype'); /* Chrome 4+, Firefox 3.5, Opera 10+, Safari 3—5 */
}
.D2 { padding:20px; font-size:36px; font-weight: normal; font-family: TrekFont, ... etc
... then in the body ...
<p class="D2"> Hi </p>
A really super simple way of generating a page listing of a directory tree, using the tree
package is:
tree -H . -o site-index.html
crontab
with a schedule, which can be
a bit confusing. Take a look at crontab guru which gives you a simple interface to decode or encode a cron entry.
Docker is an amazing platform to run contained compute resource on, and has become a standard at work. It can be installed on all main platforms including Windows, MacOS and Linux. I tend to use Linux Mint as a Desktop so below I will give an overview of how I installed it on my boxes. The best fit for my Linux distro is Ubuntu so I followed the instructions for this, but I also installed it on a secondary boot Windows install on the same machine and that was also very easy (to be fair, less steps than the Linux install), both installs worked perfectly, but the Linux build ran a bit quicker (on the same machine).
I tend to have dual boot options on my boxes for the kids to play games on, which Windows tends to be better for, though I do play Java Minecraft on Linux (kids play same on Windows).
The summary of the instructions I followed are provided below, yours may vary slightly depending on build and release of Linux
cat /etc/apt/sources.list.d/additional-repositories.list
# expect => deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable
cat /etc/apt/sources.list.d/additional-repositories.list
sudo apt-get update
sudo apt-get -y install docker-ce docker-compose
# options from previous attempt: sudo apt-get install docker-ce-cli containerd.io
sudo usermod -aG docker $USER
# this might fail depending on you rights
docker run --rm -it --name test alpine:latest /bin/sh
# then need to run this, which will fail at first, but then will pull the resources automatically, then work
sudo docker run --rm -it --name test alpine:latest /bin/sh
docker run hello-world
Git is a great tool, but it does leave behind some junk files, to clean up try:
git gc
git clean -dfX
Bourne shell (sh) or Bourne Again shell (bash) are amazing environments to work in (along with other shells such as KornShell (ksh) and others), with wonderful tools that can do pretty much anything. Below is a very short list of things I have found useful. They are NOT all my own work, but a collection of Google discovered solutions and some tweaking.
d=$(date -d "1 month 1300" '+%Y%m01'); w=$(date -d $d '+%w'); i=$(( (8 - $w) % 7)); answer=$(( $d + $i ));
echo $answer; echo $(date -d $answer '+%w')
awk '{ sum += $1 } END { print sum }' myfile
Press Windows key + R
Type: shell:appsfolder
Hit Enter