How to Compile and Install a Tar file in Linux

The .tar file format is derived from the phrase “tape archive”. Developers often use this format to compress and distribute their sources. By doing this, they need not worry about the platform, so anyone on any platform can directly compile and install on their computers. This short guide will teach you how to extract an tar file, compile and then install it on any linux distro.

After you download a .tar file, open Terminal and navigate to the directory where the file exists using ‘cd’ command. Then perform following commands:

xvzf packagename.tar.gz
cd packagename
./configure
make
make install

That’s it. The program should be installed now.

Category: Linux | Comments Off on How to Compile and Install a Tar file in Linux

MySQL Error in Fantastico

A client opened a ticket since they were receiving the following error when trying to install a script via fantasticrap…I mean fantastico.

Warning: mysql_connect() [function.mysql-connect]: Access denied for user ‘linuxnoo’@’localhost’ (using password: YES) in /tmp/cpanel_phpengine.1304688239.24500MvupN_eQWd on line 1642
Access denied for user ‘linuxnoo’@’localhost’ (using password: YES)

This issue is caused by a mismatch in the cPanel password and the MySQL users password. You can verify this in SSH by running the following.

mysql> use mysql;
mysql> select user,password,password(‘YourPassword’) from user where user=’YourCpanelUser’;
+———-+—————————–+———————–+
| user | password | password(‘–‘) |
+———-+—————————–+———————–+
| linuxnoo | *E6…..3F | *B6…..3A |
+———-+—————————–+———————–+
2 rows in set (0.00 sec)

As you can see above, the two password fields do not match so we need to update this.

mysql> update user set password=password(‘bNEQL13dvJ’) where user=’linuxnoo’ limit 2;
mysql> select user,password,password(‘bNEQL13dvJ’) from user where user=’linuxnoo’;
+———-+——————————————-+——————————————-+
| user | password | password(‘bNEQL13dvJ’) |
+———-+——————————————-+——————————————-+
| linuxnoo | *E6D911C8973EEDDA0CE0618EFB493E704776DB3F | *E6D911C8973EEDDA0CE0618EFB493E704776DB3F |
+———-+——————————————-+——————————————-+
2 rows in set (0.00 sec)

After the password update try to install again and it should work just fine.

Category: Linux | Comments Off on MySQL Error in Fantastico

File Permissions in Ubuntu

Ability to set file permissions for individual users or user-groups is one of the most sought after features of Linux. If you are system admin for a school, college or a company you work for then proper file permission setting is among the most vital tasks.

The command used to modify file permissions is chmod, short for change mode of a file. You can also use Nautilus file browser to change the file permissions. I will cover the details after a little background on the file permissions. To find the permission settings for a file, issue the following command int he terminal from the directory where your file is.

ls -l
cmd output

As you can see, the first column in the output has some strange looking character sets. This set is the file permissions for that file (directory). The third column is the owner of the file (directory) and the fourth column is the default group of the file (directory). We can ignore all the other columns at this point.

In the first column, each set would be 10 character wide. The very first character is a d for a directory or just a (hyphen) for files. After that, the next three characters are the permissions for the owners account. The order is read-write-execute. If the superuser can read the file it would display r otherwise just a . Similarly for write and execute w and x would be displayed. The next three characters are permissions for all the other users belonging to the file group (from the fourth column in the output above). Final three characters are the permissions for everyone not part of the group. Superusers (root accounts) can always override all the settings mentioned here and none of the permissions apply to them.

Changing Permissions – The Easy Way

The easiest way, as I said, is to just change the file permissions using Nautilus but it’s time consuming if you want to change the permissions of a lot of files. Command line way may seem tedious to begin with but it’s the faster way once you know your way around. To change the permissions in Nautilus, right click on any file (directory). Go to properties and then to permissions. Change the permissions and click ok. That’s it.

File Permissions

Changing Permissions – The Faster Way

To change file permissions via the terminal, you can use the chmod command. To change permissions of a file, enter the following command in the terminal.

chmod ABC path/to/file

Here, ABC is a 3 digit number which is the decimal representation of the file permissions. For example, r-x means 101 in binary which translates to 5 in decimal. So, if you want everyone to have just read and execute access to files and only the owner has the write access to files then the permissions are rwx,r-x,r-x which is 111,101,101. That translates to 7,5,5 (comma is only given for clarity here). So, the command would now be,

chmod 755 path/to/file

Don’t worry if you don’t know how binary works, you will get used to it. Easiest way is add 4 for read, 2 for write and 1 for execute. So, considering the examples above, rwx = 4 + 2 + 1 = 7 and r-x = 4 + 0 + 1 = 5. You’ll get used to this. There is another way to to this, the text method (which I don’t prefer).

chmod who=permissions filename

Where Who is any from a range of letters, and each signifies who you are going to give the permission to. They are as follows:

u – The user that own the file.
g – The group the file belongs to.
o – The other users i.e. everyone else.
a – all of the above – use this instead of having to type ugo.

And then you can directly write rwx in front of the equal sign. For example,

chmod g=rx

Next post will cover setting default permissions to files you create using umasks.

Category: Linux | Comments Off on File Permissions in Ubuntu