LinuxHelps.com

A blog for Linux Lovers.

Archive for the ‘Linux Helps’ Category

Posted by sibu on March 10, 2009

To set fsck on next reboot.

fsck is used to check and optionally repair one or more Linux file systems. All you need to do is just create empty file /forcefsck.

#touch /forcefsck

By creating /forcefsck file you will force the Linux system to perform a full file system check.

Posted by sibu on March 10, 2009

Command to check the Processor type in Linux

In order to find whether the processor is 32bit or 64 bit in Linux, use the command

[root@server1 ~]# getconf LONG_BIT
32

Also you can use

[root@server1 ~]# uname -i
i386

Posted by sibu on March 8, 2009

vmstat - command

vmstat reports information about processes, memory, paging, block IO,
traps, and cpu activity.


FIELD DESCRIPTION FOR VM MODE

Procs
r: The number of processes waiting for run time. or
Average number of kernel threads that are runnable, which includes threads that are running and threads that are waiting for the CPU.
b: The number of processes in uninterruptible sleep. or Average number of kernel threads in the VMM wait queue per second. This includes threads that are waiting on filesystem I/O or threads that have been suspended due to memory load control.

Memory
swpd: the amount of virtual memory used.
free: the amount of idle memory.
buff: the amount of memory used as buffers.
cache: the amount of memory used as cache.
inact: the amount of inactive memory. (-a option)
active: the amount of active memory. (-a option)

Swap
si: Amount of memory swapped in from disk (/s).
so: Amount of memory swapped to disk (/s).

IO
bi: Blocks received from a block device (blocks/s).
bo: Blocks sent to a block device (blocks/s).

System
in: The number of interrupts per second, including the clock.
cs: The number of context switches per second.

CPU
These are percentages of total CPU time.
us: Time spent running non-kernel code. (user time, including nice time)
sy: Time spent running kernel code. (system time)
id: Time spent idle. Prior to Linux 2.5.41, this includes IO-wait time.
wa: Time spent waiting for IO. Prior to Linux 2.5.41, shown as zero.

Posted by sibu on March 8, 2009

Define “/dev/null 2>&1″

some_prog > /dev/null 2>&1

2 = standard error
1 = standard outout

The first part

“> /dev/null” means send standard output to the ‘bit bucket” or in other words, throw it away.

Second part

2> redirects STDERR to the specified file.

& only means to run the process in the background if it appears at the end of the line. 2>&1 redirects STDERR to STDOUT. Since in this case, STDOUT is being redirected to /dev/null,

2>&1 causes both STDERR and STDOUT to /dev/null.

Posted by sibu on March 8, 2009

What is glibc ?

The glibc package contains standard libraries which are used by multiple programs on the system. In order to save disk space and memory, as well as to make upgrading easier, common system code is kept in one place and shared between programs. This particular package contains the most important sets of shared libraries: the standard C library and the standard math library. Without these two libraries, a Linux system will not function.

Posted by sibu on March 3, 2009

Fields in /etc/passwd

sibu:x:504:532:sibuhomepage:/home/sibu:/bin/bash

1. Username: User’s login name. It should be between 1 and 32 characters in length.
2. Password: An x character indicates that encrypted password is stored in /etc/shadow file.
3. User ID (UID): Each user must be assigned a user ID (UID).

UID 0 (zero) is reserved for root and UIDs 1-99 are reserved for other predefined accounts. Further UID 100-999 are reserved by system for administrative and system accounts/groups.
4. Group ID (GID): The primary group ID (stored in /etc/group file)
5. User ID Info: The comment field. It allow you to add extra information about the users.
6. Home directory: user’s home directory
7. Command/shell: shell (/bin/bash).

Posted by sibu on March 3, 2009

Error: Script Alias for scgi-bin was missing

Error:

Script Alias for scgi-bin was missing

FIx:

Add the following Script Alias for the user’s virtual host  /usr/local/apache/conf/httpd.conf

ScriptAlias /scgi-bin/ /home/username/public_html/scgi-bin/Restart apache.
Posted by sibu on March 3, 2009

Semaphore

Semaphore

A semaphore is an inter-process communication tool that is used by Apache to communicate with its child processes. Semaphore marks memory locations as locked and may not release it upon completion of process. In most case, if parent process dies before the child.

Due to the marking of  too many memory locations as being used while they are not,  the system will run out of memory locations after some time. This can happen in very busy servers with high uptime.

========================

warn] pid file /etc/httpd/run/httpd.pid overwritten — Unclean shutdown of previous Apache run?

[emerg] (28)No space left on device: Couldn't create accept lock

========================

In the previous case, the error message indicates that the apache server fails to allocate semaphores for new child processes.

When you stop all service, the semaphore and shared memory segments have to be removed. If not, you will be able to them using ‘ipcs’ command.

We can remove the segment ID using ‘ipcrm’ command.

#ipcs -a

#ipcrm -s < sem id>

To increase the semaphore values.

# /sbin/sysctl -a | grep sem => To display the Sem values.

# /sbin/sysctl -w kernel.sem=250

Add new value in /etc/sysctl.conf file inorder for the change to persist across system reboots.

# sysctl -f => to save values

You should periodically clean up the shared memory you have allocated using the command ipcrm. A fast way to remove every bit of shared memory you have priviledges for is

ipcs -m | awk ‘{print $2}’ | xargs -n1 ipcrm -m

OR

for i in `ipcs -s | grep nobody | awk '{print $2}'`; do ipcrm -s $i; done


Posted by sibu on March 3, 2009

grub-md5-crypt

grub-md5-crypt - Encrypt a password in MD5 format

Description

Encrypt a password in MD5 format.

-h, –help
print this message and exit
-v, –version
print the version information and exit
–grub-shell=FILE
use FILE as the grub shell

Here is an example of the output from grub-md5-crypt

# grub-md5-crypt
Password:
Retype password:
$1$DLnnu$YTAMkz7.eNxy7narRzfwR/