Linux

By 2016 I was getting fed up with Microsoft operating systems. Constant filesystem errors, inability to recover properly from a bad shutdown or power loss. Registry files corrupting on their own. System slowing down over time due to the way the registry wants to track every file, spyware telemetry, inability to use old Win 3.1 or 32 bits apps fully, dodgy driver updates and a cesspit of virii. and forced updates I'd had enough. So I tried Linux as dual boot system for a week. By the end of the week I'd deleted Windows and went 100% Linux and never looked back.  My daily driver is to use Linux Mint (either Cinnamon or Mate desktop style / skin.  Or Debian, which is a little less polished, but forms the basis from what just about every other Linux distro is made of. Raspberry Pi's also use Linux, reskinned and modified for their single board computers and it runs superbly.

With Linux things just work. No driver issues, the "kernel" already knows how to handle things. Just plug a device in and go. There's no such thing is a virus scanner for Linux, they don't exist in the Windows sense.  Source code is available for all the software for you to either modify yourself and compile or check for funnies (can't do that with Windows closed source). There's no shortage of software, in fact there's more of it, free ! And good stuff too. And there's WINE that allows you to run quite a few old Windows apps if you can't find a Linux replacement. Need Office ? Most Linux distro's have it included, all licence free and highly compatible with MS stuff. You can run Linux from a command line (DOS style) or from a GUI (various desktop flavours available). DOSBOX will run all your old MSDOS apps too. And it's easy to make BASH scripts to automate your work. No wonder 98% of the worlds super computers all run Linux or Unix. 

With GNU Linux being free, there's no licensing restrictions, have as many copies as you want,modify it and you can also boot a full system from a USB drive, a DVD or external hard disk. There is such a thing as a free lunch after all.

The following notes are now mainly useful for radio amateurs for general info or an aide memoire. They are not intended for much else so don't expect this to be anything else.

General advice, don't be an upgrade addict ! Once a system is setup then preserve it. While Linux is 10x better at NOT slowing down over time, unlike Windows, it still can still be subject to degradation. I've very rarely found that kernel upgrades and so called security upgrades are worth the bother.

If you are a Raspberry Pi user then pretty much everything here is valid info. too.


REMEMBER - LINUX IS CASE SENSITIVE.  ALL PROGRAMS FROM A COMMAND LINE MUST HAVE THE CORRECT CASE !


My favourite Linux distros.


There's lots of good distributions about, too many to mention but eventually one has to try and standardize.  I have two personal choices.

Debian Buster (with the Raspberry Pi desktop). Don't confuse yourself here because you have just seen mention of Raspberry Pi.  Keeping it brief,  there's Debian proper, then there's a Raspberry Pi version made to be mean and lean, and then from that was a spin off for a X86 PC version.  It's probably the best Linux you can get if you want to run it on very low spec machines, especially old 32 bit CPU's. In fact it's the only Linux distro that I can get to run with sensible speed on an ancient Asus EEE PC (although web browsing is a bit painful). It's got all the essentials include Libre Office. Currently downloadable from here - https://www.raspberrypi.org/software/operating-systems/#raspberry-pi-desktop 

Linux Mint. A very well produced and tweaked distro. Looks real nice with either the Cinnamon or Mate desktops. Windows 7 or 98 users will feel very comfortable with them. Comes with Libre Office and a whole load of other nice goodies and features. The software manager is very good (in modern parlance the "app store") and has very good support.  Up until version 19.3 there were 32/64 bit versions available.  The minimum  spec is really 2Gb RAM and a half decent two core CPU for a sensible user experience. 4Gb RAM and you've go it made. In other words this distro is good for the average machine, but don't expect too much if you put it on something really ancient like a single cored CPU. Downloads for ALL versions here - https://linuxmint.com/

I quite like ARCO Linux too.

  


Old Windows software that is known to run on WINE (tested by myself).


Using WINE is simple enough once installed. You copy the Windows file to the hard disk and execute it as normal. WINE creates a virtual drive and you run the program as normal. Sometimes you might need to alter the WINE settings to account for a certain version of Windows but that's about it. 

Warning, use the following procedure to install WINE otherwise you end up with weird problems such as Windows programs not creating the correct virtual C:\ drive directories !

1. copy and paste sudo dpkg --add-architecture i386 into terminal window, press enter

2. copy and paste sudo wget -nc -O /usr/share/keyrings/winehq-archive.key https://dl.winehq.org/wine-builds/winehq.key into that same terminal window,

3. given " Ubuntu 20.04

Linux Mint 20.x" literally means that Linux Mint 20.3 is based upon Ubuntu 20.04, you'll copy and paste

sudo wget -nc -P /etc/apt/sources.list.d/ https://dl.winehq.org/wine-builds/ubuntu/dists/focal/winehq-focal.sources

4. sudo apt update

5. sudo apt install --install-recommends winehq-stable -y


Spectrum Lab (DL4YHF). 

Argo. QRSS and audio spectrum viewer. [Linux users usually use  native QRSSPIG / Lopora software]

MMANA. antenna modeller.  Use Wine Config, specify Windows 2003.

MRS Mini VNA front end [Linux users have vnaJ (note the case) to access this equipment]

RFSIM99 RF tool box.  Use the unzipped files here.

HAMCAP. HF propagation program. . Use Wine Config, specify Windows 2003.

DXATLAS - A companion for Hamcap. Good on 18/19/20. Use Wine Config, specify Windows 2003.

Note for  HAMCAP users. HAMCAP needs an updated solar data file called SSN.dat to be copied to the following folder - wine/drive_c/users/YOUR USERNAME/appdata/roaming/afreet/reference here !


Some useful commands - Linux is case sensitive !


grep "andy"  blah.txt  > results.txt  would search blah.txt for andy and and send to a new file called results.txt

lsblk List all available disks

Avoiding Terminal clutter - add a space before a command. It stops the command from showing up again or getting logged.

sudo umount /dev/sdc unmount a disk called sdc.

sudo dd if=/dev/mmcblk0 of=sd-card-copy.img status=progress Data duplicator. Use to copy bit for bit one disk to an image or iso file. Example below would be an SD card. You can do the same with a CD or DVD. Just use lsblk to work out what the device is to copy from. Does not work on encrypted disks.  An SD  card might be called SDB or SDC too. I came across an oddity when trying to make an SD card image from my Raspberry Pi.  I had to use .img instead of .iso for it to look at the whole of the SD CARD correctly. This despite an .img being the same as a .iso. Weird.

sudo Some commands require admin status. Prefixing some commands allows you to enter admin password.

inxi -xxxW london,uk Gives you a weather report. No location date gives report based upon your IP address.

curl wttr.in Get a weather report and forecast. 

inxi Gives you basic info about your computer system.

sudo dmesg | more Let's you work out what device is on what comport.

sudo cat /dev/ttyACM0 View the data coming into ACM0 (replace with comport of your choice)

man <command> Show manual for a command.

sudo systemctl disable rsyslog Stops logging to disk, useful to prevent hammering SD cards with disk writes etc.

ALT-SYSRQ-O closes down the PC fast without saving anything.

telnet mapscii.me Google maps via ascii.

sudo sysctl vm.swappiness=0 In terminal mode type this to temporarily disable using physical disk for swap file.

systemd-analyze time Shows bootup times.

speaker-test -t sine -f1000 Uses ALSA to generate a sine wave test tone at 1000Hz.

sudo hwclock --systohc - Sets the BIOS hardware clock to that of the ntp server.  

xdotool - Once installed you can emulate and automate mouse clicks. e.g.  xdotool 1 does the left mouse button.

head -n 100000 file.txt | more - head command allows you to view any file with no editor. 100000 is the max number of lines to view.


Do You Wanna FSCK ?

In the world of Linux the equivalent of Windows "checkdisk" is called fsck (file system check). If you want it to check the disk on start up then you need to navigate to /etc/default/grub and edit the file so that it looks like this, save the file and then from the terminal run the command "sudo update-grub" and then reboot. Some other Linux systems may vary but this is used by myself on Linux Mint (Debian / Ubuntu derived) and using systemd.

# If you change this file, run 'update-grub' afterwards to update

# /boot/grub/grub.cfg.

# For full documentation of the options in this file, see:

#   info -f grub -n 'Simple configuration'

GRUB_DEFAULT=0

GRUB_TIMEOUT_STYLE=hidden

GRUB_TIMEOUT=0

GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`

GRUB_CMDLINE_LINUX_DEFAULT="fsck.mode=force fsck.repair=yes fsck.repair=yes"

GRUB_CMDLINE_LINUX=""

# Uncomment to enable BadRAM filtering, modify to suit your needs

# This works with Linux (no patch required) and with any kernel that obtains

# the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...)

#GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef"

# Uncomment to disable graphical terminal (grub-pc only)

#GRUB_TERMINAL=console

# The resolution used on graphical terminal

# note that you can use only modes which your graphic card supports via VBE

# you can see them in real GRUB with the command `vbeinfo'

#GRUB_GFXMODE=640x480

# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux

#GRUB_DISABLE_LINUX_UUID=true

GRUB_CMDLINE_LINUX_DEFAULT="fsck.mode=force fsck.repair=yes fsck.repair=yes"

# Uncomment to disable generation of recovery mode menu entries

#GRUB_DISABLE_RECOVERY="true"

# Uncomment to get a beep at grub start

GRUB_INIT_TUNE="480 440 1"


Adding permissions to use certain OS functions.

Unix and Linux are built upon security of allowing user functions. You can control if you or others have access to certain facilities. Sometimes you have to add yourself or others permission to use comports / printers / audio devices etc etc. Here are a few examples. Note the cAsE !


If you can't access some external devices like drives QRP Labs kits and RTL radio dongles then try - $ sudo usermod -aG plugdev your_username

Or audio devices - $ sudo usermod -aG audio your_username

Or comports - sudo usermod -a -G dialout username

What is your username ? Type the command whoami and it will tell you !


Using dd command to destroy ALL data on a disk (privacy).


At the terminal prompt use the command lsblk to list connected disks.

$ lsblk

sda      8:0    0 931.5G  0 disk 

├─sda1   8:1    0   512M  0 part /boot/efi

└─sda2   8:2    0   931G  0 part /

sdb      8:16   0   1.8T  0 disk 

└─sdb1   8:17   0   1.8T  0 part /media/laptop99/2tb

Then, for example if you want to write zeros all over it then type (in this example my 2Tb backup disk) is listed as device "sdb" -

sudo dd if=/dev/zero of=/dev/sdb bs=4096 status=progress

Then you see it "copying" a file of zeros to it. When it's finished you see the message about run out of disk space (normal) and get returned to the terminal prompt. That's it. But it's SLOW. A 2Tb drive might take 12 hours on a USB3 connection. But at least your data is totally erased.


Creating a RAMDISK.


Sometimes it is useful to create a RAMDISK for some operations to speed certain things up, rather than rely upon the slower spinning hard disk method. You can create a RAMDISK by doing the following:

At the terminal prompt type the following and this will give you a 2 Mbyte ramdisk:

"sudo mount -t tmpfs -o size=2048k tmpfs /home/pi/ramdisk"

Once the end user has determined his/her needs then there are two options:

(1) Manually enter the mount command via the terminal at start up.

(2) Create an automounted ramdisk through the following method -


What if you want to have the ramdisk automatically created at boot?  This can be done with the help of /etc/fstab. Open up that file and  add the following (edit to suit your needs):

none /home/pi/ramdisk tmpfs nodev,nosuid,noexec,nodiratime,size=2048k 0 0


Basic source code compiling. [My NON expert experience).


In the world of Linux we are blessed with usually having the source code available for our programs or "apps". Quite often we will grab the source from Gitlab or similar, or maybe from your favourite distro's server using a command in apt. So how do we convert that source code to a program ?  Usually it starts with obtaining the source code and unzipping it to a convenient folder. Then we can unzip it and see what "dependencies" are required for it (if any). There's usually file included that states what those dependencies are (if required) and in the world or Raspberry Pi or Debian based Linux distros we usually get them using something called a package manager called apt. If we require a module called foobar then we'd type "sudo apt-get install foobar". NOTE - there may be LOTS of these modules are none at all. Also some modules might require the -dev extension added e.g. foobar-dev. And then it's been known that some distro repositories screw up the filename convention. foobar-dev might be Foobar-dev (note the case!). Once you've got this out the way then you navigate to where you put the source code e/g /home/mystuff/widget 

Then you type the magic commands -

mkdir build

cd build

cmake ..

make

sudo make install 

Now wait anything up to about an hour of your life and let it get on with converting the source code to binary files, and then it puts them in the right places. I've only randomly compiled a few programs so I am working from memory and there are probably a few errors and omissions. Your distro might not have cmake installed as standard, but most do. You might have to use a different compiler, gcc or gcc+ or something entirely different if it's another programming language like FORTRAN or something. This is a crude guide, sorry. All compilers should be installed as usual via the apt-get install command.


Tips for using WINE (Old versions of WINE e.g as supplied with Linux Mint 18.x)


If you are using Windows software through WINE, then you need to allow it access to the comports. From the terminal type following, where username is YOUR username.

sudo usermod -a -G dialout username

and then type -

ln -s /dev/ttyUSB0 ~/.wine/dosdevices/com1 which will map out what Windows what call COM1 in it's software through to Linux connection ttyUSB0.

Reboot and then fire up you Windows application that requires a comport. It should now connect.

Newer versions of WINE have a totally different method that requires you to use the Windows Regedit program to set up the comports. It's a PITA but hopefully the resources here will help.


Video conversions and tricks.


Mencoder - Do you have a video that comes in several parts, but you want to make it one big file instead ? Install Mencoder usually via your distro's package manager or use "sudo apt-get install mencoder". Then put the video files in a directory. The following command should be then self explanatory - mencoder part1.mp4 part2.mp4 -ovc lavc -oac lavc -o output.mp4 and you run it from the command line (terminal).

FFMPEG - ever wanted to have two videos playing side by side in real time ? Try this ffmpeg -i part1.mp4 -i part2.mp4 -filter_complex hstack output.mp4


Nemo file browser bug.


Usually occurs when using USB memory sticks and the stick appears to become read only. It' s not real. Use the command from the terminal "sudo killall nemo" or reboot and Nemo now accesses the USB stick properly. Don't ask me why. There is also a bug that effects remote server logins e.g qsl.net whereby you'll get a message such as "location is not a folder" if you create an ftp bookmark. Once again use the killall command and try again.


Making Nemo in Cinnamon faster.


Go to Preferences. Disable Colour Switcher, count items in folders and Emblems,


About WINE.

WINE acts as a shim converting Windows programs into something that Linux can understand.  If the Windows program has used code that uses standard programming language then it can send that to Linux and it works normally.  It's usually a good way to run Windows stuff if you can't find a Linux equivalent.  Sometimes you need to tweak what version of Windows to emulate. You use Wineconfig for that. If a software writer has used non standard code then it fails. Standard code is referred to as POSIX code. WINE only converts the instructions to x86 CPU's, so don;t expect it to work on Raspberry Pi's that use ARM RISC architecture.


Useful Linux software to get you started.


Winff media file convertor. Uses ffmpeg needs to be installed). It's a GUI for ffmpeg that allows files to be converted, e.g. a.wav  to .mp3 or .avi to .mp4 etc.

Image Magik - a powerful image manipulation tool and editor. And by using the command "display" in the Linux terminal you get a very effective old school paint program.  Available for Raspberry Pi too.

Youtube-dl - excellent video downloader. Grabs just about any video from any website (not just YT). Note, if you install via your Linux distro "app store" then updates are usually zero. If you trust the author then head on over to the official website and follow his instructions. Note - LM20 and modern Linux distro's are now using Python 3, which screws up youtube-dl from working (it prefers Python 2). To fix this just install python-is-python3 and that will resolve the issue.

NOTE - As of November 2021 there seems to be a bit of political argy bargy with YT and youtube-dl downloader. The result appears to be restricting download speeds to about 50Kb/sec, pathetic. A fork that gets around this can be found here https://github.com/yt-dlp/yt-dlp Some tips, to update use the command "sudo yt-dlp -U". By default yt-dlp will always download the highest video and audio format available. If you are downloading something that you do not require the highest quality then use the command line "yt-dlp www.somewhebsite.com/blah.mp4  -f worst" <enter>.

vnaJ - Yes the case IS correct. Java based software for various VNA's on the market (inc old school MRS Mini VNA's too) but no Nano VNA's.

