Categories
Linux

How to See Hidden Files on Linux, Mac and Unix

Files and directory names starting with a dot are treated as hidden files on operating systems derived from Unix. That means you won’t normally see these dot files in Mac OS X, Linux, FreeBSD or enterprise Unix.

Linux includes Ubuntu, Red Hat, CentOS, SuSE, Debian, Fedora & Mandriva. Unix includes Enterprise Unix like AIX, HP/UX and Solaris.

Hidden files are typically used for configuration or program history. For example:

  • .bash_history contains a Unix user’s shell configuration.
    (A Unix shell is used to enter text commands.)
  • .ssh is a directory holding configuration files for SSH.
  • .bash_history keeps the history of shell commands entered.
  • .htaccess is used to override a folder’s Apache configuration.

Files are typically hidden so they don’t distract from the files people usually work with, such as documents, movies or music.

To list hidden files in a terminal session, add the -a option to the ls (list files) command. Here you can see the difference from a normal ls:

Tazs-MacBook-Air:~ taz$ cd /Users/taz

Tazs-MacBook-Air:~ taz$ ls
Backups		Movies
Desktop		Music
Documents	Pictures
Downloads	Public
Library		Sites

Tazs-MacBook-Air:~ taz$ ls -a
.
..
.CFUserTextEncoding
.DS_Store
.Trash
.Xauthority
.bash_history
.cups
.fontconfig
.lesshst
.mysql_history
.ssh
.viminfo
Backups
Desktop
Documents
Downloads
Library
Movies
Music
Pictures
Public
Sites

The cd command means change directory to.

There are two special files in this listing. The single dot file “.” is the current directory. The double dot file “..” is the parent directory. To see how this works:

Tazs-MacBook-Air:~ taz$ pwd
/Users/taz

Tazs-MacBook-Air:~ taz$ cd ..

Tazs-MacBook-Air:Users taz$ pwd
/Users

The pwd command means print working directory.

I’ve tested the commands above for working with hidden files on Mac OS X 10.7 Lion, Mac OS X 10.6 Snow Leopard (10.6.7, 10.6.8), Ubuntu Server 7.04, Ubuntu Server 10.10 LTS, Ubuntu Desktop 10.04, CentOS 5.1, 5.3 & 5.4, Red Hat Enterprise Linux 5.6, as well as ancient HP/UX, AIX and Solaris versions. They should work on nearly every Unix-based system.

Hackers sometimes hide files using dot files.

Nearly all file transfer programs provide an option to show hidden files. Dot files like .htaccess are essential for some websites to work. Dot files can be a security risk. Many file transfer programs show files starting with a dot by default.

If you have more questions about hidden files, please post a comment below.

Categories
Linux

What’s the Best Linux Distro according to Google?

What’s the best Linux distribution? Here are the top Linux distros according to global search volumes in Google.

Best Linux Distro by Number of Google Searches

One way to find the most popular Linux version is to look at the number of Google searches.

Here’s the most popular Linux distributions by number of general searches:

[table id=1]

(Source: Google Keyword Tool, last updated 3 August 2010)

These search volumes can be interpreted as the level of interest and activity for a particular Linux distro. You could argue a Linux distro gets more searches because it has more problems!

It’s mostly the usual suspects at the top of the table: Ubuntu, Debian, Fedora, Red Hat, Suse, CentOS, Gentoo, Mandriva (formerly Mandrake) & Knoppix. The KDE version of Ubuntu, Kubuntu, pops into the top ten with the same number of searches as Mandriva. Linux Mint, a distro derived from Ubuntu, focussing on usability, is ranked twelfth.

Ubuntu is the gorilla in the room, with 56% of searches. Wow. I knew Ubuntu was popular, but I had no idea that it is seven times more popular than any other distro.

A surprise for me was to find gOS, a Linux version I hasn’t heard of, in the top ten. gOS or Good OS is an Ubuntu derivative focussed on web-based applications (like Google Docs). It looks like the gOS distribution hasn’t been updated since 3 January 2009. For an eighteen month old distro to have this much popularity, gOS must have something special. The screen shots look really good, showing a sexy interface, that’s at once Mac-like, but also unique.

Notes on General Search Volumes

Note 1: These search numbers are from the Google Keyword Tool for phrase matches, which means any search containing the keyword is included in the search volume. For example, the searches “ubuntu”, “install ubuntu”, “ubuntu iso”, “download ubuntu” would all be included in the search volume numbers for Ubuntu above.

Note 2: These two major Suse distros, openSUSE (open source) and Suse Linux Enterprise (commercial), can’t be meaningfully separated at the level of searches. Their search numbers are combined above.

Note 3: Puppy Linux, Arch Linux and other Linux distros where I’ve added “linux” to their keywords may be disadvantaged in the measure. Since they don’t have a unique brand name, I’ve had to add “linux” on the end. (C’mon, I can’t count all the searches for “puppy” towards Puppy Linux!)

Popular Linux Distros By Number of Download Searches

The number of general searches for a Linux distro names indicates the current popularity of a distro. The search volumes above include queries like “update mysql on centos”. What the numbers of general searches doesn’t show, is what distros people are searching to install.

For that reason, I’ve compiled most popular Linux distributions by number of download searches:

[table id=2]

(Source: Google Keyword Tool, last updated 3 August 2010)

These search volumes can be interpreted as what versions of Linux people are actually installing.

There are some big differences in the number of download searches compared to the number of general searches. Fedora and Red Hat take positions two and three for download searches, ahead of Debian. Gentoo, popular in general searches, falls to position 14 for download searches. Downloading gOS seems less popular than just searching about it, with gOS ranking 17th in download searches, while being 10th for general searches.

Just because an operating system is a popular download, it doesn’t mean it’s actually getting used a lot. It’s more than common for Linux distros to just be downloaded for people to take a look.

Puppy Linux (from general search rank 15 to download rank 8), Arch Linux (from rank 16 to 14), Sabayon (from rank 28 to 18) and Linux Mint (from rank 12 to 10) are disadvantaged in the general search numbers due to the lack of a unique brand keyword.

Notes of Linux Download Search Volumes

Note 1: These search numbers are from the Google Keyword Tool for phrase matches, so, for example, searches for “download ubuntu” and “download ubuntu 8.04” “download ubuntu hardy heron” will be counted towards the searches for “download ubuntu”. Other download phrases that don’t include the words “download ubuntu” in that order are not included, e.g. “ubuntu download” or “get ubuntu”. These search volumes for these keywords could have been included, but these numbers are meant as an indicator of popularity only.

Note 2: Linux variants that were disadvantaged in the general search numbers above by having “linux” appended to their name (e.g. “puppy linux” instead of “puppy”) are probably more fairly represented in table of download search volumes. While we needed the phrase “puppy linux” for general searches, the phrase “download puppy” is probably specific enough, rather than needing “download puppy linux”. (Or perhaps there are children out there right now, hoping to download a puppy…)

What Version of Linux does Google use?

Almost half of Google’s employee use Google’s custom version of Ubuntu, called Goobuntu. Note that Goobuntu is not available outside Google.

So there’s a big vote for Ubuntu.

I don’t know if Goobuntu is also used on Google’s servers. Mark Shuttleworth suggests Google probably uses a variety of Linux variants.

Best Linux Desktop Distro

There is no best Linux desktop distro. The distros are different. They suit different people.

For example, some distros are simple, using the maxim “just one application for each job”, while other distros are feature rich. There are distros that focus on work well out of the box, providing accelerated graphics drivers, Flash and common video formats at install time, while other distros focus on power users or using only pure open source. Some distros provide powerful graphical environments like Gnome or KDE, while others use a lightweight graphical environment like Xcfe, or a bleeding edge graphical environment like Enlightenment.

With the intelligence and passion that has gone into Linux’s software engineering, there are many excellent Linux desktop distros. You’re probably best off trying a LiveCD, USB key or VM version to see which one works best for you.

If you’re looking for a good starting point, go for Ubuntu.

Best Linux Distro on a USB Key

My suspicion is that Puppy Linux would take the crown on this one. Why? It’s small. It’s very fast – it runs entirely from the computer’s RAM. It’s compatible with Ubuntu packages, so there’s access so an incredibly large software base.

