Sunday, August 31, 2014

Change FAT / NTFS file attributes from Linux

The original use case was born for me when one of my friends gave me a memory card that was infected by the 'hidden file' virus (he calls it so). All of the files were applied the +S +H +R attributes which made the file System file, Hidden and Read only respectively. For this reason he could not see them in his cell phone which depended on this attributes (Nokia Symbian OS).
I personally don't like to work with Microsoft born tools, so instead of booting into my Windows 7 installation (I usually never do that), I wanted to find a way that allowed me to change these attributes right from my Linux installation. There it came, the awesome 'mtools' toolset.

To change the file attributes, you first need to switch into that directory (which points to the card). But the mtools have a catch. They do not let you work with them, unless you ignore some errors. And to instruct it to do so, you have to make an RC file that will do just that right before one of tools takes any actions. The location of the RC file will be
~/.mtoolsrc
or
/home/<user>/.mtoolsrc
The contents have to be
drive s: file="/dev/<your-usb-drive>"
mtools_skip_check=1
The significance of the first line is, it assigns the directory into drive S. it could be anything else, like C, D, E etc. The second line tells mtools to check for some errors, it has to be set to not check because otherwise it refuses to operate on the drive (please don't look at me, I just copied it from somewhere)
Then change into your drive
$ mattrib -/ s:
And change the attributes (actually unset them) for all the files
$ mattrib -/ -h -s -r s:
That's it :)

Credits due:
http://blogs.gnome.org/diegoe/2012/04/21/removing-the-hiddensystem-bit-of-vfatfat32-files-on-gnulinux/

Tuesday, August 12, 2014

Running Counter Strike Source on Linux (native version)

CAUTION: Try this only if you face any problem running the game(s).
Well, it's great news that companies are now releasing Linux version of many games including Valve. They've already made Portal, Half Life and Counter Strike: Source available on Linux. But running them is sometimes a bit tricky mainly when CPU architectures mismatch. I have a 64bit setup while the copy I was trying to run was 32 bit so some libraries were reported to be missing when what it actually meant was, the 32 bit versions were missing. A little bit of research goes a long way.
1. First execute this command in you Counter Strike: Source installation directory (cd into it)
LD_LIBRARY_PATH=bin ldd bin/vguimatsurface.so | grep found
This should tell you exactly which libraries are missing
2. To give you an idea about exactly what is going to happen with the next command, these are the libraries that are need to be installed
lib32-fontconfig lib32-gtk2 lib32-libxi lib32-nss lib32-libpng12 lib32-alsa-lib lib32-pango lib32-cairo lib32-sdl2
So, to install them, type these in your terminal
libfontconfig1:i386
libgtk2.0-0:i386
libnss3:i386   
References:
1. https://bbs.archlinux.org/viewtopic.php?id=169422
2. Torrent page on The Pirate Bay

Monday, July 21, 2014

Some useful Apache web server commands

These are mostly for reference, to find the ones I use the most
Enable module: a2enmod vhost_alias
Enable site: a2ensite vhosts_alias
List enabled modules: apache2ctl -M

Saturday, July 19, 2014

Installing the Atom editor in Linux (Ubuntu)

To install the Atom editor by Github, you do not have any compiled deb/binaries except you use some third party repositories, which I try to avoid all the time. So, while searching for a way to compile this thing and avoid the errors, I found some info on several links that actually helped make it possible.
The steps:
1. Install the necessary dependencies using
sudo apt-get install libgnome-keyring-dev python2.7 git git-core
2. (Optional) In order to ensure that npm is using python2 use this
npm config set python /usr/bin/python2 -g
3. Now get the source and go into it
git clone https://github.com/atom/atom
cd atom
4. Now build it using the command
script/build
NOTE: You might need to become root before doing these
You might face problems regarding 'grunt' and 'npm' which means you might not have the latest version of 'npm'. So to install that, first try the command
npm update npm -g
If that does not help then try this
npm update -g
And if none of it helps, use this.
curl https://www.npmjs.org/install.sh | sh
After installing the latest version run the build command again and then it should go smoothly from there 5. Now to make 'atom' a command accessible from /usr/local/bin/atom do this
sudo script/grunt install


Credits:
1. http://blog.xero.nu/atom_editor_linux_install
2. http://stackoverflow.com/a/6237400/1928610