Showing posts with label ubuntu. Show all posts
Showing posts with label ubuntu. Show all posts

Tuesday, January 3, 2012

How To Set up a repository cache with apt-cacher


By Pallavi Shastry

When running multiple machine with the same distribution, it is sensible to set up a repository cache on your network so that once a package is downloaded from an official repository, all other machines will download it from your local area network.
Having different machines running the same linux distribution, it becomes interesting to set up a repository cache in your local network. This way, you won't download common packages more than 1 time from official repositories.
Here is the situation, we have one machine called repository-cache, this machine is going to act as the repository cache, basically, any other machines in your network is going to use it as a repository.



1. Getting started : Server configuration

As usual, you need to install the required packages in the first place. So type in a terminal:

$sudo apt-get install apt-cacher apache2

To start the service of the apache web server. 
 $sudo /etc/init.d/apache2 start
 
Then test by going to http://repository-cache:3142/apt-cacher to verify that it's running. 
repository-cache in the URL above is the host name or IP of the cache server in the LAN. 

Once this is done, it is time to get into the configuration files in /etc/apt-cacher/apt-cacher.conf

$sudo gedit /etc/apt-cacher/apt-cacher.conf

The default port apt-cacher is running on is port 3142.

Allowed_hosts: by default, all host are allowed to use the repository cache. You can change this value if you want to only allow certain host.

Generate_reports: This directive makes apt-cacher create a report on how efficient your cache was on a daily basis. Default is 1, if you want to disable this, set it to 0.apt-cacher will generate report on the usage of the cache every day.

Clean cache: This directive makes apt-cacher clean the cache every 24 hours . So reset it , clean cache =0


2. Activating apt-cacher to start

In order to start, apt-cacher needs to be activated from /etc/default/apt-cacher. So open /etc/default/apt-cacher and set AUTOSTART to 1:
AUTOSTART=1
Now restart apt-cacher:
$sudo /etc/init.d/apt-cacher restart
Now that apt-cacher runs, it is time to update all our clients /etc/apt/sources.list files so every host on the network will use our repository-cache machine.


3. Importing existing package from /var/cache/apt/archives/ to apt-cacher repository

It might happen that your server already has got a whole lot of packages cached in its local repository: /var/cache/apt/archives/.  
apt-cacher offers a tool to import those files to apt-cacher repository logically without in fact replicating copies of these packages.
There are whole lot of cool and useful scripts that can be found in /usr/share/apt-cacher/
The one we are interested in here is apt-cacher-import.pl which is handy to import deb files from /var/cache/apt/archives to apt-cacher repository run:

$sudo /usr/share/apt-cacher/apt-cacher-import.pl -s /var/cache/apt/archives


5. Setting up the Clients sources.list

Now it is time to set up the client hosts apt source list files: /etc/apt/sources.list
It make sense to use the repository cache on the server too, as that way, any updates made by the server will fill up the cache.

In each line , ie every instance of the sources.list file, if for example there is an entry

deb http://archive.ubuntu.com/ubuntu/ main restricted

becomes

deb http://repository-server:3142/apt-cacher/archive.ubuntu.com/ubuntu/ main restricted

Cool, now, every host should be able to retrieve the .deb packages from our repository cache once has been ran on every host.

$ sudo apt-get update

Then test report by going to http://repository-cache:3142/reports to verify that it's running. The report is generated once a day, but if you need it at a certain time, you can force it by running:

$sudo /usr/share/apt-cacher/apt-cacher-report.pl


6. Conclusion

apt-cacher is an easy and efficient package which will save you both time and bandwidth when using multiple machines with the same distribution like it could happen in a home network or at a company.

Sunday, October 23, 2011

Adding custom menu entries in Debian/Ubuntu

Some of the applications which we install from third party sources are not indexed in the Applications tab in the GNOME shell.

The problem in such a case is the high chances of forgetting what the application name is! And this happens so often with me, that I am forced to create these entries in the Applications menu.

Here's a simple procedure to do this. Although there's System->Preferences->Main Menu to do this, this one is better for some obvious reasons (you can give your custom icons)

  • The Applications Menu entries reside in the directory /usr/share/applications , and to create a new entry create a .desktop file in this directory
cd /usr/share/applications
sudo nano myapp.desktop

  • The .desktop files have just the information needed to put up an entry in the Applications tab, and to run your app; Here is the sample content of the Qtoctave entry from the file qtoctave.desktop
[Desktop Entry]
Version=1.0
Name=QtOctave
Comment=Graphical Qt frontend for GNU Octave
TryExec=qtoctave
Exec=qtoctave
Icon=qtoctave
Type=Application
Categories=Development;Math;Science;Education;Electronics
  • Make these entries into the myapp.desktop file with relevant modifications like your executable file name in the exec field.
  • After modification of the .desktop file, save and close it. Now, the entry should appear in the categories which you mention.
  • To add your application an icon, crop a 32x32 png image and add it into the default icons directory /usr/share/app-install/icons/,
sudo cp myicon.png /usr/share/app-install/icons/ 

In the Icon field of the .desktop file, provide the file name if the icon resides in the aforementioned default directory, or give the full path of the icon

And there you go, your own custom application entry with a custom icon!

Friday, October 14, 2011

Over to Oneiric Ocelot

Ubuntu 11.10 aka Oneiric Ocelot made a silent appearance yesterday in the Operating system arena. Although it has come silently, it does make quite a bit of noise with whatever it has brought along.


After Natty Narhwal and the controversial Unity, Oneiric Ocelot comes somewhat as a pacifier, with improvements on Unity (yes, Unity is here to stay) and official support to Gnome3.


Here are some salient features of Oneiric.
  • Linux kernel 3.0! 
Of all the reviews I had read, no one seemed to have noticed that Ubuntu 11.10 ships with the Linux 3 series kernel. That is certainly worth a mention. Although the Linux3.0 by itself has had no major changes except for the notation and rumors about power regression. Will keep an eye on the battery on my machine.


  • Unity revamped
As all other reviews have been posting, Unity does get a revamp and seems more stable. It responds quickly, no lag whatsoever. And the aesthetics are more pleasing than in Natty. When I am going to get Oneiric as my production OS, I will certainly want to have picked up all the keyboard shortcuts for Unity.
super+s, super+a, super+f and super+m are for now really handy to view the workspaces, browse applications, files and music respectively.

Another important aspect about the feel of Unity is the dash itself. The new dash is gorgeous which acquires a tinge correlating the backdrop of the other windows/the desktop itself.


  • Login screen is sleeker
Another small but pleasing change is on the Login screen itself. It looks simple, yet futuristic. There is also something about the new asterisk while typing the password which grabs one's attention :-)


  • No Me menu
The elaborate Me menu has been removed and a less elaborate dock with access to most performance options like Power, hardware, etc.. has been added. Unclear of the intent of this change though.
  • Evolution gives way to Thunderbird
Evolution the  long associate as the default mail client has been replaced with Mozilla Thunderbird. Having used only Evolution and not Thunderbird I'm not in  a position to comment on it. From Mozilla must be good. 

  • Software Centre is bigger, better
I haven't been a big fan of Software Center. Nonetheless, it has a more professional look and will be of certain use to new users. First thing, I am getting Synaptic, just for sentimental reasons ;-) 

  • Missing applications
After removing GIMP from the default install in Maverick, there's no Synaptic Package Manager and Pitivi video editor. Nonetheless, still very much supported by Ubuntu.
  • Miscellaneous: Default font all across is the Ubuntu font. Looks a little weird on the terminal though. The default set of wallpapers are amazing, except for the Oneiric one.
  • Installation took about 7 minutes and that is still the best in Industry!
  • Multitouch support still there; One point touch is left click, Two point touch is right click and the accelerometer simulation kind of an effect with the track pad are still thriving.
  • Booting takes about 10-12 seconds on a fresh install; Will see if it slows down as Natty did when I had loaded with hundreds of startup applications. 

 Of all the current OS'es, Oneiric, if not for everything, just for its aesthetics takes a far leap ahead!


Wednesday, August 17, 2011

Right Click, Refresh Desktop in Debian/Ubuntu

Windoze users when switching to Debian/Ubuntu or any other flavours of GNU/Linux seem to have a hangover of some futile actions, that one would get used to while being desperate on the Windoze environments :D

And if you seriously are missing the "refresh desktop" options on the GNU/Linux environments, just to demonstrate the power of Free and Open Source Software, and the freedom they provide the users with, here's a small tweak which gives the "Refresh Desktop" option.

By the way, F5 on Debian/Ubuntu still perform the Refresh blink. This tweak is to add the Right Click -> Refresh Desktop option.

