2016-08-28

Kubuntu 14.04 black screen after monitor off/on


Whenever I turned my display off and on again after having logged on,  the screen stayed black. After rebooting, the logon screen appeared, but after logon with my user account, the screen got black. Logging with other user accounts had no problem.

This problem occurred using Kubuntu 14.04.  and a Nvidia graphics card connected by a display port cable.

Here is the description how I corrected it.


In short



Change the first false value of your screen definition file 
.kde/share/apps/kscreen/xxxxxxxxxxxxxx
from false to true.
Than make this file read only.



In Detail


Start one of the consoles: Ctrl-Alt-F1
Then enter your OS-User name and password.

Go to the directory .kde/share/apps/kscreen located in your home directory:
cd ~/.kde/share/apps/kscreen

Listing the files in this directory (ls -1), should display at least one file, that looks like the one bellow.
The files name is a mix of number an letters (seems a long hexadecimal number):
ls -1

7134be4579e47853d9bc866485e252fb

If you have/had more than one monitors, several files will be listed.

This is a text file. Its contents can be displayed with the command cat :
cat 7134be4579e47853d9bc866485e252fb

[ { "enabled" : false, "id" : "9a9b7a71150d853203babd861f68d8c5", "metadata" : { "fullname" : "xrandr-Dell Inc.-DELL U2515H-9X2VY61E10XL", "name" : "DP-1" }, "mode" : { "refresh" : 59.9506, "size" : { "height" : 1440, "width" : 2560 } }, "pos" : { "x" : 0, "y" : 0 }, "primary" : true, "rotation" : 1 } ]

Change the false value after "enabled" (from above) to true.

Here I show how to do it using the vi editor, that is available on every Linux system.
vi 7134be4579e47853d9bc866485e252fb

  • Go to the beginning of false by using the arrow keys
  • press the key [DEL] until false is completely deleted
  • press the key [i] in order to enter the insert mode
    (-- INSERT -- will then by displayed at the bottom line)
  • type true
  • press the key [ESC] in order to leave the insert mode
    (-- INSERT -- disappear from the bottom line)
  • press the keys [:] and [x]
    (":" starts the command mode and "x" is the command "exit with saving")

If you display the contents of your file again, the false should now have been replaced by true

Now the Graphical environment can be restarted by entering the command startx.
startx

I could avoid that this problem occurs again I made this file read only


chmod ugo-w 7134be4579e47853d9bc866485e252fb


I hope this helps.



Tags: Problems&Solutions, Kubuntu, Publish, Monitor, Black Screen
August 28, 2016 at 08:52AM

2016-08-06

Sending WakeOnLan (WOL) from Linux (KUbuntu)


In order to have the Synology NAS already been running when I boot up my Ubuntu (KUbuntu) computer, I make my Ubuntu send a WOL packet to the NAS when booting with etherwake.

Here is the command used in the script below (Replace the exemplary MAC address 00:11:22:33:44:55 below by the MAC address of the device you want to be woken up.)
root@Ubuntu:~# etherwake -i eth1 00:11:22:33:44:55


root@Ubuntu:/etc/init.d# cat sendWOLtoNAS
#! /bin/sh
### BEGIN INIT INFO
# Provides: sendWOLtoNAS
# Required-Start:    
# Required-Stop:     
# Default-Start: 2
# Default-Stop:      
# Short-Description: Sends Wake On Lan (WOL) packet to the Synology NAS
# Description: Is used in order to make sure that the NAS will also be started when this computer is starting
### END INIT INFO

MYSELF="/etc/init.d/sendWOLtoNAS"

logger "${MYSELF} Start"
etherwake -i eth1 00:11:22:33:44:55
logger "${MYSELF} WOL sent, sleeping 10s"
sleep 10
logger "${MYSELF} Done"

Making the script be run on startup of Ubuntu
root@Ubuntu:/etc/init.d# update-rc.d sendWOLtoNAS start 20 2 .
 Adding system startup for /etc/init.d/sendWOLtoNAS ...
  /etc/rc2.d/S20sendWOLtoNAS -> ../init.d/sendWOLtoNAS

If you want to undo it:
root@Ubuntu:/etc/init.d# update-rc.d -f sendWOLtoNAS remove 20 2 .
 Removing any system startup links for /etc/init.d/sendWOLtoNAS ...
  /etc/rc2.d/S20sendWOLtoNAS


Tags: ubuntu, Linux, Boot, WOL, Startup, Publish
May 30, 2016 at 09:22PM

2016-08-02

Configure WOL from Internet (WAN) / ASUS Router RT-AC88U

In order to be able to Wake On LAN (WOL) a computer, a NAS (Network Attached Storage) etc. from the Internet (WAN), perform the following configuration steps.

Altough the examples in this article use the ASUS Router RT-AC88U, the configuration in general is not specific to this router. The only specific part is how to make the static ARP rule "survive" a router reboot.

