Archive

Archive for the ‘Linux Tricks’ Category

stropts.h: No such file or directory – How to Fix

January 30th, 2010 No comments

It is a known issue that modern Linux systems are missing stropts.h file. You will probably have some problems when trying to compile software like pppd, pptp, gftp, etc from sources. Seems to be a strange thing, as you won’t get any errors in previous versions of Linux. Most recent versions of don’t contain this file, that’s why we need to know what to do if software compilation fails because of missing stropts.h.

Let’s determine when we need to have this file on our machine.When we’re compiling any “old” package from sources, we may receive the following error:

error: : No such file or directory

What could be the reason and why isn’t this file included into our Linux distribution?This error means that your system doesn’t support STREAMS.

Linux doesn’t support STREAMS (many years ago it was available as a third party module, but it hasn’t worked for years). stropts.h is part of a POSIX XSR option, which is not supported in modern Linux distributions. Do we really need it in Linux?

This means that software you’re trying to compile, will not use the functions listed under stropts.h as they’re not supported by the operating system. So we will do a simple trick that will let you to compile your software without these functions.

Since the stropts.h is required for a successful compilation, the most simple way to solve the issue is to create a blank file named stropts.h under /usr/include. You may want to put any comments there, this way you won’t forget what was the reason to create this file.

This simple trick will help you to compile pptp (1.7.2),  pppd (2.4.5), and I think that the list will be much bigger. That was just my experience, but the sense remains the same: you need this file for a successful compilation. Just create it and have fun! :)

Setting Up NTP Time Synchronization in CentOS

January 29th, 2010 2 comments

If you need to have valid date and time on your server, you need to synchronize it with a time server as well. In order to do this in Linux (especially in CentOS),  we will follow my short howto.

1. Ensure you’ve got ntp installed. Run rpm -qa | grep ntp to find out if it already exists on your system and yum install ntp if it is not present.

2. Run ntpdate. On CentOS, you will probably get this error:

[root@server ~]# ntpdate
29 Jan 09:52:54 ntpdate[8463]: no servers can be used, exiting

This means you have to include a server into your request, just like shown below.

[root@server ~]# ntpdate 0.pool.ntp.org
29 Jan 10:08:07 ntpdate[8853]: step time server 213.198.55.2 offset 676.605025 sec

This means my server had a 10-minute time diffrence with the time server. After this command my time has been adjusted.

3. Add time synchronization to your crontab and run it as often as you need.

30 * * * * /usr/sbin/ntpdate -s 0.pool.ntp.org

Will sync your clock every hour; I think is enough to perform synchronization weekly.  Let’s do it.

30 10 5 * * /usr/sbin/ntpdate -s 0.pool.ntp.org

This simple guide will keep your clock synchronized. Have fun!

Sendmail and local-host-names file: Troubleshooting

January 27th, 2010 No comments

I will not post the whole process of sendmail configuration here, just would like to pay attention to a small detail.

/etc/mail/local-host-names is a text file, that contains the list of domain names and it is taken by sendmail when checking outgoing mail. You should make sure you have this file in the following format:

# local-host-names sample file
lampdocs.com
test.lampdocs.com
# end of file

Please, note, that you should leave the comment on the last line as it is ignored by sendmail. Your local-host-names should have the last line either blank, either commented. Hope this saves someone some time, as this feature is not so well documented and you might have problems with the last domain in the list.

updatedb: command not found – How to Fix

September 16th, 2009 No comments

This problem appears usually if you have a new server and there are no packages installed yet. If you need to use locate command for any reasons, you should run updatedb periodically in order to ensure you have the most recent cache of your file positions.

if you receive command not found error, it usually means you have no slocate package installed. On most modern linuxes you can install it using your package manager (yum, apt-get, etc). You are also welcome to compile it from source, that can be found at http://slocate.trakker.ca/ . I don’t think you should have problems with this package; you will then be able to run updatedb and locate.

It is not recommended to run updatedb if you have lots of files on your machine. In this case updatedb execution can slow down your server. But if the number of files is not so high, locate is probably the fastest way to find the files you need.

Categories: Linux Tricks Tags: