Archive

Archive for the ‘System Administration’ Category

Installing Git on Ubuntu 10.04 Lucid Lynx (Should Work for 10.10 Maverick Meerkat, too)

September 27, 2010 5 comments

In my current job one of the most frequent things I do is to setup/install git for the developers which is very much essential tool for them as per our organization’s development architecture. Previously we built a customized deb package and added that to our local debian and ubuntu repository and the “apt-get install -t local git” used to work for us (the Sys. Admins here). But with the updated versions and increased workload on other sectors somehow that process is now obsolete for us. So now we’ve gone back to that sweet old “build from source file” approach. Here’s how I do that stuff for git 1.7.3 🙂

Step 1. Resolve The Dependencies:

$ sudo apt-get install curl libcurl4-openssl-dev libexpat1-dev gettext zlib1g-dev

Step 2. Download, untar and build:

$ wget http://kernel.org/pub/software/scm/git/git-1.7.3.tar.gz

$ tar -zxvf git-1.7.3.tar.gz

$ cd git-1.7.3

$ ./configure –prefix=/usr/local/git

$ make

$ sudo make install

Step 3. Check & Confirm Installation:

$ /usr/local/git/bin/git –version

** Errors You May Find During Installation:

Error Type 1:

* tclsh failed; using unoptimized loading
MSGFMT    po/de.msg make[1]: *** [po/de.msg] Error 127
make: *** [all] Error 2

Solution:

$ sudo apt-get install gettext

Error Type 2:

CC fast-import.o
In file included from builtin.h:6,
from fast-import.c:147:
cache.h:17:18: error: zlib.h: No such file or directory
In file included from builtin.h:6,
from fast-import.c:147:
cache.h:22: error: expected ‘)’ before ‘strm’
cache.h:23: error: expected ‘)’ before ‘strm’
cache.h:24: error: expected ‘)’ before ‘strm’
fast-import.c:285: error: ‘Z_DEFAULT_COMPRESSION’ undeclared here (not in a function)
fast-import.c: In function ‘store_object’:
fast-import.c:996: error: ‘z_stream’ undeclared (first use in this function)
fast-import.c:996: error: (Each undeclared identifier is reported only once
fast-import.c:996: error: for each function it appears in.)
fast-import.c:996: error: expected ‘;’ before ‘s’
fast-import.c:1028: error: ‘s’ undeclared (first use in this function)
fast-import.c:1039: error: ‘Z_FINISH’ undeclared (first use in this function)
fast-import.c:1039: error: ‘Z_OK’ undeclared (first use in this function)
fast-import.c: In function ‘stream_blob’:
fast-import.c:1142: error: ‘z_stream’ undeclared (first use in this function)
fast-import.c:1142: error: expected ‘;’ before ‘s’
fast-import.c:1143: error: ‘Z_OK’ undeclared (first use in this function)
fast-import.c:1165: error: ‘s’ undeclared (first use in this function)
fast-import.c:1175: error: ‘Z_STREAM_END’ undeclared (first use in this function)
fast-import.c:1188: error: ‘Z_FINISH’ undeclared (first use in this function)
fast-import.c:1200: error: ‘Z_BUF_ERROR’ undeclared (first use in this function)
fast-import.c: In function ‘git_pack_config’:
fast-import.c:2846: error: ‘Z_BEST_COMPRESSION’ undeclared (first use in this function)
make: *** [fast-import.o] Error 1

CC fast-import.oIn file included from builtin.h:6,from fast-import.c:147:cache.h:17:18: error: zlib.h: No such file or directoryIn file included from builtin.h:6,from fast-import.c:147:cache.h:22: error: expected ‘)’ before ‘strm’cache.h:23: error: expected ‘)’ before ‘strm’cache.h:24: error: expected ‘)’ before ‘strm’fast-import.c:285: error: ‘Z_DEFAULT_COMPRESSION’ undeclared here (not in a function)fast-import.c: In function ‘store_object’:fast-import.c:996: error: ‘z_stream’ undeclared (first use in this function)fast-import.c:996: error: (Each undeclared identifier is reported only oncefast-import.c:996: error: for each function it appears in.)fast-import.c:996: error: expected ‘;’ before ‘s’fast-import.c:1028: error: ‘s’ undeclared (first use in this function)fast-import.c:1039: error: ‘Z_FINISH’ undeclared (first use in this function)fast-import.c:1039: error: ‘Z_OK’ undeclared (first use in this function)fast-import.c: In function ‘stream_blob’:fast-import.c:1142: error: ‘z_stream’ undeclared (first use in this function)fast-import.c:1142: error: expected ‘;’ before ‘s’fast-import.c:1143: error: ‘Z_OK’ undeclared (first use in this function)fast-import.c:1165: error: ‘s’ undeclared (first use in this function)fast-import.c:1175: error: ‘Z_STREAM_END’ undeclared (first use in this function)fast-import.c:1188: error: ‘Z_FINISH’ undeclared (first use in this function)fast-import.c:1200: error: ‘Z_BUF_ERROR’ undeclared (first use in this function)fast-import.c: In function ‘git_pack_config’:fast-import.c:2846: error: ‘Z_BEST_COMPRESSION’ undeclared (first use in this function)make: *** [fast-import.o] Error 1

 

Solution:

$ sudo apt-get install zlib1g-dev

Now that should do for your Git installation 🙂


Catch-all

August 19, 2009 Leave a comment

A Catch-all for email, usually refers to a mailbox on a domain that will “catch all” of the emails addressed to the domain that do not exist in the mail server. Configuring a catch-all address can help avoid losing emails due to misspelling.

For example: if jamee@jaamee.com is configured to be the catch-all email address on jaamee.com, then any email sent to an undefined@jaamee.com email address will be forwarded to jamee@jaamee.com instead of being rejected as an Undeliverable message or Unknown User error.

You can only set one catch-all email address per domain. So it’s better to set the Administrator email address as the catch-all.

SSH SOCKS Proxy tunnel for secure web browsing

August 16, 2009 Leave a comment

When you are at the coffee shop, or at a conference, and you are not sure that you want to send all your data over the wi-fi network in plaintext, you want a secure tunnel to browse. You can use the “-D” flag of openssh to create a SOCKS proxy.

SSH SOCKS proxy is one of the way to have a secure tunnel for web browsing. It’s comes handy when we need to do secure browsing in a public network such as in a public WiFi environment, as the traffic between our host and the proxy is encrypted .

For this to work, we need to have an SSH server somewhere that we want to tunnel our traffic to, and an SSH client at our host.

Creating an SSH SOCKS tunnel is as simple as running the following command;

$ ssh -D any-port-no-above-1024 user@proxy-address

e.g: $ ssh -D 8080 jamee@jaamee.com

This proxy address will be the SSH server address or ip.

The command assumes we have a user account with the username jamee at the server with the address jaamee.com, and 8080 is our local port to be used for the tunnel.

The next step is to configure our web browser to use the tunnel. Now all you have to do is set the preference in Firefox to use a SOCKS proxy. The proxy is, of course, “localhost”, with the port 8080. To do it in Firefox on Linux, choose Edit in the menu and click on Preferences (or Tools->Options in Windows). Then choose Advanced tab and click on the Network tab. Click the Settings button next to the Configure how Firefox connects to the internet text, and fill up the SOCKS proxy information as the following;

socks-mini

That’s just it, and from this point forward Firefox will tunnel all the browsing traffic through our SOCKS proxy, and the end server will see our traffic coming from our SOCKS proxy server. This can also be considered as a VPN as servers in our proxy server’s network can be accessed with their internal adresses.

lmhosts File

August 3, 2009 Leave a comment

A local hosts file used by Microsoft Wins Clients such as Microsoft Windows 98 or Windows NT to provide mappings of IP addresses to NT computer names (NetBIOS name). The lmhosts file is located in either the root Windows directory, the Windows\System32\drivers\etc directory, or Winnt\System32\drivers\etc depending on the version of Windows and is called “lmhost.sam“. The lmhosts file will likely already contain data in the file, such as commented instructions and examples similar to the below example.

127.0.0.1          localhost    #example of the local host

123.0.123.7      example    #example of a fake IP and name.

In the above two examples, you can see that we have specified the IP address, the name, and the # remark for that line. In the above example, “localhost” or “example” would be the NetBIOS name; therefore, when typing “localhost” or “example” in Internet Explorer, for example, the computer would attempt to resolve that name by accessing the IP address corresponding with that name.

This file is also commonly modified when unable to access or having difficulties with the DNS server, to help prevent access to a specific domain, and/or redirect the computer to a different location.

How do you edit this file?

  1. Locate and open the file. Because this file can be in different locations its usually easiest to simply open the Windows search and search for “lmhosts.sam” file. Additional information about finding files in Microsoft Windows can be found on document CHFIND.For users who are manually looking to locate the file below is a listing of the version of Windows and the location of the lmhosts file.

    Microsoft Windows 98

    C:\Windows\

    Microsoft Windows 2000

    C:\Winnt\System32\drivers\etc

    Microsoft Windows XP

    C:\Windows\System32\drivers\etc

  2. Once the file has been located right-click the file and select “Open With…” and if prompted select “Select the program from a list” and click Ok.
  3. In the listing of programs used to open the file scroll to the bottom of the list and highlight WordPad and click the Ok button.

Following the above steps should open the lmhosts.sam file in WordPad and allow you to add or remove content from the file.

Viewing Physical & Virtual Memory on Solaris

August 3, 2009 Leave a comment

Often you need to check total Physical and Virtual Memory size on Sun SPARC or X86 Servers running on Solaris OS. Just invoke as the following:

* Physical Memory:

# prtconf -v | grep Mem

*Virtual Memory:

# vmstat

Remember you have to have root privileges in order to issue these commands.