DDNS

Configure a (DDNS) Dynamic Domain Name System in order to address your home network, even with changing ip addresses.
This is not described here. There are plenty of descriptions around. (The ASUS router can configure one for you automatically):
Our exemplary DDNS here is: myDDNS.asuscomm.com

In order to improve security a little (really only "a little"), do not use standard ports for WOL.
For example, we will use the port: 4231

NAS

For example in the NAS configure the Port: 22 for WOL.

ASUS Router

Port Forwarding
On the router configure the mapping of the incoming Port 4321 to the NAS Port 22 and a broadcast LAN ip address 192.168.1.254.

ARP

Setup a ARP (Address Resolution Protocol) entry / rule, that redirects the WOL packets send to destination 192.168.1.254 to be broadcast to all MAC addresses (i.e. to ff:ff:ff:ff:ff:ff)

Login to the router via telnet or ssh as admin (root) user.

Once logged in, use this command in order to add the needed ARP entry:
arp -s 192.168.1.254 ff:ff:ff:ff:ff:ff

On another router (a Netgear router with Gargoyle, a Firmware based on OpenWrt), I used the following statement in order to add this entry:
ip neigh add 192.168.1.254 lladdr ff:ff:ff:ff:ff:ff nud permanent dev br-lan

List the resulting ARP table containing the new highlighted entry:
admin@(none):/jffs/scripts# arp
? (192.168.1.155) at <incomplete>  on br0
? (XXX.XXX.178.1) at XX:XX:XX:XX:fc:81 [ether]  on eth0
? (192.168.1.254) at ff:ff:ff:ff:ff:ff [ether] PERM on br0
? (192.168.1.58) at XX:XX:XX:XX:4c:c4 [ether]  on br0
? (192.168.1.251) at XX:XX:XX:XX:5d:0a [ether]  on br0
? (192.168.1.170) at XX:XX:XX:XX:0e:f3 [ether]  on br0
? (192.168.1.40) at XX:XX:XX:XX:8a:58 [ether]  on br0

Now you can check, if this configuration works with Programs / Apps that can send WOL Packets.
As target you will need to set your chosen DDNS and port. (In our example it would be myDDNS.asuscomm.com and port 4231)
On the iPhone I use the "iNet WOL" app.

Although this ARP entry is marked as permanent (PERM), the configuration will disappear once the router is rebooted.

In order to avoid this, set up a script that executes the ARP statement from above when the router reboots.
This can be achieved by using the ASUSWRT feature that executes a user defined script, every time a USB drive is mounted.

The ASUS router offers a small non volatile "disk storage" under /jffs
So, create a folder in this directory. In this example, the folder "scripts".

This generates the script wan-wol.sh in the current folder:
cat <<EOF > wan-wol.sh
#!/bin/sh

scriptName="/jffs/scripts/\$(basename $0)"
myIp="192.168.1.254"

/usr/bin/logger -t "\${scriptName}" \$$ "arp -s \${myIp} ff:ff:ff:ff:ff:ff"
arp -s \$myIp ff:ff:ff:ff:ff:ff
/usr/bin/logger -t "\${scriptName}" \$$ "Check: \$(arp | grep $myIp)"
EOF


Displaying the content of this script:
OS> cat /jffs/scripts/wan-wol.sh

The resulting script should look like:
#!/bin/sh

scriptName="/jffs/scripts/$(basename $0)"
myIp="192.168.1.254"

/usr/bin/logger -t "${scriptName}" $$ "arp -s $myIp ff:ff:ff:ff:ff:ff"
arp -s $myIp ff:ff:ff:ff:ff:ff
/usr/bin/logger -t "${scriptName}" $$ "Check: $(arp | grep $myIp)"

Only the highlighted lines are really relevant.
The rest in only for logging.

Do not forget to make the script executable:
admin@(none):/jffs/scripts# chmod a+x wan-wol.sh

Make a copy of this script elsewhere, because it can be deleted, if a new firmware version is installed.

NVRAM

With nvram, the parameters of the router can be shown/configured.

Display the actual value of the parameter "script_usbmount" in case you need to set it back.
In the example below, it was not set:
master@(none):/tmp/home/root# nvram show 2>&1 | grep script_usbmount
script_usbmount=

Set the parameter "script_usbmount" in order for your script to be executed when a USB drive is mounted:
master@(none):/jffs/scripts# nvram set script_usbmount="/jffs/scripts/wan-wol.sh"
master@(none):/jffs/scripts# nvram commit

Check the result:
master@(none):/jffs/scripts# nvram show 2>&1 | grep script_usbmount
script_usbmount=/jffs/scripts/wan-wol.sh

After the router is rebooted, the following highlighted lines should appear in the router log (if you implement the logging lines in the script from above):




Tags: Asus, Router, NAS, WOL, ARP, Publish, RT-AC88U
July 29, 2016 at 10:39PM