Openwrt dmesg human timestamp

To viel on busybox dmesg with human readable time for debug do:

$vi /root/dmesg.sh

insert:
base=$(cut -d '.' -f1 /proc/uptime);
seconds=$(date +%s); 
dmesg | sed 's/\]//;s/\[//;s/\([^.]\)\.\([^ ]*\)\(.*\)/\1\n\3/' | 
while read first; do 
  read second; 
  first=`date +"%d/%m/%Y %H:%M:%S" --date="@$(($seconds - $base + $first))"`;
  printf "[%s] %s\n" "$first" "$second"; 
done 
exit 0

run it sh dmesg.sh..

System Echo:

...
[16/03/2018 14:55:18] br-lan: port 3(wlan1) entered blocking state
[16/03/2018 14:55:18] br-lan: port 3(wlan1) entered disabled state
[16/03/2018 14:55:18] device wlan1 entered promiscuous mode
[16/03/2018 14:55:18] br-lan: port 3(wlan1) entered blocking state
[16/03/2018 14:55:18] br-lan: port 3(wlan1) entered forwarding state
[16/03/2018 14:55:19] br-lan: port 2(wlan0) entered blocking state
[16/03/2018 14:55:19] br-lan: port 2(wlan0) entered forwarding state
[16/03/2018 15:34:17] device wlan1 left promiscuous mode
[16/03/2018 15:34:17] br-lan: port 3(wlan1) entered disabled state
[16/03/2018 15:34:17] device wlan0 left promiscuous mode
[16/03/2018 15:34:17] br-lan: port 2(wlan0) entered disabled state
[16/03/2018 15:34:24] br-lan: port 2(wlan0) entered blocking state
[16/03/2018 15:34:24] br-lan: port 2(wlan0) entered disabled state
[16/03/2018 15:34:24] device wlan0 entered promiscuous mode
[16/03/2018 15:34:24] br-lan: port 3(wlan1) entered blocking state
[16/03/2018 15:34:24] br-lan: port 3(wlan1) entered disabled state
[16/03/2018 15:34:24] device wlan1 entered promiscuous mode
[16/03/2018 15:34:24] br-lan: port 3(wlan1) entered blocking state
[16/03/2018 15:34:24] br-lan: port 3(wlan1) entered forwarding state
[16/03/2018 15:34:25] br-lan: port 2(wlan0) entered blocking state
[16/03/2018 15:34:25] br-lan: port 2(wlan0) entered forwarding state
...

Breaking News Timeline

Surf Browser Slim Twitter Timeline on Desktop

If you search for a slim twitter client on desktops try the small „surf“ browser

install with:

sudo apt-get install surf

and use
surf https://mobile.twitter.com/yourprofilename

Now you have a slim and clean Twitter Timeline like on Tablets, it can be resized to Banner or Fullscreen.

Linux: Systemd ignore console-setup settings

If you work on older Laptops and you use a Console only System Setup like on Debian there is a Bug on systemd and the console-setup package since years. After reboot all Font Settings seems gone. But the Settings are not real gone, cause systemd does not pull the settings on boot!

How to fix?

  • edit the crontab of root by

sudo su -
crontab -e

  • insert the /bin/setupcon command on „@reboot“ means on every boot!

@reboot     /bin/setupcon > /dev/null 2>&1 

  • save and exit, reboot now
  • now the PC should echo big Fonts for old eyes „Terminus 20×12 Frambuffermode“

 

Security: Isolated Browser eMail Programs

If you want to be more secure, on Linux you can isolate used programs on different Users! All you need is installed by default!

isolated firefox thunderbird

Howto:

  • Add a new User for eMail and Browser to the System with:

$sudo adduser mailuser
$sudo adduser webuser

  • now install if not installed by default „gksu“ User Switch

$sudo apt-get install gksu

  • copy now the default App Links to webuser’s Home Desktop, for mailuser enter mailuser’s name

$cp /usr/share/applications/firefox-esr.desktop /home/webuser/Desktop/firefox-esr.desktop

  • edit the firefox-esr.desktop by right click on nautilus or a editor and change command line:
  • old:

/usr/lib/firefox-esr/firefox-esr %u

  • to:

gksu -u webuser -w "/usr/lib/firefox-esr/firefox-esr %u"

  • save and exit
  • Now to test click on the Firefox App Link and a Password is asked! Enter the webuser password and you use Firefox on a isolated Account!
  • Do same for thunderbird eMail Client! that no bad Code can access your Emails!
  • Set the Home Folder rights for webuser and mailuser to 700 with:

$sudo chmod 700 /home/webuser
$sudo chmod 700 /home/mailuser

  • Remark: Same Technics available at Windows or other Unix Systems, alternate use VNCSERVER! a App to run Desktops inside Desktops!
  • Advantage: Programs run on isolated RAM Space!

Raspberry Pi: Resize Shrink SDCard Image Clone Backup Noobs

If you own a raspberry pi, in some cases it is useful to shrink the sdcard, cause you need often not more than 8/16GB.

What do you need and how to solve shinking or extending the OS:

Hardware you need:

  • 2 empty SDCards (Source + Dest.)
  • 2 SDCard Adaptors Micro-SD to SD Fullsize
  • 2 SD-USB Card Readers, i use them for stable work, cause USB SDCard Readers on Laptops often fails (Shared Sources)
  • 1 Laptop with Ubuntu CD inside the CD-Rom or installed ubuntu with gparted
gparted raspian shrink sdcard
gparted raspian shrink sdcard
gparted shrink progress pi
gparted shrink progress pi

Howto:

  • Plug the Cards into the Adaptors and into the Readers, connect to the Laptop
  • Boot ubuntu and rund $sudo gparted
  • On the destination SDCard (/dev/sdd) create a new msdos Partition Table, (Top Menu gparted)
  • Switch on gparted to Source SDCard (/dev/sdc) where noobs / raspian is
  • Copy first the primary and the last partition to the sdd-disk on same area! (start Bootloader + end Config)
  • Create on sdd at the middle area a new „extended“ partition
  • Go to Source Card sdc and Shrink the patition at the middle near to the „yellow“ area!
  • Enter at Menu the green arrow to start gparted work! Take a coffee now..
  • If gparted is ready the LED Controls of the Adaptors stop blinking! Copy the shrinked partition to sdd paste it into the extended partition
  • Here you can expand the middle partition to all free grey space
  • Enter the green arrow on menu to start gparted work again..
  • If ready (LEDS not blinking), close gparted plug out the cards, and use them to boot the PI

Remark:

  •   Do ALWAYS have a 2nd working Card for the PI as FULL BACKUP!! If a Update fails you are online by restore the SDCard in 10Minutes!!!

Feedback:

  • Mail me Errors if iam wrong..

Debian: Update SSD Firmware without CDROM

If you want to update the SSD Firmware of a device you should know some things:

  • Do you REALLY need the update? Bugs? If NOT exit here!
  • Firmwareupdates can destroy DATA on Drives!
  • Data cant be restored if the Controller fails after Update
  • Downgrade a Firmware to older is most IMPOSSIBLE!!

.. now you need a USB Stick 4GB and the ISO File of the Firmware Disk of the Manufacter then open the Gnome Terminal or Console and:

$sudo su - #become root
$apt-get update && apt-get install unetbootin gparted # install the tools
$dd if=/dev/null of=/dev/sdc bs=10240 count=1 # delete usbstick unmounted with zeros (factory reset)
$gparted /dev/sdc #create new Primary Partition with FAT32, set "managed flags" to "boot lba", now exit gparted
$mount /dev/sdc1 /mnt #mount usbstick to /mnt 
$unetbootin #select FreeDOS at Menu, and select /dev/sdc1 and create the FreeDOS Stick, then exit unetbootin WITHOUT reboot!
$mkdir /iso && mount -o loop /home/yourusername/firmware-cd.iso /iso # mount the CDImage to /iso readonly
$cd /iso && cp firmware.img /mnt/firmware.img # copy firmware-data to usbstick

  • NOW, reboot and unplug other HDDs of the PC, ONLY the SSD must be insert!
  • Boot the PC on the usbstick, on the unetbootin Menu PRESS „Tab“ to get the „Unetbootin-Console“!
  • Here change the value of „initrd=/ubinit“ to „initrd=firmware.img“ and PRESS ENTER
  • Follow now the Firmware Update Dialog and Reboot with disconnected usbstick and replugged Drives…

Ubuntu Debian Samsung SSD secure erase with Linux

If you use a Samsung (possible others brands same howto) SSD and you want to secure erase the SSD for reuse or resale (better destroy it!!!) do:

  • Insert your Debian/Ubuntu Setup CD/Stick
  • Boot into Live/Setup Mode
  • open Gnome Terminal or Console and enter $sudo su – #to be root
  • then enter..

$ apt-get update && apt-get install hdparm # get the tool
$ sudo fdisk -l # show drives
$ sudo hdparm -I /dev/sda #show drive Infos and lock for "frozen" state!!! shoud be not frozen/locked
$ sudo hdparm --security-set-pass NULL /dev/sdb # set the "NULL" password to UNLOCK the Controller
$ sudo hdparm --security-erase NULL /dev/sda # run secure erase!