*nix

Linux notes, mostly done on ubuntu > 17

Control service with systemd

Change visudo editor

sudo update-alternatives --config editor
Then select the prefered editor from the list.

Mount mp3 player as non root

Create directory with permissions
mkdir -p /media/mp3
	  chown gregory /media/mp3
	  chmod 0777 /media/mp3
In fstab add mount point
/dev/sda /media/mp3 auto user,umask=000,utf8,noauto 0 0
Then when connected mount with
mount /media/mp3

Bash

Clear history

In each terminal enter the commands

history -c
	  history -w

Graphviz diagrams

Convert to svg

dot -Tsvg -o $nameonly.svg $path

Reload window with xdotool

Look in the title for the window name, below example is for surf browser whose name is @cgDISVMf, not really a name but that is what's in the title :-))
	  browser=$(xdotool search --name "@cgDISVMf")
	  back=$(xdotool getactivewindow)
	  xdotool windowactivate --sync $browser
	  xdotool key --window $browser --clearmodifiers "CTRL+R"
	  xdotool windowactivate --sync $back
	

Ignore first N lines in pipes

	  cat SOMEFILE | awk '{if(NR>7)print}'
	

Runlevel

Default to runlevel 3 at boot

	  man systemctl
	  systemctl isolate multi-user.target
	  systemctl enable multi-user.target
	  systemctl set-default multi-user.target
	

Filesystem

Install new harddrive

Use parted to partition the drive. Format it with eg. ext4 and then find PARTUUID

	  sfdisk -l
	  blkid /dev/sda1
	

Update /etc/fstab

	  PARTUUID=51d86c9d-3a01-4bb6-b173-b6ec70d76a02 /media/newdrive ext4 errors=remount-ro 0 2
	

Logging

Centralize logging with syslog-ng. On the sender side change /etc/syslog-ng.d/remote.conf

destination d_remote-syslog {
  network("192.168.1.101" transport("udp") port(514));
};
log {
  source(s_system); destination(d_remote-syslog);
};