Misc notes — mostly linux

A variety of links and ideas


Shutdown slow with Samba/Windows shares in Linux

http://techdelirium.blogspot.com/2015/11/slow-shutdownreboot-when-mounting.html

sudo ln -s /etc/init.d/umountnfs.sh /etc/rc0.d/K14umountnfs.sh

sudo ln -s /etc/init.d/umountnfs.sh /etc/rc6.d/K14umountnfs.sh


Linux bash script – Windows batch script links

http://www.dostips.com/DtTipsStringManipulation.php

 


 OCR in linux

https://help.ubuntu.com/community/OCR


Déjà Dup instead of Lucky Backup

https://www.linux.com/learn/total-system-backup-and-recall-deja-dup


Monitor linux disk usage, send email

https://www.linux.com/learn/customized-file-monitoring-auditd

https://www.linux.com/blog/linux-shell-script-monitor-space-usage-and-send-email


Bluetooth headset controls

https://wiki.archlinux.org/index.php/X_KeyBoard_extension#Multiple_keyboards

https://bugs.freedesktop.org/show_bug.cgi?id=53907


Quick backup of linux?

http://manpages.ubuntu.com/manpages/trusty/man8/dump.8.html
Dump examines files on an ext2/3/4 filesystem and determines which
files need to be backed up.


Create a live cd of the installed Linux system

https://sourceforge.net/projects/pinguy-os/files/ISO_Builder/


Systemd service after network is connected

Sometimes the service is wireless, so connection doesn’t happen until a user logs in.

Try this (not tested yet)

[Unit]
Description=start script

[Service]
Type=idle
ExecStart=/script/location/name
Restart=always
RestartSec=30

[Install]
WantedBy=network-online.target

Find command

http://www.binarytides.com/linux-find-command-examples/


Linux bluetooth headset

The headsets send info as sound input, sound mic, keyboard and mouse.

Check what happens when the hangup button is pushed, maybe use automation to make it click Zoiper voip softphone


List linux packages by date installed

https://help.ubuntu.com/community/ListInstalledPackagesByDate


Systemd information

https://www.digitalocean.com/community/tutorials/how-to-use-systemctl-to-manage-systemd-services-and-units

 

https://wiki.archlinux.org/index.php/systemd

Run script right before shutdown
http://unix.stackexchange.com/questions/39226/how-to-run-a-script-with-systemd-right-before-shutdown?noredirect=1&lq=1

[Unit]
Description=Log Traffic
DefaultDependencies=no
Before=shutdown.target reboot.target halt.target

[Service]
ExecStart=/usr/local/bin/perl /home/me/log_traffic.pl –stop
Type=oneshot

CIFS shutdown problems

test by mounting local windows share

try to shut down nrservice before closing down — didn’t help

use oneshot to umount?

run umount before shutdown.target reboot.target halt.target?


Automate what is seen on screen

http://www.sikuli.org/
Sikuli automates anything you see on the screen. It uses image recognition to identify and control GUI components. It is useful when there is no easy access to a GUI’s internal or source code.

 http://alternativeto.net/software/xdotool/?platform=linux
This tool lets you simulate keyboard input and mouse activity, move and resize windows, etc. It does this using X11’s XTEST extension and other Xlib functions.

https://github.com/guoci/autokey-py3
AutoKey-Py3 (GitHub) is a Python 3 port of AutoKey, a desktop automation utility for Linux and X11.
Click on or move pointer to an area that can be identified with an image


Linux containters (like vms)

https://linuxcontainers.org/


Hide command screens that must run in the background

http://www.linuxdevcenter.com/cmd/cmd.csp?path=s/screen

sudo apt-get install screen

create a script shrewsoft-ikec.sh that will start an ikec command with a screen name of shrew.
This will hide the ensuing command window ikec creates while keeping the program running at low cpu.

#!/bin/bash
screen -dmS shrew /user/bin/ikec -r bcws -a
sleep 2s
screen -d shrew

Create Startup Application named a.shrew to run script at login

To kill the screen create above by name

screen -X -S shrew kill

To get ikec running iked has to be started first and if there is a problem it has to be killed and restarted before ikec is restarted

sudo iked

To run iked with systemd, create the following in /etc/systemd/system

iked.service

[Unit]
Description=Shrew VPN client

[Service]
ExecStart=/usr/sbin/iked
TimeoutSec=0 StandardOutput=tty
RemainAfterExit=yes
SysVStartPriority=99

[Install] WantedBy=multi-user.target

 

Run

sudo systemctl start iked.service
sudo systemctl enable iked.service

To kill the iked or ikec process

killall -9 ikec

Test network information

View most cpu intensive processes

top

View

Get route info for specific ip address

ip route get xxx.xxx.xxx.xxx

Get route info for all ip connections

route -e

display process info for name

ps -ef | grep processname

check if ip exists with a specific

ip route get 10.141.229.1 | grep ” tap” &> /dev/null; if [ $? == 0 ]; then echo “tap0”; else echo “not tap0”; fi