Thursday, January 22, 2015

How to Get CPU & RAM info in Linux


For CPU

1. cat /proc/cpuinfo for complete details
2. To get no. of processors/cores run below command

cat /proc/cpuinfo | grep processor | wc -l




For RAM
1. cat /proc/meminfo (for complete details)
2. free -m (currently installed & used RAM)

To find RAM slots & installed memory type below command

dmidecode | grep -A 8 'Memory'

you will see below outout. There are 2 slots available & RAM installed at both slots. Please check No. of devices & Memory Device for more info

[root@bhagwat ~]# dmidecode | grep -A 8 'Memory'
Physical Memory Array
    Location: System Board Or Motherboard
    Use: System Memory
    Error Correction Type: None
    Maximum Capacity: 16 GB
    Error Information Handle: Not Provided
    Number Of Devices: 2

Handle 0x0040, DMI type 4, 42 bytes
Processor Information
    Socket Designation: SOCKET 1155
--
        MTRR (Memory type range registers)
        PGE (Page global enable)
        MCA (Machine check architecture)
        CMOV (Conditional move instruction supported)
        PAT (Page attribute table)
        PSE-36 (36-bit page size extension)
        CLFSH (CLFLUSH instruction supported)
        DS (Debug store)
        ACPI (ACPI supported)
--
Memory Device
    Array Handle: 0x003F
    Error Information Handle: Not Provided
    Total Width: 64 bits
    Data Width: 64 bits
    Size: 2048 MB
    Form Factor: DIMM
    Set: None
    Locator: ChannelA-DIMM0
--
Memory Device Mapped Address
    Starting Address: 0x00000000000
    Ending Address: 0x0007FFFFFFF
    Range Size: 2 GB
    Physical Device Handle: 0x0041
    Memory Array Mapped Address Handle: 0x0045
    Partition Row Position: Unknown
    Interleave Position: 1
    Interleaved Data Depth: 1

Handle 0x0043, DMI type 17, 34 bytes
Memory Device
    Array Handle: 0x003F
    Error Information Handle: Not Provided
    Total Width: 64 bits
    Data Width: 64 bits
    Size: 2048 MB
    Form Factor: DIMM
    Set: None
    Locator: ChannelB-DIMM0
--
Memory Device Mapped Address
    Starting Address: 0x00080000000
    Ending Address: 0x000FFFFFFFF
    Range Size: 2 GB
    Physical Device Handle: 0x0043
    Memory Array Mapped Address Handle: 0x0045
    Partition Row Position: Unknown
    Interleave Position: 2
    Interleaved Data Depth: 1

Handle 0x0045, DMI type 19, 31 bytes
Memory Array Mapped Address
    Starting Address: 0x00000000000
    Ending Address: 0x000FFFFFFFF
    Range Size: 4 GB
    Physical Array Handle: 0x003F
    Partition Width: 2

Handle 0x0047, DMI type 131, 64 bytes
OEM-specific Type

Note
You can also run dmidecode -t 17 for type of RAM (DDR2/DDR3) & manufacturer.

Thursday, January 1, 2015

Edit Hosts File in Windows 8 or 8.1 With Single Command

There are so many posts on internet to edit hosts file in Windows 8,1 but none of the method worked for me.

I found a very easy way to edit the hosts file

Please run Command Prompt with Administrator privileged & run following command

attrib -r %WINDIR%\system32\drivers\etc\hosts

& that's it. Open the hosts file with your desired editor & change the file

Enjoy.....:)

Please share your comments if it's worked for you

Wednesday, August 27, 2014

How to Install & Run NFS Server with Fixed Ports

Important Files for NFS Configuration
/etc/exports : Its a main configuration file of NFS, all exported files and directories are defined in this file at the NFS Server end.
/etc/fstab : To mount a NFS directory on your system across the reboots, we need to make an entry in /etc/fstab.
/etc/sysconfig/nfs : Configuration file of NFS to control on which port rpc and other services are listening.

NFS Default Ports
111  NFS
2049 Portmap


Install Server with below command
yum install nfs-utils nfs-utils-lib


Start the service & add in startup
/etc/init.d/nfs start
chkconfig nfs on

Edit file to share directory
vi /etc/exports

To share with all
/home/shared *(rw,sync)

To share with particular IP
/home/shared  172.39.253.10(rw,sync)

Important NFS Sharing Options
Some other options we can use in /etc/exports file for file sharing is as follows.
ro: With the help of this option we can provide read only access to the shared files i.e client will only be able to read.
rw: This option allows the client server to both read and write access within the shared directory.
sync: Sync confirms requests to the shared directory only once the changes have been committed.
no_subtree_check: This option prevents the subtree checking. When a shared directory is the subdirectory of a larger file system, nfs performs scans of every directory above it, in order to verify its permissions and details. Disabling the subtree check may increase the reliability of NFS, but reduce security.
no_root_squash: This phrase allows root to connect to the designated directory.


Need to run the below command to export directory after adding in exports file
exportfs -a
 
After changing in exports file run below command to share again (Only required once you shared new directory or changed permission in exports file)
exportfs -r
 
To check files
exportfs -v
 ................................................................................
Client machine
yum install nfs-utils nfs-utils-lib