If you are using your USB key Linux for specific tasks, such as system recovery or disk partitioning, you might select another more specific distro, like SystemRescueCd or Parted Magic.

Best Linux Server Distro

Are you looking for the best Linux server distro to run your web server or database on?

The requirements for a Linux server are quite different to a Linux desktop. Reliability, scaleability & security are more important for a server, as a server is shared by many users. Slow service, no service or being hacked has a bigger impact on a server.

Here I would tend to steer towards the Linux distros which have existing massive deployments, as their widespread use will tend to have flushed out most scaleability, reliability & security issues. Widespread deployment also typically means there is a wider community for support.

The Linux distros with massive server deployments are CentOS, Debian, Red Hat, Ubuntu, Fedora, Suse, Gentoo, Mandriva, and for Japan, Turbolinux. All of these Linux variants are probably are good choice for production use.

Here is each distribution’s marketshare of webservers, as measured by w3techs.com:

[table id=3]

(Source: Historical trends in the usage of Linux versions for websites,
last updated 3 August 2010)

If you look at the stats or graph on the source webpage, you’ll see the proportion of webservers using CentOS & Ubuntu is climbing, and for all other major Linux variants, it’s falling. It’s worth noting that the use of the Linux variants whose proportion is falling is probably still increasing, as the number of webservers in the world is increasing.

There is also a decision to be made between commercial offerings and free software. The commercial offerings have paid support, which could be invaluable if there are problems. Note I have seen several posters on the web, running both small and large Red Hat deployments, saying their experience of Red Hat’s support has not been good.

If you are running Oracle, consider running Oracle Enterprise Linux, which is based on RHEL. Oracle have been enhancing Linux for their database for many years now.

CentOS

CentOS is a free clone of Red Hat Enterprise Linux (RHEL), built from Red Hat’s source code. You can take almost everything good I say about CentOS and apply it to RHEL. Red Hat has a reputation from being conservative with the features it puts into RHEL, so it is stable and well tested. Apparently Red Hat puts the more bleeding edge features into Fedora first.

Personal Experience of CentOS, Debian & Ubuntu for Server Use

I’ve got a fair bit of driving time on CentOS for production web & database servers. At first I found CentOS very primitive, with fairly low-brow terminal defaults (e.g. no use of color). Over time, I come to appreciate the strength and scaleability of CentOS. It works very well with 16GB of memory and 16 cores.

I’ve found CentOS to be rock solid. I have never had a server crash for the four thousand websites we’ve had running on it. Despite having some very large MySQL and PostgreSQL databases, I have had one only data corruption in 2008. This was in a forty five million row MyISAM table, and the issue could have been MySQL code or the disk controller hardware rather than CentOS.

Adding software in CentOS, for example PHP extensions, to CentOS has been a snap. Everything has been a single line install, and has worked first time.

If had a production Debian server for awhile. I found Debian’s directory layout and terminal defaults helped me be more effective. As well as web and database duties, the server also served HD broadcast-quality video downloads. Debian performed flawlessly, though the server was never seriously loaded. We did have small issues with the default PHP extensions (e.g. the gd graphics library, which needed to be recompiled for our purposes).

I’ve only used Ubuntu as a server in a development VM. It worked perfectly, operating very similarly to Debian. (Ubuntu is in fact based on Debian.)

Best Linux Server Distro Conclusions

Any of the Linux distributions in massive deployment should work well for you.

If I personally had a large, mission critical system I would use RHEL or it’s free clone CentOS. Half of the world’s webservers are running Red Hat or CentOS, and I know from experience they are reliable & scaleable. If I had a non-critical system, I would love to try out Ubuntu to see if it works as well as a server as it does for desktop.

Can I Use the Desktop Version of a Distro as a Server?

Many distros have a server version and a desktop version. You can use the desktop version as a server – Apache and MySQL are usually only a few clicks or commands away from being installed & activated. Using the desktop version of a Linux distro is fine for development.

For production servers, always use the server version of a distro. The server versions configured & tuned for server tasks. For example, there are several disk IO schedulers for Linux. The default disk IO scheduler for the desktop version of a distro might perform badly for a database server.

