Thursday, December 20, 2012

How to open/extract ISO file in Linux?

mount -o loop -t iso9660 filename.iso /mnt/iso

(remember to create the directory /mnt/iso first)

Then browse to /mnt/iso and install

Wednesday, October 31, 2012

HowTo: Speedup ping and traceroute Command Responses under Linux / Unix

The ping command line utility act as a computer network tool. It used to test whether a particular host is reachable across an IP network. The traceroute command also act as a computer network diagnostic tool for displaying the route (path) and measuring transit

Speedup ping command

The syntax is:

 ping -n -W VALUE -i VALUE host

Where,
  1. -n : Disable DNS lookup to speed up queries.
  2. -W NUMBER : Time to wait for a response, in seconds. The option affects only timeout in absence of any responses, otherwise ping waits for two RTTs.
  3. -i SECONDS : Wait interval seconds between sending each packet. The default is to wait for one second between each packet normally, or not to wait in flood mode. Only super-user may set interval to values less 0.2 seconds.
The default command will produce output as follows:
 ping -c 5 google.com

[sibin@localhost]$ ping -c 5 google.com
PING google.com (74.125.235.8) 56(84) bytes of data.
64 bytes from sin01s04-in-f8.1e100.net (74.125.235.8): icmp_req=1 ttl=54 time=234 ms
64 bytes from sin01s04-in-f8.1e100.net (74.125.235.8): icmp_req=2 ttl=54 time=45.7 ms
64 bytes from sin01s04-in-f8.1e100.net (74.125.235.8): icmp_req=3 ttl=54 time=88.1 ms
64 bytes from sin01s04-in-f8.1e100.net (74.125.235.8): icmp_req=4 ttl=54 time=45.7 ms
64 bytes from sin01s04-in-f8.1e100.net (74.125.235.8): icmp_req=5 ttl=54 time=46.2 ms

--- google.com ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4002ms
rtt min/avg/max/mdev = 45.758/92.011/234.135/72.918 ms


 Now optimize the ping command:

$ ping -c 5 -n -i 0.2 -W1 google.com

[sibin@ast-wks-069 ~]$  ping -c 5 -n -i 0.2 -W1 google.com
PING google.com (74.125.235.9) 56(84) bytes of data.
64 bytes from 74.125.235.9: icmp_req=1 ttl=54 time=46.4 ms
64 bytes from 74.125.235.9: icmp_req=2 ttl=54 time=46.4 ms
64 bytes from 74.125.235.9: icmp_req=3 ttl=54 time=45.7 ms
64 bytes from 74.125.235.9: icmp_req=4 ttl=54 time=45.5 ms
64 bytes from 74.125.235.9: icmp_req=5 ttl=54 time=49.5 ms

--- google.com ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 803ms
rtt min/avg/max/mdev = 45.569/46.762/49.541/1.433 ms






Speedup traceroute command

The syntax is:
 
traceroute -n -w SECONDS -q NUMBER host



Where,
  1. -n : Disable DNS lookup to speed up queries.
  2. -w seconds : Set the time (in seconds) to wait for a response to a probe (default 5.0 sec).
  3. -q NUMBER : Sets the number of probe packets per hop. The default is 3.
The following example will wailt 3 seconds (instead of 5), only send out 1 query to each hop (ineader of 3):
$ traceroute -n -w 3 -q 1 www.google.com

 The -N option specifies the number of probe packets sent out simultaneously. Sending several probes concurrently can speed up traceroute considerably. The default value is 16:
$ traceroute -n -w 3 -q 1 -N 32 www.google.com
Please Note that some routers and hosts can use ICMP rate throttling. In such a situation specifying too large number can lead to loss of some responses. You can also limit the maximum number of hops to 16 before giving up (instead of default 30) using the -m option:
$ traceroute -n -w 3 -q 1 -N 32 -m 16 www.google.com

Friday, October 12, 2012

Centos Extra Repos for yum packages


Epel.repo

[epel]
name=Extra Packages for Enterprise Linux 5 - $basearch
#baseurl=http://download.fedoraproject.org/pub/epel/5/$basearch
mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=epel-5&arch=$basearch
failovermethod=priority
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL

[epel-debuginfo]
name=Extra Packages for Enterprise Linux 5 - $basearch - Debug
#baseurl=http://download.fedoraproject.org/pub/epel/5/$basearch/debug
mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=epel-debug-5&arch=$basearch
failovermethod=priority
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL
gpgcheck=1

