Brief Guide To Ubuntu Permissions Part 2

Over a year and half ago, I posted a brief guide about Ubuntu permissions.

Whilst this covered most of the basics of Ubuntu permissions there was one part that I found myself looking into today: chmod.

You may or may not be familiar this command to change permissions. But the general usage is:

chmod 777 file.txt

In the above example, file.txt will be given complete read and write access for all users.

But where does 777 come from?

Well I’m glad you asked handsome stranger.

If you refer back to the original post, you will be reminded that permissions are split into three blocks:

  1. Permission for the user who owns the file.
  2. Permissions for the group that owns the file.
  3. Permissions for the rest of the world.

Each individual ‘7’ refers to each of those blocks in that order.

7 means all privileges for that section i.e. rwx. So 777 would be rwxrwxrwx. (Refer to the previous article for explanation of what r, w and x means).

Below shows what each number means:

7 = rwx
6 = rw-
5 = r-x
4 = r–
3 = -wx
2 = -w-
1 = –x
0 = —

So giving a file a privilege of 644 would mean, rw-r–r–, which means the owner can read and write in it only and everybody else can only read it.

But how can I remember those numbers?

Each privilege type is given a number as follows:

1 = execute
2 = write
4 = read

Simply add up the numbers of the privileges that you want to give. For example, read and write only would be 4 + 2 = 6, hence 6 is rw-.

Simple really isn’t it?

That is all for now. Thank you for reading!

Popping Champagne

Student No More

Today is a very special day.

Today is the day that my University course finishes. So despite handing in my final dissertation 6 weeks ago and receiving my final results more than a week ago, today is the day that I am no longer enrolled as a student!

Oh yes, my results!

Well I am pleased to say that despite my concerns about the dissertation submission, I managed to achieve a First for it and I have managed to achieve a First for the whole degree!

I am naturally very pleased with this and it still hasn’t really sunk in.

Post student life has pretty much remained unchanged except that I feel less guilty when I want to relax (as I now can with the knowledge that I do not have a pressing coursework deadline coming up or an exam I should be revising for).

I am also now working full time. From a high level, this is just the same as before, except I work for one more day.

Another change is that my student travel card will expire at midnight and so I will have to pay full price for my monthly travel card tomorrow!

Other than these three things, it has just felt like I am just outside of term time.

It is a little bit unnerving to not know what the next few months will bring. October 2014 is the first month in a very long time (even beyond starting University to my school days) where the future hasn’t just been “Get a first in module X.” or “Complete the Y coursework.”

More nerve-racking is that 2015 will be the first year with a similar predicament! I am now an adult who can no longer say that I am just continuing “Year N” of school or University.

xkcd - Graduation

I have 3 main aims for between now and 2015:

1) Build a website for a personal client of mine – this has been an ongoing project for most

of this year with a version currently live (I am not happy with it enough to share it!).

2) Build an Android game – I wanted to do this for a while but University work got in the way. I am currently looking at coco-2d but am currently struggling to know where to start!

3) Maintain this blog – I am going to try and get back to doing regular posts starting with this one.

That is quite a lot to do. There are also a couple of other things that I have not mentioned here.

So here is to life as an adult!

And…..Done

Hello all!

Around now, 4 years ago, after weeks of worrying, I found out that I had done enough on my A-Levels that I had been offered a place at my first choice University.

4 years later and the final deadline for my dissertation – my final assessment for this course –  has passed. At 3pm yesterday, I officially finished.

Horray!

This has been the most difficult assessment that I have done over the past 4 years and perhaps even the most difficult one that I have done in my whole academic life!

The past week was particularly stressful as I set out to finish the report in time for today. I actually finished it for the day before because I had to get it printed and bound.

Then there was the stress a few weeks back to get a working system ready to demo. In fact, there were many stresses of trying to get that thing to work! This dissertation has been a constant presence in my life.

Also both my desktop and netbook failed. My desktop seems to randomly have power cuts. Then it didn’t even switch on for a week until it randomly started working fine until last weekend…I hope its the power supply unit and not the motherboard.

