Tuesday, December 30, 2008

Negative caching

sulekha

this is what i have read about negative caching in the book , "practical guide to Ubuntu Linux by mark sobell"

Storing the knowledge that something does not exist. A cache normally stores information about something that exists. A negative cache stores the information that something, such as a record, does not exist.

can any one give an example(s) / practical situation(s) where and why this is used ?


iponeverything

Squid does negative caching, it saves a lot of time with not having to go out and look for something that you already know does not exist.


kenjackson

DNS requires that caching nameservers remember negative responses as well as positive ones. If an authoritative nameserver returns a negative response, indicating that a name does not exist, this is cached. The negative response may be perceived as a failure at the application level; however, to the nameserver caching it, it is not a failure.

Monday, December 29, 2008

Howto: Restart Ubuntu Linux safely when it is frozen or locked up!

If anyone faces a freeze with Ubuntu where you cannot do anything, then this will certainly be helpful if you want to reboot the OS as cleanly as possible without damaging their HDD's or losing their data.

In case of a freeze where you cannot do anything, simply press Alt+PrintScreen+R+E+I+S+U+B, keep in mind that the italicized keys must be kept pressed through the rest of the sequence AND that you will need to keep holding the sequence keys for a small period of time before going to the next one so that their actions can be carried out properly (For example, hold the R key for about 1-2 seconds before moving on to S). If the sequence does not work at first, then increase the time period between each sequence key press and try again.

It stands for Raw (take control of keyboard back from X), tErminate (send SIGTERM to all processes, allowing them to terminate gracefully), kIll (send SIGKILL to all processes, forcing them to terminate immediately), Sync (flush data to disk), Unmount (remount all filesystems read-only), reBoot. These keystrokes should be entered a few seconds apart. This should prevent a fsck being required on reboot; it also gives some programs a chance to save emergency backups of unsaved work.

Here is a breakdown of the other sysrq keys:
0 - 9 - sets the console log level, controlling which kernel messages will be printed to your console so that you don't get flooded.

B - restarts the system without making steps to ensure that the conditions are good for a safe reboot, using this key alone is like doing a cold reboot.

E - sends SIGTERM to all processes except init. This means that an attempt is done to end the current processes except init, safely, e.g. saving a document.

F - call oom_kill(Out Of Memory Killer), which will kill a process that is consuming all available memory.

H - displays help about the SysRq keys on a terminal though in actuality you can use any key except for the ones specified, to display help.

I - sends SIGKILL to all processes except init. This means that all the processes except for init are killed, any data in processes that are killed will be lost.

K - kills all processes on the current terminal. It is a bad idea to do this on a console where X is running as the GUI will stop and you can't see what you type, so you will need to switch to a tty after doing the magic SysRq.

L - sends SIGKILL to all processes, including init. This means that every process including init will be killed, using this key will render your system non-functional and no further magicSysRq keys can be used. So in this case you will have to cold reboot it.

M - dumps memory info to your console.

O - shuts down the system via ACPI or in older systems, APM. As in key "B", using this key alone is like a cold reboot(Or in this case, a cold shutdown).

P - dumps the current registers and flags to your console.

Q - dumps all timers info to your console.

R - takes keyboard and mouse control from the X server. This can be useful if the X-Server crashed, you can change to a console and kill the X-Server or check the error log.

S - writes all data from the disc cache to the hard-discs, it is a sync and is necessary to reduce the chances of data corruption.

T - dumps a list of current tasks and info to your console.

U - remounts all mounted filesystems read-only. After using this key, you can reboot the system with Alt+SysRq+B without harming the system.

W - dumps uninterruptable (blocked) state tasks.


For more information see:- http://en.wikipedia.org/wiki/Magic_SysRq_key

source:- http://www.ubuntu-unleashed.com/2008/05/howto-restart-ubuntu-safely-when-it-is.html

Saturday, December 27, 2008

My Hard Drive Is Clicking Again So I’m Stopping It Cold When Ubuntu Boots

source: http://eric.biven.us/2008/10/09/my-hard-drive-is-clicking-again-so-im-stopping-it-cold-when-ubuntu-boots/

aarklon

Earlier I wrote an article discussing the hyperactive APM modes that some drive manufacturers use and how that leads to excessive head parking and severly reduced drive life. It seems newer versions of Ubuntu and Kubuntu are coming with APM on the drives completely disabled (a setting of 255 using the -B option of the hdparm command). This is all swell and good but disregards the fact that many of us have hardware that doesn't support the 255 option and rely on the slightly lower setting of 254, which doesn't completely disable APM on the drive but causes it to be very, very slow to park.

So let's set up the system for the rest of us. First we need to edit the /etc/hdparm.conf file and add this at the end. Please be aware that your hard drive may not be "/dev/sda" like mine, so make sure you get that part right for your system.

/dev/sda {
apm = 254
}

Finally, let's reboot and check our current APM settings on the drive to be sure our settings are being applied at startup. The command to check the drive's current state is:

sudo hdparm -I /dev/sda|grep "Advanced power management level:"

If that shows you a value of 254 then you're golden. Congratulations on extending the life of your hard drive. It looks like the folks at Ubuntu also got this sorted out for both ATA and SATA drives when resuming from sleep, but do yourself a favor and check that on your system as well.

As a side note, how can you tell how many times the heads have parked? First, install the smartmontools package, then check the number of load cycles that the drive has gone through:

sudo apt-get install smartmontools
sudo smartctl -A /dev/sda|grep "Load_Cycle_Count"

As a rule of thumb most consumer drives can load cycle at or just above 500,000 times. Be aware that this isn't a hard limit, it's just a guess. Your mileage will vary.


source: http://eric.biven.us/2008/10/09/my-hard-drive-is-clicking-again-so-im-stopping-it-cold-when-ubuntu-boots/


see: http://ubuntuforums.org/showthread.php?t=1021561&highlight=hard+drive+clicking


I tried what is said in this howto and found that my clicking sound
has
now reduced to a very small noise, now what i want is to eliminate
this sound completely, so how to do it ?

what is the method/means to know if hardware doesn't support 255
option ?
How to find out the optimal apm value for a particular hard disk ?

NB: I use ubuntu 8.04.1


propman

http://www.samsung.com/global/business/hdd/

Anton Ertl
Yes, the load cycles would also be my first guess, a start-stop cycle my second. You can check which one is the case with the method mentioned in the posting:

smartctl -a /dev/hda|grep Count

If the Start_Stop_Count goes up on clicking, it's a start-stop cycle (full spindown and spin-up); if only the Load_Cycle_Count goes up, then it's a load cycle (parking and unparking the head assembly in its rest position).

> I tried what is said in this howto and found that my clicking sound
>has
> now reduced to a very small noise, now what i want is to eliminate
>this sound completely, so how to do it ?

> what is the method/means to know if hardware doesn't support 255
>option ?

From what I read in the hdparm man page, trying 255 does not hurt. So you could try it, and if there's still clicking, settle for 254. For my purposes 254 is good enough, though.

What I find strange is that you write that the clicking is reduced to a very small noise; a load cycle should have the same volume when it happens, it should just happen much more rarely. Maybe the lower-volume stuff is ordinary head-moving noise. You may be able to reduce that noise with "hdparm -M 128 /dev/..." (sorry, I don't know the name of this setting in /etc/hdparm.conf).

The other thing I wonder about is: What do you mean when you write "whenever the computer stops"?

sheridan hutchinson

There are two types of clicking that occur. Either, I'm dying clicking from the drive itself, or the sound of the drive heads parking due to power management.

As you describe this happening when activity calms down I'm going to assume the latter.

If this a laptop? If this is a laptop this is desirable as it will decrease power usage.

In Debian or Ubuntu the laptop-mode-tools package manages this. You need to go through the configuration file with a fine tooth comb to get the settings how you want them. If you do use laptop-mode-tools you can be assured that there is a way of disabling this when on AC and or battery.

If you are using a desktop then this is and odd situation however I think you could use hdparm and configure that to disable the powermanagement completely.


annalissa

when i issue the command sudo telinit 0 or when i click system ->
Quit option

the following is the o/p of my smartctl command

zodiac@ubuntu:~$ sudo smartctl -a /dev/sdb
[sudo] password for zodiac:
smartctl version 5.37 [i686-pc-linux-gnu] Copyright (C) 2002-6 Bruce
Allen
Home page is http://smartmontools.sourceforge.net/

=== START OF INFORMATION SECTION ===
Device Model: SAMSUNG HD252HJ
Serial Number: S17HJ9DQ803060
Firmware Version: 1AC01113
User Capacity: 250,059,350,016 bytes
Device is: In smartctl database [for details use: -P show]
ATA Version is: 7
ATA Standard is: Not recognized. Minor revision code: 0x52
Local Time is: Sun Dec 28 11:38:48 2008 EST

==> WARNING: May need -F samsung or -F samsung2 enabled; see manual
for details.

SMART support is: Available - device has SMART capability.
SMART support is: Enabled

=== START OF READ SMART DATA SECTION ===
SMART overall-health self-assessment test result: PASSED

General SMART Values:
Offline data collection status: (0x00) Offline data collection
activity
was never started.
Auto Offline Data Collection: Disabled.
Self-test execution status: ( 0) The previous self-test routine
completed
without error or no self-test has ever
been run.
Total time to complete Offline
data collection: (3751) seconds.
Offline data collection
capabilities: (0x7b) SMART execute Offline immediate.
Auto Offline data collection on/off support.
Suspend Offline collection upon new
command.
Offline surface scan supported.
Self-test supported.
Conveyance Self-test supported.
Selective Self-test supported.
SMART capabilities: (0x0003) Saves SMART data before
entering
power-saving mode.
Supports SMART auto save timer.
Error logging capability: (0x01) Error logging supported.
General Purpose Logging supported.
Short self-test routine
recommended polling time: ( 2) minutes.
Extended self-test routine
recommended polling time: ( 63) minutes.
Conveyance self-test routine
recommended polling time: ( 8) minutes.

SMART Attributes Data Structure revision number: 16
Vendor Specific SMART Attributes with Thresholds:
ID# ATTRIBUTE_NAME FLAG VALUE WORST THRESH TYPE
UPDATED WHEN_FAILED RAW_VALUE
1 Raw_Read_Error_Rate 0x000f 100 100 051 Pre-fail
Always - 0
3 Spin_Up_Time 0x0007 094 094 011 Pre-fail
Always - 2840
4 Start_Stop_Count 0x0032 100 100 000 Old_age
Always - 55
5 Reallocated_Sector_Ct 0x0033 100 100 010 Pre-fail
Always - 0
7 Seek_Error_Rate 0x000f 253 253 051 Pre-fail
Always - 0
8 Seek_Time_Performance 0x0025 100 100 015 Pre-fail
Offline - 0
9 Power_On_Hours 0x0032 100 100 000 Old_age
Always - 84
10 Spin_Retry_Count 0x0033 100 100 051 Pre-fail
Always - 0
11 Calibration_Retry_Count 0x0012 100 100 000 Old_age
Always - 0
12 Power_Cycle_Count 0x0032 100 100 000 Old_age
Always - 55
13 Read_Soft_Error_Rate 0x000e 100 100 000 Old_age
Always - 0
183 Unknown_Attribute 0x0032 100 100 000 Old_age
Always - 0
184 Unknown_Attribute 0x0033 100 100 099 Pre-fail
Always - 0
187 Unknown_Attribute 0x0032 100 100 000 Old_age
Always - 0
188 Unknown_Attribute 0x0032 100 100 000 Old_age
Always - 0
190 Temperature_Celsius 0x0022 076 066 000 Old_age
Always - 403963928
194 Temperature_Celsius 0x0022 071 065 000 Old_age
Always - 29 (Lifetime Min/Max 0/7444)
195 Hardware_ECC_Recovered 0x001a 100 100 000 Old_age
Always - 10
196 Reallocated_Event_Count 0x0032 100 100 000 Old_age
Always - 0
197 Current_Pending_Sector 0x0012 100 100 000 Old_age
Always - 0
198 Offline_Uncorrectable 0x0030 100 100 000 Old_age
Offline - 0
199 UDMA_CRC_Error_Count 0x003e 100 100 000 Old_age
Always - 0
200 Multi_Zone_Error_Rate 0x000a 100 100 000 Old_age
Always - 0
201 Soft_Read_Error_Rate 0x000a 253 253 000 Old_age
Always - 0

SMART Error Log Version: 1
No Errors Logged

SMART Self-test log structure revision number 0
Warning: ATA Specification requires self-test log structure revision
number = 1
No self-tests have been logged. [To run self-tests, use: smartctl -t]

SMART Selective Self-Test Log Data Structure Revision Number (0)
should be 1
SMART Selective self-test log data structure revision number 0
Warning: ATA Specification requires selective self-test log data
structure revision number = 1
SPAN MIN_LBA MAX_LBA CURRENT_TEST_STATUS
1 0 0 Not_testing
2 0 0 Not_testing
3 0 0 Not_testing
4 0 0 Not_testing
5 0 0 Not_testing
Selective self-test flags (0x0):
After scanning selected spans, do NOT read-scan remainder of disk.
If Selective self-test is pending on power-up, resume after 0 minute
delay.



Anton Ertl

Ok, so you halt the system. Parking the head is fine under these circumstances, and clicking is normal; now that I think of it, my system also produces a very audible click when I shut it down, and that may well come from the Samsung drive I have (HD753LJ). And the hdparm apm (-B) setting won't affect this; the -M setting might make it quieter, but I doubt it.

Is there any particular reason why you want to make that click
quieter?

>zodiac@ubuntu:~$ sudo smartctl -a /dev/sdb

Hmm, no Load_Cycle_Count (neither for my Samsung disk), but since this is a desktop disk, it probably won't park the head unless it is spinning down (i.e., load-cycle count = start-stop count).


anton ertl

Sheridan Hutchinson writes:

[heads parking]

>If this a laptop? If this is a laptop this is desirable as it will
>decrease power usage.

AFAIK parking does not decrease power usage. Laptop drives do it as a safety precaution: if the user drops the laptop, the chances of the drive surviving are much better if the heads are parked than if they are not.

Spinning down does decrease power usage (but spinning up again takes a few seconds, so drives are much more reluctant to do it).

However, the OP uses a 3.5" desktop drive.

Back to laptops and heads parking:

However, in Linux normally the system writes the atime of various files every few seconds, so it unparks the heads very shortly after they are parked, leading to very high load-cycle counts for some drives unless you tell the drive to be less aggressive with their head parking (my latest laptop drive reached 300000 load cycles before I noticed that); you can then reach the life expectancy of the drive (a SMART VALUE entry of 0) wrt load cycles in less than a year on some
drives. So you should either tell the drive to be less aggressive with parking, or tell the OS to write less (e.g., by mounting the file systems with the noatime option, and/or by using laptop mode). On my laptop I took the first approach.

aarklon

BTW how could you figure out from the o/p of sudo smartctl -a /dev/sdb ,that i am using desktop hard disk ?

pascal hambourg

Probably from the device model "SAMSUNG HD252HJ". BTW, my Hitachi hard disk drive also makes a clicking sound when parking the heads at shutdown. I believe this is perfectly normal.


Aragorn

It is. Most hard disk models park the heads on the inner cylinder, but Hitachi disks park their heads on a ramp outside of the platter circumference. Yet, all modern hard disks not only park their heads in the sense of "moving them away from the readable/writable surface of the
platters" but they will also lock the heads in their parked position. As such, you would hear two sounds: one from the heads moving to their respective landing zone, and one from the heads being locked in place there.


Anton ertl

AFAIK that's no longer true. They used to do that several years ago, but nowadays the surfaces and the heads are so smooth that they would stick together if the heads landed on the surface, so now they are all doing this:

Wednesday, December 24, 2008

Use the Contents of the /proc Directory to Interact with the Kernel

/proc/asound/version find alsa version

/proc/cpuinfo. Getting CPU information, such as the family, type, and speed

/proc/net Viewing important networking information under

/proc/net/dev, such as active interfaces information

/proc/net/route routing information

/proc/net/netstat network statistics.

/proc/kmsg Contains messages generated by the kernel

/proc/loadavg Lists the system load average

/proc/meminfo Displays memory usage

/proc/modules Lists the kernel modules currently loaded

/proc/mounts Shows all mounted file systems in Linux


/proc/net Lists status information about network protocols

/proc/stat

Contains system operating statistics, such as page fault occurrences,other statistics such as CPU load, swap file usage

/proc/uptime Displays the time the system has been up

/proc/version Displays the kernel version

Retrieving file system information.

/proc/interrupts Displays the interrupts in use

/proc/ioports Shows the I/O ports in use

/proc/num

Each process is held in a directory that’s labeled by its number: /proc/1 is the directory for process 1, for example

/proc/devices
Lists the device drivers configured for the currently running kernel

/proc/dma
Displays the Direct Memory Access (DMA) channels currently used

/proc/filesystems
Lists file systems configured into the kernel


proc/kcore
Holds an image of the physical memory of the system


/proc/net/arp

when a linux system (or any device with ethernet) wishes to address an IP address, the ARP request message "who is X.X.X.X tell Y.Y.Y.Y" is sent using the ethernet broadcast address. the target system forms an arp response "X.X.X.X" is hh:hh:hh:hh:hh:hh and sends it to the requesting host.An arp response is cached for a short time in /proc/net/arp to avoid the need to continually reestablish the mapping between hardware ethernet addresses and IP addresses.


/proc/sys/net/core/netdev_max_backlog

When the kernel receives packets from the places them on a special queue.By default, a maximum of 300 packets is allowed on the queue. Under extraordinary circumstances,you may need to edit this file and change the value for the allowed maximum.

/proc/sys/net/ipv4/icmp_echo_ignore_all

Default = 0, meaning that the kernel will respond to Internet Control Message Protocol ICMP) echo-reply messages. Set this to 1 to tell the kernel to stop replying to those messages.


/proc/sys/net/ipv4/icmp_echo_ignore_broadcasts

Default = 0, meaning that the kernel will allow ICMP responses to be sent to broadcast or multicast addresses.


/proc/sys/net/ipv4/ip_forward

Default = 0, meaning the kernel will not forward packets between network interfaces.To allow forwarding (e.g., for routing), change this to 1.



/proc/sys/net/ipv4/ip_local_port_range

Range of ports Linux will use when originating a connection. Default = 32768–61000.



/proc/sys/net/ipv4/tcp_syn_cookies

Default = 0 (Off). Change to 1 (On) to enable protection for the system against SYN flood attacks.



Reporting media mount point information via USB; for example, the Linux kernel reports what device to use to access files (such as /dev/sda) if a USB camera or hard drive is detected on the system. You can use the dmesg command to see this information.

See http://procps.sourceforge.net/faq.html

Tuesday, December 23, 2008

installing vista fonts in ubuntu

see:- http://ubuntu.wordpress.com/2007/09/16/installing-vista-fonts-in-ubuntu/

known hardy bugs and work arounds

http://ubuntuforums.org/showthread.php?t=773851

preload

Preload is a little application that monitors files of frequently used applications and and loads them in to the memory when system is idle. This usually results in lesser startup times for those applications. Install preload by executing following command.

sudo apt-get -y install preload

digital camera support in Linux

Linux supports over 800 cameras through the gPhoto2 digital camera software package, which comes bundled with your system. What gPhoto2 essentially consists of is a collection of drivers that
works in the background to tell your computer how to communicate with your camera. To see if your camera is supported, go to the gPhoto2 website (www.gphoto.org), scroll down, and click 800 cameras (the number may actually be higher when you check). On that page you will find a complete
list of all the cameras supported by gPhoto2. If your camera isn’t on the list, it most likely means (as the page points out) that your camera is so old that there is little demand for support for it or that it is so new that there hasn’t been enough time to develop support for it. Of course, gPhoto2 is constantly being updated, so if your camera isn’t on the list now, it could be in the near future. Updating gPhoto2 with Synaptic now and again should keep you as up to date as possible.

Monday, December 22, 2008

linux/ubuntu forums

http://www.ubuntuforums.org

The official Ubuntu community forum.Always a good place to start when you’re in a fix, have a question, or justwant to find out what’s going on.

http://www.ubuntux.org/forum

Another slightly smaller Ubuntu specific forum. A good place to turn if you find UbuntuForums.org a bit too much to wade through.

http://www.kubuntuforums.net

A forum dedicated to Kubuntu, an official Ubuntu edition based on the KDE desktop environment.


http://www.justlinux.com

If you can’t find what you want in the previously mentioned forums, you can try this or the following two forums dealing with general Linux issues. You are sure to find many Ubuntu users on any of them.

http://www.linuxforum.com

http://www.linuxquestions.org

Using Nautilus as an FTP Client

Nautilus not only allows you to browse and mount shares on local networks, but it can also act as an FTP client, say for instance when you want to change the files for your website on a remote server. To do this, go to the Connect to Server window (File Connect to Server), and then select FTP (with login) for Service Type. Then type the information provided by your website host,and click the Connect button. An FTP Network Share icon will then appear on the desktop and in the side pane. Double-click that icon, type your password (for that account—not the one for your Ubuntu system, unless it happens to be the same) when prompted to do so, and then you will be able to view and add to the files you have there.


source:- Rickford Grant
verified on ubuntu 8.04

Saturday, December 20, 2008

sort command

sulekha

what is the algorithm used in the sort command ,for 2.6.24-21-generic linux kernels ?


gnashley

What sort command in the kernel? sort is a separate program, which uses glibc. It's part of the coreutils package, so you can get the sources and read for yourself.


Billymayday

/* Sort the array LINES with NLINES members, using TEMP for temporary space.
NLINES must be at least 2.
The input and output arrays are in reverse order, and LINES and
TEMP point just past the end of their respective arrays.

Use a recursive divide-and-conquer algorithm, in the style
suggested by Knuth volume 3 (2nd edition), exercise 5.2.4-23. Use
the optimization suggested by exercise 5.2.4-10; this requires room
for only 1.5*N lines, rather than the usual 2*N lines. Knuth
writes that this memory optimization was originally published by
D. A. Bell, Comp J. 1 (1958), 75. */

From coreutils 6.9

Get last accessed File time in Ubuntu Linux

Ubuntu Linux has a rich set of commands for manipulating and accessing files. The stat utility gives detailed access to file information, including last accessed and last modified file time.

From the terminal window, run the command with this syntax:

stat filename


ex:-
stat /usr/bin/k3b
File: `/usr/bin/k3b'
Size: 1996852 Blocks: 3912 IO Block: 4096 regular file
Device: 801h/2049d Inode: 5661472 Links: 1
Access: (0755/-rwxr-xr-x) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2008-09-30 18:59:08.000000000 +0530
Modify: 2008-01-30 17:31:38.000000000 +0530
Change: 2008-09-25 18:22:55.000000000 +0530

source :- how to geek

NB:- Tested on ubuntu 8.04.1

pkill

Kill Linux Processes Easier with pkill

One of the best features in Linux is the way you can control processes from the command line, so if you have an application that locks up your GUI, you can always SSH over from another machine and just kill the offending process.

The problem is that if you are killing the same process repeatedly, it's very tedious to have to figure out the process ID every single time so that you can kill it… so here's the easier way to do it.

The Old Way

The classic way of killing processes meant you'd first need to use the ps command piped through grep to find the process you are trying to kill:

$ ps -ef | grep swiftfox
geek 7206 22694 0 Dec04 ? 00:00:00 /bin/sh /opt/swiftfox/swiftfox
geek 7209 7206 0 Dec04 ? 00:00:00 /bin/sh /opt/swiftfox/run-mozilla.sh /opt/swiftfox/swiftfox-bin
geek 7213 7209 0 Dec04 ? 00:04:29 /opt/swiftfox/swiftfox-bin
geek 14863 14224 0 18:19 pts/4 00:00:00 grep swiftfox

Then to kill the process, you'd have to use the kill command:

$ kill 7206

The New Way

Instead of going through all of that, you can simply use the pkill command if you already know the process name or part of it.

$ pkill swiftfox

It's as simple as that. You should note that pkill will kill all processes matching the search text, in this case swiftfox

If you want to see what process names are matched before using the pkill command, you can use the pgrep command. Passing the -l switch tells pgrep to show the process name as well.

$ pgrep -l swiftfox
7206 swiftfox
7213 swiftfox-bin

Swiftfox seems to crash on me a lot, so I've unfortunately had to use this command a lot lately.

source howtogeek

Show the List of Installed Packages on Ubuntu or Debian

While working on the instructions for compiling MonoDevelop from source, I relied heavily on the dpkg and apt-cache commands to tell me what was already installed vs what packages were available in the repository. After completing that article it occurred to me that I should explain how to show what packages are currently installed… so here we are.

The command we need to use is dpkg –get-selections, which will give us a list of all the currently installed packages.

$ dpkg --get-selections
adduser install
alsa-base install
alsa-utils install
apache2 install
apache2-mpm-prefork install
apache2-utils install
apache2.2-common install
apt install
apt-utils install

The full list can be long and unwieldy, so it's much easier to filter through grep to get results for the exact package you need. For instance, I wanted to see which php packages I had already installed through apt-get:

dpkg --get-selections | grep php

libapache2-mod-php5 install
php-db install
php-pear install
php-sqlite3 install
php5 install
php5-cli install
php5-common install
php5-gd install
php5-memcache install
php5-mysql install
php5-sqlite install
php5-sqlite3 install
php5-xsl install

For extra credit, you can find the locations of the files within a package from the list by using the dpkg -L command, such as:

dpkg -L php5-gd
/.
/usr
/usr/lib
/usr/lib/php5
/usr/lib/php5/20060613
/usr/lib/php5/20060613/gd.so
/usr/share
/usr/share/doc
/etc
/etc/php5
/etc/php5/conf.d
/etc/php5/conf.d/gd.ini
/usr/share/doc/php5-gd

Now I can take a look at the gd.ini file and change some settings around…

source:- how to geek

See What Version of a Package Is Installed on Ubuntu

The package management system on Ubuntu makes it extremely simple to install and remove packages, but sometimes it's important to figure out what version of a particular package that you actually have installed.

The apt-get utilities are simply a front-end to the debian dpkg utility, which actually does the real work. You can use this utility to figure out what version is installed.

dpkg -s

ex:- dpkg -s k3b

apt-cache

When you are trying to install software on Ubuntu or Debian linux using the apt-get package system, quite often you'll forget the exact name of the package you are trying to install. Here's how you can get a little help figuring out what the name is.

Syntax:

apt-cache search SearchTerm

Ex:- apt-cache search monodevelop
Ex:- apt-cache search firefox | grep plugin


source how to geek

How to Tell What Version of Ubuntu You Are Running

Telling what version of Ubuntu you are running is extremely easy. You would commonly use this command to figure out if you are running Edgy after you upgraded from Dapper.

cat /etc/issue.net

Use the Windows Key for the "Start" Menu in Ubuntu Linux

Use the Windows Key for the "Start" Menu in Ubuntu Linux

Ubuntu has a dropdown menu at the top of the screen to launch applications, which is very similar to the way Windows has the start menu at the bottom of the screen. If you are a windows user new to Ubuntu, you may prefer to have the windows key launch the applications menu. Thankfully this is an easy thing to do in Ubuntu.

Go to the System \ Preferences \ Keyboard Shortcuts menu item:

Scroll down till you see the "Show the panel menu" item. Click in the Shortcut column, and when it changes to "New accelerator…", hit the Windows Key. Click the close button. You're done!

Now when you hit the windows key, the application menu will pop up. If you hit the right arrow key, you can go to the Places or System menu as well.


source: how to geek

Thursday, December 18, 2008

groups

Creating a group

To create a new group, use the groupadd command: groupadd group

where group specifies the name of the group to be added. Groups are stored in the file etc/group, which can be read by any user but modified only by root. For example, to add a group named newbies, you would enter the following command: groupadd newbies

Deleting a group

To delete a group, user the groupdel command: groupdel group
where group specifies the name of the group to be deleted. For example, to delete the group named newbies, you would enter the following command:
groupdel newbies

Adding a member to a group

To add a member to a group, you use a special form of the adduser command:adduser user group

where user specifies the member and group specifies the group to which the member is added. For example, to add the user newbie01 to the group newbies, you would enter the following command:
adduser newbie01 newbies

Removing a member from a group

Unfortunately, no command removes a user from a specified group. The easiest way to remove a member from a group is by editing the /etc/group file. Here's an excerpt from a typical /etc/group file:
users:x:100:nogroup:x:65534:bmccarty:x:1000:newbies:x:1002:newbie01,newbie02,newbie03

Each line in the file describes a single group and has the same form as other lines, consisting of a series of fields separated by colons (:). The fields are:

Group name: The name of the group.
Password: The encrypted password associated with the group. This field is not generally used, containing an x instead.
Group ID : The unique numeric ID associated with the group.

Member list

A list of user accounts, with a comma (,) separating each user account from the next.
To remove a member from a group, first create a backup copy of the /etc/group file:
cp /etc/group /etc/group.SAVE

The backup can prove helpful if you modify the file incorrectly. Next, open the /etc/group file in a text editor. Locate the line that describes the group and delete the user name and the following comma, if any. Save the file, exit the editor, and check your work.

Changing a User's Name

You can change the name associated with a user account, by using the chfn command:
chfn -f name userid

where name specifies the new name and userid specifies the account to be modified. If the name contains spaces or other special characters, it should be enclosed in double quotes ("). For example, to change the name associated with the account newbie to Dewbie Newbie, you would enter the following command:

chfn -f "Dewbie Newbie" newbie

Kernel logging with klogd

The klogd daemon records information from the kernel. These Linux kernel messages report on the kernel’s interaction with the hardware in the system — from the processor to the hard drives to the serial ports. All this information is placed in the /var/log/kern.log file.

NB: tested on ubuntu 8.04.1

/dev/sndstat

/dev/sndstat — This device indicates the status of the sound card.

You can determine the status of the sound card and the drivers loaded by using the
following: cat /dev/sndstat

structure of a debian package name

debsums

The debsums program is a utility for Ubuntu and other Debian-based systems that checks the MD5 sums of every installed package against the md5sum files found in the /var/lib/dpkg/info directory.

Install this program with the following command: sudo aptitude install debsums

common debsums options


debsums -a Checks all files (including configuration files which are, by default, left out).


debsums –e Checks config files for packages only.

debsums –c Lists only changed files to stdout.

debsums –l Lists files that don’t have md5sum info.

debsums –s Lists only errors; otherwise be silent.

debsums Lists the packages you want debsums to analyze.

Wednesday, December 17, 2008

Debfoster

Definition: debfoster: Install only wanted Debian packages debfoster is a wrapper program for apt and dpkg. When first run, it will ask you which of the installed packages you want to keep installed. After that, it maintains a list of packages that you want to have installed on your system. It uses this list to detect packages that have been installed only because other packages depended on them. If one of these dependencies changes, debfoster will take notice, and ask if you want to remove the old package. This helps you to maintain a clean Debian install, without old (mainly library) packages lying around that aren't used any more.


Once in a while, you may want to do some maintenance on your Ubuntu machine and clean up unnecessary files that are chunking up large storage space in your hard disk.



Debfoster creates a dependency files to enable you to keep track of what you have installed. When you uninstall an application, it will check for any leave behind dependencies files or orphaned packages and ask you if you want to remove it.

Install debfoster, or via the terminal,

sudo apt-get install debfoster

Creating the initial keeper file:

sudo debfoster -q

Force the system to conform to the keeper file

sudo debfoster -f

If you have some packages that you never want to uninstall and do not want debfoster to handle those packages, you can edit the keeper file and remove those packages from the list.

gksu gedit /var/lib/debfoster/keepers

To see is there is any orphaned package or dependencies files that need to be removed:

sudo debfoster


NB:- verified on ubuntu 8.04

Source: Debian 3.0r0 APT / Linux Dictionary V 0.16
http://www.tldp.org/LDP/Linux-Dictionary/html/index.html
http://maketecheasier.com/8-ways-to-maintain-a-clean-lean-ubuntu-machine/2008/10/07

Tuesday, December 16, 2008

/usr/share

sulekha

the following is the explanation i have read about /usr/share in a book

Data for installed applications that is architecture−independent and can be shared between systems. A number of subdirectories with equivalents in `/usr' also appear here, including `/usr/share/doc', `/usr/share/info', and `/usr/share/icons'.

how correct is this explanation ?


secesh

http://tldp.org/HOWTO/HighQuality-Apps-HOWTO/fhs.html

Quote:
/usr/share/doc, /usr/share/man

The "share" word is used because what is under /usr/share is platform independent, and can be shared among several machines across a network filesystem. Therefore this is the place for manuals, documentations, examples etc.

I'd say your explanation is fairly good.

ryedunn

That being said, would it be purdent for me to store my music files in /usr/share/mp3 on a server?
I know many people might want to put these in a /home dir but which would best follow the FHS?


Lew pitcher

I believe that /usr/local/share/mp3 would be the canonical directory to use.The /usr/local tree is reserved for /local/ files (that is, files that are not derived from, or manipulated by the distribution or it's installers) that can be shared between users and processes



dave

In an ideal world it should still be a separate partition so that it can survive an OS upgrade/reinstall. When I upgrade Fedora I usually let it format everything except the /home partition to make sure it's a clean install. Having a partition mounted at /usr/local/share/mp3 would also work.


snova

No better. Use your home directory.

The /usr/local tree is identical (well, almost) to the /usr tree. The sole difference is that /usr is meant for the package manager, and /usr/local is meant for programs you install yourself.
Programs, not data. Never put any personal files outside of your home directory.

tim greer

You don't need to store any file in any specific area, though some common paths for some specific types of files are usually best. For files such as mp3 files, however, there's no specific area, but I'd personally store them in a home directory or some such similar area.If you plan to share those files with other users on the system, than that's different. If you want to store them for personal use/reasons, store them in your home directory. I don't believe the FHS is relevant
for audio files, again, unless you intend to provide some (possibly default) access to other users on a shared server.

darren salt

I'd say so; something like /usr/local/share/mp3 or /srv/mp3, I think.



nevrial

You can put them there, but then remember to chmod them properly so that no one having access to it erases it.


laurenz albe

The file system hierarchy is a guideline rather than a codex, and it's largely a matter of taste where you put a certain data file.

The idea is that /home is for everything that belongs to a certain user,and /usr/share is stuff that is useful for everybody.

One guideline is maybe that a file in /usr/share should belong to root -it should be stuff that is here to stay and not be changed on the whim
of a user.

So if you have a constant set of mp3 files that every user can depend on, /usr/share/mp3 doesn't sound wrong. On the other hand, if you add and delete mp3 files all the time (I hope you are not root when you acquire them), they should be stored in a directory that belongs to a mortal user (under /home).


noiance

HELL NO!!!
If you upgrade or switch your OS bye, bye bye MP3s if you didn't make a backup.

IMHO, /home/MP3 would be the correct place for sharing the mp3s on the server. Change the permission and share options to allow access to /home/MP3.

cariboo907

/usr is not the place to store normal user accessable files. The directory is for executeables, the libraries they need, configuration files and documentation. I would suggest putting your mp3 files in a subdirectory of /home, like /home/mp3 then you can set the permission of the directory to world readable with having to worry about accidentally changine permissions of a directory in /usr, the may hose your installation.


dcstar

Quite right, never EVER use system directories for user files.

People, you have a system (Linux) that is flexible and allows you to do stupid things as well as intelligent things, so don't do stupid things by mucking around with system directories and files because they contain a name that saves you typing a few characters somewhere else.

Just read some of the posts in forums like this - bemoaning their loss of data/having to reinstall their system - if you need a lesson in never tampering in places that you shouldn't.

/usr/share/calendar

The following table gives the name of each calendar file and describes its contents.


calendar.debian Interesting dates around Debian collected at Infodrom

calendar.ubuntu Interesting dates in Ubuntu history

calendar.birthday Births and deaths of famous people.

calendar.christian Christian holidays.

calendar.computer Significant dates in the history of computing.

calendar.history Dates of U.S. historical events.

calendar.holiday Standard and obscure holidays.

calendar.judaic Jewish holidays.

calendar.music Dates related to music, mostly 1960s rock and roll.

NB: tested on ubuntu 8.04.1

Wednesday, December 10, 2008

arping

Finding Duplicate IP Addresses

You want to know how to test an IP address on your LAN to see whether it is a duplicate.
Solution

Use arping, like this:
$ arping -D 192.168.1.76
ARPING 192.168.1.76 from 0.0.0.0 eth0
Unicast reply from 192.168.1.76 [00:14:2A:54:67:D6] for 192.168.1.76 [00:14:2A:54:67:
D6] 0.605ms
Sent 1 probes (1 broadcast(s))
Received 1 response(s)

Received 1 response(s) means that this address is already in use, and arping even gives you the MAC address. You may also test with a hostname:

$ arping -D uberpc
ARPING 192.168.1.76 from 0.0.0.0 eth0
Unicast reply from 192.168.1.76 [00:14:2A:54:67:D6] for 192.168.1.76 [00:14:2A:54:67:
D6] 0.590ms
Sent 1 probes (1 broadcast(s))
Received 1 response(s)

You should set a time limit or count limit, or arping will keep running when it gets no response. This example sets a time limit of 10 seconds:

$ arping -w10 -D 192.168.1.100
ARPING 192.168.1.100 from 0.0.0.0 eth0
Sent 11 probes (11 broadcast(s))
Received 0 response(s)

Use -c5 instead of -w10 to tell arping to run for five counts.

if you have intermittent connectivity problems with a particular host , run arping to see if it has a duplicate address

arping will work when ping fails.



source:- carla schroder

Tuesday, December 9, 2008

lanmap utility

Lanmap Listens to all available traffic on the interface of your choice, figures out who’s talking to who, how much, using which protocols.

This information is then put into a nice human-readable 2d image (various formats are available) which can be used to understand a network’s topology.

Install lanmap in Ubuntu

sudo apt-get install lanmap

This will complete the installation

Using lanmap

lanmap syntax

lanmap [-o directory] [-e program] [-T {png,gif,svg}] [-f filtetr] [-D {#,all,raw}] [-r seconds]

[-i {?,*wildcard*,iface}] [-h] [-v] [-V]

lanmap example

lanmap -i eth0 -r 30 -T png -o /tmp/

This will create a lanmap.png file under tmp folder


download lanmap from here http://www.parseerror.com/lanmap/

source : ubuntugeek

Linux IP Command Lines

Display Current Config for all NIC's: ifconfig

syntax:- ifconfig dev ip netmask broadcast

Display Current Config for eth0: ifconfig eth0

Assign IP: ifconfig eth0 192.168.1.2

Assign IP/Subnet: ifconfig eth0 192.168.1.2 netmask 255.255.255.0

Assign Default Gateway: route add default gw 192.168.1.1

Assign multiple IP's: ifconfig eth0:0 192.168.1.2

Assign second IP: ifconfig eth0:1 192.168.1.3

Disable network card: ifconfig eth0 down

Enable network card: ifconfig eth0 up



View current routing table: route "or" route -n

View arp cache: arp "or" arp -n

Ping: ping -c 3 192.168.1.1

Trace Route: traceroute www.whatismyip.com

Trace Path: tracepath www.whatismyip.com

DNS Test: host www.whatismyip.com

Advanced DNS Test: dig www.whatismyip.com

Reverse Lookup: host 66.11.119.69

Advanced Reverse Lookup: dig -x 66.11.119.69

NB:- Warning untested



Setting Up NICs under Fedora and RHEL

Fedora and other Red Hat–type systems use a simple setup that makes it easy to configure network cards at boot time. It is done through the creation of files in the /etc/sysconfig/network-scripts directory that are read at boot time. All of the graphical tools
under Fedora create and manage these files for you; for other people who like to get under the hood, the following sections show how to manually manage the configuration files.

For each network interface, there is an ifcfg file in /etc/sysconfig/network-scripts.
This filename is suffixed by the name of the device; thus, ifcfg-eth0 is for the eth0 device,ifcfg-eth1 is for the eth1 device, and so on.

If you choose to use a static IP address at installation time, the format for the interface configuration file for eth0 will be as follows:

DEVICE=eth0
ONBOOT=yes
BOOTPROTO=none
NETMASK=255.255.255.0
IPADDR= 192.168.1.100
GATEWAY=192.168.1.1
TYPE=Ethernet
HWADDR=00:0c:29:ac:5b:cd

TIP In Fedora, Red Hat Enterprise Linux (RHEL), and Centos distros, the file /usr/share/doc/initscripts-*/sysconfig.txt explains the options and variables that can be used in the “/etc/sysconfig/network-scripts/ifcfg-*”, among other things.

From linux news

Monday, December 8, 2008

mac fonts in ubuntu

Want these mac fonts?
AppleGaramond
Aquabase
LITHOGRL
Lucida Grande
Lucida Mac
lucon
MacGrand
If you do follow me, I'll show you how easy it is to install them!

Open up a terminal:
Applications->Accessories->Terminal
Copy/paste these commands:
wget http://ubuntu-debs.googlecode.com/files/macfonts.tar.gz
tar zxvf macfonts.tar.gz
sudo mv macfonts /usr/share/fonts/
sudo fc-cache -f -v

Now the Mac Fonts are installed, if you like these fonts and want them to be the default gnome font, right click on your desktop and select Change Desktop Backround then click on Fonts, and you can customize your system fonts there.

collin henderson

This is terrific .... I love my linux (new ubuntu user - one year) but hate the fonts. Have tired the MS TT''s but this result is exceptional, and I will stick with mac fonts. Also found this to help to know which ones are for where:

You can choose the fonts from:

System -> Preferences -> appearances -> Font

From Font Preferences, I choose these following fonts:

* Application font: Lucida Grande 9

* Document font: Lucida Grande 9

* Desktop font: MACGrande 9

* Window title font: LucidaMacBold

* Fixed width font: Lucida Console


john nillson

To get the fonts to render really nice you have to change two settings wrt to font rendering
1. Enable subpixel rednering
2. Disable all hinting

The first option make sure the highest possible resolution is used when deciding how the pixels should be colored.

The second option disable alignment on pixel edges. In theory hinting should make the font easier to read on a monitor, but in practice I find it easier to read if the font alignment just ignore the pixels. They get somewhat blurrier, but at the same time the blurriness makes them softer and thus easier on the eye.

kahrytan

Better yet, Extract to ~/.fonts folder. no need to place them in /usr/share/fonts


source ubuntu unleashed
NB tested in ubuntu 8.04.1

Friday, December 5, 2008

/proc/sys/vm/drop_caches

what exactly is the purpose of /proc/sys/vm/drop_caches file ?

can any one give a practical situation where the tip given in the following how to is used ?

In the past, I've been forced to do ridiculous things like cat a file larger than available RAM to /dev/null and edit gigabyte files which flood my cache with this data. Luckily, Linux kernels 2.6.16 and newer provide a mechanism to clear the inode, page, and dentry caches on demand avoiding all this headache. All you have to do is echo a value to the proc filesystem, and you're done.

To use /proc/sys/vm/drop_caches, just echo a number to it.

To free pagecache:
echo 1 > /proc/sys/vm/drop_caches

To free dentries and inodes:

echo 2 > /proc/sys/vm/drop_caches

To free pagecache, dentries and inodes:

echo 3 > /proc/sys/vm/drop_caches

As this is a non-destructive operation and dirty objects are not freeable, the user should run "sync" first!

This was originally found @ http://www.linuxinsight.com/proc_sys_vm_drop_caches.html


ilikejam

The only time I've ever seen anyone use this is when doing I/O benchmarking - dropping the caches forces disk operations to happen on the disk instead of in RAM.

Wednesday, December 3, 2008

linux installation in a logical partition ?

sulekha

1. why is it said that linux should always be installed in primary partitions ?

2. what is the trade off between installing linux on a primary partition and installing linux on a logical partition, is there any performance issues ?

3.is there really a concept of logical partition , since there are only 4 primary partitions and one of them is treated as extended partition which can contain any no: of logical partitions ?


syg00

1) Who said that ? (it's rubbish BTW)
2) Nope.


brianL

Debian testing is running just fine in a logical partition for me.No tradeoff. It's Windows and the BSDs that have to be on a primary partition.

billymayday

3 isn't true anyway - sata can have total of 16 partitions (or is it 15?), ide was 64 from memory


sulekha

Oh you mean the nof logical partitions. in SATA which value is correct 2^4 or 2^4 - 1 , BTW how did IDE or PATA drives get the value 64 ?