403 Permission denied on Apache in Debian/Ubuntu with changed document root

I had just made a brand new installation of both Ubuntu trusty and vivid and Debian jessie (tried all of them) on my android phone with Linux Deplow, and installed the LAMP stack via SSH. I wanted Apache to serve files decrypted from an EncFS mount, so I found easier to move the DocumentRoot to a subfolder of my home (by editing /etc/apache2/sites-available/000-default.conf – by the way, this file has changed location quite a bit in the past, being called just default.conf, or being httpd.conf in older versions), and changed Apache’s username to my own (by editing /etc/apache2/envvars).

Well, what happened is that, no matter what I did, I was still getting a 403 Permission denied error, which had nothing to do with EncFS.

By pure chance, I went checking what was inside /etc/apache2/apache2.conf, and other than a reference to envvars for the username and group definitions for the user Apache is run as, scrolling further down there are folders definitions which were, in previous versions, located in the default.conf file. Changing in there the reference to /var/www into the new custom folder made it.

You obviously need to restart Apache after such changes.

AFWall+ and Linux Deploy, no internet access unless firewall is disabled

This is a personal reminder and also an easier-to-find heads up to those looking for a solution: if you installed linux on Android via Linux Deploy, and find that, no matter how you set rules on AFWall+ you can never get internet to the mounted linux image, unless you disable the firewall altogether (not recommendable since you installed a firewall in the first place), then here is the solution provided in this thread (it’s all due to DNS calls being blocked without a possibility to make them pass through in the vanilla AFWall+).

Under AFWall+ contextual menu, open the custom script editor, and inser these lines:

 

$IPTABLES -A afwall-wifi -m owner --uid-owner root -p udp --sport=67 --dport=68 -j RETURN
$IPTABLES -A afwall-wifi -m owner --uid-owner nobody -p udp --sport=67 --dport=68 -j RETURN
$IPTABLES -A afwall-wifi -m owner --uid-owner root -p udp --sport=53 -j RETURN
$IPTABLES -A afwall-wifi -m owner --uid-owner nobody -p udp --sport=53 -j RETURN
$IPTABLES -A afwall-wifi -m owner --uid-owner root -p tcp --sport=53 -j RETURN
$IPTABLES -A afwall-wifi -m owner --uid-owner nobody -p tcp --sport=53 -j RETURN
$IPTABLES -A afwall-3g -m owner --uid-owner root -p udp --dport=53 -j RETURN
$IPTABLES -A afwall-3g -m owner --uid-owner nobody -p udp --dport=53 -j RETURN
$IPTABLES -A afwall-3g -m owner --uid-owner root -p tcp --dport=53 -j RETURN
$IPTABLES -A afwall-3g -m owner --uid-owner nobody -p tcp --dport=53 -j RETURN

making sure you preserve the line return after each RETURN since pasting directly into the tiny textbox of AFWall+ may lose the carriage returns.

BAM you will have internet from your android linux without having to disable the firewall. Naturally, you will also have to enable internet access to “Applications running as root”.

Update: as per Peter’s suggestion in the comments (thank you Peter!) if you still get errors with this approach you may need to add a couple more lines, like so:

$IPTABLES -A afwall-wifi-wan -m owner –uid-owner 5000 -j RETURN
$IPTABLES -A afwall-wifi-lan -m owner –uid-owner 5000 -j RETURN

where “5000” is an id you have to customize to your needs, and you can get it either from AFWall’s errors logs, or by checking the /etc/passwd file for the current user’s entry.

Enable Dolby Digital Live Surround 5.1 in Far Cry 4 and Watchdogs

Self reference, and also a heads up for those people looking into listening to 5.1 surround sound in Far Cry 4 and Watchdogs which usually play no sound when Dolby Digital is enabled.

This was tested and works in my configuration using a Sound Blaster USB Surround Pro X-Fi, and doesn’t involve any patch or hack, but a simple linear procedure; the first step is to download the latest drivers from Creative website (may ’14), and then, as the good sir melgu said on steamcommunity:

  • Open Creative Entertainment Console
  • Click on the Dolby Digital Live icon
  • Check the second box (a warning will appear, read it to undestand what it does, then accept clicking Yes)
  • Open Change Sound Card Settings from Windows Start Menu, and set the entry Speaker (Sound Blaster blahblah) as the default peripheral
  • Test your games

 

Samba share connection doesn’t accept user:password login from Windows

This is mainly a self-reference for when I find myself reinstalling Samba on my home server, if something goes wrong and the previous system got corrupt, or if I am upgrading something.

It happens, ALWAYS, that I setup a share with a login, which is the same of the user on the server the share resides into, and when I insert that login info in the Windows dialogue that appears, it just gives me an access denied error, as if the password I inserted wasn’t correct.

What I forget to do, every single time, is to create first a samba user with

sudo smbpasswd -a username

and then using those credentials (which you can create as matching the linux user’s) in the windows dialogue.

Change the user Transmission Debian daemon runs under and avoid warning message

I am writing this post also for personal reference (and currently I am writing in bare HTML since my WordPress installation lacks an updated multilanguage plugin to be able to use the WYSIWYG editor).
I was moving my home server from a slow Raspberry PI to a way faster Cubieboard 2, and got to reinstall Transmission daemon. I needed to change its user tho, because I needed a certain folder to be accessible to it.
So I edited as SU the /etc/init.d/transmission-daemon file changing the transmission-debian value into the username I wanted to use, but I kept getting a (warning) message when trying to start the daemon.
Long story short, here are some tips you have to follow, but first credits where they’re due:
This is the page where I got started the first time: http://www.webupd8.org/2009/12/setting-up-transmission-remote-gui-in.html
And this is a heads up I got while trying to solve this problem: https://forum.transmissionbt.com/viewtopic.php?f=2&t=13964

So, back on track:
1) Make sure the transmission daemon is stopped, otherwise changes you make to configuration files will be reverted to original
2) Edit the init.d starting script changing the username to your wanted username
3) chown the default transmission-debian folders to the user you need:

sudo chown username:group /var/lib/transmission-daemon/info –R
sudo chown username:group /etc/transmission-daemon/ –R

4) If you are importing a settings.json file from a previous installation, make sure to copy it to both /etc/transmission-daemon/ and /var/lib/transmission-daemon/info/ so that both copies are identical
5) You can now start the daemon and everything should work as expected

Cyclic sound MP3 audio recording in ubuntu

I work in a relatively safe environment, yet it may very well happen that I need to prove something that someone said in my office, so I can hold it against them when the time comes.

My laptop is always turned on, so I could use it to record the environmental sounds around it, with a couple of requirements:

  • the recording must be totally unattended, starting when I turn on the pc, and stopping when I turn it off, without any user intervention
  • the recorded files must be somehow purged, starting from the oldest ones, so that my disk doesn’t get filled with audio files

As in the Ubuntu spirit, I tried to search for something that did the job right away, but with no luck.

So, still in the Ubunt spirit, I had to arrange it myself: the idea is to record the audio in chunks of 10 minutes, and each time delete the oldest files, so that there is a chosen number of max files inside the recording folder.

You will need the audio-recorder package for the job, install it as follows:

sudo apt-add-repository ppa:osmoma/audio-recorder
sudo apt-get update
sudo apt-get install audio-recorder

when the program is installed, open it (Alt-F2 and then launch audio-recorder), click on the “additional settings” button, and setup your default recording folder there, in this example it’s the folder “audiofiles” directly under your home folder.
Also I suggest changing the file naming standard to %Y-%m-%d-%H:%M:%S so that each recording can be easily associated with the time of starting.

Then, you need to make a bash script that will deal with starting a new recording, while closing the previous one, this is what I came up with:

#!/bin/bash

/usr/bin/audio-recorder --display=:0.0 -c stop
/usr/bin/audio-recorder --display=:0.0 -c start
cd /home/username/audiofiles
rm `ls -t | awk 'NR>150'`

which does exactly the following: stops a previously open (if existing) instance of the program, and starts a new one, then deletes the oldest recorded audio chunks so that there are maximum 150 files inside the recording folder (if you want a different amount, just replace 150 with the number you prefer); please note that the recording folder written in this bash script must be the same that is set in the additional settings, so if you want to use a different folder make sure to set it up both in audio-recorder and in this bash script.
Also, please note that the username part of the path must be replaced with your ubuntu username.

You can create this bash script as a “recordaudio.sh” file in your home folder, and then be sure to chmod +x recordaudio.sh so you can execute it.

Then, you need something that actually starts the recording, and cron is our friend here.

Run the command

crontab -e

and if it’s the first time you run it,  you should be presented with a choice screen asking you which editor you prefer… absolutely choose nano!

Inside the editor screen, paste this:

*/10 * * * * /home/username/recordaudio.sh

where “username” must be replaced with you ubuntu username, then press Ctrl-X to save the file (press Y is prompted to confirm).

What this cron line does, is running the bash script we just created every ten minutes, so the recorded sound files will be 10 minutes long. If you want to change this length, just change the 10 in the command to the number of minutes you prefer.

Restart the pc, and notice how files are being created inside of your folder. After a while, you will also get over the set limit for the files, and you will notice how the number of files will always stay the same, with the oldest files being deleted.

Howto batch watermark resize convert crop images and pictures

  • Download IrfanView (if you already don’t have it installed, it is an awesome image viewer, and great for basic editing with its Paint plugin, installed by default)
  • After opening the main viewer window, go to File>Batch Conversion/Rename
  • What opens is a window crammed with options and tools, with which you can:
    1. Convert between different formats (Jpeg, Gif, PNG, BMP, TIFF, whatever)
    2. Rename with serial progressions
    3. Crop at given dimensions (this and the following are accessible pressing the Advanced button)
    4. Resize to given dimensions, or proportionally inside a maximum dimensions rectangle
    5. Change color depth
    6. Flip horizontally and/or vertically
    7. Rotate 90° to left or right
    8. Grayscale or negative color
    9. Add an overlay text with custom color, font, size, position, alignment, you name it (this is a fast and easy way to watermark your pictures)
    10. Add a proper watermark image overlay, pointing to an image file, choosing its position and transparency
    11. Change color scheme inverting the order of the RGB values
    12. Apply other filters: sharpen, brightness, contrast, gamma correction, saturation, color balance for R G and B, bur, median, and fine rotation (choose amount of degrees)
    13. You can choose whether overwriting or renaming destination files, move them to subfolders, and so on
    14. You can add multiple files to the batch job by picking them from different arbitrary folders or loading them from a list saved into a TXT file

How to drag and drop files between windows in Ubuntu Unity launcher bar

So I like Unity, it looks nifty and the Zeitgeist launcher is so productive.
One huge gripe about unity though, is that you cannot, apparently, drag&drop files between applications open in the Unity launcher bar, namely:

  • a file from nautilus into thunderbird as a mail attachment
  • an image from nautilus into a photo-editing program
  • the same file from nautilus into an archive manager
  • an image into the upload page of imgur.com opened in your browser
  • anything else

I use a Precise Pangolin installation, and this is what works for me:

  1. Start dragging the file until you have it under your mouse pointer, ready to be dropped somewhere
  2. At this point you will notice the launcher bar buttons become gray (almost all of them, Nautilus and Firefox stay bright for me)
  3. Trying to drop onto any of the buttons, be it grayed out or bright, will NOT bring up its window
  4. Keep the mouse button pressed, and on your keyboard use theWinKey+TAB combination, you will see the applications buttons on the unit launcher bar brighten one at a time, cycling though both bright ones and grayed ones
  5. When you have highlighted the button of the program you need (for example, Thunderbird to attach a file into a mail), release the WinKey+TAB combo and the relative application window will open
  6. Finally drop your file in the opened window
  7. After you’ve done your job, flood LaunchPad with bug reports until we get this dumb problem fixed

MyPhoneExplorer via Bluetooth: phone could not be indentified and parameter incorrect

Chances are that you are trying to have your Android phone sync with Outlook via MyPhoneExplorer, but whatever you do won’t work, since as soon as you try to connect, the procedure stops at “identification” and MyPhoneExplorer pops up a “phone could not be identified” error.

Syncing via USB cables works though, but you are not going to settle for something as annoying and remembering to plug in your cable everytime.

Update: try this first:
Chris, in the comments below (thank you, Chris), suggests doing this, which is apparently working in Windows 7 (Windows 8 doesn’t have such possibility):

Easier if you just go to control panel > hardware and sound > devices and printers > bluetooth devices

Then right click on the device you’ve already paired. Go to Services tab, and under Bluetooth Services there should be a checkbox for Serial port(SPP) ‘MyPhoneExplorer’.

Check it, apply, done…

If that doesn’t work, continue reading!

Compared to the first version of this article, when I was on Windows 7 + Ice Cream Sandwich, now I’m on Windows 8 + Lollipop, and started having this problem a short while after upgrading from KitKat. The solution was to open MyPhoneExplorer settings, select bluetooth in the connection tab, and choose, from the dropdown menu, the other Bluetooth port that was not selected before, and try again to connect, in my case it went by as normal.

If this doesn’t work as well, then proceed with the very first guide.

So let’s start by saying this out front: this is black magic.

You may have tried to go into “change bluetooh settings” in your control panel, then open the “COM Ports” tab, and manually add incoming ports and trying them out one by one in MyPhoneExplorer… this should not work, no matter how many times you reboot your phone and/or unpair/pair again with your PC.

The procedure I am going to illustrate may work for you, or it may not. It may do nothing on a sunny day of April, but deal impressive results in a foggy evening of november.

I tried to replicate the same method previously, but it worked for me just a few minutes ago as a blessing (and this is why I rushed to write an article about it) while it didn’t at my previous attempts, so these are the steps (keep in mind I have ICS on my phone, and Windows 7 x64 on my laptop, the BT sync worked before, but had stopped working after I upgraded from Gingerbread to Ice Cream Sandwitch on my Galaxy Note)

  1. Find your phone entry in bluetooth devices in Windows, click it and remove it
  2. Unpair with your PC from your Android phone
  3. If there are any remaining, remove every reserved port in “COM Ports” tab of bluetooth settings (unless there are other ports being used by other BT devices you own, leave those alone)
  4. Reboot both your PC and your phone, preferably at the same time (black magic, remember?)
  5. Pair the device from Windows (go into bluetooth panel, “add device”, then proceed with the pairing)
  6. Your aim here is to have Windows itself add the COM ports, you should end up with two COM ports, one Incoming, and one Outgoing, they should both carry the BT name you have given to your phone, and the Outgoing port should also say “MyPhoneExplorer”
  7. You should set MyPhoneExplorer to use the Outgoing port among the two, but if it doesn’t work for you, also try the Incoming port (black magic)

Good luck!

Convert a micro-SIM into a normal SIM card, just a knife without adapter

Sometimes you’re stuck with a brand new microSIM that you can’t use in your phone, because you need a normal form factor SIM, but maybe you had this chance to activate a special promotion that only came in microsim format.

Well do not despair, you can get a normal SIM (-ish) from a microSIM, just DON’T remove the microsim from its matrix just yet!

microsim converted inside it's credit card holder
This is what we are going to get at the end
width comparison between SIM and microSIM
Our micro-SIM in its credit-card like holder, compared to a standard SIM card
marking width on microsim holder
After aligning the correct contacts of SIM and micro-SIM, I used insulating tape to mark the side borders of the new SIM card
marking the outer borders of the SIM on the microsim holder
I did the same thing with upper and lower borders, aligning the microSIM and SIM through their chips
almost finished microsim sim conversion
This is the rough result after cropping the external borders with an exacto knife guided by a ruler, slightly bigger but centered nonetheless
microsim converted to SIM, adapted and rounded with dremel
After cutting the angle, I used a dremel to round the corners

The SIM card works perfectly inside my Galaxy Note, just slightly harder to plug inside but once inserted it goes as a charm.

The headquarters of Ephestione, online since 2001