Mailing List Articles Atom Feed Comments Atom Feed Twitter

Tag Cloud

3d account algorithms announcement archives arduino artificial intelligence assembly async audio bash batch blog bookmarklet booting c sharp c++ challenge chrome os code codepen coding conundrums coding conundrums evolved command line compiling css dailyprogrammer debugging demystification distributed computing downtime embedded systems encryption es6 features event experiment external first impressions future game github github gist graphics hardware meetup holiday html html5 html5 canvas interfaces internet io.js jabber javascript js bin labs learning library linux low level lua maintenance network networking node.js operating systems performance photos php pixelbot portable privacy programming problems project projects prolog protocol pseudo 3d python reddit reference release releases resource review rust secrets security series list server servers software sorting source code control svg technical terminal textures three thing game three.js tool tutorial twitter ubuntu university update upgrade version control visual web website windows windows 10 xmpp

UFW and Samba

Today I have another post for you about Samba. Today I found that people couldn't actually access the samba shares I set up (I must have forgotten to test them). They were getting a weird "The Network Path was not found" error. Strange. After looking into it, I found that I didn't unblock the right ports in ufw. You see, Samba operates using two listeners, one called smbd, and the another called nmbd. I had forgotten to read the output of netstat -peanut correctly, and I missed a few ports.

For future reference (and for others having the same problem), here's the list of commands you need to enter in order to use shared folders with Samba correctly:

sudo ufw allow 139/tcp
sudo ufw allow 445/tcp
sudo ufw allow 137/udp
sudo ufw allow 138/udp

Hopefully it doesn't take you as long to fix your problem as it did mine...!

Custom Brightness Controller for Ubuntu

While I love Ubuntu's desktop, the brightness and volume controls are rather annoying as they don't provide a great degree of control. To fix this, I wrote a bash script to control the brightness. Here's what I came up with:

#!/usr/bin/env bash

echo $1
if [[ "$1" = "decrease" ]]; then
    echo decreasing
    increment=$(expr -${increment})

cur_brightness=$(cat ${backlight_prefix}brightness)
max_brightness=$(cat ${backlight_prefix}max_brightness)

new_brightness=$(expr ${cur_brightness} + ${increment})

# Permissions changes on brightness: 
## change group to sbrl
## add g+w
# Old command:
#gksudo -- bash -c "echo ${new_brightness} >${backlight_prefix}brightness"
echo ${new_brightness} >${backlight_prefix}brightness

### Notification ###
### uncomment the following line to disable the notification
# Calculate the percentage
new_percent=$(echo "(${new_brightness} / ${max_brightness}) * 100" | bc -l)
new_percent=$(printf "%.1f" "${new_percent}")

echo new_percent: $new_percent

bar_length=$(echo "(${new_percent} / 100) * ${max_bar_length}" | bc -l)
bar_length=$(printf "%.0f" "${bar_length}")

n_bar=$(head -c $bar_length < /dev/zero | tr '\0' '=')

# Kill the previous notification
killall notify-osd
notify-send "Brightness: ${new_percent}%" "${n_bar} (${new_brightness})"
#notify-send "Brightness" "${new_percent}%"

(Pastebin, Raw)

To use the above, you need to do several things. Firstly, you need to find your screen's brightness settings. Open a terminal, and navigate to /sys/class/backlight, and find your backlight's folder. Mine is intel_backlight, but yours might acpi_video0. Once found, you should have a file called brightness inside it. Change the value of the backlight_prefix variable on line #3 to equal the path to this folder, not forgetting the trailing slash.

You then need to alter the permissions on the brightness file in order to allow your user account to change it - otherwise you will get prompted for your password every time you change your brightness! To do this, open a terminal and navigate to the folder we found earlier that contains the brightness file. Change the user group to be your username with sudo chgrp username brightness, and then allow write access to group members with sudo chmod g+w brightness. If this doesn't persist across reboots, you might need to add these commands to your rc.local or Xsession files.

It should work now. If you don't want the notification to show every time you change your brightness (or if it doesn't actually work), uncomment line #27.

Adding a New Samba User

I found myself looking up how to create a new user in samba for about the 5th time today, so I tought I'd post about hwo to do it here so I don't forget :P

Starting from version 4, from what I can tell, Samba doesn't use the local unix accounts on your system. You need to create Samba accounts instead.