Nano VNA Saver - software for Nano VNA. Available for Linux, Raspberry PI, Mac, Windows. See here.

Krename - best utility for renaming batches of files on Linux. Beats Nemo and other utils (so far). Note. Nemo in Linux Mint now contains a sensible batch renamer too.

Sox - amazingly small audio player, virtual audio cable,  mixer, converter and recorder from a command line.  Available on all Linux distros and Raspberry Pi. Use sudo apt-get install sox" to install it. You may need to install libsox-fmt-all (use same apt-get command as above) to play MP3's. SOX has an alias called "play". To use it, simply type "play filename.mp3". Note the lower case !

Tilde - a nice MS DOS EDIT clone. Available for Linux and the Raspberry Pi. Use "sudo apt install tilde" to get it.

Vidcutter - a dead simple video editor, the video equivalent of Audacity. No PhD required to use this one, it's great !

feh - lower case ! a command line picture viewer. Very fast. sudo apt-get install feh will it it for you.

Nemo image resizer for Nemo file manager - sudo apt install nemo-image-converter

Wavemon for montoring your internet and wifi in terminal mode - sudo apt install wavemon

wget - Great for grabbing stuff, Rip off  a whole website, use wget -mpEk "url"


Make Firefox browser faster by using a RAM Cache instead of disk access.


