and has 0 comments
Another Linux related post, this time about errors when trying to use yum to update or install some packets on Fedora 9. The error I encountered is [Errno -3] Error performing checksum when trying to get primary.sqlite.bz2, eventually ending with an ugly Python error AttributeError: 'NoneType' object has no attribute 'cursor' .

In the etc/yum.repo.d folder there are some files with the .repo extension. Each one contains some modules that can be enabled=0/1. Those modules are used by yum to download and update files. Yes, you will see yum failing and "trying another mirror", which means another server, but not another module! Therein lies the problem. I had a repo enabled that was not for Fedora 9, but for Fedora 14 aka Rawhide. The checksum was obviously failing.

The solution is to enable only the fedora repos, and disable everything else. Eventually, start enabling and disabling different modules and see what works and what doesn't.

My problems were not over. After running yum update I was getting Missing Dependency errors. Analyse each one and see what you can do. In my case, the subversion packet wanted a libneon.so.25 file. The problem was not in the neon file, but in the fact that the subversion packet that threw the error looked something like subversion-1.6.6-0.1.el5.rf.x86. Notice the el5 portion which identifies the packet for CentOS, not Fedora 9. It's the wrong packet.

Use rpm -qa | grep el5 to get all the packets that are wrongfully installed for el5, then use yum erase <packet name> to remove it. Now the update and yum should work fine.

Sometimes the errors lie in corrupted caches. You have two additional commands that might help, although in my case I don't know if they had any effect:
yum clean dbcache
rpm -rebuilddb

Hopefully this will clear things up for other Fedora noobs :)

I wanted to build a script to copy some files from a computer to another. This can be done using a few utilities like:
  • nc - for stream network transfer
  • tar - for clumping all files together
  • gpg - for encryption


Here is the quick and dirty version.
On the receiving computer:
nc -dl _MyPort_ | gpg -d -q --no-mdc-warning --passphrase _MyPassword_ | tar -xjC _DownloadFolder_

On the sending computer:
tar -cj -C _Folder1_ _File1_ -C _Folder2_ _File2_ -C _Folder3_ _File3_ _File4_ _File5_ | gpg --passphrase _MyPassword_ -c | nc _MyIP_ _MyPort_

In other words:
On the receiving side nc is listening on a specific port for a stream that will be passed through gpg and decrypted, then passed to tar which will decompress it and split it into different files in a specified download folder.
On the sending site the files to be transferred are clumped and compressed into a stream by tar passed through gpg and encrypted, then sent to a specified IP and port via nc.

nc and tar are standard Linux utilities. gpg must be downloaded and installed.

The scripts themselves are more complicated, but the gist of it is in here.

Short version: use nc -dl portNumber instead of just -l

Netcat is a nice little tool that is very useful in all kinds of networking problems. Basically it listens on a port and it sends to ports via TCP/IP. Using the piping mechanism of Linux, one can send anything, from files compressed on the fly in the network stream to telnet sessions and back doors.

Today I was trying to copy a few files from a computer to another, therefore I did something like this:
tar -c -C /source/folder file1 file2 file3 | nc theOtherComputer portNumber
on the second computer I did this:
nc -l portNumber | tar -x /destination/folder

And it worked perfectly. I made all kinds of cool stuff in the bash scripts and then, wanting to execute the "server" in the background I did:
serverApp &

From then on, nothing worked. The sender would report success, the received file would always be truncated. After trying all kinds of things, I stumbled upon the -d switch of the nc tool. The man page says: -d' Do not attempt to read from stdin.. It appears the application is trying to keep a reference to the input of the starting environment. It makes no sense for a listening scenario, but it does it anyway. Failing to find one (since it is runnning in the background), it just exits earlier than expected.

So, whenever you want to use NetCat listening in the background, don't forget to use the -d switch.

In simple words, it seems there is none. After doing a query like SELECT stuff FROM (SELECT * FROM Table1 UNION ALL SELECT * FROM Table2) x WHERE condition, where Table1 and Table2 are identical in signatures, I noticed that it took 30 seconds on a combined 1 million rows. So I thought I would try to move the condition on each of the UNIONed tables: SELECT stuff FROM (SELECT * FROM Table1 WHERE condition UNION ALL SELECT * FROM Table2 WHERE condition) and it took 2 seconds.

So it seems as the server performed the union on all the rows, perhaps moving them in a temporary table, then filtered on the condition.

Coming from the world of Microsoft Sql Server which carefully creates a query execution tree and routinely solves queries similar to there two in an identical and optimised fashion, I was a bit surprised. Then again, being a Linux MySQL, maybe it was just not compiled right or didn't have an obscure option set up or something like that. Anyway, I was dissapointed.

and has 0 comments
I am not a Linux guru, but sometimes I need to use Linux systems and for that I use SSH. It is customary nowadays that one doesn't login remotely using the root account, but rather use another user, then use the command su (super user) to gain root priviledges. I've done it tens of times, most of the time checking if I can log in and then su with the new user.

Well, a few days ago I did not and, to my horror, I noticed that I couldn't use su from my new user, as a permission denied error message popped up. Plus, I had already locked the user I had previously logged in with. Add to this that the device in question had no keyboard/monitor jacks, it was remote, it only had a serial connection, my laptop did not and that the serial cable I tried to use with a borrowed desktop computer was not good enough for this damn device and you can understand the hell I was in.

Enough said, the idea is that some Linux distributions (like the ones based on BSD. Gentoo, for example) use what is known as the wheel group or the group that permits users to use su. Use usermod -G wheel myNewUser to add your user to the wheel group and always ALWAYS check if you have enough permissions for login users before you log off from root.

and has 0 comments
I did a service on Linux for a friend of mine, mainly a script that he was supposed to execute. He tried using it, but failed every time. I was logging in, tried it and it ran perfectly well. We scratched our heads a little until he noticed some error messages from when he executed the script, saying that a specific command could not be found.

So, this is what happens: he logs in using SSH with credentials that are not root (as it should be) then he executes su (super user) to gain root privileges. He then executes the script and the commands inside the script are not found by the system. I do the same thing, and it works.

It took a while until I realized that he gained super user privileges using just su while I was using su -. Leave it to Linux guys to have a single minus sign as an important command line parameter :) su - executes the complete shell environment for the root user and changes the PATH variable and the home directory (to root). su gives you root privileges, su - makes you root.