1.Open terminal (ctrl+alt+t)
2. Install the the nautilus (default file browser) menu configuration tool and the lineakd is the daemon that runs in the background of an X session and listens to incoming events from multimedia buttons

sudo apt-get install nautilus-actions lineakd

3. Create a directory to dump this and anymore future tweaks you might be performing to nautilus

mkdir nautilus-scripts

4. Enter the new directory,

cd nautilus-scripts

5. Create the script file,

gedit refresh-desktop

6. Copy these contents in the file (this will perform toggling of F5, and hence the refresh !)

#!/bin/bash
xsendkeycode 71 1
xsendkeycode 71 0

Save and close.

7. Make the script executable using chmod.

sudo chmod u+x refresh-desktop

8. Now, the script is ready, we need to link it to the action. And to add the right-click -> Refresh Desktop short cut, go to System -> Preferences -> Nautilus Actions configuration,

9. Create a new action


10. Change the context label to "Refresh Desktop", or "Mimic Windoze", or anything that pleases you :P

11. Check all the "Display Item options"

12. In the command tab, click on the browse option of Path, and link the refresh-desktop file in the directory "nautilus-scripts" created in step 5
13. In the conditions tab, select "Both"
14. Record all changes, or Save
15. Logout and login
16. And there you go! No more missing a futile action :P

Friday, August 12, 2011

GRUB and Reinstalling GRUB : Debian/Ubuntu

GNU GRUB is a Multiboot boot loader. It was derived from GRUB, the GRand Unified Bootloader, which was originally designed and implemented by Erich Stefan Boleyn. 

And playing around with GRUB to get multiple Operating Systems indexed and to make them available for booting is as awesome as it could get. 
The sheer scalability GRUB has to offer in terms of the number of OS'es it can index is superb. I have gone up to six different operating systems at one point of time, and currently am running five. And that doesn't still represent the number of OS'es that can be multi-booted via GRUB. It is only constrained by the space on your hard drive!

My current Grub entry
While trying the tricks of installing multiple operating systems, if care is not taken the latest OS will overwrite the GRUB and if it ain't a GRUB based bootloader (as would be the case when the last OS is M$ Windoze, or sometimes even Redhat!) the entries of other OS will be lost. 

GRUB on the top of Ubuntu/Debian are the best to retrieve and index all the installed OS. 

Here are the steps for reinstalling GRUB at the MBR for an Ubuntu/Debian distro. 

  • Get hold of a Live CD/Live USB stick with either Debian or Ubuntu
  • After entering the Live user environment, spot the ext4 partition of the Ubuntu/Debian
  • To get to know the partition where the hidden Ubuntu/Debian is installed, usually   
sudo fdisk -l
would suffice. Or gparted is another tool which could be of help
  •  Once you've got to know the ext4 partition, then mount it in the Live environment 
sudo mount /dev/sda5 /mnt (assuming that the ext4 partition of the hidden Ubuntu/Debian install is on sda5)

  • Now, reinstall GRUB :)
sudo grub-install --root-directory=/mnt /dev/sda
(GRUB will be installed on the MBR of sda)

And you're done!

  • Now, boot into your Ubuntu/Debian distro which was running on sda5 (in the example) and run  
sudo update-grub

This will generate a new grub.cfg file as shown in the image above.

Wednesday, July 27, 2011

DNS and DNS flushing in Ubuntu

The Domain Name System (DNS) is a hierarchical naming system built on a distributed database for computers, services, or any resource connected to the Internet or a private network. Most importantly, it translates domain names meaningful to humans into the numerical identifiers associated with networking equipment for the purpose of locating and addressing these devices worldwide. (Wikipedia)

Translating URL's to point at the IP addresses of servers is an important portion of the Internet browsing. There could be multiple levels of DNS resolutions happening to expedite the browsing experience of users.

On a GNU/Linux machine, if the user is aware of the URL and IP address of a host, he/she can make a manual DNS entry on the /etc/hosts file.


To view and add the DNS servers the host machine is using, the file to look at is
/etc/resolv.conf