Then the netbook hardrive died. I had to buy a new one and reinstall everything. Decided to go for an SSD drive and it really sped things up. Luckily, in both cases, there was no loss in data as everything was in the cloud.

I do have some worries. I am constantly thinking, what if I missed out something major! I was not able to check with my tutor if it was OK before I finished, so I worry that I have gone completely the wrong way. Or what if I have missed out a section? Or done the references wrong so I get done for plagiarism? What if I submitted an incomplete version by accident (I have checked but still)?

So what next?

Well despite finishing all possible work I am still technically a student. Here are a few more milestones that will be happening until I finish:

1st September – Start my new full time job. Although it is at the same company doing more or less the same role, I will no longer be a student in their eyes, just a full time employee.

Latest 19th September – I find out my final mark for the dissertation and indeed my entire degree.

30th September – This is the date that my course officially ends. My student card and my student travel card both expire on this date. This is the date I am no longer a student.

27th, 28th, or 29th January 2015 – The graduation ceremony is on one of these three dates. Not sure which one yet.

Next week I shall be going on my summer holiday. It is still in August so technically, although late, it is a summer holiday! I have been looking forward to it and although I can’t completely forget about University until my result, at least there will be no hard work until I return and I can relax a little bit.

BRB

I can’t believe that I haven’t done a post here since April! It is amazing how “tomorrow” becomes “the weekend” which then becomes “next week”.

The truth is that I won’t be able to get back into the swing of things until September (or at the very earliest, late August)! The reason: university.

Being in my final year, I am currently undertaking a final year project. It is a project that I pretty much started a year ago and will not finish until towards the end of August.

At this point, I will have finished my long 4 years at university and I will no longer be a student. I have been looking forward to that day for a long time now and now, it is just around the corner.

However, between now and then, there is a lot of hard work. There is lots to do on the project before the deadline and I don’t have a lot of time to do it.

I want to spend a lot of time looking after this blog and it is time that I simply don’t have whilst the deadline is looming.

So this will probably be the last post I make more a while. I will check in occasionally to keep the back end up to date and will still read comments that I receive and when I return, I will commit the proper amount of time that I want to give this blog!

Why Does It Take So Long When Unsubscribing From Newsletters?

I recently posted a comment on an article for the Guardian newspaper. The process was quick and easy but I inadvertently signed up for a daily newsletter!

This is annoying as it is. I am usually very careful to spot the check-boxes and rigorously read them to make sure that I do not sign up to more unwanted mail.  So when one slips through, I come to the conclusion that it wasn’t there.

But I digress, this article is about something that annoys me even more: the unsubscribe process.

After following the “unsubscribe” link, I am greeted with this message: unsubscribe“This will take effect within 7 days.”

7 days?! It takes 7 days for a simple PHP script to update a single record in a database after pressing a button?!

The Guardian are not the only ones. Every time I have unsubscribed from any newsletter, they have shown me a similar message.

But I don’t understand why! They are able to sign you up instantly, so why can’t they unsubscribe instantly.

It is obvious to me that it is not a technical issue. Updates on a database should take seconds at most.

So if it is not a technical issue what is it? Is it so they can get as much of our attention as possible before we go? Surely anyone unsubscribing will just delete any remaining e-mails that come through, so this is a waste of time!

There is simply no good explanation.

I am not the only person to question this. But the answers people have suggested on that post are unsatisfactory.

The only decent explanation can be found as a comment of this post they said:

Until recently it used to take around 10 days (sometimes less) to process the unsubscribe requests as the email newsletters were managed by a third party company. The requests were sent through to them once a week in a batch.

That still doesn’t answer the question of why it doesn’t take that long to subscribe. If it took 10 days to unsubscribe, it should take 10 days to subscribe! There is no excuse really.

This answer was from 2010, but even then, I would expect any third-party company to handle instant requests! Maybe via an API?

So that concludes my rant. Let me know your thoughts in the comments if you have had similar experiences. I would be particularly interested if you are maintaining a system that handles unsubscribe requests, maybe you can enlighten us!