Installing RADIUS Library for PHP

August 3, 2009 Leave a comment

Overview:

This package is based on the libradius of FreeBSD. This PECL adds full support for Radius Authentication (» RFC 2865) and Radius Accounting (» RFC 2866). This package is available for Unix (tested on FreeBSD and Linux) and for Windows.

The libradius library implements the client side of the Remote Authentication Dial In User Service (RADIUS).  RADIUS, defined in RFCs 2865 and 2866, allows clients to perform authentication and accounting by means of network requests to remote servers.

Download Link: http://pecl.php.net/package/radius

Installation:

* At the build time of PHP:

  • untar the package (Usually into php/ext)
  • Rename radius-x.x to radius
  • run ./buildconf in php
  • run ./configure –enable-radius
  • make
  • make install

* To have it as .so:

  • untar the package
  • run phpize in the radius-x.x directory
  • run ./configure in the radius-x.x directory
  • make
  • make install
Categories: Linux, PHP, System Administration, Unix Tags:

Copy Files using SCP without Remote Log In

August 3, 2009 Leave a comment

Sometimes you need to copy a file from or to a remote hosts. We use the scp command not only in a different but efficient way to copy the file from or to the remote hosts not logging into that remote host.

The syntax is as follows-

* Copy from Remote Host:

$ scp username@<remote-host-name/IP>:<remote-host-file-name-with-location> <path-you-want-to-keep-file>

$ scp jamee@10.11.12.13:/home/jamee/jamee.gz /home/shopno

* Copy to Remote Host:

$ scp <file-name-with-location> <remote-host-name/IP>:<remote-host-path-you-want-to-keep-file>

$ scp /home/jamee/jamee.gz jamee@10.11.12.13:/home/shopno/

Just add a ” -r ” before directory name in case of copying a diretory.

Anacron

July 4, 2009 Leave a comment

What is anacron

Anacron is a computer program that performs periodic command scheduling which is traditionally done by cron, but without assuming that the system is running continuously. Thus, it can be used to control the execution of daily, weekly, and monthly jobs (or anything with a period of n days), on systems that don’t run 24 hours a day.

Advantages

Most Unix systems are set up to run “housekeeping chores” such as log-rotation, unused files deletion, indexing local files for the search engine, etc. With cron, often these tasks are scheduled to be executed overnight or another low-usage time to avoid straining the system. If the system is turned off at the time a given task should have been run, it will not be executed for that iteration.

In contrast, Anacron makes sure that these commands are run at the specified intervals as closely as machine uptime permits.

Drawbacks

Only the system administrator can configure anacron tasks. In contrast, cron allows non-admin users to configure scheduled tasks. If necessary, a non-admin user can use the at Unix command to request a scheduled task (which is guaranteed to run). Upon starting, this command can then automatically request to run itself at a future date, thus giving the appearance of a regularly scheduled task, with guaranteed execution.

Anacron can only run tasks once a day (or less often such as weekly or monthly). In contrast, cron allows tasks to run as often as every minute (but does not guarantee their execution if the system goes down). In practice, this is not usually an issue, since it is rare to have a task that must be guaranteed to run more often than (at least) once a day – especially on a system that is not necessarily running at all times.

If the system is rebooted or started after midnight, the daily tasks are run immediately (after a delay, usually 5 minutes), which can consume system resources that are needed by the user, who has just started the machine, and is presumably expecting to do work. In contrast cron will only run daily tasks at the set time in the middle of the night (presumably when the machine is not being used).

Setup Easy Hosting Control Panel (ehcp) for Debian/Ubuntu

November 27, 2008 Leave a comment

ehcp is a new Hosting Control Panel in Linux world. Although it is in beta stage, its basic functions are well functioning. it operates strongly with debian/ubuntu”s apt-get package manager..

it differs from other control panels, or even other opensource panels that, ehcp is the first and only: opensource,full php, object oriented, gpl, free hosting control panel on the earth !

You may use ehcp to easily setup a hosting environment, for yourself or for selling hosting..You may also use it for only ftp hosting..

A clean ubuntu or any debian based linux install. nothing else. Any apt-get enabled linux is enaugh.

to install copy and paste following on your linux console:

wget http://www.ehcp.net/ehcp_latest.tgz

tar -zxvf ehcp_latest.tgz

cd ehcp

./install.sh
#

the installer will ask some questions about your settings, then will automatically install any needed server programs such as apache, mysql and so on..

After installer finishes, navigate to localhost (if you installed on local) or to ip by typing at address bar of your browser.

default login: admin
default pass: 1234

Viewing Physical and Virtual Memory on Solaris

October 27, 2008 Leave a comment

Often you need to check total Physical and Virtual Memory size on Sun SPARC or X86 Servers running on Solaris OS. Just invoke as the following:

  • Physical Memory:

# prtconf -v | grep Mem

  • Virtual Memory:

# vmstat

Remember you have to have root privileges in order to issue these commands.