editing your personal crontab
crontab -e
backing up a crontab file
to backup personal crontab
crontab -l > my-crontab
to restore
crontab my-crontab
Entries tagged "linux".
editing your personal crontab
crontab -e
backing up a crontab file
to backup personal crontab
crontab -l > my-crontab
to restore
crontab my-crontab
To enable passwordless ssh to machines on your network use ssh keys
generating keys
ssh-keygen will generate a new key
however if you already have a key it will overwrite it
ls -l ~/.ssh to verify that there are none
ssh-keygen -b 4096
generates a strong key
press enter for default location
enter a passphrase if you want one you can leave it blank to do away with passwords
To copy the key to the server you want to access
first try connecting to the server using a password.
if that works you can do
ssh-copy-id username@ipaddress
you will need to enter the password one last time
from then on you can connect without a password unless you entered a passphrase in the first command.
for more info watch
https://www.youtube.com/watch?v=33dEcCKGBO4
Occasionally there is a need to use an X windows program with ssh. However these programs will fail with the message cannot open display:
But wait there is a way! simply use the -X option with your ssh command and if your local machine has Xwindows capability then you can get the window for the program.
Using Xwindows from Microsoft windows:
This used to be a real headache. all kinds of esoteric stuff needed to be installed but nowdays you can just install linux subsystem for windows and you can display those xwindows screens with no issues.
So I have been reading a lot about a linux virtual machine system known as proxmox.
I had tried installing it a couple yoears back but never did much with it as the PC i put it on had issues.
Looking around Ebay a few months ago I discovered the HP elitedesk line of mini PC's
They were originally intended to be office workstations a bit beefier than a thin client.
I found the elite desk 800 for sale with a 8 gigs or ram and no hd for about $60.
I bought one. added another 16gb memory to it that i had on hand and a 2 terabite ssd to it for another $60. I installed proxmox and started adding virtual machines to it.
First I created a debian server vm to be an apache webserver and run gridtracker a ham radio program. That is the server hosting this blog.
Second I decided to try creating a container. A container is like a limited virtual machine. I picked a container with the Gallery photo server software that installed with out problems. I have some family pictures on it so my extended family can access it.
I also have a Jellyfin server for hosting a few videos on the local network.
I also created a windows 10 vm just to see if I could and that works fine too.
Conclusion. The cheap little HP elitedesk works quite fine for running multiple home servers via proxmox. Didnt cost much more than a raspberry pi but offers a lot more muscle.
Give it a try
Kiwix ia a cool way to make online data available when the grid is down.
https://kiwix.org/en/
For example I keep the entirity of wikipedia on a raspberry pi for when the net isn't available.
offline wikipedia is about 80 gigabytes so you will need a large sd card or what i use is a ssd hard drive .
there is a lot of other info available using kiwix. for example open street maps.
Check it out.
So the digipi is an amazing peice of tech for ham radio digital modes.
Below are some of my customizations.
Beaconing using gpsd
By default the digipi beacons using the fixed coordinates you hand entered when you initialized it. However if using it with an icom 705 or other gps source you can have it use those coordinates dynamically.
To so so when in digipeater mode do the following into direwatch.digipeater.conf
Put near the top of the config file a line reading
GPSD localhost
comment out the pbeacon line
below the PBEacon line add a the following lines
# Beacon to RF using gpsd
TBEACON delay=00:05 every=30:00 symbol="house" overlay=R via=WIDE2-1 power=5 height=5 gain=2 comment="KD0YTE local digi using IC705,"
edit the comment and symbol to suit yourself
Maybe you want to take the digipi mobile. In that case you probably waant smart beaconing.
comment out the previous TBEACON lines and add these. I changed the overlay to a car since it will be mobile
I like orienting the digipi with power port up.
So in both
/home/pi/digibanner.py
/home/pi/direwatch.py
change the line that says rotation = 180 to rotation = 0
This makes fixes the upside down screen text when in this orientation.
More info to come...
I sometimes use a terminal on a windows machine to log into an ssh session on linux host.
Tonight I discovered MobaXterm at https://mobaxterm.mobatek.net/
This is a great terminal program. By default runs an xserver so you can run xwindows apps (even without using the -X switch)
also has a directory structure at the left that allows quick navigation to other places on the host.
It also honors linux colors which my previous fave tabby has issues with.
Give it a try!
I have a semi sheltered area that I want to put some plants in but springtime in NE MO is hit and miss and I dont want to damage the plants.
I also have a garage that is unheated that i want to monitor how cold it gets this winter.
So I fixed up raspberry pi zeros to keep a temp monitor of those areas.
installed pi os 32 bit lite version
On it installed pyhon3-pip
sudo apt-get install python3-dev python3-pip
sudo python3 -m pip install --upgrade pip setuptools wheel
Also installed the ADafruit library for the DHT11
sudo pip3 install Adafruit_DHT
Then i came up with a script to read from the sensor and report temp in Fahrenheit and humidity
named it tempf.py
import Adafruit_DHT
import time
DHT_SENSOR = Adafruit_DHT.DHT11
DHT_PIN = 4
humidity, temperature = Adafruit_DHT.read(DHT_SENSOR, DHT_PIN)
tempf = (temperature*1.8)+32
print (today, ",", now, ",", tempf, " ,", humidity )
# print (humidity, "%,")
2nd found a script to output current date and time
named it dateit.py
Then I wrote a bash script to call those 2 and send output to tempout.txt
temprec.sh
#!/bin/bash
python dateit.py >> ftemp.txt
python tempf.py >> ftemp.txt
Finally setup a crontab to run it every 5 minutes
crontab -e
*/5 * * * * /home/pi/temprec.sh
This could probably be done from 1 single python script but I am just not that good with python.
This works well. I might change to a longer interval for readings.
Output looks like this
2024-09-20 , 10:00:02.247606 , 78.80000000000001 , 64.0
2024-09-20 , 11:00:01.831673 , 82.4 , 61.0
The screen command is one of those linux commands that many newbs don't know about or don't see the usefulness of right away.
It is actually quite powerful.
If you ssh into a linux machine and want to start a process that stays running for a long time if your ssh session dies or
you need to log out the process will be killed.
However with screen you can keep it running in the background.
How to use screen:
You may need to install screen as it isn't installed by default on many distro's
Say you have a command that looks like this.
python dht11.py for example.
type screen python dht11.py
Screen will start the process running.
press ctrl A and then d to detach the screen and be returned to the command prompt.
The process is still running and you can log out of your ssh session.
Log back in and type screen -r to bring the process back to your terminal.
While i used an ssh session in my example the same applies if you are running an X terminal locally and need to close the terminal for a while.
So once the raspberry pi became availabe I purchased one.
The first pi I ever owned was a raspberry pi 2, it was a slug bug except for the simplest of tasks.
I have owned several pi 3's, a pi zero and a pi zero 2 w, and several pi 4's.
The pi 3 was much more useful than the pi 2 and the pi 4 was approaching usable for desktop use.
When I purchased the pi 5 I had heard the hype about how it was much faster than the pi 4 but to be
honest I was dissapointed. It was a little faster but not much. and for some reason about every couple of
months it would bork the sd card and I would have to reinstall. I finally purchased one of those high
endurance sd cards thinking that they would last longer. However I decided about that time to try an
nvme hat from geekworm and a patriot gen3 nvme drive.
I set boot to do nvme first then booted from the nvme drive cloned from the sdcard. (BOOT_ORDER=0xf416)
in /boot/firmware/config.txt
Holy Cow! What a difference. suddenly my pi 5 was a speed demon. chrome which always took several seconds to
load was now popping right up.
I also enabled gen3 speeds which is expiramental. that makes it faster but not profoundly faster.
If you are running pi5 from an SD Card, I highly reccomend you try nvme.
I will come back here with stabilty results after using it for a few months.
Have fun!
I had a need to move a home folder to a second drive for more space
I found these instructions from Derek Taylor aka DistroTube on youtube
Move Your Home Folder To A Second Drive
By Derek Taylor at February 20, 2020
Make Reinstalling Faster By Having Home On A Second Drive
Note: You may want to drop into tty to perform the following to avoid any weird side effects from doing this within your graphical environment. Also, for this example we will assume that your partition is sdb1 (change this to the id of your drive!). Also, have a backup handy…just in case.
Mount the new partition to /tmp:
sudo mkdir /mnt/tmp
sudo mount /dev/sdb1 /mnt/tmp
Copy your HOME content to the second drive:
sudo rsync -avx /home/ /mnt/tmp
Mount our new HOME partition:
sudo mount /dev/sdb1 /home
If all your data seems to be present on the second drive and new partition, you may delete your old /home directory. To do this, you must first unmount the new /home partition!
sudo umount /home #unmount the new home first!
Then you may delete the original /home:
rm -rf /home/*
Now let’s make your new /home permanent. Get the UUID so we can add it to your fstab:
sudo blkid
Then edit the fstab:
sudo vim /etc/fstab #or nano if you prefer
Add this line at the end of the fstab:
UUID=
Now reboot and see if it works!
sudo reboot
----------
Copyright © 2020-2021 Derek Taylor (DistroTube)
This content is licensed under a Creative Commons Attribution-NoDerivatives 4.0 International License (CC-BY-ND 4.0).
Sometimes you dont want a graphical desktop to load on your PC
This is what you need to do for linux mint
sudo nano /etc/default/grub
change the line that reads "quiet splash" to "text"
save file
This lets you see all the boot messages scrolling by
then to final step to disable the gui boot
sudo systemctl set-default multi-user.target
reboot
if you need to get into the gui desktop for some reason
sudo systemctl start lightdm
So in an earlier post I talked about setting up a pi zero to do temp and humidity recording
Today we will take this output and convert it to an html file to post on a local webserver.
We will also automate this process and add an archiving operation in case we want to go back and look at past data
First you will need to install a couple of things on the pi.
1. a webserver. I am using nginx as it is light on resources and the pi zero isnt very fast
2. the pandas python library to do the converting so
sudo apt install nginx python3-pandas
Next make a python script. We will call it csvconv.py
nano csvconv.py
## Python program to convert
## CSV to HTML Table
import pandas as pd
## to read csv file named "temps.csv"
a = pd.read_csv("temps.csv")
## to save as html file
## named as "temps.html"
a.to_html("temps.html")
## assign it to a
## variable (string)
html_file = a.to_html()
press ctrl o to save and ctrl x to quit
next make a bash script to do the html conversion and add some header and footers
nano dohtmltemps.sh
#!/bin/bash
cp ftemp.txt temps.csv
rm temps.html
python csvconv.py
cat gheader.html temps.html gfooter.html > index.html
cp index.html /var/www/html/
ctrl o and ctrl x as before to save
(by default the /var/www/html folder is writable only as root you will need to get around this so the script can write the file.)
(you could chmod +w -R the folder but if you will have this webserver connected to the internet that is a security risk.)
the gheader.html and gfooter.html are simple html snippets to make the page more complete.
make yours as fancy as you like.
next I made a script to run weekly to archive the data for posterity.
nano arctmp.sh
#!/bin/bash
echo ftemp.txt > "ftemp-$(date +"%m-%d-%Y").txt"
echo temps.csv > "temps-$(date +"%m-%d-%Y").csv"
sleep 5
cp ftheader.txt ftemp.txt
This simply appends the date to the file name.
Finally you want to setup cron to record the temp hourly, make the html file nightly and archive the temp data weekly.
crontab -e to edit the crontab
Here is what I have in mine
*/60 * * * * /home/pi/temprec.sh
46 23 * * * /home/pi/dohtmltemps.sh
50 23 * * 0 /home/pi/arctmp.sh
enjoy!
System.d can run stop enable or disbles services with the systemctl command
Examples
sudo systemctl start httpd to start apache web service, can also use restart
sudo systemctl stop httpd stops the service
sudo systemctl enable httpd enables it to start at system startup
sudo systemctl disable httpd duisables it
sudo systemctl status httpd tells you if it is running
possible services are in 1 of 3 directories in this order of priority
the /etc/systemd/system directory ,
the /run/systemd/services directory and
the /lib/systemd/system directory.
So ls-l those directories to see units that systemctl can
control.
package managers will install units to /lib/systemd/system
If you write you own units put them in /etc/systemd/system so they wont be overwritten
by package managers.
Taskwarrior is a linux command line task manager and reminder app
there are many command line options but the simplest are as follows.
Adding a task:
$ task add "task description"
Listing tasks:
$ task
will output as follows
ID Age Description Urg
1 2min check out obsidian 0
2 1min finish printing spacers 0
Deleting a task
$ task del "task number"
Sometimes you need to discover the specs on the hardware you are running.
For example: cat /proc/cpuinfo will give you detailed info about your cpu
neofetch and fastfetch are quite popular for giving you other specs but
a more powerful command is dmidecode
the command must be run as root or with sudo it has several command line options as follows.
dmidecode -t to see info about your pc
keywords are
bios
system
baseboard
chassis
processor
memory
cache
connector
slot
for example
sudo dmidecode -t processor will show details about your cpu
dmidecode is included with most distributions
lsh is another useful tool but must be installed as an additional package
rsync is a useful tool for copying files to a remote machine using ssh.
simple command to backup a directory is
rsync -a ~/dir1 username@remote_host:destination_directory
if the username is the same on both systems you can omit the username@
if you omit the destination after the : then files are copied to the users home folder.
comand line options
-a archive mode which preserves file permissions
-z will compress the file during transfer to make the transfer faster
-P will show progress and also allows partial transfer so that files that havent been changed won't have to be transferred again.
-an --delete forces rsync to delete the files on the destination before copying the source file. this is not the default behavior of rsync
-v is for verbose output giving information about the transfer as it is happening.
-h gives human readable output on files sizes etc.
Give rsync a try it is quite useful
pacman is Arch linux's package manager. similar to apt in debian and dnf in fedora but much more complex as several
operations depend on multiple use flags.
One can go read https://wiki.archlinux.org/title/Pacman on the arch wiki but a quick synopsis is as follows.
pacman -S packagename installs a package (must be run with root priveleges)
pacman -R package name uninstalls a package
pacman -Rs uninstalls the package and its dependancies if not used by other packages.
pacman -Ss search for a package
pacman -Syu upgrade all packages to the very latest
in addition their are a few other useful commands.
paccache -r cleans the package cache of old unneded package versions
pactree packagename lists all dependancies for a package