Start the service & add in startup
/etc/init.d/nfs start
chkconfig nfs on

Run the below command to check shared directory
showmount -e Server-IP

To mount share directory
mount 172.39.253.28:/home/Shared /mnt

Check mount directory
mount | grep nfs

To mount on reboot
172.39.253.28:/home/Shared /mnt  nfs defauls 0 0
 ........................................................................................

 IMPORTANT
Allow NFS with Fixed ports  on Server

Please add the following lines in  /etc/sysconfig/nfs configuration file on server. Any free port may be specified.
LOCKD_TCPPORT=33776
LOCKD_UDPPORT=33776
MOUNTD_PORT=33777
STATD_PORT=33778
RQUOTAD_PORT=33779
RPCNFSDCOUNT=32

Allow above ports on iptables with default 111 & 2049 ports

Restart NFS service
# service nfs restart
# service nfslock restart

Tuesday, August 19, 2014

Bandwidth Monitoring Tool for Linux

There are lot of tools to do the task, I am using bwm-ng

To install it on FEDORA / CENTOS, use
   
yum -y install bwm-ng

To run it , Type the below command at terminal

    bwm-ng

Use following shortcut to tune bwm-ng

Press + to set time interval, default is set to 0.5 seconds which is too short, make it at least 1.00 or 1.1 to get mroe stable value.

Press u to get DATA in kb (kilobits), default is set to KB (Kilo Bytes)

To see data of eth0, with kilobits, and 1 second refresh rate , use following . . .

    bwm-ng +I eth0 -u bits -t 1000

.......................................................................

You can also try alternate tools like iptraf & netwatch (For IP Based utilization)

Friday, August 8, 2014

"There was a problem sending the command to the program" Error in MS Excel

 While double clicking on excel file you got the error There was a problem sending the command to the program & then you need to open the file manually from File menu.
 
Follow below steps to resolve this issue

Microsoft Excel 2010 and 2013

Click the File tab, and then click Options.
Click Advanced, scroll down to the General section, and then clear the Ignore other applications that use Dynamic Data Exchange (DDE) check box in the General area.
Click OK.

Microsoft Excel 2007

Click the Microsoft Office Button, and then click Excel Options.
Click Advanced, and then clear the Ignore other applications that use Dynamic Data Exchange (DDE) check box in the General area.
Click OK.

Now double click any Excel file & it will open without any error

Wednesday, July 30, 2014

Squid Stop Responding/Slow after some time - "WARNING! Your cache is running out of file descriptors"


Squid working fine for some time after restarting & then suddenly goes very slow. Even taking too much time to open google.co.in

Here are the steps need to check

[root@bhagwat ~]# tail -f /var/log/squid/cache.log

WARNING! Your cache is running out of filedescriptors
WARNING! Your cache is running out of filedescriptors
WARNING! Your cache is running out of filedescriptors
WARNING! Your cache is running out of filedescriptors
WARNING! Your cache is running out of filedescriptors


Please follow the below steps to fix the issue & improve the performance of squid

[root@bhagwat ~]# /etc/init.d/squid stop

##Open below file
v
i /etc/security/limits.conf

##Append following line to increase current limit from 1024 to 4096:

* - nofile 4096

[root@bhagwat ~]# vim /etc/squid/squid.conf

##Add the below line at last of squid.conf file

max_filedesc 8096

Save & quit squid.conf

Now open below file

[root@bhagwat ~]# vim /etc/init.d/squid

##Add this line before any code

ulimit -HSn 4096

save & quit the file

Start squid with below command

[root@bhagwat ~]# /etc/init.d/squid start

Enjoy..... Your issue is resolved.

Saturday, June 28, 2014

Install VNC Server in Centos

Installing TightVNC Server

[root@bhagwat ~]# yum install tigervnc-server

Create 1 User for VNC

[root@bhagwat ~]# useradd bhagwat
[root@bhagwat ~]# passwd bhagwat
Changing password for user bhagwat.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.

Set VNC Password for User

[root@bhagwat ~]# su - bhagwat

[bhagwat@bhagwat ~]$ vncpasswd
Password:
Verify:

[bhagwat@bhagwat ~]$ exit


Now set the Xstarup Resolution

Go to
[root@bhagwat ~]# vi /etc/sysconfig/vncservers

Add the following lines at the bottom of file

## Single User ##
VNCSERVERS="1:bhagwat"
VNCSERVERARGS[1]="-geometry 1024x768"

Save & quit the file

Now start the VNC Server with below command

[root@bhagwat ~]# /etc/init.d/vncserver start
Starting VNC server: 1:bhagwat
New 'bhagwat.imcl:1 (bhagwat)' desktop is bhagwat.imcl:1

Starting applications specified in /home/bhawgat/.vnc/xstartup
Log file is /home/bhagwat/.vnc/bhagwat.imcl:1.log
                                                                                     [  OK  ]


Now Download VNC Viewer from Client machine & enter the VNC Server IP along with VNC ID(1 in our case)
Ex. if VNC server IP is 192.168.4.200 & your VNC ID is 1 then it should be
192.168.4.200:1

Enter password that we created with “vncpasswd” command.

##########
Disable SELinux & iptables if you are not able to access the shared directory