Further, caching the DNS entries ( mapping of URL's to IP addresses) is a feature used to avoid the repeated Domain Name resolution iterations. But sometimes, when a single URL points to multiple servers ( like google mail etc..), and when secure sessions on different servers are established the chances that one of the servers would not resolve might occur.


During such instances, the DNS cache has to be flushed. The first and simple command which has to be manually run to flush the DNS cache is dns-clean.
It can be invoked by the following command:

raghu@fossphosis:~$ sudo /etc/init.d/dns-clean


But, repetitive invoking of this command might get on to the nerves of the users, and a daemon to automate this task is NSCD (Name Server Cache Daemon).
NSCD automates the DNS table flushing and refreshing process at the back end.
NSCD on Ubuntu can be installed by the following apt-get command.

raghu@fossphosis:~$ sudo apt-get install nscd

Fine tuning of the refresh rate and time-to-live of the DNS entries can be altered by changing the values in the configuration file /etc/nscd.conf

Monday, June 20, 2011

Running SMTP server on two ports concurrently in Ubuntu

The Simple Mail Transfer Protocol(SMTP) server in Ubuntu is available via the package "Postfix", which is the most widely used SMTP server in UNIX-like systems including AIX, BSD, HP-UX, Linux, MacOS X, Solaris, and more environments.

SMTP as a service runs on Port 25.


fossphosis@fossphosis:~$ cat /etc/services | grep smtp
smtp         25/tcp          mail
ssmtp        465/tcp        smtps        # SMTP over SSL

To get Postfix running on Ubuntu, all one needs to do is apt-get the package.

fossphosis@fossphosis:~$ sudo apt-get install postfix

Once, Postfix is installed, in case of configurations apart from the default ones, reconfigure the settings by running the dpkg-reconfigure, to set the parameters matching the network requirements.

fossphosis@fossphosis:~$ sudo dpkg-reconfigure postfix

I wanted my SMTP instance available on the local network for all the machines on the 192.168.1.X subnet. To accomplish this the only change, or the appendage to the existing default configuration is to add the subnet in the entry, as shown below:
Adding 192.168.1.0/24 subnet for reachability of the SMTP server on my network
In case of applications, like the one I was faced with, where i wanted the SMTP to run on an alternate port other than Port 25  parallely, all you need to do is add the port entry in the following postfix configuration file.

Edit /etc/postfix/master.cf,

I wanted SMTP to run on port 2525, so added the following entry just, as shown below:

# ==========================================================================
# service type  private unpriv  chroot  wakeup  maxproc command + args
#               (yes)   (yes)   (yes)   (never) (100)
# ==========================================================================
smtp      inet  n       -       -       -       -       smtpd
2525      inet  n       -       -       -       -       smtpd

Once editing is done, restart the Postfix server

fossphosis@fossphosis:~$ sudo service postfix restart
[sudo] password for fossphosis:
 * Stopping Postfix Mail Transport Agent postfix           [ OK ]
 * Starting Postfix Mail Transport Agent postfix           [ OK ]

To verify if SMTP is running on both the ports,perform a basic telnet to the ports.
Testing on port 25
fossphosis@fossphosis:~$ telnet localhost 25
Trying ::1...
Connected to localhost.localdomain.
Escape character is '^]'.
220 Comp ESMTP Postfix (Ubuntu)


Testing on port 2525

fossphosis@fossphosis:~$ telnet localhost 2525
Trying ::1...
Connected to localhost.localdomain.
Escape character is '^]'.
220 Comp ESMTP Postfix (Ubuntu)

And, that's it!


Saturday, April 30, 2011

Natty Narhwal Release


Ubuntu 11.04, the thirteenth edition of Ubuntu, aka Natty Narhwal is out. I call Natty a mix bag, with lot of improvements and major digressions from its previous versions.

  • Unity: It is the new GUI for Ubuntu, replacing the long standing GNOME-Ubuntu rapport. After a somewhat regressive debacle in the community, Ubuntu vs GNOME, the two have parted and that GNOME will not be officially supported by Ubuntu, and will be available only via a PPA. Canonical is obviously pushing Unity, and although GNOME isn't dependent on Canonical or Ubuntu, it will certainly be a setback for GNOME. I personally am missing GNOME on Natty. On the positive side of Unity is the four point touch support. That is something to look forward to in the releases to come.

  • Open Office to Libre Office: With the Oracle takeover of Sun Microsystems, projects such as Virtual Box, Open Office, Mysql, etc.. which were mentored by Sun have been under the threat of losing their traits (although Oracle argues otherwise). With Ubuntu switching from Open Office to Libre office, this apprehension about Oracle effect is reduced, nevertheless Open Office will be missed. (BTW, Open Office and Libre Office are almost the same)

  • Banshee replaces Rhythmbox: The default music player for Natty is Banshee, and I don't mind, for I haven't got used to Rhythmbox as yet. VLC still is what I'll be going for. 

  • It's still Mozilla: Firefox4 ships as the default browser, and no prizes for guessing as to why. 
 
  • Proprietary codecs and Software more easily accessible. In order to attract new users, Ubuntu is more than happy to prompt the users to go for proprietary codecs, which has been under a lot of debate since the release of Maverick.  
  • Installation in Telugu and (broken) Kannada are on in Natty.
While the Debian community insists (rightly) to call Debian, a GNU/Linux Operating system as Free (free as in Freedom),

Canonical has been consciously pushing Ubuntu as an Open Source Linux based OS as Free ( as in no price).


Yesterday in Bangalore, the Ubuntu Loco team had called for the Natty Release party, and it was nice to see a bunch of Free and Open Source Software enthusiasts join in and have a small Party for Natty.



PS: Ubuntu is getting no better with every release :(
They're now only "Open", "free" is only a matter of price to Canonical.
But, Ubuntu is like my first love. It drew me into the Free Software Movement, and I am still not ready to part with it.
Nonetheless, if they keep digressing the way they are now, soon I shall have to part with it :)

Thursday, January 27, 2011

Ubuntu Developers Day-2011,Bangalore


"Ubuntu is Humanity", and I have come a long way since knowing Ubuntu in September,2008. That is when I first came across Ubuntu and started using it, right away. Since then, I have almost perennially been on Ubuntu, with a very small percentage of all the 'lot' of technical and non-technical work I do, on anything apart from Ubuntu.


Although, I am no 'Developer', I proudly call myself an Evangelist and better a 'tweaker'( even hacker is a term too big for my C and bash aptitude). To be part of the the meet up was a warm homecoming kind of a feeling.

To have immense passion towards  ' a piece of software' is not regular in the regular world, but amonsgt the FOSS'ers it is a denominating trait. My passion about FOSS and in particular Ubuntu is very explicitly shown by me,for, in 'any' discussion you'd have with me, chances that I do not bring Ubuntu into it would be a rarity!


So, today's Ubuntu Developers Day was something I was looking forward to for quite sometime. And, it did leave me all happy by the end of the day. Today's meet was impeccable- organizationally and pleasantly intuitive - content-wise (except for one sponsored firm's blah blah;)

Firstly, I was a little apprehensive about Unity becoming the default GUI starting Natty Narhwal ( Ubuntu 11.04), but today's sessions have gotten me all excited like rest of the Ubuntu community. Ubuntu will be the first Operating System to ship with full multi-touch abilities, and it was really nice to have had it heard from Chase Douglas.


Secondly, IBM's Linux Technology Center made its presence felt, by very aptly showing off the team behind the ext4 filesystem, and its own contributions to Linux, as a whole.One pleasant surprise in IBM's keynote though was, they mentioning the two Kernel workshops which was conducted along with FSMK,with due attribution to FSMK :)

If I were to call today, a day of de-apprehensions, it would fit perfectly. For, the other major apprehension "The Obscure Cloud" got elucidated in Ubuntu terms. Although, my disassociation with the Public Cloud would still go on, the idea of Private Clouds within enterprises on enterprise owned servers has got me all excited. And, the two great talks by Nick Barcet , did bring a better insight about 'Ubuntu on Cloud' and 'Cloud on Ubuntu'.


The lunch was complex, for we were at the Leela Palace. Nevertheless, I did enjoy the salads and the Shepherd Pie (excellent  minced mutton, baked and garnished like a pie:), with a climactic relishing of the yummy chocolate dessert.

Post lunch, apart from Nick and Chase's second talks the other talk was boring, can't complain, for I know the terms of sponsorship. As, i was running late for another commitment, couldn't stay for the two other sessions post tea.
And in exchange for our feedback, the goody bag given was awesome, with a cool Maverick Meerkat T-shirt, Ubuntu stickers, Ubuntu branded Diary and pen, stuffed in an uber cool bag.


The exhibition rooms, where Ubuntu and variants of Ubuntu were displayed took me by awe. The cutest was Spark's smart book powered by an ARM Cortex and running Ubuntu. Another cool product was the one which would only play media, connect to the net and do some simple things, running Ubuntu Netbook on a Freescale chip,with SD memory! Then the muti-touch demo with the finger painting application was simply stunning.


Looking forward to more of Ubuntu Developers Day, and will try to increase my karmas on Launchpad, before the next UDD!