In the URL bar of Firefox type:

about:config

Press Enter.

Ignore the warning and click on the button "I accept the risk!".


Past the following into the filter bar (search bar): browser.cache.disk.enable

Toggle its value to false by double-clicking it: this will disable "cache to disk" entirely.


Make sure that "cache to RAM" is enabled (it is by default, but it may have been changed earlier). Copy and paste the following into the filter bar (search bar): browser.cache.memory.enable This should already be set to true; if not, toggle it to true by double-clicking it.

Then you're going to determine how much memory can be used as RAM cache. Copy and past this into the filter bar (search bar): browser.cache.memory.capacity

Set it to 307200 (the figure indicates KB, which equals 300 MB). That's usually enough for all amounts of RAM.

Restart  Firefox.

Note that if you use an SSD or a fast hard disk then these changes might not make any appreciable difference.


Linux Mint 20.3 on a GPD Pocket 1


If you have a rare, and very nice GPD Pocket 1 nano laptop then you I can recommend installing Linux Mint 20.3 Mate or the Cinnamon edition. The GPD Pocket 1 has a slightly unusual 32 bit boot loader bolted to a 64 bit CPU, and many standard Linux images will not boot / install properly. It works a treat, the best ever ! All the usual ham radio apps are available and more.

Create a normal bootable ISO on a USB stick. Boot the the GPD and hold the ESC key until you are presented with the BIOS screen. It will be a 90 degrees, so you have a use your arrow keys to force it to boot in the USB stick. first. Now reboot. Install as normal (install icon on the GUI) which takes about 20 minutes. 

The screen will still be rotated, so once the install has completed you can then use the LM DISPLAY options to set up the screen rotation correctly, as well as add 200% scaling and a few tweaks to the fonts so that things look right etc. Job done ! Note, that using the GPD with the touchscreen is not possible (mouse only).

Linux Mint mirror service, all versions found here http://www.mirrorservice.org/sites/www.linuxmint.com/pub/linuxmint.com/stable/

Or my copy is here.

I've not tried later versions of LM, but I suspect now that the LM team have taken up support for the GPD1 then the later versions will include it too.


The GPD's normally come with a US keyboard layout. Now if like me you install your OS and instantly hit the UK (or local keyboard settings) then you'll get confused! You can overcome this with one simple command in the terminal "sudo update-locale LANG=de_US.UTF-8" <enter> and that's it. Now your keyboard will be correct according to the physical layout.