My fstab
# /etc/fstab: static file system information.
#
# Use ‘blkid’ to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point> <type> <options> <dump> <pass>
# / was on /dev/sda1 during installation
UUID=da0cf23f-cb0d-443e-911a-36247b48f0d7 / ext4 errors=remount-ro 0 1
# swap was on /dev/sda5 during installation
UUID=75445880-eb29-4784-a890-157ac38c4be1 none swap sw 0 0
# /mnt/bak was on /dev/sdb1 during installation
UUID=6ab84907-1cd0-4509-b8c5-4ae8c0b8e024 /mnt/bak ext4 defaults 0 2
# /mnt/store was on /dev/sdb2 during installation
UUID=a469e9cb-50fe-4f91-8615-78cd81fa7ba1 /mnt/store ext4 defaults 0 2
#
#
//10.1.1.10/store /mnt/fishmythstore cifs guest,nounix,user,uid=1000 0 0
Clean up old kernels in Linux Mint:-
This should remove all kernels except your current kernel and the two latest old ones:
sudo apt-get install byobu
sudo purge-old-kernels
Or you can do it via “Update Manager”
To Do before upgrading or changing distro:-
Save fstab, smb.conf
Save /home
Save packages which are possibly not in new version
Export bookmarks, addressbook and calendar
Check (and maybe save) password.pwm, cron.daily and cron.hourly stuff, VMWare image folder
Take note of sound settings
To mount Shares from Windows PC’s
Create directory e.g /share
To mount…. type…
smbmount //winsys/winshare some-mount-point
Example for me (X = win pc, C = Share name)
smbmount //X/C /share
To unmount (my example)…
smbumount -t smbfs /share
Mounting smbfs Shares Permanently
http://www.justlinux.com/nhf/Filesystems/Mounting_smbfs_Shares_Permanently.html
And some notes I found useful to access Vista shares…..
Using a text editor, create a plain text file containing two lines:
username=windows_username
password=windows_password
Substitute your actual Windows username and password for the italicized text. Save the file in your home folder as .smbpasswd (don’t forget the dot at the beginning of the filename, which makes the file hidden). Finally, change the permissions on the file so only you can open and change it by issuing the following command in a Terminal window:
chmod 600 .smbpasswd
On the Linux machine, open /etc/fstab in a text editor.
(On Ubuntu, I used the command sudo gedit /etc/fstab. You can use another editor if you prefer.)
At the end of the file, add a new line containing the following:
//vista_pc_name/share_name mount_folder_name smbfs credentials=/home/linux_username/.smbpasswd,uid=linux_username,gid=users 0 0
Use the UNC path for the Windows share, and replace mount_folder_name with, for example, /mnt/vista_public).
Substitute your Linux username for the values in red. These credentials will be passed to the Vista machine.
(Note: there’s no space after the comma and before the uid and gid.)
[Update: Thanks to Jeremy Allison in the comments of the previous post for pointing out that smbfs is deprecated and no longer maintained. You can safely substitute cifs for smbfs in the fstab entry.]
Sitecopy
.sitecopyrc…..
site mysite
server fisherfamily.orconhosting.net.nz
username *******
password *******
local /home/robert/Shared/robert/my_web
remote ~/fisherfamily.orcon.net.nz/htdocs/
Maintenance
sitecopy –update sitename (or for the above)….
sitecopy –update mysite
Imagemagick
To resize…
# convert -sample 80×40 input.jpg output.jpg
for multiple files….
mkdir new
for n in *; do convert -sample blabla $n new/$n; done
where that asterisk stands for any shell glob pattern you wish to use to match the files to be converted (you can also use more than one pattern, space-separated).
For example…..
mkdir new
for n in *jpg; do convert -sample 80×40 $n new/$n; done
or
for n in *jpg; do convert -sample 400×400 $n new/$n; done
Someone else suggested…..
for x in *.jpg; do convert -sample 80×40 $x ${x/.jpg/640×480.jpg}; done
To rotate…
convert -rotate -90 dscf0010.jpg 10.jpg
Album
<a href=”http://marginalhacks.com/Hacks/album/”>http://marginalhacks.com/Hacks/album/</a>
To create captions file –
ls > captions.txt
You get a file with the names of all the pics in the directory, then edit it with your captions. Do it with the browser viewing the pics, and an xterm editing the file open at the same time.
WGET
Try wget, it is a commandline tool, but don’t be scared! It is very robust.
example:
wget http://www.microsoft.com/win2k.iso
if it stops part way through
wget -c http://www.microsoft.com/win2k.iso
-c = continue.
It will dump the file in your current directory.
I often cut and paste the file’s URL into a terminal window to save a lot of retyping.
SCP
To copy a file from where you are working to a remote machine, the command is
$> scp @:{}
where is optional. If the directory is not given after the colon, the file will be saved in your home directory.
The statement
$> scp foo.java blair@foo.clarku.edu:java
will save the file foo.java to my directory java/ on the machine foo.clarku.edu
To retrieve a file from a remote machine, the order is reversed:
$> scp blair@foo.clarku.edu:java/foo.java ./java
will bring foo.java from the java directory on foo and save it to the java directory where I am giving the scp command.
To save to the home directory the ./ is just a . /
Use -r for recursive copies e.g.
scp -r /localfile user@othercomputer:/otherfolder
My examples:-
scp -P xxx 60.234.134.181:Shared/robert/my_web/super15/week10.html .
(Note: The dot at the end means the current local directory. This is a handy trick that can be used about everywhere in Linux.)
scp -P xxx week10.html robert@60.234.134.181:Shared/robert/my_web/super15/
Various Linux Commands:-cat /proc/bus/usb/devicescat /proc/pcicat /proc/modulescat /proc/cpuinfocat /proc/ioportscat /proc/sys/dev/cdrom/infocat /proc/scsi/scsicat /proc/version
To Display Messages as they occurtail -f /var/log/messages
To find Default Gateway:-route -nip route shownetstat -rn
To show active internet connections:-netstat -tlpn
To show DNS addresses
nmcli dev show | grep DNS
To Mount an iso image to see files….
mount -o loop -t iso9660
To see pci devices…cat /proc/pci
To see Drives…dmesg | grep hd
or
df
To find files or folders….
locate name
For case insensitvity use -i (locate -i filename)
locate name | less (e.g. locate icon | less)
locate name | most (e.g. locate icon | most)
locate name | grep another_name | most (e.g. locate icons | grep mozilla | most)
or
qpkg -l mozilla|grep icons|less
OR – finding files with specific text……
find dir | xargs (z)grep (e.g. find /etc | xargs grep GENTOO_MIRRORS=)
(the z is used for zipped files)
Creating executable script file
create a text file with
#!/bin/bash
as the first line then just add the command-line stuff you want.
Then when you are finished do:
chmod +x filename
to make it executable
then hey presto you have a script ready to run.
Backups with Linux and Rsync
<a href=”http://www.mikerubel.org/computers/rsync_snapshots/”>http://www.mikerubel.org/computers/rsync_snapshots/</a>
SSH on different port (normally 22)
For example – ssh ipcop -p 222
How to create Image (ISO) files from CD/DVD
Assuming that /dev/cdrom is the location of CD/DVD-ROM
sudo umount /dev/cdrom
readcd dev=/dev/cdrom f=file.iso
or
Turn a CD/DVD into an .iso
sudo umount /dev/cdrom
dd if=/dev/cdrom of=file.iso bs=1024
Turn a folder into an .iso
mkisofs -r -o file.iso /location_of_folder/
Generate an MD5 checksum file
md5sum file.iso > file.iso.md5
To test pop3 use telnet:
telnet pop3.xtra.co.nz 110
user xxxx
pass yyyy
list
quit
To set up my USB Portable Hard drive enclosure.
Create ntfs partion with
cfdisk /dev/sdc
Format ntfs partition with
mkfs.ntfs /dev/sdc1 -L portable (portable = volume name)
Mount drive (writable) with
mount -t ntfs-3g /dev/sdc1 /mnt/usbdrive/ -o force
(Having first created folder /mnt/usbdrive)
or for my pocket drive…..
mount -t ntfs-3g /dev/sdc5 /mnt/usbpocket/ -o force
My bak backup……sudo rsync -urC --delete /mnt/bak/ /media/robert/HP\ Pocket\ Media\ Drive1/
To Install Webmin
First, you need to install the components Webmin needs.
This can be done with one command:
#aptitude install libnet-ssleay-perl libauthen-pam-perl libio-pty-perl libmd5-perl
When that is done, you need to download Webmin, the current version is 1.470.
You could simply go to the webmin website and download it
After it is downloaded, install it using dpkg:
#dpkg –install webmin_1.470_all.deb
How I installed Transmission on Ubuntu 16.04
(I followed http://www.htpcguides.com/install-transmission-bittorrent-client-on-ubuntu-15-x/)
sudo apt-get install transmission-cli transmission-common transmission-daemon transmission-gtk minissdpd
sudo service transmission-daemon status
sudo service transmission-daemon stop
sudo nano /var/lib/transmission-daemon/info/settings.json
sudo usermod -a -G debian-transmission robert
sudo service transmission-daemon start
sudo service transmission-daemon stop
sudo service transmission-daemon status
sudo mkdir -p /etc/systemd/system/transmission-daemon.service.d
sudo nano /etc/systemd/system/transmission-daemon.service.d/local.conf
sudo systemctl daemon-reload
sudo service transmission-daemon stop
sudo usermod -aG robert debian-transmission
sudo usermod -aG debian-transmission robert
sudo chmod 775 /etc/transmission-daemon/settings.json
sudo nano /etc/transmission-daemon/settings.json
sudo service transmission-daemon restart
sudo service transmission-daemon status
How I installed Google Drive on Linux Mint
google-drive-ocamlfuse
Don’t be frightened by the name, google-drive-ocamlfuse is a CLI fuse-based filesystem backed by Google itself, and with it you can perform directory operations on your Google Drive account.
It features syncing with multiple accounts, access to Google Drive’s trash directory, and read-only access to Google docs, sheets, and slides.
sudo apt-add-repository ppa:alessandro-strada/ppa
sudo apt-get update
sudo apt install google-drive-ocamlfuse
sudo groupadd fuse
sudo usermod -a -G fuse robert
exec su -l $USER
google-drive-ocamlfuse
mkdir ~/googledrive
google-drive-ocamlfuse ~/googledrive
mount
To disconnect manually:- fusermount -u ~/googledrive
To connect your googledrive manually:- google-drive-ocamlfuse ~/googledrive
How I set up Passwordless SSH
cd /home/robert/.ssh/
ls
rm id_rsa
rm id_rsa.pub
ls
ssh-keygen (Do not enter any passphrase. Just hit ENTER key and continue with default values.)
ssh-copy-id robert@123.456.789.123 -p 246
ssh-add
ssh-add -l
ssh robert@123.456.789.123 -p 246
Pruning old docker imagessudo docker system dfsudo docker imagesdocker image prune -a
Upgrading HASS (docker-compose)cd /path/to/compose/file//usr/bin/docker-compose pull && /usr/bin/docker-compose up -d
Backup my HASS (docker-compose)
First run sudo mount -a
sudo rsync -urC --delete /srv/homeassistant/ /mnt/fishmythstore/bak-hass/
Upgrading HASS (virtualenv)sudo -u homeassistant -H -s
cd ~/.homeassistant/
cd /srv/homeassistant
python3 -m venv .
source bin/activate
python3 -m pip install --upgrade homeassistant
Downgrading HASS (virtualenv)sudo -u homeassistant -H -s
cd ~/.homeassistant/
cd /srv/homeassistant
python3 -m venv .
source bin/activate
python3 -m pip install homeassistant==x.xx.x
Hass Crontab:-
#10 2 * * * systemctl restart homeassistant.service
12 2 * * * systemctl restart nginx.service
#30 2 5 * * certbot renew –pre-hook “systemctl stop nginx.service” –post-hook “systemctl start nginx.service”
#0 1 * * 3 rm /home/homeassistant/.homeassistant/.google_maps_location_sharing.cookies.hass_fisher_net_nz
Hass MQTT topics examples:-mosquitto_sub -h localhost -t '#' -v | grep shelly1
mosquitto_sub -h localhost -t '#' -v | grep shellyswitch25
Hass MQTT blinds with Shelly25:-
http://www.bujarra.com/controlando-las-persianas-con-shelly-2-5-y-home-assistant/?lang=en
Fishminder Crontab:-
# m h dom mon dow command
#10 04 * * * systemctl restart zoneminder.service
#10 4 * * * systemctl restart zoneminder.service
0 */6 * * * systemctl restart zoneminder.service
#00 04 * * 0 /usr/bin/mysqlcheck –all-databases –auto-repair
0 4 * * 0 /usr/bin/mysqlcheck –all-databases –auto-repair
Updating my letsencrypt certificate:-
## SCRIPT CONTENTS
#!/bin/bash
sudo certbot -d *.fisher.net.nz –manual –preferred-challenges dns certonly
##
– ./renew_cert
– 1stdomains -> login & Manage DNS Zone Records
– update _acme-challenge.fisher.net to challenge string from script above.
– Browse to https://mxtoolbox.com/TXTLookup.aspx
– lookup: _acme-challenge.fisher.net.nz
– confirm Record matches challenge string from script above.
To check certificates:-sudo certbot certificates
Important: Update calendar reminder to new expiry date.
How I installed VNC on my Ubuntu 20.04 server
https://linuxconfig.org/vnc-server-on-ubuntu-20-04-focal-fossa-linux
sudo apt update
sudo apt install tightvncserver xfce4 xfce4-goodies
vncpasswd
vncserver (You will require a password to access your desktops.)
vncserver -kill :1
mv ~/.vnc/xstartup ~/.vnc/xstartup.bak
nano ~/.vnc/xstartup
Edit as follows:-
#!/bin/bash
xrdb $HOME/.Xresources
startxfce4 &
Save and make executable – sudo chmod +x ~/.vnc/xstartup
Start the server again – vncserver
netstat – tlpn (will show active connections)
Note: If using Vinagre as VNC client it pays not to save the password for multiple servers. (On Ubuntu or Linuxmint they can be removed using Seahorse)
Wake on lan:-
Enable Wake on LAN on server and after shutdown ensure lights are still on on NIC then on client (machine sending the magic packet):-sudo apt-get install wakeonlan
wakeonlan (MAC address)
e.g.wakeonlan f8:b1:56:b7:93:3d
Ookla Speedtest-cli (install and use):-
curl -s https://packagecloud.io/install/repositories/ookla/speedtest-cli/script.deb.sh > script.sh
chmod 755 script.sh
sudo os=ubuntu dist=jammy ./script.sh
sudo apt install speedtest-cli
speedtest --version
To run – speedtest-cli --secure
or speedtest --secure
Installing new ROM on Google phones
Recent Comments