Tuesday, August 28, 2012

BIOS Information


how to get BIOS info without rebooting the system. The command for this is dmidecode(DMI table decoder). Some times BIOS is called as DMI too. Just execute the command, It will just dump lots and lots of information about the sytem.
#dmidecode
To get more presised/cliped information for particular category such as only BIOS or only hardware or only RAM details or just only CPU info we have to specify the type(–tyep or -t option), here are the types list for your reference.
DMI TYPES
The SMBIOS specification defines the following DMI types:
Type Information
—————————————-
0 BIOS
1 System
2 Base Board
3 Chassis
4 Processor
5 Memory Controller
6 Memory Module
7 Cache
8 Port Connector
9 System Slots
10 On Board Devices
11 OEM Strings
12 System Configuration Options
13 BIOS Language
14 Group Associations
15 System Event Log
16 Physical Memory Array
17 Memory Device
18 32-bit Memory Error
19 Memory Array Mapped Address
20 Memory Device Mapped Address
21 Built-in Pointing Device
22 Portable Battery
23 System Reset
24 Hardware Security
25 System Power Controls
26 Voltage Probe
27 Cooling Device
28 Temperature Probe
29 Electrical Current Probe
30 Out-of-band Remote Access
31 Boot Integrity Services
32 System Boot
33 64-bit Memory Error
34 Management Device
35 Management Device Component
36 Management Device Threshold Data
37 Memory Channel
38 IPMI Device
39 Power Supply
Here is some examples.
Note : In RHEL4 there are no options for dmidecode command.
To find only BIOS info
#dmidecode –t 0
[root@test ~]# dmidecode –type 0
# dmidecode 2.7
SMBIOS 2.5 present.

Handle 0×0000, DMI type 0, 24 bytes.
BIOS Information
Vendor : Phoenix Technologies, LTD
Version : MS7352 1.14
Release Date : 09/03/2008
Address : 0xE0000
Runtime Size : 128 kB
ROM Size : 1024 kB
Characteristics:
ISA is supported
PCI is supported
PNP is supported
APM is supported
BIOS is upgradeable
BIOS shadowing is allowed
Boot from CD is supported
Selectable boot is supported
BIOS ROM is socketed
EDD is supported
5.25″/360 KB floppy services are supported (int 13h)
5.25″/1.2 MB floppy services are supported (int 13h)
3.5″/720 KB floppy services are supported (int 13h)
3.5″/2.88 MB floppy services are supported (int 13h)
Print screen service is supported (int 5h)
8042 keyboard services are supported (int 9h)
Serial services are supported (int 14h)
Printer services are supported (int 17h)
CGA/mono video services are supported (int 10h)
ACPI is supported
USB legacy is supported
LS-120 boot is supported
ATAPI Zip drive boot is supported
BIOS boot specification is supported
Function key-initiated network boot is supported
Targeted content distribution is supported
BIOS Revision: 1.14
Even we can specify keyword for specifying type if you forget the type number, so just type the keyword to check particular property of the styem.
Keyword Types
——————————
bios 0, 13
system 1, 12, 15, 23, 32
baseboard 2, 10
chassis 3
processor 4
memory 5, 6, 16, 17
cache 7
connector 8
slot 9

Suppose we want to see system details
[root@test ~]# dmidecode –type system
# dmidecode 2.7
SMBIOS 2.5 present.
Handle 0×0001, DMI type 1, 27 bytes.
System Information :Manufacturer : Hewlett-Packard
Product Name : HP Compaq dx7400 Microtower
Version:
Serial Number: SGH83801NJ
UUID: 809AF9C0-17F0-1310-9511-C4681D1F835D
Wake-up Type: Power Switch
SKU Number: GD384AV
Family: 103C_53307F
Handle 0×0024, DMI type 32, 11 bytes.
System Boot Information
Status: No errors detected
[root@test ~]#
Some other useful commands to get system info are
To get CPU info
#cat /etc/cpuinfo
To get HW info
#lshal
or 
#lshw
To get PCI info
#lspci
To get USB info
#lsusb

Nmap (Port Checker)