Should I Use the 32-bit or 64-bit Version of my Distro?

Linux Server distros usually come in a 32-bit or 64-bit version. Which should you use?

32-bit is used by the majority of servers out there, and hence has had most issues fixed. The downside is you’re limited to 4GB of RAM.

We used to have frequent issues with 64-bit. The kernel was fine, but the 64-bit versions of the software frequently had bugs or interoperability issues. 64-bit is now common enough that most of the issues have been worked out, and I haven’t had and 64-bit issues for the last year.

64-bit software is usually a bit faster and uses more RAM.

We have frequently had circumstances where we wanted to add RAM to a server to increase capacity, e.g. for the Linux file cache, memcached, database cache or full text search cache, but the server was running a 32-bit distro and RAM was already at the 4GB limit. I recommend to run the 64-bit version of your distro, so you have the flexibility to add over 4GB of RAM to your servers. You might even get a bit of a performance boost!

Conclusions for Choosing Your Linux Distro

The short answer is for many people, the best linux distro for servers is CentOS, and the best Linux distro for desktops is Ubuntu.

Comments, corrections, feedback and “you forgot this obvious important Linux distro” messages welcome!

Categories
Linux

How to Find a Yum Package

Yum (Yellowdog Updater Modified) is a utility for finding, installing, updating and removing software on Linux. It runs on rpm-compatible Linux distributions, e.g. RedHat, Fedora, SUSE, CentOS, Mandriva.

Get the Yum Package Name by Just Using the Software’s Name

When you want to install some software, sometimes you’re lucky and can use the software’s name. For example, installing the GNU screen terminal utility is as simple as:

sudo yum install screen

Guessing the package name doesn’t always work. For example, try installing vim (an improved vi text editor with syntax highlighting) with just the package name vim:

[root@sayonara ~]# yum install vim
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * rpmforge: ftp-stud.fht-esslingen.de
 * base: centos.aol.com
 * updates: mirror.nexcess.net
 * addons: centos.aol.com
 * extras: centos.mirror.seiri.com
Setting up Install Process
Parsing package install arguments
No package vim available.
Nothing to do

In this case yum reports: No package vim available.

Similarly, trying to install the MySQL database with just mysql as the package name, will probably result in the same error No package mysql available:

sudo yum install mysql

Are vim and MySQL really not available for installation with yum?

Find a Yum Package Using Yum Search

The following yum command searches for different pacakages mentioning vim:

[root@sayonara ~]# yum search vim
Loaded plugins: fastestmirror, priorities
Loading mirror speeds from cached hostfile
* rpmforge: ftp-stud.fht-esslingen.de
================================================================================= Matched: vim =================================================================================
vim-X11.i386 : The VIM version of the vi editor for the X Window System.
vim-common.i386 : The common files needed by any version of the VIM editor.
vim-enhanced.i386 : A version of the VIM editor which includes recent enhancements.
vim-minimal.i386 : A minimal version of the VIM editor.

Then just pick the package you want to install, for example:

sudo yum install vim-minimal.i386

Another example is looking for the package to install MySQL:

[root@sayonara ~]# yum search mysql
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * rpmforge: ftp-stud.fht-esslingen.de
 * base: mirror.rackspace.com
 * updates: mirror.cs.vt.edu
 * addons: yum.singlehop.com
 * extras: mirror.cs.vt.edu
