Tuesday, November 15, 2005

Linux Cool Commands

Linux Conversion: Tutorial - Convert from Red Hat to Debian Remotely.

CPU Information: View CPU Information including processor, vendor_id, cpu family, model, model name, stepping, cpu MHz, cache size, physical id and much more

cat /proc/cpuinfo

Memory Information: View memory information

cat /proc/meminfo
total: used: free: shared: buffers: cached:
Mem: 2104721408 1756086272 348635136 0 171274240 632188928
Swap: 2097434624 23314432 2074120192
MemTotal: 2055392 kB
MemFree: 340464 kB
MemShared: 0 kB
Buffers: 167260 kB
Cached: 607604 kB
SwapCached: 9768 kB
Active: 741528 kB
ActiveAnon: 268996 kB
ActiveCache: 472532 kB
Inact_dirty: 212624 kB
Inact_laundry: 45804 kB
Inact_clean: 38408 kB
Inact_target: 207672 kB
HighTotal: 1179520 kB
HighFree: 323304 kB
LowTotal: 875872 kB
LowFree: 17160 kB
SwapTotal: 2048276 kB
SwapFree: 2025508 kB
Committed_AS: 484020 kB
HugePages_Total: 0
HugePages_Free: 0
Hugepagesize: 2048 kB


Partition Tables Information: list partition tables for devices listed in /proc/partitions
-l List the partition tables for the specified devices and then exit. If no devices are given, those mentioned in /proc/partitions (if that exists) are used. - man fdisk)

fdisk -l
[root@plain scripts]# fdisk -l

Disk /dev/sda: 73.4 GB, 73407820800 bytes
255 heads, 63 sectors/track, 8924 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 268 2048287+ 82 Linux swap
/dev/sda3 269 399 1052257+ 83 Linux
/dev/sda4 400 8924 68477062+ f Win95 Ext'd (LBA)
/dev/sda5 400 8924 68477031 83 Linux

Disk /dev/sdb: 73.4 GB, 73407820800 bytes
255 heads, 63 sectors/track, 8924 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sdb1 1 8924 71681998+ 83 Linux

Disk /dev/hda: 200.0 GB, 200049647616 bytes
255 heads, 63 sectors/track, 24321 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/hda1 1 24321 195358401 83 Linux

Disk /dev/hdb: 200.0 GB, 200049647616 bytes
255 heads, 63 sectors/track, 24321 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/hdb1 1 24321 195358401 83 Linux


Restart sendmail: You can also you stop and start instead of restart.

/etc/rc.d/init.d/sendmail restart
# OR
service sendmail restart




text

CODE


text

CODE


text

CODE


text

CODE



Resources:
Reference Sheets: HTTP Status Codes, Top Level Domains reference sheet, Shell commands, Packet Forwarding, RFC 1812 - IP v4 Routers, IP SySCTL, TCP Tuning, TCP Whitepaper, Tuning Server

How to Install / Upgrade Apache 2.0 (Apache2)

While I prepare a detailed how-to guide about installing and upgrading Apache, checkout How to upgrade to Apache 2.0 on EV1 forums.



SMART Disks - Controlling and monitoring SMART SCSI disks with smartctl

What are SMART disks?


SMART is an abbreviation for Self-Monitoring, Analysis and Reporting Technology (SMART). SMART system is built into many ATA-3, ATA, IDE and SCSI-3 hard drives.

What is smartctl?
According to manual entry for smartctl,
smartctl is a command line utility designed to perform SMART tasks such as printing the SMART self-test and error logs, and enabling and disabling SMART automatic testing. Note: if the user issues a SMART command that is (apparently) not implemented by the device, smartctl will print a warning message but issue the command anyway. This should not cause problems: unimplemented SMART commands issued to a drive are ignored and return an error.


Check the health of a disk drive with smartctl

To check the health of a disk drive, use smartctl with -H option.

What does the -H option for smartctl do?
Again, the "man" is your best friend. The -H option checks for system health:


-H, --health
Check: Ask the device to report its SMART health status or pending TapeAlert messages. SMART status is based on information that it has gathered from online and offline tests, which were used to determine/update its SMART vendor-specific Attribute values. TapeAlert status is obtained by reading the TapeAlert log page.

If the device reports failing health status, this means either that the device has already failed, or that it is predicting its own failure within the next 24 hours. If this happens, use the â-aâ option to get more information, and get your data off the disk and someplace safe as soon as you can.


Here is how you would check the health of a hard disk device. Note, the hard disk drive temperatures in the output

[root@plain scripts]# smartctl -H /dev/sda
smartctl version 5.1-11 Copyright (C) 2002-3 Bruce Allen
Home page is http://smartmontools.sourceforge.net/

SMART Sense: Ok!
Current Drive Temperature: 34 C
Drive Trip Temperature: 65 C
Manufactured in week 34 of year 2002
Current start stop count: 93 times
Recommended start stop count: 10000 times


We can use the -a option to print all SMART information about the disk device.


[root@plain scripts]# smartctl -a /dev/sda


smartctl version 5.1-11 Copyright (C) 2002-3 Bruce Allen
Home page is http://smartmontools.sourceforge.net/

Device: FUJITSU MAP3735NP Version: 5605
Serial number: UPG3P28001M1
Device type: disk
Local Time is: Tue Nov 15 20:14:03 2005 CST
Device supports SMART and is Enabled
Temperature Warning Enabled
SMART Sense: Ok!
Current Drive Temperature: 34 C
Drive Trip Temperature: 65 C
Manufactured in week 34 of year 2002
Current start stop count: 93 times
Recommended start stop count: 10000 times

Error counter log:
Errors Corrected Total Total Correction Gigabytes Total
delay: [rereads/ errors algorithm processed uncorrected
minor | major rewrites] corrected invocations [10^9 bytes] errors
read: 0 1027 0 0 0 60202.631 0
write: 0 1 0 0 0 15293.201 0
verify: 0 0 0 0 0 0.000 0

Non-medium error count: 168

SMART Self-test log
Num Test Status segment LifeTime LBA_first_err [SK ASC ASQ]
Description number (hours)
# 1 Background long Completed - 0 - [- - -]
# 2 Background short Completed - 0 - [- - -]

Long (extended) Self Test duration: 2191 seconds [36.5 minutes]


If your disk has encountered any errors, they should appear in the output. To check your hard drive for bad sectors, use


badblocks -v /dev/sda





smartctl

hostname - Changing server host name

Before starting ensure that your desired hostname is resolving to the server and read the disclaimer below. Steps in changing the hostname on a plain Red Hat Enterprise Linux server are:

1. Modifying /etc/sysconfig/network (replace XXX.XXX.XXX.XXX with your gateway IP )

NETWORKING=yes
HOSTNAME="plain.ev1servers.net"
GATEWAY="XXX.XXX.XXX.XXX"
GATEWAYDEV="eth0"
FORWARD_IPV4="yes"


2. Modify /etc/hosts (
replace YYY.YYY.YYY.YYY with server ip)
replace server1.company.com with your server name.
replace server1 with your first part of your desired hostname.

127.0.0.1 localhost.localdomain localhost
YYY.YYY.YYY.YYY server1.company.com server1


3. restart kernel logging services

/etc/rc.d/init.d/syslog restart


4. To verify, type the following at prompt

hostname



Disclaimer: Please use this only if you know what you are doing. I take no responsibility if something breaks on your server.

Tags: