User Tools

Site Tools


This is an old revision of the document!

Linux tips

Get a remote display

The idea is to have on a Ubuntu machine 2 X screens. One for the local ubuntu and one for a remote machine, in the example a Raspberry Pi.

user@ubuntumachine> X :1 -query raspberrypi.local

Then FIXME because it doesn't work for me (I switched to VNC server):

user@ubuntumachine>xhost +raspberrypi.local
pi@raspberrypi.local> export DISPLAY=ubuntumachine.local:1
pi@raspberrypi.local> lxsession

Set library path when shared library is not found

export LD_LIBRARY_PATH=/usr/local/lib

If you want to export the variable at startup, add the same line in /etc/profile.

This kind of issue can also be linked to a bad update of shared libraries links, usually after a manual installation. To update link, launch this command as root:


Use IPTables to prevent DOS attack

First rule : Limit NEW traffic on port 80 and 443

sudo iptables -A INPUT -p tcp --dport 80 -m state --state NEW -m limit --limit 50/minute --limit-burst 200 -j ACCEPT
sudo iptables -A INPUT -p tcp --dport 443 -m state --state NEW -m limit --limit 50/minute --limit-burst 200 -j ACCEPT

Ban a IP adress using IPTables

iptables -A INPUT -s XXX.XXX.XXX.XXX -j DROP

To get the list of blocked IP:

iptables -L INPUT -v -n

Launch a command a startup

Just add a script in /etc/init.d

nano myscript
chmod +x myscript

And register it:

sudo update-rc.d myscript defaults

Example for the script:

#! /bin/sh

case "$1" in
    echo -n "Starting server: "
    # Run myServer in the backround, with both stdout and stderr saved in /var/log/myServer.log, and use nohup to protect against HUP signals.
    nohup /usr/local/Arnl/examples/myServer  >/var/log/myServer.log 2>&1 &
    echo "myServer"
    echo -n "Stopping all myServer processes: "
    killall myServer
    echo "myServer"
    # Re-run this script with stop and start arguments.
    $0 stop
    sleep 5
    $0 start 
    echo "WARNING reload and force-reload not supported by this script
linux_tips.1457287239.txt.gz · Last modified: 2016/03/06 19:00 by sgripon