Friday, March 14, 2014

How to Check How Much Memory a Process is Consuming in Linux

The pmap command reports the memory map of a process or processes.

OPTIONS

  • -x extended -> Show the extended format.
  • -d device -> Show the device format.
  • -q quiet -> Do not display some header/footer lines.
  • -V show version -> Displays version of program.

Example : we want to check how much memory is consumed by the apache(httpd) process. Run the below commands step by step :

Step:1

To get a pid of httpd process,run below command
  • [root@mail1 ~]# ps -eaf | grep http
root 1759 4493 0 04:02 ? 00:00:00 /usr/sbin/httpd
apache 1760 4493 0 04:02 ? 00:00:25 /usr/sbin/httpd
apache 1761 4493 0 04:02 ? 00:00:23 /usr/sbin/httpd
apache 1762 4493 0 04:02 ? 00:00:21 /usr/sbin/httpd
apache 1763 4493 0 04:02 ? 00:00:18 /usr/sbin/httpd

Step:2

Now run the pmap command against the PID number:
  • [root@mail1 ~]# pmap 1760 | tail
97406000 28K r--s- /usr/lib/gconv/gconv-modules.cache
97463000 16K rw--- [ anon ]
97467000 524288K rw-s- /tmp/apc.tE1RRo (deleted)
b7467000 11096K r---- /usr/local/zend/lib/libicudata.so.38
b7f3d000 4K rw--- /usr/local/zend/lib/libicudata.so.38
b7f3e000 64K rw-s- /dev/zero (deleted)
b7f4e000 504K rw-s- /dev/zero (deleted)
b7fcc000 32K rw--- [ anon ]
bfd74000 144K rwx-- [ stack ]
total 2742152K

The process, which is apache is consuming about 2.7GB of memory

Difference Between Build / Verify, Clear, Quick Init & Skip Init While Creating An Array In RAID

The differences between these options are listed below. If unsure of which option to use, it is recommended to choose "Build / verify".

Build / Verify

  • Array is available for use immediately. The Build operation continues in the background. Therefore, an operating system installation may begin while the array is going through the Build process, although performance will be impacted until the process has completed. 
  • Creates parity/redundancy for each disk in the array. Example: For a RAID 1 logical drive, data is copied from the source drive to the mirrored drive. For RAID 5 and RAID 6, parity is computed and written. 
  • A Build can take up to 20x longer than Clear (due to parity generation).

Clear

  • Array is not available to use until the operation completes. 
  • Fastest way to set the disks into a known good state. 
  • Writes only zeroes to the disk. Although no real redundancy/parity is created, all disk sectors contain zeroes (no data) so none is required. Any future write operations will create required redundancy.

Quick Init

  • Array is available for use immediately. 
  • Only creates metadata on member disks of the array, the build process is bypassed, the first few and last blocks in the user addressable area (incl. partition tables) will be wiped off. While this is the fastest method for creating a RAID array, it is only recommended for use with new drives. Performance will be impacted while the logical drive is in Quick Init mode until a Verify with Fix is performed. 
  • For striped arrays (such as RAID 0, RAID 10, RAID 50, RAID 60), write performance is affected when less than a full stripe is written. The array remains in full-stripe write mode until a Verify with fix operation is completed to validate redundant information. 
  • Default Setting for RAID 1, RAID 1EE, and RAID 10 arrays.

Skip Init

  • Updates metadata only. 
  • If multiple disk drives fail in the same logical device, it may be possible to recover the data by recreating the logical device without the initialization step (skip init). Omitting the initialization step reconstructs the logical device metadata without modifying or destroying other data on the disks. 
  • Not available on HostRAID controllers.

Wednesday, March 12, 2014

How To Edit PDF Files in Ubuntu

With the help of pdfedit software we can edit the pdf files in ubuntu. Pdfedit can change either raw pdf objects (for advanced users) or use predefined gui functions. Functions can be easily added as everything is based on a scripts.

Installing pdfedit


Use Below command to install pdfedit

Starting pdfedit software :

OR


Open the terminal type the below command :
  • [linux-expert@nextstep4it] sudo pdfedit

Editing the pdf file


click on file Option , then click on Open , then it will ask you the location of pdf file.Once you have selected the pdf file . It will look like below :

Now edit text and other objects of the pdf files by selecting appropriate options.

How to Secure Your Apache WebServer using SSL Certificates in Linux

In Linux,Apache is the most widely used WebServer , so in this document we will use Apache WebServer on Centos-6.3 and will make it secure by implementing SSL Certificates. I am assuming httpd package(i.e apache software) is already installed on the linux box.

Step 1 : Install the necessary packages

  • [root@localhost /]# yum install mod_ssl openssl.

Step 2: Genrate the self signed certificate.