To do this, run the following command:

sudo smbpasswd -a username

Then type and retype the password you want for the new account. Note that you need to have a local unix account created under the same name as the samba account that you want to create. If you don't want a real account under the name of the samba account that you want to create, you can create a 'dud' account without a home directory or shell like so:

sudo useradd username --shell /bin/false

I hope this helps someone besides myself. If it did, try commenting below. You don't need an account, and you don't have to provide your email address either (though I seriously won't spam you at all if you do provide it!).

Ubuntu: Second Impressions

Ubuntu's Default Background I've had my laptop dual booted with Ubuntu for a while now, and I've been using Ubuntu in a Virtual Machine and as a live CD, but I've only just gotten around to rearrenging my partitions and reimaging my Ubuntu partition with Ubuntu 15.04. Previously, I had a bunch of issues with ubuntu (for example my laptop kept heating up), but I seem to have solved most of them and I thought that I'd post here about the problems I encountered, how I fixed them, and what I think of the latest version of ubuntu.

Firstly, I installed ubuntu from a live CD iso on my flash drive. Annoyingly, I used the 32 bit version by accident, and had to do it again. It would be nice if it told you which version you were about to install. Anyway, I found the installer to be rather temperamental. It kept freezing for ages, and all I could do was wait.

After the installation finished, I was left with a brand new, and very buggy, 64 bit Ubuntu 15.04 installation. As soon as it booted, the first job was to stop my cursor from flickering. Because I have an Nvidia GeForce 550M GPU, Ubuntu didn't recognise it properly (it detected it as a second 'unknown display') and so custom drivers were needed to fix it. I found this post, which guided me through the installation of both bumblebee (to control which of my two GPUs I use), and the official Nvidia drivers for my graphics card.

After banishing the flickering cursor, I found my laptop cooler, though it still wasn't right. Next up was to install thermald, indicator-cpufreq and lm-sensors. This trio of packages automatically controls the frequency of your CPU to both save power and prevent overheating. Normally, linux doesn't pay any attention to the frequency of the CPU of it's host system, leaving to run at it's maximum speed all the time - which causes battery drain and overheating.

Now that my laptop wasn't overheating too much, I could focus on other problems. When in Windows 7, I have something called SRS Premium Sound. It is brilliant at tweaking audio just before it reaches the speakers to improve it's quality. I quickly found when I got this laptop that it was essential - the speakers are facing downwards and the output sounds 'tinny' or 'hollow' without it. Since linux doesn't have SRS, the next best thing was PulseAudio, which provides you with an equaliser to tune your sound output with. Note that PulseAudio does actually work with Ubuntu 14, even though some people have said that it has been discontinued (I don't think it has?).

The other thing that needed changing was my touchpad. I felt like I had to hammer it in order to get it to recognise my touch, whereas in Windows it picked up the lightest of touches. My solution was to add the following to my .profile:

synclient FingerLow=2
synclient FingerHigh=3
synclient AccelFactor=0.145
synclient TouchpadOff=0
synclient MinSpeed=1.25
synclient MaxSpeed=2
synclient CoastingFriction=30

This improved the responsiveness of my touchpad a whole lot to the point where I could actually use it without getting frustrated :)

That covers the main problems I came across. As for what I think, I'm finding Ubuntu to be a great operating system to work with - now that I've worked most of the bugs out. Things like indicator-cpufreq and thermald ought to be automatically installed on systems that support them at install time. You should also be prompted to install bumblebee and the offical nvidia graphics drivers at install time too, as a system with multiple GPUs (i.e. integrated graphics and a graphics card) are pretty unusable without them. Sensible default settings would be nice too - nobody likes hammering their touchpad just to get a response.

The Ubuntu unity desktop developers seem to have remvoved a bunch of configuration options from the GUI in recent releases. Hopefully they wil readd them - it's rather annoying to have to enter the terminal to change something as simple as the login screen background.

On the plus side, Ubuntu seems to load much faster than Windows 7, and is more responsive too. I also feel like I have more screen space to work with as there isn't a task bar taking up space at the bottom of the screen. The customisability is amazing too. I am finding that there are far more things that you can tweak and fiddle with in Ubuntu compared to Windows.

To finish off this post, here's a list of smaller problems I had, and a link to the appropriate post that fixed it for me:

Art by Mythdael