How to Fix Heartbleed OpenSSL Bug

This week, a major bug on Openssl, called Heartbleed, was announced which basically renders any ssl protection useless.

You can test if your site is vulnerable by doing this test by Qualys.heartbleedbeforeAs you can see, we have failed the test and it highlights the fact that we have the vulnerability.

How to patch it

sudo -s
(optional, but the other commands will have to be proceeded with sudo if you do not).

openssl version -b

You will get something like, built on: Wed Jan  8 20:45:51 UTC 2014. If the date is less than April 7th, then you will have the bug.

Do

apt-get upgrade openssl

Press Y to continue.

Note: you may need to do apt-get update first to get the latest packages.

And that is it. Vulnerability fixed. Do openssl version -b again and check the day is at least Apr 7.heartbleed after

The test also shows the vulnerability is fixed!

Thanks to my colleague, Sheraz, for help finding a solution to the problem!

Quick Guides: #1 – Installing PHP Composer

Want to install and use PHP Composer on your Ubuntu machine?

Simply run:

curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

You can now use the command, composer install in a directory that has a composer.json file.

Want to know what a composer.json file should look like?

See below for an example:

{
    "require": {
        "symfony/class-loader": "v2.4.1",
        "symfony/yaml": "v2.4.1"
    }
}
Voila! Another guide decrapified.

Life before vs Life after the Web

This week, the World Wide Web turned 25! Seems strange to think that it is only a little bit older than me!

The Metro ran an article where they looked at 11 ways that the web has changed our lives.

I thought I would add to the list some more ways that I thought of.

Enjoy.

1. Sharing photos

tumblr_inline_mjipr3iCae1qz4rgp

Before:  Use up the rest of the film used for the holiday pictures and then take it to the chemist to be printed. “Would you like the 24 hour service or the 7 day service?”

After:  Plug camera into computer. Log on to Facebook. Upload all photos. Spend 24 hours tagging them all.

2. Selling stuff

ebay-ad

Before: Put a hand written note in the corner shop window. If you are feeling really posh, make a listing in the local paper or in the Loot newspaper. Wait by the phone.

After: Take amazing pictures from every angle. Create a listing on a website such as eBay, go about your day whilst buyers have a bidding war over your item.

3. Fund raising for sponsored activity

Stewie-Demands-Brian-Griffin-Give-Him-Back-His-Money-On-Family-Guy

Before: Get people to pledge how much they will donate for you to do something. Spend three months following the event tracking down the pledgers, who are suddenly always busy.

After: Create a page on Justgiving. Spread this page through the power of social media. Anyone who pledges automatically has money taken from their account and placed directly in the hands of the charity.

4. School research project

Cat Reading

Before: Go to the library and use the Dewey Decimal System to locate the books on the topic. “The book is checked out for another week?! But the deadline is tomorrow!”

After: Google.

5. Topup pay as you go phones (does anyone even have these anymore?)

queen-phone-460a_1127984c

Before: Down the local shop. “Hi can I have £10 top up for O2 please.” “O2?” “Yes, O2″ (seriously, the guy in the sweet shop would always do this double check and it would infuriate me inside. You heard the £10 part correctly, so why do you need to know the network again!?). Then call a number, and type a 10000 digit number to load your call time. That is if your top up ticket doesn’t get wet or blown away by the wind.

After: Log into the network’s website and top up online. Balance is added instantly.

It is interesting to note that in all these scenarios, the World Wide Web on its own did not do anything. It was people who used this amazing tool to create and do even more amazing things.

Ubuntu Editors

Ubuntu Text Editors

I remember the first time that I used an Ubuntu text editor.

It was during a simpler time when I was some how developing on a Windows machine.

I was trying to debug and fix multiple PHP scripts using vi. I still have nightmares to this day about that.

This week, I was reminded of this pain by a fellow colleague who came to me after experiencing the same pain.

I have no idea why vi was designed the way it was. So you open a file up with it (making sure you do it with “sudo”, otherwise everything you do would be for nothing).