[epel-source]
name=Extra Packages for Enterprise Linux 5 - $basearch - Source
#baseurl=http://download.fedoraproject.org/pub/epel/5/SRPMS
mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=epel-source-5&arch=$basearch
failovermethod=priority
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL
gpgcheck=1

webtatic.repo

[webtatic]
name=Webtatic Repository $releasever - $basearch
#baseurl=http://repo.webtatic.com/yum/centos/5/$basearch/
mirrorlist=http://repo.webtatic.com/yum/centos/5/$basearch/mirrorlist
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-webtatic-andy

[webtatic-debuginfo]
name=Webtatic Repository $releasever - $basearch - Debug
#baseurl=http://repo.webtatic.com/yum/centos/5/$basearch/debug/
mirrorlist=http://repo.webtatic.com/yum/centos/5/$basearch/debug/mirrorlist
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-webtatic-andy

[webtatic-source]
name=Webtatic Repository $releasever - $basearch
#baseurl=http://repo.webtatic.com/yum/centos/5/SRPMS/
mirrorlist=http://repo.webtatic.com/yum/centos/5/SRPMS/mirrorlist
enabled=0
gpgcheck=1

rpmforge.repo

# Name: RPMforge RPM Repository for Red Hat Enterprise 5 - dag
# URL: http://rpmforge.net/
[rpmforge]
name = Red Hat Enterprise $releasever - RPMforge.net - dag
#baseurl = http://apt.sw.be/redhat/el5/en/$basearch/dag
mirrorlist = http://apt.sw.be/redhat/el5/en/mirrors-rpmforge
#mirrorlist = file:///etc/yum.repos.d/mirrors-rpmforge
enabled = 1
protect = 0
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rpmforge-dag
gpgcheck = 1


Wednesday, September 12, 2012

Batch resize your images using mogrify in Linux

Batch resize your images using mogrify

Let's say you have lots of images and want to upload them to Facebook or to your website but you have to resize or edit all the images to suitable size for faster web access without losing too much of the quality of them. One tool to help you in this situation is mogrify.

mogrify is in imagemagick package. So you just need to install the package to get it. How to use it? Let's see some examples below:

1. mogrify -resize 320x240 *.jpg
This command will resize all files ending with .jpg (jpeg image) to resolution of 320x240 and replace all the files with the same name. mogrify may not produce the exact resolution to preserve aspect ratio.

2.mogrify -path Image-Small/ -resize 800x600 -density 25x25 *.gif
This command will resize all images ending with .gif to 800x600 with density 25x25. The resized images will be saved in Image-Small directory. So the original files is unmodified.

3. mogrify -resize 50% rose.jpg
This will resize the image to 50% and the original file replaced.

4. mogrify -format jpg *.png
This will convert all png files in currect directory to jpeg.

mogrify has many options for you to explore. Just man mogrify to read the manual or go to http://www.imagemagick.org/www/mogrify.html.

Monday, September 10, 2012

Mounting a Logical Volume in linux

  1. Install lvm2:
    $ sudo yum install lvm2
    
  2. Load the necessary module(s):
    $ sudo modprobe dm-mod
    
  3. Scan your system for LVM volumes and identify in the output the volume group name that has your Fedora volume (mine proved to be VolGroup00):
    $ sudo vgscan
    
  4. Activate the volume:
    $ sudo vgchange -ay VolGroup00
    
  5. Find the logical volume that has your Fedora root filesystem (mine proved to be LogVol00):
    $ sudo lvs
    
  6. Create a mount point for that volume:
    $ sudo mkdir /mnt/fcroot
    
  7. Mount it:
    $ sudo mount /dev/VolGroup00/LogVol00 /mnt/fcroot -o ro,user
    
  8. Copied my files.

Monday, July 2, 2012

Linux LVM How-to: Adding a new partition


Linux LVM How-to: Adding a new partition

Since I started out with Linux (so about six years ago), I always used the Linux Logical Volume Manager (LVM) to partition my tables. First it was just because it seemed easier to configure my harddisks with it (also, the installer usually provided a nice option to do so), but in the last few months I had the possibility to work more with LVM and got to know some nice features.
One thing I regularly have to do is to extend an existing logical volume on a server. This article focuses on extending a logical volume with the help of LVM.


Initial setup

To begin, let’s define our goals: We have a partition (mounted as /), which we want to extend from 7G to 16G. We will do this by following these steps:
  1. Partition the new disk
  2. Create New Physical Device (pvcreate)
  3. Extend the existing volume group
  4. Extend the logical volume
  5. Extend the filesystem (ext4 in my case)