Using OpenSSL we will generate a self-signed certificate. If you are using this on a production server you are probably likely to want a key from Trusted Certificate Authority, but if you are just using this on a personal site or for testing purposes a self-signed certificate is fine. To create the key you will need to be root so you can either su to root or use sudo in front of the commands.

# Generate private key using below command

  • [root@localhost /]# openssl genrsa -out server.key 1024

Now create certificate Signing Request(CSR) With Server RSA Private Key using below command

  • [root@localhost /# openssl req -new -key server.key -out server.csr
# Now choose the CA to Sign Your Server's Certificate , using below command
  • [root@localhost /#openssl x509 -req -days 365 -in server.csr -signkey server.key -outserver.crt
Now we have successfully created and signed a certificate and Copy the files to the correct locations.
  • [root@localhost ~]# cp server.crt /etc/pki/tls/certs/
  • [root@localhost ~]# cp server.key /etc/pki/tls/private/
  • [root@localhost ~]# cp server.csr /etc/pki/tls/private/

Step 3: Now edit the ssl.conf file


  • [root@localhost ~]# vi /etc/httpd/conf.d/ssl.conf

Change the paths to match where the Key file is stored. If you've used the method above it will be

  • SSLCertificateFile /etc/pki/tls/certs/server.crt
  • SSLCertificateKeyFile /etc/pki/tls/private/server.key
Save quit the file and restart the apache serivce

  • [root@localhost ~]# /etc/init.d/httpd restart

Step 4: Now modify the httpd.conf file


  • [root@localhost ~]# vi /etc/httpd/conf/httpd.conf
Save & quit and Put the html files in /var/www/html and restart httpd service using below command :

  • [root@localhost html]# /etc/init.d/httpd restart

Step 5

If your web server is ruuning behind the firewall , then open 443 port. Once all the steps are done , we can access the our website “https://www.example.com” using webroswer.

Swap file in windows & How to change the size of the virtual memory paging file

A swap file, also called a page file, is an area on the hard drive used for temporary storage of information. Windows uses the swap file to improve performance. A computer normally uses primary memory, or RAM, to store information used for current operations, but the swap file serves as additional memory available to hold additional data.

Note:

Microsoft recommends that you allow Windows to manage the Virtual Memory settings for you (i.e., leave the default setting as is). Only experienced users should change this setting, as it can adversely affect system performance.

Also note that you can manually move the location of the swap file to a different drive. In some situations, this can be advantageous. If you have a drive with more free space or a faster access time, you may improve performance by moving the swap file to this drive.

Windows 7, Vista, and XP allow you to set up swap files for each drive on your system. In these versions of the Windows operating system, the swap file is dynamic and hidden.

Windows 7 and Vista

To view your current swap file information in Windows 7 and Vista:

  • From the Start menu, right-click My Computer or Computer, and then select Properties.
  • From the Tasks menu, select Advanced system settings.
  • In the dialog box that opens, click the Advanced tab. Under the "Performance" section, select Settings....
  • In the Performance Options dialog box, select the Advanced tab.

Click Change.... The swap file information is listed at the bottom.

Windows XP

The name of the Windows XP swap file is pagefile.sys, located in the root directory. The swap file is dynamic, changing size depending on system conditions. If you run several applications at once, the swap file will grow to accommodate the additional information required to run each application smoothly. This is a hidden file, so you will have to change your folder view setting to be able to see the file.
To view your current swap file information in Windows XP:
  • Right-click My Computer, and then select Properties. 
  • Select the Advanced tab. 
  • Under "Performance", click Settings. 
  • Select the Advanced tab. Information about your swap file is listed under "Virtual memory".

To change the size of the virtual memory paging file in windows OS.

You must be logged on as an administrator or a member of the Administrators group in order to complete this procedure. If your computer is connected to a network, network policy settings may also prevent you from completing this procedure. 
  • Open System in Control Panel. 
  • On the Advanced tab, under Performance, click Settings.
  • On the Advanced tab, under Virtual memory, click Change. 
  • Under Drive [Volume Label], click the drive that contains the paging file you want to change.
  • Under Paging file size for selected drive, click Custom size, and type a new paging file size in megabytes in the Initial size (MB) or Maximum size (MB) box, and then click Set.
If you decrease the size of either the initial or maximum page file settings, you must restart your computer to see the effects of those changes. Increases typically do not require a restart.

Note


  •  To open System, click Start, click Control Panel, click Performance and Maintenance, and then click System. 
  • To have Windows choose the best paging file size, click System managed size. 
  • For best performance, do not set the initial size to less than the minimum recommended size under Total paging file size for all drives. The recommended size is equivalent to 1.5 times the amount of RAM on your system. Usually, you should leave the paging file at its recommended size, although you might increase its size if you routinely use programs that require a lot of memory. 
  • To delete a paging file, set both initial size and maximum size to zero, or click No paging file. Microsoft strongly recommends that you do not disable or delete the paging file.