It is nice to have an IRC connection that is always available and that doesn’t have your home IP address exposed. With the ZNC setup you can then use your local IRC client (BitchX, irssi, HexChat etc) to connect to the ZNC and you will be able to see all the networks and channels it is connected to. This tutorial will explain how to setup ZNC on a $5/month DigitalOcean droplet (ref link) with Ubuntu 16.04.1. Of course this setup should work on any hosting and setup – DigitalOcean is just given as an example here.
Create a Droplet
1. Press on the Create a Droplet button once you are logged in your DO account
- Select the OS image (Ubuntu 16.04.X), the Droplet size/price ($5/mo), data center region, add extra features, ssh key if you want that extra security and then press on Create Droplet
2. Login to your Droplet (box) and make sure everything is up to date
sudo apt-get update sudo apt-get upgrade
Installation and Build of ZNC
1. Grab few essentials that are needed to compile the ZNC from source
sudo apt-get install build-essential libssl-dev libperl-dev pkg-config
2. Grab the latest ZNC source tar ball
cd /usr/local/src; sudo wget http://znc.in/releases/znc-latest.tar.gz
3. Extract the package and enter the directory
sudo tar -xzvf znc-latest.tar.gz; cd znc*
4. Configure the source system wide (you can use ./configure –prefix=$HOME/znc if you don’t want system wide)
5. Then, compile ZNC (might take few minutes)
sudo make; sudo make install
Configuration of ZNC
1. Create a new user on which we will run ZNC
2. Switch to the new user
su znc-admin; cd ~
3. Start ZNC and its configuration
4. Below is a sample configuration (ZNC version 1.6.4) – I highlighted in red all the config that I entered manually, the rest is the default values (what is given in the brackets [ ])
[ .. ] Checking for list of available modules... [ >> ] ok [ ** ] [ ** ] -- Global settings -- [ ** ] [ ?? ] Listen on port (1025 to 65534): 14125 [ ?? ] Listen using SSL (yes/no) [no]: yes [ ?? ] Listen using both IPv4 and IPv6 (yes/no) [yes]: yes [ .. ] Verifying the listener... [ >> ] ok [ ** ] Unable to locate pem file: [/home/znc-admin/.znc/znc.pem], creating it [ .. ] Writing Pem file [/home/znc-admin/.znc/znc.pem]... [ >> ] ok [ ** ] Enabled global modules [webadmin] [ ** ] [ ** ] -- Admin user settings -- [ ** ] [ ?? ] Username (alphanumeric): redoEm [ ?? ] Enter password: [ ?? ] Confirm password: [ ?? ] Nick [redoEm]: [ ?? ] Alternate nick [redoEm_]: [ ?? ] Ident [redoEm]: [ ?? ] Real name [Got ZNC?]: Redo'Em [ ?? ] Bind host (optional): [ ** ] Enabled user modules [chansaver, controlpanel] [ ** ] [ ?? ] Set up a network? (yes/no) [yes]: [ ** ] [ ** ] -- Network settings -- [ ** ] [ ?? ] Name [freenode]: [ ?? ] Server host [chat.freenode.net]: [ ?? ] Server uses SSL? (yes/no) [yes]: [ ?? ] Server port (1 to 65535) : [ ?? ] Server password (probably empty): [ ?? ] Initial channels: #redoEm [ ** ] Enabled network modules [simple_away] [ ** ] [ .. ] Writing config [/home/znc-admin/.znc/configs/znc.conf]... [ >> ] ok [ ** ] [ ** ] To connect to this ZNC you need to connect to it as your IRC server [ ** ] using the port that you supplied. You have to supply your login info [ ** ] as the IRC server password like this: user/network:pass. [ ** ] [ ** ] Try something like this in your IRC client... [ ** ] /server <znc_server_ip> +14125 redoEm:<pass> [ ** ] [ ** ] To manage settings, users and networks, point your web browser to [ ** ] https://<znc_server_ip>:14125/ [ ** ] [ ?? ] Launch ZNC now? (yes/no) [yes]: [ .. ] Opening config [/home/znc-admin/.znc/configs/znc.conf]... [ >> ] ok [ .. ] Loading global module [webadmin]... [ >> ] [/usr/local/lib/znc/webadmin.so] [ .. ] Binding to port [+34125]... [ >> ] ok [ ** ] Loading user [redoEm] [ ** ] Loading network [freenode] [ .. ] Loading network module [simple_away]... [ >> ] [/usr/local/lib/znc/simple_away.so] [ .. ] Adding server [chat.freenode.net +6697 ]... [ >> ] ok [ .. ] Loading user module [chansaver]... [ >> ] ok [ .. ] Loading user module [controlpanel]... [ >> ] ok [ .. ] Forking into the background... [ >> ] [pid: 19576] [ ** ] ZNC 1.6.4 - http://znc.in
That is it – ZNC is now up and running!
Connect to ZNC with your local IRC Client
Now find the IP address from your Droplet and setup your IRC client to connect to it.
Example with HexChat:
After connecting to the ZNC all the networks and channels you have added will appear.
This might work on other systems too, I tried it on Ubuntu 14.04.1.
In VirtualBox the screen for Ubuntu was very small and it was difficult to see what’s on the screen. To fix this issue, you need to install the following packages on the guest (VM) box:
sudo apt-get install virtualbox-guest-dkms virtualbox-guest-x11
If you get this error:
The following packages have unmet dependencies. virtualbox-guest-x11 : Depends: xorg-video-abi-15
You will need to remove this package (note: I am not sure what all this removes, it was a lot – use caution):
sudo apt-get remove libcheese-gtk23
Then install these
sudo apt-get install xserver-xorg-core-lts-trusty
sudo apt-get install xserver-xorg-core
Then try to install the virtualbox packages, as the first step:
sudo apt-get install virtualbox-guest-dkms virtualbox-guest-x11
Once they install properly, restart the VM and the screen should be normal size. You might need to increase the Display memory in VB before starting the VM.
By default the Delete button does not move files to trash, you need to use Ctrl+Delete which is major annoyance. This is after 3.2 Gnome I believe and still the same up to 3.10. They say it is a feature but I don’t see it as such.
To fix this, you will need to modify the accels of Gnome, with few simple steps:
Run the following in the terminal as your user:
gsettings set org.gnome.desktop.interface can-change-accels true
Now you are able to give items different buttons.
Select a file that you might want to delete (create New Folder for example) and after you have selected it, go to the Edit menu (right-click doesn’t work) and position your mouse over the Move To Trash field. Once the field is in focus, press the Delete button twice. The button combination on the right should be changed from Ctrl+Delete to Delete only.
That is all, now it is enabled. You should disable changing of accels now because you might accidentally do it for other things:
gsettings set org.gnome.desktop.interface can-change-accels false
This was tested on Gnome 3.4.2 on Debian Wheezy.
I had issues with Firefox not finding the plugins for flash. I had to setup the following environment variable for it to find it:
Check if it is already set:
If it is not, set it:
Any path will work, I just used the .mozilla directory to keep things clean.
You should restart Firefox to see the plugins.
This was tested on Debian Wheezy.
It happens that sometimes (after 2 days 🙂 ) you forget the password for your root user on MySQL, well there are few steps to perform to recover it.
This was performed on version:
$ mysql -V mysql Ver 14.14 Distrib 5.1.61, for debian-linux-gnu (x86_64) using readline 6.2
The following steps need to be performed as root user, so either login with it or use sudo.
Step 1:Stop the MySQL service
$ sudo /etc/init.d/mysql stop
Step 2: Start the MySQL server without password
$ sudo mysqld_safe --skip-grant-tables &
Step 3: Connect to the MySQL server using the MySQL client
$ sudo mysql -u root
Step 4: Change the password for the root user
mysql> use mysql; Database changed mysql> update user set password=PASSWORD("YOUR_NEW_PASS") where user = 'root'; Query OK, 3 rows affected (0.01 sec) Rows matched: 3 Changed: 3 Warnings: 0 mysql> flush privileges; Query OK, 0 rows affected (0.00 sec) mysql> quit Bye
Step 5: Stop the MySQL server again
$ sudo /etc/init.d/mysql stop
Step 6: Start the MySQL server (normally) and test the new password
$ sudo /etc/init.d/mysql start $ sudo mysql -u root -p
This should also work on Windows as well, you will just need to use different commands for start/stop of the MySQL deamon.
There is a time when you are leaving your home empty and you don’t have an expensive security and alarm system. You need to be protected and be aware if there are any changes or visits that you do not approve of while you are gone. There is an easy way to achieve just that with Motion. What you need is:
- Linux OS (ex. Ubuntu)
- Motion (free)
- Internet (optional)
- Hosting (optional)
- Smartphone with data plan (optional)
After you have your computer ready, webcam installed and working, go and download the Motion project or use Ubuntu’s apt to get it (check to get the latest version):
sudo apt-get install motion
Run the program (Motion) with root privileges, like sudo motion, however please note that you should probably run it with sleep or cron, otherwise it will activate immediately and most probably detect you while you are exiting the room.
Now you are all set for the basic surveillance with just a webcam which will record when there is a movement in front of the camera, however there are some more advanced options which could help a lot.
Email you when there is movement detected
For this you will need to install sendmail and mutt, assuming you are on Ubuntu
sudo apt-get install sendmail mutt
The basic settings for sendmail are enough for most users, but if you are an advanced user feel free to modify it as you desire.
Open the file /etc/motion/motion.conf in your favorite text editor (ex. vim), then locate the text on_even_start value and change the value part with:
echo "This is the body of the message" | mutt -s "Motion has been detected" firstname.lastname@example.org
If there is a ; (semi-colon) on the beginning of the row, remove it, also if there is any empty space before the on_event_start.
Sending images to a webserver
It would be good to have the images taken from the motion to a webserver so that you can check from a remote location what is there on the images and report to the police if needed.
Open the /etc/motion/motion.conf file again in a text editor and locate the text on_picture_save value and change the value part with:
scp %f email@example.com:/path/for/images/
If there is a ; (semi-colon) on the beginning of the row, remove it, also if there is any empty space before the on_picture_save.
Enable login without password on your webserver
You need to create a ssh key on your machine with the following
sudo ssh-keygen -t dsa
Upload the key to your webserver:
sudo ssh-copy-id -i /root/.ssh/id_dsa.pub firstname.lastname@example.org
Tips and tricks: if you have a LED light on your camera, put a plastic electrician tape (isolation tape) on it so that the camera is not noticeable. Also, make sure you have some light in the room, unless the camera has a feature for night vision.
If you need to execute a process that will run in the background so that it does not lock one terminal window then you should try using the NOHUP command.
nohup <command here> &
After executing it, a nohup.out file will be created (append if it exists) which will contain all the output from the command (if any).
However, if you want to close the terminal window, like if you are working on a remote machine, do the following:
(nohup <command here> & ) &
This will disconnect the process from your session completely so you should be able to close the terminal window and do not interrupt the process.
To check if the process is still running, perform the following:
ps -ef|grep -i <command name or part of command name>
This is listing all the processes on the machine and then grepping for the command name with case insensitive (-i).
If you want to stop the process, you will need to kill it with the following command:
kill <process id>
The process-id can be seen from running the ps command above. In most instances it is the first number of the row.
If the process hangs after the kill command, do force kill:
kill -9 <process id>
This will kill any process, so please double check the process id before executing it.
I have an older tiny HDD of 80GB and I am planning to give it to a friend or donate it to the local hacklab, but before it goes out of the house I want to make sure that nobody (at least with the technology available to most individuals) can restore what was on the disk. There was nothing very important or secretive on it, but people snooping around my files creeps me out a bit.
There are many ways to completely erase a hard disk drive, a partition or individual files with the GNU/Linux utility called shred.
The command to use is very simple:
sudo shred -n <NUMBER OF ITERATIONS> -vz /dev/to/hddOrPartition
And to shred a file:
shred -n <NUMBER OF ITERATIONS> -v file1 file2 file3 etc
It should be executed as super user/root so that there will be full access to erase/write everything. I use about 20 iterations (default is 25), because that seems like enough to me. The -z option means to run an extra run at the end which will zero the drive which will hide the shredding (in -n is 20, there will be total of 21 passes). -v is verbose, to show progress of the task.
WARNING: please be VERY careful about the disk/partition that you select because EVERYTHING on it will be deleted. Create backup before the command is executed!
On Asus K53 most of the hot-keys are not working with the default installation of Ubuntu 11.04 with kernel 2.6.38-8, however there is a package available that will enable them, here are instructions on how to perform that:
sudo apt-get install git (unless you already have git installed)
git clone git://git.iksaif.net/acpi4asus-dkms.git
sudo make install
sudo modprobe asus-nb-wmi (this command will load the newly installed module)
After every kernel update the above will be erased and you will need to re-do it every time until it is included in a kernel version at a later stage. To make it easier create a .deb package which will be easier to install.
sudo apt-get install debhelper
sudo dpkg -i [newly-created-package].deb
sudo modprobe asus-nb-wmi
After you install a new applet in some versions of Ubuntu (gnome) it will not be available in the list until you log-out and login again or if you do not restart your computer. This is bad because you will need to close everything to perform either of these things, however it is safe to kill the gnome-panel process and it will then automatically re-load and all the new applets will be available in the list.
No root/sudo privileges are needed for this command.