Linux Blog

Monitor Disk Usage for Large Copies

Filed under: Shell Script Sundays — Owen at 12:24 pm on Sunday, August 23, 2015

Note: There are probably better ways of doing this. I am currently coping a decent amount of data using rsync between a NAS drive and a locally mounted USB drive and wanted to monitor the process.

This works for the local drive:

owen@thelinuxblog:~$ df -h /dev/sdc1 | cut -d \  -f 11 | tail -n 1

I started figuring out the way to display the NAS total usage, which looks something like this:

df -h |grep NAS2 | cut -d % -f 1 | cut -d \  -f 35- | cut -d \  -f 1

Which is fine, but really is not needed and is bit overkill when I know the total amount that is going to get copied, so I simplified it down a bit to look like this:

owen@thelinuxblog:~$ echo `df -h /dev/sdc1 | cut -d \  -f 11 | tail -n 1` of 100G
41G of 100G

Then I wrote a loop to print out the usage every 5 minutes (300 seconds) and the date.

owen@gibson:~$ while [ $(echo `df -h /dev/sdf1 | cut -d \  -f 11 | tail -n 1` | sed 's/G//') -lt 100 ]; do echo `df -h /dev/sdf1 | cut -d \  -f 11 | tail -n 1` of 100G `date`; sleep 300; done;

This was a quick and dirty way of monitoring progress while passing time and now I’m able to keep an eye on things.

Debian 8.1 OpenVPN Setup

Filed under: General Linux,Linux Software — Owen at 12:12 am on Thursday, July 23, 2015

ovpntech_logo-sAfter installing the latest Debian “Jessie” 8.1 and attempting to setup OpenVPN, I noticed a small issue with the OpenVPN Debian Wiki page. In step 2 of the Server Configuration section the information is no longer correct. After reading the /usr/share/doc/easy-rsa/README.Debian file it became apparent that rather than doing:

mkdir /etc/openvpn/easy-rsa
cp -ai /usr/share/doc/openvpn/examples/easy-rsa/2.0/ /etc/openvpn/easy-rsa
cd /etc/openvpn/easy-rsa/2.0

You need to do:

make-cadir /etc/openvpn/easy-rsa/

and adjust the remaining instructions to not use /easy-rsa/2.0/ accordingly.

Not rocket science, but I figured I’d post since in my brain more people will Google a question rather than reading the documentation.

Running dual boot for gaming or using Virtual Machines

Filed under: General Linux,Linux Software — Owen at 12:01 am on Tuesday, May 26, 2015

This is a guest post by Fredrick Cameron and Parking Games 365!

VM

Being a hardcore gamer is not an easy “job” – you have to invest large amounts of money into cutting-edge hardware, and just when you think you have the best gaming rig, something better pops up. As if that’s not enough, you might find yourself in the situation of having to use multiple operating systems, which will lead you to one crucial question: what’s the best approach for getting everything working just right? When it comes to using multiple operating systems and gaming on a single machine, is dual-booting the better choice, or will virtual machines get the job done just as good?
Convenience vs. Performance
Dual-boot and virtualization are both use for the same final purpose: being able to run multiple operating systems on a single machine. However, each approach works differently, and thus they’re not both appropriate for all tasks.
VM1

Virtual machines are exactly what their name suggests – virtual computers that run inside your own real computer. The main advantage of virtual machines is that they run inside the main operating system, and as long as your hardware can keep up the pace, you can have multiple virtual machines running simultaneously, each machine being able to run a different operating system. By running inside the operating system, virtual machines are easy to manage, configure and deploy, thus being very convenient if you need to quickly switch between operating systems, as you don’t have to restart your PC and wait for everything to load over and over again.
VM2

Dual-booting implies installing two operating systems on a PC. Unlike the case of running virtual machines, in a dual-boot system you have to restart the PC every time you want to switch between operating systems. Installing the two operating systems also requires considerably more work and configuration. So far all these aspects seem to indicate that dual-boot is far less convenient than running virtual machines, so you might expect there’s a catch, and there is: dual-booting means that each system gets exclusive access to the hardware in your PC. In other usage scenarios, this might not mean much, but when it comes to gaming, it’s a complete game-changer. Literally.

Virtual machines get limited access to hardware, as they run as “guests” inside the main operating system. For example, if you’re running a PC with a dual-core processor and 4GB of RAM, one core of the processor and 2GB of RAM might be used by the host operating system, leaving the guest operating system with just one core and the other 2GB of RAM. This basically cuts down the performance of both the host and the guest operating systems to 50%. When you’re running a powerful gaming machine, with quad-core, hexa-core or even octa-core processors and tons of RAM, having the host operating system consume a chunk of those resources might not seem like such a big deal, but gamers tend to hold on to every bit of computing power, as recent games are power-hungry.

However, the key factor that prevent virtual machines from being adequate solutions is the fact that they can’t access and use the hardware as efficiently as a separate operating system does. Ironically, the main component that can’t be fully taken advantage of via a virtual machine is the graphics card, which also happens to be the most important component when it comes to gaming. There is a VGA pass-through procedure that should allow you to give the virtual machine direct access to the video card, but setting it up is a lengthy and complicated process.

Dual-boot may seem a bit inconvenient at first, requiring you to install and configure two separate operating systems, and have to go through “the pain” of a system reboot every time you want to switch, but it’s still far better than having to go through the pain of seeing your games shutter or lag.

Apotheon: A heroic action game set released for Linux

Filed under: General Linux — TheLinuxBlog.com at 12:18 am on Friday, May 22, 2015

This is the guest post by Fredrick Cameron and Makeover Games 365!

Apotheon

It has taken four years of development but has it been worth the wait? Apotheon, a heroic action game is now available to play on Linux systems. Originally accessible through Steam for Windows and by opting into the Beta section for Linux, it is now available and fully functional for the Linux user.

The game

The setting is ancient Greek mythology and all the Greek Gods are present. The player takes charge of the character Nikandreos, and his mission is to save humankind from the wrath of the Gods; you will need to ascend to the realm of the Gods and return with many battles along the way. The ultimate confrontation is with Zeus, who is surrounded by many of the deities you will have heard of from Greek mythology. The challenge is to strip the old Gods of their powers and take control of the elements yourself – no easy feat. The game characters appear almost like puppets with the setting appearing realistic and the fighting fluid. This creates a very smooth game to play.

Is this just another hero action game?

In short, the answer is no. The developers have worked hard to keep the game true to its subject matter; they have successfully merged classic culture with modern entertainment. Nikanderos is a typical hero of this period, very masculine but without any deeper affliction. He is forced into a world on the throes of massive change, constantly fighting for his life whilst looking for redemption. The game is unique in the way it merges art and game play.

Something New

Apotheon is a 2D side scrolling game like so many before it. It literally delights a player and draws you into the game, and somehow makes you feel like you are there. A player can take pleasure in steering his character into battle and taken on the most powerful Greek Gods. Each realm needs to be explored and challenges solved before you can rise to the realm of the Gods. The fact that all this has to be done with the traditional weapons of the time simple adds to the experience.

Greek Mythology

Apotheon1

The game in many respects looks like you’re looking at the side of a Greek vase. Figures and scenery is directly lifted from pottery between the fourth and sixth century. The result is a fully rendered, authentic Greek setting. Thanks to the open world design you are able to explore each level. Your character is the centre of the story, but the story is not set in stone. You are in control of where your character goes and how the story unfolds; it can be different each time. All these elements combine to make the player feel as though they are part of the Greek myth, not just looking in the window.

Apotheon2

Every game has an atmosphere although some are better at creating it than others. In many games it is set by the music, whether sound tracks or background noise. In Apotheon the answer lies in humankinds continuing obsession with Greek Mythology. Many have debated whether there is any truth to the stories, but few would dismiss them without further thought. This time period holds a fascination and the game capitalises on that.

It is impossible to say which parts of the mythology are true or truth based. The confusion this creates allows us to ponder, and perhaps dream every time we are confronted with the subject. It is this that creates the atmosphere in Apotheon. It is this atmosphere that makes the game so enjoyable to play, especially on Linux.

Expert tips to play games on your Linux machine

Filed under: General Linux,Linux Software — TheLinuxBlog.com at 12:52 am on Friday, March 20, 2015

This is the guest post by Fredrick Cameron and Dirt Bike Games 365!

Linux is the leading operating system on servers around the world, yet it is used on only 1% of desktop PC’s. Linux is free and open source collaboration – meaning it is available to anyone and can be modified, distributed or just used. Due to its rarity on desktop PC’s it has not been well catered for the massive games market. However, it is now possible to play games on Linux. In fact, the system is now so good that you may question whether you need a Windows PC to play games.

Linux is a top-choice for high-performance computing these days. The operating system has come a long way, and because it is “open-source”, users can easily change its code and make it suit their gaming needs. Also, you don’t need a licence to use Linux. It also prides with a smooth infrastructure, and it can run on every form of relevant piece of hardware. Linux is becoming more and more user friendly and the following tips will allow you to play any modern PC game on your Linux system:

(Read on …)

Shell Script Input Parameters

Filed under: Shell Script Sundays — TheLinuxBlog.com at 8:00 am on Sunday, March 1, 2015

When writing shell scripts, it is often useful to have some type of input parameters. There are a few ways to do this, and it turns out I’ve written about two of the main ways before. The first is the Shell Script to get User Input post which is essentially using read, and the second is Creating Script Parameters with GetOpts. I’ll also cover a quick and dirty way of getting input into a shell script. From this you’ll be able to see the differences and decide what input method is best for your situation.

(Read on …)

Random Numbers in Bash

Filed under: Shell Script Sundays — Owen at 8:00 am on Sunday, February 22, 2015

Going back to last weeks article on running things continuously, part of the use case was generating random numbers.

While using echo $RANDOM works, but it doesn’t work very well for having a minimum and max value. There are techniques to do this, but what I’ve found easier is to use another language of your choice and run that separately using expansion ( $() or “). I’m sure there is a way to do it in Ruby and Python and whatever language but since I’m familiar with PHP, I’ll use that in this example first:

1
2
3
for i in `seq 1 10`; do
echo `php -r 'echo rand(1, 100);'`
done;

This example iterates the loop 10 times, and echo’s a random number between 1 and 100. here is more information on PHP’s random function Note that this does require having php5-cli package installed.

If you don’t have PHP, but have perl you can use:

1
2
3
for i in `seq 1 10`; do
echo `perl 'print rand(100);'`
done;

That’s great and all, but perl uses what looks like floating numbers. To get an int, you have to cast to an int which adds additional typing:

1
2
3
for i in `seq 1 10`; do
echo `perl 'print int(rand(100));'`
done;

To me, this is easier but, if you don’t have PHP, Perl, Ruby, Python or whatever your choice, you could use bash (I always forget how, but here it is for reference:)

echo $[ 1 + $[ RANDOM % 100 ]]

Or if you have complex requirements, you could write a quick binary that does the same thing. Another alternative is to use another shell that you do have access to that happens to have a more robust RNG.

Compiz Config

Filed under: General Linux,Linux Software — TheLinuxBlog.com at 8:00 am on Wednesday, February 18, 2015

One of the great things about Linux is that if you don’t like something, you have the power to change it. You can add features, or remove them to suit your needs. One of the cool features that has been added to modern distributions is the OpenGL compositing manager called Compiz. A lot of distributions come with Compiz as standard, but some don’t. If it does and you have no need for it you can remove or tweak features and functionality it provides. Personally I’m not a fan of every feature or all of the flashiness, so sometimes I tweak it. Follow the jump for more information.
(Read on …)

Bash Continuous Loop

Filed under: Quick Linux Tutorials,Shell Script Sundays — Owen at 8:00 am on Sunday, February 15, 2015

I came across a use case for running something continuously until breaking, rather than pick a large number and a for loop (for i in `seq 1 10000`) you can use a while loop with something that returns true, my first instinct was to use while echo, but that returns a blank line in-between each iteration, which could be useful, but if you don’t want any kind of spacing or notifications you can use while true as follows:

while true; do 
echo "STUFF"; 
done;

This technique could be used with sleeps to run something every x seconds, although when you start getting into that you’d probably be better off using cron.

DIY Monitor Stand

Filed under: Linux Hardware — TheLinuxBlog.com at 7:00 am on Wednesday, February 11, 2015

At work, we have these pretty sweet monitor mounts. I used to have a wall mounted one at home, although it was not nearly as nice. The reason I no longer used it was, my laundry room is behind my monitor, and anytime the washing machine was on it would vibrate which was really annoying. It got thrown in storage, not to be seen again for a while – until recently. I decided to have a go at making my own, similar to the ones we use at work except for a single monitor and a fraction of the cost. I had some black iron from another project, a piece of L tubing from a bed frame otherwise known as “poor mans angle-iron” and the mount. The idea was to take my VESA mount and mount it to the pole, use the bed frame to attach it to the desk with c-clamps. After welding the black iron to the bed frame I chopped up an old bicycle seat post which happened to be the perfect inner diameter to fit over the black iron, I welded two bolts to the bike seat post pieces and welded a captive nut for a hex bolt to the bottom one to make it height adjustable. I put my monitor on the VESA mount, attached the mount to each of the slides, and placed it over the black iron tube. It works great, I can adjust it from desk height to about 20″ and move the monitor from left to right. The monitor does “tilt” a little when it extended further to the left or right, but it is hardly ever fully extended.

This was a pretty decent turnout for about an hour with my angle grinder and welder. It seemed like the primer took longer to dry than it took to fabricate it. I never did get around to painting it black. Please ignore the dusty shots, I didn’t bother to clean it for these pictures, and the flash causes every spec to show up. Yea, that’s it – the flash.

Auto Clean-up Downloaded Files – Part IV

Filed under: Shell Script Sundays — TheLinuxBlog.com at 8:00 am on Sunday, February 8, 2015

In order to avoid the complex task of file comparisons on unknown files and types for what should be a simple task, I’ve made an executive decision to handle statistics. Hopefully I will not regret this should I decide to tackle file comparisons. For the cleaning up of Downloaded files there are really only a few statistics that I can think of that are meaningful to the task of deleting multiple files.

The first being counts, this could be the count of files in the folder, the number that matches the (?) find pattern and the total count of deleted files.
For the second “metric” disk space is a good one, but could be tricky to calculate given different file size types (byte, kilobyte, megabyte, etc.)
Timing is another option. We’ll skip how long I spent on this, as it is useless. I’d rather spend my time writing something that can be reused rather than wasting time pointing and clicking – although it would be interesting to calculate how much time was spent writing vs. the total run time we wont cover that. What we will cover is how long did it take to discover and delete the files? A fun number if for nothing else bug giggles.

Fortunately for us, utilities exist for all of these items and can be added fairly simply. We’ll start with the first and work our way down, regardless of how I feel about the last two items.
(Read on …)

Next Page »