=================================================================== Matched: mysql ====================================================================
mod_auth_mysql.i386 : Basic authentication for the Apache web server using a MySQL database.
qt-MySQL.i386 : MySQL drivers for Qt's SQL classes.
MySQL-python.i386 : An interface to MySQL
aimsniff.i386 : Monitor and archive AOL Instant Messenger messages
apr-util-mysql.i386 : APR utility library MySQL DBD driver
bytefx-data-mysql.i386 : Database connectivity for Mono
cacti.noarch : Complete network graphing solution designed on top of RRDTool
cacti-docs.noarch : Documentation for the cacti network graphing solution
freeradius-mysql.i386 : MySQL bindings for freeradius
freeradius2-mysql.i386 : MySQL support for freeradius
gtksql.i386 : Graphical database query tool for MySQL and PostgreSQL
krecipes.i386 : Recipe manager
libdbi-dbd-mysql.i386 : MySQL plugin for libdbi
lighttpd-mod_mysql_vhost.i386 : Virtual host module for lighttpd that uses a MySQL database
motion.i386 : Video-surveilance system
mtop.noarch : Tool to monitor a MySQL database
mysql.i386 : MySQL client programs and shared libraries.
mysql-bench.i386 : MySQL benchmark scripts and data
mysql-connector-odbc.i386 : ODBC driver for MySQL
mysql-devel.i386 : Files for development of MySQL applications
mysql-server.i386 : The MySQL server and related files.
mysql-test.i386 : The test suite distributed with MySQL
mytop.noarch : Top clone for MySQL
nagios-plugins.i386 : Host/service/network monitoring program plugins for Nagios
ndoutils.i386 : Nagios plugin to store Nagios data in a relational database
pdns-backend-mysql.i386 : MySQL backend for pdns
perl-Acme-BeyondPerl-ToSQL.noarch : Perl module to have RDBMS calculate instead of Perl
perl-Class-DBI-mysql.noarch : Perl module that extends Class::DBI for MySQL
perl-DBD-MySQL.i386 : A MySQL interface for perl
perl-DBD-SQLite.i386 : Small fast embedded SQL database engine
perl-DBD-mysql.i386 : Perl module that implements a MySQL driver for DBI
perl-DBIx-TableHash.noarch : Tie a hash to a mysql table + SQL utils
perl-DBIx-TextIndex.i386 : full-text searching in SQL databases
perl-DNS-BL.noarch : Manage DNS black lists
perl-DateTime-Format-MySQL.noarch : Perl module to parse and format MySQL dates and times
perl-MySQL-Config.noarch : Perl module to parse and utilize MySQL's /etc/my.cnf and ~/.my.cnf files
perl-Qmail-Mysql.noarch : Perl module for mysql database used by qmail-mysql
perl-Time-Piece-MySQL.noarch : Perl module adds MySQL-specific methods to Time::Piece
php-adodb.noarch : Portable Database Library for PHP
php-mysql.i386 : A module for PHP applications that use MySQL databases.
php-pdo.i386 : A database access abstraction module for PHP applications
php-pear-MDB2-Driver-mysql.noarch : MySQL MDB2 driver
php-pecl-session_mysql.i386 : PECL package to save sessions to a MySQL database
phpmyadmin.noarch : Web application to manage MySQL
proftpd-mysql.i386 : Module to add MySQL support to the ProFTPD FTP server
pure-ftpd.i386 : Lightweight, fast and secure FTP server
python-sqlalchemy.noarch : SQL toolkit and object relational mapper for Python
qt4-mysql.i386 : MySQL drivers for Qt's SQL classes
rsyslog.i386 : Enhanced system logging and kernel message trapping daemons
rsyslog-mysql.i386 : MySQL support for rsyslog
sphinx.i386 : Free open-source SQL full-text search engine
synbak.noarch : Universal backup system
sysbench.i386 : System performance benchmark
unixODBC.i386 : A complete ODBC driver manager for Linux.

Looking over the available packages, the package for installing the MySQL database would be mysql-server.i386.

More information is available at the yum homepage.

Categories
CentOS

Install the PHP DOM Extension on CentOS – the Easiest Way

Here we cover the fastest, most effective way to get the PHP DOM extension installed on CentOS. If you’ve just found out you need to install this extension, but don’t really know what it is, we’ve included some background first.

What is DOM?

“The Document Object Model (DOM) is a cross-platform and language-independent convention for representing and interacting with objects in HTMLXHTML and XML documents.” (Source: DOM in Wikipedia.)

What is PHP DOM extension?

“The DOM extension allows you to operate on XML documents through the DOM API with PHP 5.” (Source: Introduction to the PHP DOM Extension on php.net.)

How to install the PHP DOM Extension on CentOS

You will need superuser privileges. Run the following command:

sudo yum install php-xml