NMAP is one of the most important tool. Which checks which ports are open on a machine.
Some important to note about NMAP
  1. NMAP abbreviation is network mapper
  2. NMAP is used to scan ports on a machine, either local or remote machine (just you require ip/hostname to scan).
  3. NMAP is can be installed on windows, Sun Solaris machines too.
  4. NMAP can be used to scan large networks, remember I am saying large networks.
  5. NMAP can be used to get operating system details, uptime, software used for a service and its version no, vender of network card and uptime of that system too(Don’t worry we will see all these things in this post.
  6. Please do not try to use NMAP on machines which you don’t have permission.
  7. Can be used by hackers to scan for systems for venerability.
  8. Just a funny note : You can see this NMAP used by trinity in Matrix-II, when she tries to hack in to electric grid super computer.
Note : NMAP man pages one of the best man pages I have come across. It is explained in such a way that even new user can understand it easily and one more thing it is even having examples in to how to use NMAP in different situations, when you have time read it. You will get lots of information.

Example1 : Using NMAP in normal way, i.e. to scan a particular system for open ports
#nmap hostname
Example2 : Scanning for a single port on a machine
#nmap –p 22 hostname
This will scan for 22 port is open on a host or not. And here –p indicates port.
Example3 : For scanning only ports
#nmap –F hostname
-F is for fast scan and this will not do any other scanning like IP address, hostname, operating system, and uptime etc. It’s very much fast as it said in man pages.
Example4 : For scanning only TCP ports
#nmap –sT hostname
Here s is for scanning and is for only scanning of TCP ports
Example5 : For scanning only UDP ports
#nmap –sU hostname
Here indicates UDP port scanning
Exmaple6 : Scanning for ports and to get what is the version of different services running on that machine
#nmap –sV hostname
V indicates version of each network service running on that host
Example7 : To check which protocol is supported by the remote machine
#nmap –sO hostname
Example8 : To scan a system for operating system and uptime details
# nmap -O hostname
-O
 is for operating system scan along with default port scan
Example9 : Scanning a network
#nmap networkID/subnetmask
For the above command you can try in this way
#nmap 192.168.0.0/24

Thursday, March 29, 2012

lsof command with examples

lsof command with examples

lsof stands for list open files. Which will list information about files opened by processes.


Command to show all opened Internet sockets
#lsof -i

Command to print all tcp connections
#lsof -i tcp

Command to print all udp connections
#lsof -i udp

Command to find who are the users using the folder right now
#lsof +D /tmp

Command to print who and what are the files using in /dev/sda5 partitions
#lsof /dev/sda5

Command to list all the files associated with process ID 2665
#lsof +p 2665

Command to listing of files for processes executing the command that begins with vmstat
#lsof -c vmstat

Listing of files for processes executing the command that begins with character a
#lsof -c a

Command to print all the files opened by the user rajkumar
#lsof -u rajkumar

Scenario:
========

Suppose consider that you are usnig nfs to transfer files between multiple systems in you local LAN. Assume that the folder which shares for NFS is /sharing, if you what to find out who all are the user’s using the folder means use the below command

#lsof +D /sharing

The above command will display who all the user’s using the folder right now.

Monday, January 9, 2012

How to Exclude a specific package not to update in RHEL

# vim /etc/yum.conf

Append below line at the end of a file.

exclude=httpd-2.2.17-1.fc14.
i686

Or

exclude=httpd*

Save and exit the file.tt

Now update your system using yum. YUM will exclude httpd package updates.

Mount remote machine file system on local machine through ssh

SSH (Secure Shell) is a network protocol that allows secure communication between two network devices. Normally, we use ssh to access Linux and Unix based system shell remotely. But we can also use ssh to mount remote machine file system on local machine. For that you need to install SSHFS packaged on your machine. SSHFS is a filesystem client based on the SSH File Transfer Protocol.
Install sshfs via YUM,

# yum install sshfs -y

 
Or install sshfs via APT,

# apt-get install sshfs

 
If you want to mount /root partition of 192.168.0.1 server then,
First create a mount point


# mkdir /mnt/root

 
Then run sshfs as,


# sshfs root@192.168.0.1:/root /mnt/root

 

How to extract a specific file From RPM Without installing:-

By mistake If u have deleted /sbin/poweroff file from system.
How to find the RPM has this /sbin/poweroff

# yum whatprovides /sbin/poweroff

systemd-sysvinit-10-2.fc14.1.
i686 contains /sbin/poweroff in Fedora 14.

Now, if you try to install that package using yum, we will get “Package systemd-sysvinit-10-2.fc14.1.
i686 already installed and latest version”.

To restore /sbin/poweroff, all we need is systemd-sysvinit-10-2.fc14.1.
i686.rpm and rpm2cpio, this is bundled with rpm-x.x.x…i386.rpm.

# rpm -ql rpm | grep rpm2cpio
/usr/bin/rpm2cpio

/usr/lib/rpm/rpm2cpio.sh

/usr/share/man/ja/man8/
rpm2cpio.8.gz

/usr/share/man/ko/man8/
rpm2cpio.8.gz

/usr/share/man/man8/rpm2cpio.
8.gz

/usr/share/man/pl/man8/
rpm2cpio.8.gz

/usr/share/man/ru/man8/
rpm2cpio.8.gz

# rpm2cpio systemd-sysvinit-10-2.fc14.1.
i686.rpm | cpio -idmv

# cp sbin/poweroff /sbin/

Note: There is another way to install systemd-sysvinit-10-2.fc14.1.
i686.rpm by forcefully installing it.

# rpm -ivh systemd-sysvinit-10-2.fc14.1.
i686.rpm –force

How to restore the DELETED Files in Linux

After deleting a file from your computer, it goes straight into the Trash bin. If you want to get that file back then you can get it by restoring it from the Trash bin.

If you want to delete it permanently, delete it from the Trash bin. You can then run the following command to do the trick,

# rm-rf /home/USER/.local/share/Trash/info/*

# rm-rf /home/USER/.local/share/Trash/
files/*