I am using the latest Debian 6.0.4 release with EXT4 as the filesystem on my virtual machine, but the same steps apply to an EXT3 partition. This is the default layout that Debian created for me when I selected the “Use all diskspace and setup LVM” option during the installation:
simon@pandora:~$ df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/pandora-root
                      7.3G  843M  6.1G  12% /
tmpfs                 502M     0  502M   0% /lib/init/rw
udev                  497M  136K  496M   1% /dev
tmpfs                 502M     0  502M   0% /dev/shm
/dev/sda1             228M   16M  201M   8% /boot
Now we add a new disk to the system. This is done by physically adding a new disk or in my case, by adding a new disk via iSCSI. Using /var/log/messages, we can determine that the new disk is accessible under /dev/sdb. So let’s prepare this new disk…

Prepare the new disk

Change to root and use the fdisk utility to partition the new disk:
simon@pandora:~$ su -
Password: 
root@pandora:~# fdisk /dev/sdb 
[..]

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-1044, default 1): 
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-1044, default 1044): 
Using default value 1044

Command (m for help): p

Disk /dev/sdb: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x4fce54ed

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1        1044     8385898+  83  Linux

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
Now we have our new partition accessible under /dev/sdb1 (as seen above). Now you could use the mkfs tools to create a new filesystem on this partition and use it without LVM. But that is not what we want to do, so let’s continue by configuring LVM itself…

Configure LVM

LVM itself consists of three logical “layers”:
  • Physical devices (pv)
  • Volume groups (vg)
  • Logical volumes (lv)
So we want to configure LVM in that order. First, we’ll create a new physical volume by adding the partition we created above to the LVM configuration. Then, we will add this newly created physical volume to the existing volume group and then extend the existing logical volume containing the root filesystem.
Alright, let’s add our newly created partition to the LVM configuration:
root@pandora:~# pvcreate /dev/sdb1
  Physical volume "/dev/sdb1" successfully created
Nice. So let’s see which physical volumes we have:
root@pandora:~# pvdisplay
  --- Physical volume ---
  PV Name               /dev/sda5
  VG Name               pandora
  PV Size               7.76 GiB / not usable 2.00 MiB
  Allocatable           yes (but full)
  PE Size               4.00 MiB
  Total PE              1986
  Free PE               0
  Allocated PE          1986
  PV UUID               HsOAt3-snnh-MskC-mlE4-Runf-IkYx-KuDJ5j

  "/dev/sdb1" is a new physical volume of "8.00 GiB"
  --- NEW Physical volume ---
  PV Name               /dev/sdb1
  VG Name               
  PV Size               8.00 GiB
  Allocatable           NO
  PE Size               0   
  Total PE              0
  Free PE               0
  Allocated PE          0
  PV UUID               Oddlkr-jSoL-2PKR-kyxG-Wy33-T0Hh-JvflWQ
Ah nice, so we can see that LVM has a “NEW Physical volume”.
Now that is done, let’s extend our existing volume group (named “pandora” in my case, use “vgdisplay” to check the name for your volume group). Using the vgextend command we can extend the volume group:
root@pandora:~# vgextend pandora /dev/sdb1
  Volume group "pandora" successfully extended
root@pandora:~# vgdisplay
  --- Volume group ---
  VG Name               pandora
  System ID             
  Format                lvm2
  Metadata Areas        2
  Metadata Sequence No  4
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                2
  Open LV               2
  Max PV                0
  Cur PV                2
  Act PV                2
  VG Size               15.75 GiB
  PE Size               4.00 MiB
  Total PE              4033
  Alloc PE / Size       1986 / 7.76 GiB
  Free  PE / Size       2047 / 8.00 GiB
  VG UUID               hTcf4N-Srft-Myz2-YQYc-AC9T-pfaA-LIL1KZ
That went well. Now we’re basically done with adding new space to our volume group. We can now use the newly added physical volume and assign it to different logical volumes that are then used by the filesystem.
So remember what we wanted to do in the first place? Right, we wanted to add the new disk to the root filesystem. So let’s check which logical volumes we have by entering lvdisplay:
root@pandora:~# lvdisplay
  --- Logical volume ---
  LV Name                /dev/pandora/root
  VG Name                pandora
  LV UUID                UJQUwV-f3rI-Tsd3-dQYO-exIk-LSpq-2qls13
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                7.39 GiB
  Current LE             1892
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           254:0

  --- Logical volume ---
  LV Name                /dev/pandora/swap_1
  VG Name                pandora
  LV UUID                KHBPkh-qrv8-uZkS-dU4C-f3vF-SpHW-d3vtMH
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                376.00 MiB
  Current LE             94
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           254:1
We can see that on this machine, we have two logical volumes, one for the root filesystem and one for our swap partition. Since we want to extend the root filesystem, we simply take the LV name (“/dev/pandora/root”) and use the following command to extend that logical volume with all the space available on the specified VG (in my case “pandora”):
root@pandora:~# lvextend -l 100%FREE /dev/pandora/root 
  Extending logical volume root to 15.39 GiB
  Logical volume root successfully resized
Alternatively, you may specify the amount of space that is added to the logical volume (e.g. lvextend -L+1G /dev/pandora/root).

Extend the filesystem

Now the underlying volume /dev/pandora/root was successfully extended, we can extend the filesystem using the resize2fs tool. The tool will choose to do an on-line resizing, which is what we want:
root@pandora:~# resize2fs /dev/mapper/pandora-root 
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/mapper/pandora-root is mounted on /; on-line resizing required
old desc_blocks = 1, new_desc_blocks = 1
Performing an on-line resize of /dev/mapper/pandora-root to 4033536 (4k) blocks.
The filesystem on /dev/mapper/pandora-root is now 4033536 blocks long.
Done. To validate, let’s run the same command we ran at the beginning of this article.
root@pandora:~# exit
logout
simon@pandora:~$ df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/pandora-root
                       16G  845M   14G   6% /
tmpfs                 502M     0  502M   0% /lib/init/rw
udev                  497M  144K  496M   1% /dev
tmpfs                 502M     0  502M   0% /dev/shm
/dev/sda1             228M   16M  201M   8% /boot
simon@pandora:~$ 

Monday, May 28, 2012

Check If A Certificate & Private Key Match

Check if an SSL certificate and private key match in two simple commands. The OpenSSL commands below will require you to replace <file> with your file’s name.

For your SSL certificate:
openssl x509 -noout -modulus -in (Certificate file) | md5sum


For your RSA private key:

openssl rsa -noout -modulus -in (Key file) | md5sum

The output of these commands should be identical. If it isn’t, your keys do not match.
  1. The pipe to md5sum is solely to make the output shorter and easier to visually compare 
  2.  

How do I generate a CSR and private key?

You need to generate a CSR and private key on the server that the certificate will be used on. You can find instructions in your server documentation or try the instructions from one of these certificate authorities:

Once you have your CSR generated, you can use our SSL Wizard to find the best SSL certificate that will meet your needs. If you are familiar with OpenSSL you can use the following command to generate a CSR and private key:
openssl req -new -keyout server.key -out server.csr

How do I decode a CSR?

You can easily decode your CSR to see what is in it by using our CSR Decoder. In order to decode a CSR on your own machine using OpenSSL, use the following command:
openssl req -in server.csr -noout -text
     

Monday, May 14, 2012

List top 5 files eating your disk space

List top 5 files eating your disk space in current dir:

du -hsx * | sort -rh | head -5

du -hsx * | sort -rh | head -10

du -hsx * | sort -rh >/tmp/out.txt
26

Wednesday, April 25, 2012

Tuesday, April 10, 2012

Make Sure Unix / Linux Configuration Files Are Free From Syntax Errors

Command Summary