Don’t forget to restart Apache so PHP picks up the new extension:

sudo service httpd restart

How to Check PHP DOM is Installed

You can see PHP DOM is installed by creating a simple web page that calls the phpinfo() function:

<?php phpinfo(); ?>

When you go to this webpage in a browser, you should see this output for the dom extension if it’s installed:

dom

DOM/XML enabled
DOM/XML API Version 20031129
libxml Version 2.6.26
HTML Support enabled
XPath Support enabled
XPointer Support enabled
Schema Support enabled
RelaxNG Support enabled

Tested on CentOS 5.3.

Categories
CentOS

How to Install Vim on CentOS

To install vim, run the following command from a CentOS shell:

sudo yum install vim-enhanced.i386

Tested on CentOS 5.3 (32 bit).

How to Find the Yum Package for Vim

To find the command, run:

yum search vim

The gives you the different packages mentioning vim:

Loaded plugins: fastestmirror, priorities
Loading mirror speeds from cached hostfile
* rpmforge: ftp-stud.fht-esslingen.de
================================================================================= Matched: vim =================================================================================
vim-X11.i386 : The VIM version of the vi editor for the X Window System.
vim-common.i386 : The common files needed by any version of the VIM editor.
vim-enhanced.i386 : A version of the VIM editor which includes recent enhancements.
vim-minimal.i386 : A minimal version of the VIM editor.
Categories
CentOS

How to Find Your CentOS Version

Someone’s given you a CentOS server to do some work on, perhaps putting up a website. “What version of CentOS is it running?”, you ask. “I don’t know” is a pretty common answer, or “version 5, I think”.

The CentOS version tends to indicate the rough age of the software (e.g. Linux kernel, PHP, MySQL) you’ll be using.

Here’s how you can check the CentOS version directly.

Find the CentOS Version

If you want to know what version of CentOS its running.

To check, cat the /etc/issue file:

[root@bijango ~]# cat /etc/issue
CentOS release 5.3 (Final)
Kernel \r on an \m

Note the contents of /etc/issue is displayed when someone creates a terminal session on the server,
so the system administrator may have edited this file to put in a different message, and potentially deleted the CentOS version information.

This was of checking the Linux distro version was tested on CentOS 5.2, CentOS 5.3, Ubuntu 8.10 and Ubuntu 10.10.

This way of checking the OS version would probably work on Red Hat Enterprise Linux and Debian as well. This is because CentOS is a clone of Red Hat, and Ubuntu is derived from Ubuntu.

Categories
Apache

Httpd.conf’s Location on CentOS, Ubuntu, Red Hat, Mac and Others

Here’s where to find the Apache 2 web server configuration file httpd.conf The httpd.conf directory differs across Linux & Unix variants like CentOS, Mac OS X, Red Hat, Ubuntu and XAMPP Mac.

This table lists the httpd.conf location for each operating system:

Operating System / Linux Distro httpd.conf Location
CentOS 5.2 /etc/httpd/conf/httpd.conf
CentOS 5.3 /etc/httpd/conf/httpd.conf
Mac OSX 10.6 Snow Leopard /etc/apache2/httpd.conf
Mac OSX 10.7 Lion /etc/apache2/httpd.conf
Red Hat Enterprise Linux Server 5.6 Tikanga (RHEL) /etc/httpd/conf/httpd.conf
Ubuntu 7.04 Feisty Fawn /etc/apache2/httpd.conf
Ubuntu 8.10 Intrepid Ibex /etc/apache2/httpd.conf
Ubuntu 10.10 Maverick Meerkat /etc/apache2/httpd.conf
XAMPP on Mac /Applications/XAMPP/etc/httpd.conf

For more specific information on Ubuntu, see httpd.conf location on Ubuntu.

The location for Fedora will likely be the same as CentOS (same distro family).

The location for Debian will likely be the same as Ubuntu (same distro family).

If your operating system or Apache package isn’t mentioned here, you can use the find command on Linux, Unix or Mac to find httpd.conf, e.g.:

find / -name httpd.conf 2>/dev/null

On Windows, you can use the search facility of Windows Explorer to find httpd.conf.

Additions & refinements welcome!