Then you move your cursor to the right place and start typing. Nothing happens.

Oh of course, you have to press “a” first, and then you can type what you like. How obvious is that?!

OK, I now want to move to a different line. I am still in “insert mode” because I have not finished typing. In true terminal tradition, I begin using the arrow keys to move my cursor…

What the….

The joys of ViLetters are appearing!!

When I press the arrows,  the cursor moves and puts a letter in place. One of 4 depending which arrow I press. Why??? What was the design decision behind this to make it do this?!?! It just makes no sense! It is not like I don’t have 26 other keys which are dedicated to typing letters!

To move, I have to remember to press Esc, to get out of “insert mode”, then press the arrows, then press “a” again.

What about saving. Well obviously, you type a colon to do a command, followed by a letter; and obviously the letter of choice for saving is “w” (I guess, on hindsight, w means write).

But wait!

Screenshot from 2014-03-10 09:20:56What does this even mean?! It only appears sometimes! It is so spontaneous that I have gotten into the habit of adding the ! every time.

I have since gotten used to the commands of vi. But I will never be able to understand the logic behind having letters appear when I press arrows. It is so ridiculous!

Luckily, there is a solution that fixes this. It is called vim.

Simply run: apt-get install vim and it will automatically install and be used instead of vi.

It still has the same commands as vi, and you can still use it as if you are using vi (sudo vi text.txt).

It comes with two improvements:

  1. It fixes the stupid design flaw of not being able to use the arrow keys whilst in insert mode.
  2. It adds colours to the code to make it a little bit more readable.

In my opinion vim is how vi should have been to begin with. I have gotten very used it to it and always use it when I want to quickly edit, say, a config file, for example. Unfortunately, it is not always installed on every server and vi comes to haunt me.

If vim is still not easy enough for you, you can always use nano.

Nano is as close to a GUI text editor as you are going to get in terminal.

Just do apt-get install nano and then say sudo nano text.txt to use (Note: it does not automatically override vi like vim does).

Then just start typing as you would in a text editor! No pressing keys to begin typing or stop typing. No weird behaviour when you press the arrow keys.

Screenshot from 2014-03-10 09:52:51All the commands you need are helpfully listed at the bottom. Note that the ^ actually means Ctrl. So CTRL+O will save it. But you will be given the option to change the name of the file (no random need for exclamation marks either!).

Finally, you have gedit.

People who use the desktop edition of Ubuntu will be very familiar with this one. It is the text editor you open if you use the GUI interface to open a file.

But, if for some reason you have to open one in terminal (because of permissions), and nano is still too scary, sudo gedit file.txt will open the said file in gedit.

You will then have a GUI interface of a text editor with all the familiar buttons and menus. I won’t go into detail for these, as if you are struggling to use even gedit, then there is really little hope for you!

Ubuntu Editors

Quadratic Equation Calculator Icon

My First Android App!

I have finally built and published an Android App!!

It went live yesterday. Unfortunately, it is nothing too exciting. It is simply a quadratic equation calculator. But I had to start somewhere and I learnt a lot in the process of building it.

I decided to support devices pre-4.0 and this is where most of my problems came:

  • The action bar – an extremely useful built in menu bar that I had originally coded from scratch – is only available from, Android 3.0 on-wards. So I had to use a special support library to make it available for older phones. Problem was including this library in project was not that straightforward.
  • The action bar still doesn’t behave as well as it does newer devices as the support library I used didn’t support everything.
  • Getting a Context Action Bar to work on an older device was also a mission!

So most of my problems came from having to support older devices. In future apps, I don’t think I will do this. I will set the threshold as 4.0.

Today, just over a quarter of people still use devices less than 4.0, so I will lose this percentage of downloads. However, I will still cover 75% of all devices and this number can only get higher! It will also save a lot of headaches (at least for now until future versions come out!).

But to be honest, I doubt I will have much time for side projects from now until August when I finish University. This is why I was so keen to finish this app now and get it out there.

To find out more about the app including a link to the Play store,  click here!