DaemonCommand
OpenSSH/usr/sbin/sshd -t && echo $?
/usr/sbin/sshd -T
Apache/usr/sbin/apache2 -t
apachectl configtest
nginx/usr/local/nginx/sbin/nginx -t
/usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf
lighttpd/usr/local/sbin/lighttpd -t -f /usr/local/etc/lighttpd/cyberciti.biz/lighttpd.conf
Bind (named server config)named-checkconf /etc/named.conf
Bind (zone syntx)named-checkzone cyberciti.biz /var/named/zone.cyberciti.biz
Squid proxy/usr/sbin/squid -k check
/usr/sbin/squid -k parse
MySQL servermysqld --verbose --help
/usr/libexec/mysqld --verbose --help 1>/dev/null
Postfix MTApostfix check
postfix -vvv
Samba SMB/CIFStestparm -v
tcpdtcpdchk
tcpdchk -v
dhcpd (DHCP / BOOTP) serverdhcpd -t -cf /path/to/dhcpd.testing.conf
vsftpd servervsftpd -olisten=NO /path/to/vsftpd.testing.conf
nagiosnagios -v /path/to/testing/nagios.cfg
Openntpd NTPD serverntpd -d -f /usr/local/etc/ntpd.conf -n
Xorg (X11 Server)Xorg -config /path/to/xorg.conf.new -retro
syslogd / rsyslogdrsyslogd -c4 -f /etc/rsyslog.testing.conf -N 1
CUPS Printing Systemcupsd -f -c /path/to/cupsd.testing.conf -t
slapd (OpenLDAP)slapd -Tt
varnishdvarnishd -C -f /path/to/wordpress.vlc
exim MTAexim -bV
Bash/Ksh scriptsbash -n ./myscript
ksh -n /path/to/script.ksh
BSD pf firewallpfctl -nf /etc/pf.conf
proftpdproftpd -t -c /path/to/proftpd.testing.conf
Perl scriptsperl -c /path/to/script.pl
perl -wc /path/to/script.pl

Thursday, March 8, 2012

Monday, February 27, 2012

PHP : Stop Notice and Variable Warnings in Error Log Files

PHP: Stop Notice and Variable Warnings in Error Log Files

by Vivek Gite on December 20, 2008 · 6 comments
Q. I'm using error logging in place of error displaying on production web sites. However, I do not want to see error messages about the use of uninitialized variables. I'd like to see all critical errors, except for notices and coding standards warnings. How do I disable error messages?

A. PHP provides various levels of error reporting using a bit-field as follows:

Error BitPurpose
E_ALLAll errors and warnings (doesn't include E_STRICT)
E_ERRORFatal run-time errors
E_WARNINGRun-time warnings (non-fatal errors)
E_PARSECompile-time parse errors
E_NOTICE Run-time notices (these are warnings which often result from a bug in your code, but it's possible that it was intentional (e.g., using an uninitialized variable and relying on the fact it's automatically initialized to an empty string)
E_STRICTRun-time notices, enable to have PHP suggest changes to your code which will ensure the best interoperability and forward compatibility of your code.
E_CORE_ERRORFatal errors that occur during PHP's initial startup
E_CORE_WARNINGWarnings (non-fatal errors) that occur during PHP's initial startup
E_COMPILE_ERRORFatal compile-time errors
E_COMPILE_WARNINGCompile-time warnings (non-fatal errors)
E_USER_ERROR User-generated error message
E_USER_WARNING User-generated warning message
E_USER_NOTICE User-generated notice message

Show only errors

Open /etc/php.ini file
# vi /etc/php.ini
Set error_reporting as follows:
error_reporting = E_COMPILE_ERROR|E_ERROR|E_CORE_ERROR
Alternately, you can show all errors, except for notices and coding standards warnings
error_reporting = E_ALL & ~E_NOTICE
Save and close the file. Restart apache web server:
# /etc/init.d/httpd restart

Wednesday, February 8, 2012

Find Memory Usage

Memory is one of the most critical resource components on a server to ensure that the smooth and fast operation. Thus, the availability of adequate and abundant physical memory size is vital especially for any server, especially high load web host that are also running database server such as Oracle or MySQL, which is famous for memory intensive. Linux, including CentOS which is popular on cPanel and Plesk web hosting server, comes with several commands and tools to check memory usage on server.

free
free command displays amount of total, free and used physical memory (RAM) in the system, as well as shoing information on shared memory, buffers, cached memory and swap space used by the Linux kernel.
Syntax of free
free -[options]
Example usage of free
free -m
The command will display information about physical memory in MB.
free -m -s 5
The command will activate continuous polling delay at 5 seconds apart, and then display memory status in megabytes on terminal. Any floating point number for delay can be specified.
free -t -m
Same with “free -m”, but -t switch will display a line containing the totals of physical memory and swap space.
vmstat
vmstat reports report virtual memory statistics, which has information about processes, swap, free, buffer and cache memory, paging space, disk IO activity, traps, interrupts, context switches and CPU activity. With vmstat command, administrators can has instantaneous reports on memory usage.
Syntax of vmstat
vmstat -[options] [delay count]
Example usage of vmstat
vmstat
The command will display report based on averages since last reboot.
vmstat 5
The command will pool average system resources usage level for a sampling period of 5 seconds at interval of 5 seconds, except the first result that is averages since the last reboot.
top
top command displays dynamic real-time view of the running tasks managed by kernel and system information in Linux system. The memory usage stats by top command include real-time live total, used and free physical memory and swap memory with their buffers and cached memory size respectively.
Syntax and example usage of top
top
Using top is simple, simply type top at command shell, and constantly update stats page will be shown.
ps aux
ps command reports a snapshot on information of the current active processes. Advantage of ps command is that system admins will be able to see where the memory is used. ps will show the percentage of memory resource that is used by each process or task running in the system. With this command, top memory hogging processes can be identified.
Syntax and example of ps aux
aux is actually already the options for ps command to see every process on the system. So the typical command to type the following in the command shell:
ps aux
To see only the memory resources occupied by each category of processes, such as Apache httpd, MySQL mysqld or Java, use the following command:
ps aux | awk '{print $4"\t"$11}' | sort | uniq -c | awk '{print $2" "$1" "$3}' | sort -nr
The all mentioned ways of check memory usage should works on most Unix and Linux variant of operating systems. However, if you’re running a VPS (Virtual Private Server) or VDS (Virtual Dedicated Server) or Hybrid Server, especially those powered by Virtuozzo or OpenVZ, the above commands will retrieve data from the host machine, i.e. the entire server the virtual environment is running on. In these virtualization system, the memory usage info has to be calculated from control panel or /proc/user_beancounters file

INstalling Desktop effects (compiz) for Fedora

yum install compiz


#To setup compiz-fusion for Gnome you need to install these additional packages:
 
su-
yum install -y ccsm emerald-themes compizconfig-backend-gconf fusion-icon-gtk emerald compiz-fusion compiz-fusion-gnome libcompizconfig compiz-gnome compiz-bcop compiz compizconfig-python compiz-fusion-extras compiz-fusion-extras-gnome 
  
#To setup compiz-fusion for KDE you need to install these additional packages:

su-
yum install -y ccsm emerald-themes compizconfig-backend-kconfig fusion-icon-qt emerald compiz-fusion libcompizconfig compiz-bcop compiz compizconfig-python compiz-fusion-extras  compiz-kde compiz-manager

#
To setup compiz-fusion for both Gnome and KDE you need to install these additional packages:

su -
yum install -y ccsm emerald-themes compizconfig-backend-kconfig compizconfig-backend-gconf fusion-icon* emerald compiz-fusion compiz-fusion-gnome libcompizconfig compiz-gnome compiz-bcop compiz compizconfig-python compiz-fusion-extras compiz-fusion-extras-gnome compiz-kde compiz-manager

Wednesday, February 1, 2012

find runnig time of a PID and process informations

Find runnig time of  a PID

 
ps -eo pid,etime | grep pidnumber
 

Task: UNIX List Open Files For Process

First use ps command to get PID of process, enter:
$ ps -aef | grep {process-name}
$ ps -aef | grep httpd


 Next pass this PID to pfiles command,
$ pfiles {PID}
$ pfile 3533



Task: Linux List Open Files For Process

First you need to find out PID of process. Simply use any one of the following command to obtain process id:
# ps aux | grep {program-name}
OR
$ ps -C {program-name} -o pid=
For example, find out PID of firefox web-browser, enter:
$ ps -C firefox -o pid=
Output:
 7857
To list opne files for firefox process, enter:
$ ls -l /proc/7857/fd
Sample output:
total 0
lr-x------ 1 vivek vivek 64 2008-03-05 22:31 0 -> /dev/null
l-wx------ 1 vivek vivek 64 2008-03-05 22:31 1 -> pipe:[18371]
lr-x------ 1 vivek vivek 64 2008-03-05 22:31 10 -> /usr/lib/firefox/firefox
l-wx------ 1 vivek vivek 64 2008-03-05 22:31 2 -> pipe:[18371]

lsof command

lsof command list open files under all Linux distributions or UNIX like operating system. Type the following command to list open file for process ID 351:
$ lsof -p 351

Friday, January 6, 2012

seting time and date from console

date --set="STRING"
For example, set new data to 2 Oct 2006 18:00:00, type the following command as root user:
# date -s "2 OCT 2006 18:00:00"
OR
# date --set="2 OCT 2006 18:00:00"
You can also simplify format using following syntax:
# date +%Y%m%d -s "20081128"

Linux Set Time

To set time use the following syntax:
# date +%T -s "10:13:13"

Monday, January 2, 2012

disable selinux

edit /etc/selinux/selinux.conf

and change to disabled

or run the command as root


setsebool -P allow_execstack 1