Tuesday, October 17, 2006

Linux Command To Check System Profile

Linux system administrator and experienced users might interested in getting a Linux server profile in order to understand how the Linux system being setup, what is the server hardware specification, what are the software packages or drivers being installed, does it need to be patched or upgraded, etc.

  • less /etc/sysconfig/hwconf to get installed hardware information.
  • less /proc/cpuinfo to get installed CPUs specification.
  • less /var/log/dmesg or dmesg to get the Linux boot up information.
  • less /proc/interrupts to list the IRQ used by system devices.
  • less /proc/ioports to list I/O ports used by system.
  • less /proc/dma to list DMA channels and device used by system.
  • less /proc/version or uname -a or less /etc/redhat-release or lsb_release -a to show the Linux version.
  • kudzu -p to show the probe information about hardware detected
  • /usr/bin/lsdev to list devices and information on system hardware.
  • /sbin/lspci to list detected PCI devices.
  • /sbin/lsmod to list loadable modules.
  • /sbin/lsraid to list raid device.
  • /sbin/lsusb to list USB device.
  • /sbin/usbmodules to list kernel driver modules available for USB devices.
Related information:
  • Search more related info with Google Search engine built-in

Using find Command By Examples

The find command is a Linux command that is used to search for files in the Linux file system. In fact, it is a standard shell command that exists in most Linux/Unix variants.

Using find command by examples

  • To search for all files that end with .sh, from the root directory down to all sub directories. Execute the find command as

    find / -name "*.sh" -print

  • To search for all files that end with .sh, from both the dir1 and dir2 directories, and change the file permission mode to 755 for those matching files. Execute the find command as

    find dir1 dir2 -name "*.sh" -exec chmod 755 {} \;

  • To search for all files that contains case-sensitive search term ABC, from the root directory down to all sub directories. Execute the find command as

    find / -name "*" -exec grep -H "ABC" {} \;

    To narrow down the scope of file searching as well as speed up the searching efficiency, rewrite the find command as

    find / -type f -name "*" -exec grep -H "ABC" {} \;

    to get find command search for regular file only instead of all file type that exists in the file system.
    Using the grep command by understanding grep command option switches

    grep -HIirls ABC *

    1. to search all files from the current directory that contain the search pattern ABC
    2. -H to print out filename
    3. -I to ignore binary file
    4. -i to search case-insensitive
    5. -r to search recursively from the directory to all sub directories
    6. -l to show file name once only for the file that containing the search pattern and exit from further search when the first match of pattern found in the file
    7. -s to suppress any errors message about non-existent or unreadable file
    Others forms of Linux command that serve the same purpose could be

    find / -type f -print | xargs grep -H "ABC" /dev/null
              or
    egrep -r "ABC" *

  • To search for all files that are 1000KB (1MB) in file size, from the root directory down to all sub directories. Execute the find command as

    find / -size 1000k -print

  • To search for all files that are greater than 1MB in file size, from the root directory down to all sub directories. Execute the find command as

    find / -size +1000k -print

  • To search for all files that are between 1MB and 2MB (inclusive) in file size, from the root directory down to all sub directories. Execute the find command as

    find / -size +1000k -size -2000k -print

    Note! Use the +/- sign to indicate range, which apply to the time related quantity, as showing below.

  • To search for all files that are own by user ID 501, from the root directory down to all sub directories. Execute the find command as

    find / -user 501 -print

  • To search for all files that are created less than five minutes ago, from the root directory down to all sub directories. Execute the find command as

    find / -cmin -5 -print

    This form of find command is useful to find out the effects of system change after installing or updating Linux package.
    Linux file creation time vs Linux file modification time

    The Linux file creation refers to a file being created in the file system, changes of file permission, or changes of file ownership.

    Linux file modification time refers to a file last editing time.

    Take a look on the diagram below, which is a snapshot of $HOME/bin directory contents listing.

    Different of Linux file creation time and file modification time

    The ls -la command shows that wdf file modification or last edited time on Sep 29 11:25. Then ls -lc command shows that wdf file creation time on Oct 15 12:26 which is the time the file being extracted from a tarball.
  • To search for all files that are created less than 2 x 24 hours ago, from the root directory down to all sub directories. Execute the find command as

    find / -ctime -2 -print

  • To search for all files that are modified less than five minutes ago, from the root directory down to all sub directories. Execute the find command as

    find / -mmin -5 -print

  • To search for all files that are modified less than 2 x 24 hours ago, from the root directory down to all sub directories. Execute the find command as

    find / -mtime -2 -print

  • To search for all files that are accessed (such as execute the file, view the file using vi, cat, less, etc) less than five minutes ago, from the root directory down to all sub directories. Execute the find command as

    find / -amin -5 -print

  • To search for all files that are accessed less than 2 x 24 hours ago, from the root directory down to all sub directories. Execute the find command as

    find / -atime -2 -print

  • To search for all files that are own by group ID 22, from the root directory down to all sub directories, and change the group ID to 112 for those matching files. Execute the find command as

    find / -group 22 -exec chown :112 {} \;

  • To search for all directories that are global writable, from the root directory down to all sub directories. Execute the find command as

    find / -perm -0002 -type d -print

  • To search for all files that are not own by any user and group, from the root directory down to all sub directories. Execute the find command as

    find / -nouser -o -nogroup -print

  • To search for all directories exists in the file system. Execute the find command as

    find / -type d -print

    The alternative form of commands are

    ls -ap | grep /
    find / -type d -printf "%P\n" apply -printf switch to show directories name only and discarding the leading path.

  • To find the total disk space take up by all tarballs ended with .gz file extension

    find / -type f -name "*.gz" -exec du -k {} \; | awk '{sum+=$1} END {print sum"KB"}'

  • To create CPIO archive backup of dir1 and dir2 directories. Execute the find command as

    find /f1 /f2 -depth -print | cpio -ocvB -O /f2f2.cpio

Related information:

Monday, October 16, 2006

Online English Chinese Dictionary

Forget about that weighty hardcover Oxford English-Chinese dictionary or running virtual CD-ROM drive to read the CD-ROM edition of dictionary.

Dict.cn and Yahoo Dictionary perhaps are the most wanted online English-Chinese and Chinese-English dictionary.

Dict.cn is built by a group of Chinese (from China) who study at USA, and started to offer service since year 2003. Other than online Chinese-English and English-Chinese dictionary service, Dict.cn also offers some other good services, such as

  • Web browser-Dict.cn integration to consult Dict.cn dictionary service easily
  • Dict.cn Web API enable software developer to develop software with dictionary service provided by Dict.cn
  • Dict.cn widget allows webmaster to provide Dict.cn dictionary service easily in his/her website
  • Add MSN Robot MSN ID, that is dictcn021@hotmail.com, to MSN Buddies list! This robot is COOL enough! While chatting in MSN Messenger, IM a word to MSN Robot and the robot will nice to reply the dictionary definition or translated word back.
  • Find out other tools offered by Dict.cn from the link below
Yahoo Dictionary offers similar features of Dict.cn too. In case Dict.cn unavailable, Yahoo Dictionary could be the backup or vice-verse.

Some of the great features offered by these two goodies are

  1. Easy to remember URL.
  2. Reasonable fast search time.
  3. Reasonable clear pronunciation.
  4. Antonym and synonym.
  5. Variants of the search term such as adjective, adverb, verb, etc.
  6. Recent search term.
  7. Auto-listing of words that match the initial characters of search term as typing goes.
  8. List of words that have close spelling.
Related information:
  • Dict.cn is the valid URL - such a short and easy to remember web address of a online Chinese-English English-Chinese dictionary!
  • Dict.cn tools to find out how attractive is Dict.cn!
  • Yahoo English-Chinese Dictionary at HongKong
  • Yahoo English-Chinese Dictionary at Taiwan
  • Really simply and plain interface of English-Chinese dictionary
  • Really fast and simple interface of English-Chinese dictionary
  • For those who are looking for online resources of learning Cantonese and Mandarin, bookmark these two sites
    1. Dictionaries of English-Chinese, Mandarin, and Cantonese
    2. Online Chinese Tools has a list of tools and references of learning Chinese online
  • Search more related info with Google Search engine built-in

PDF Creator vs PDF Viewer

PDF, shorts for Portable Document Format, is an open standard file format developed by Adobe Systems to represent 2D document. Being an open standard file format meaning that anyone may develop application to read and write PDF files without having to pay royalties to Adobe Systems.

PDF is both device independent and resolution independent as it doesn't encode information which is specific to software, hardware, or operating system used to create and view the document. This feature makes a valid PDF file rendering exactly the same regardless of its origin or destination.

Related information:

  • Adobe Reader is the freeware version of PDF viewer provided by Adobe System to view PDF document.

  • PDFCreator is an open source program distributed under GPL GNU license. Don't get it wrong, PDFCreator is not a program that able to edit PDF file as Adobe Acrobat which cost over hundreds pound.

    PDFCreator is a PDF creator, a PDF writer, a PDF maker, a PDF printer, a document-to-PDF converter, etc, but not a PDF editor!

    PDFCreator works exactly like a legacy ASCII file printer device. PDFCreator convert a document to PDF file format when the document is "printed". For example, after finish editing a nice resume in Microsoft Word 2003, click on the print function, select the PDFCreator as the target printer, turn on some great PDF file security features and password encrypted protection, press print button, and finally getting a soft copy of resume in PDF file format.

    Why need to convert Word document to PDF? Besides the points at the top of this article, email both Word and PDF version of resume may make the recruiter more choice to read the resume, that the recipients may not using Microsoft Office at all!

  • Search more related info with Google Search engine built-in

Context Menu Create Date-based Folder

Tired of creating date-based folder daily which is used to save daily reports? Why not create a shortcut on Windows Context menu to simplify the job?

Steps to create the shortcut on Windows Context menu

  1. Click on the My Computer icon on the Desktop
  2. Click on the Tools menu
  3. Click on the Folder Options
  4. Click on the File Types tab
  5. Search for "Folder" file type and highlight it
  6. Click the Advanced button
  7. Click the New button
  8. Type a meaningful name, say DateFolder, in the Action field
  9. Type CMD.EXE /C MD "%1\%%DATE%%" in the Application Used To Perform Action field below the Action field
  10. Click OK button all the way to complete the procedures
  11. Click on the Start button
  12. Click on the Settings menu
  13. Click on the Control Panel
  14. Click on the Regional Options
  15. Click on the Date tab
  16. Set the Short Date Format to a format of date without using characters which are not valid to be used for a file name, such as "/". A valid date format such as dd-MMM-yyyy
  17. Click OK to save the changes, if any.
  18. Now, it is done. Right-click on any folder and click on the DateFolder shortcut, that has just created, from the pop up Windows Context menu.
  19. Bingo! There is a date folder named after the creation date insides the folder that being right-click just now!
Related information:
  • Enable MS-DOS auto-complete filename with TAB key and auto-change path quickly.
  • Search more related info with Google Search engine built-in

Sunday, October 15, 2006

Linux Command To Confirm Bad Sector

Hard disk being one of the vital components in computer system. Unfortunately, hard disk is also being one of the most high risk and sensitive components that is prone to failures, owed to the fact of mechanical subsystem attached!

The Linux command badblocks could be used to run bad sector burn-in test on a new or suspected faulty hard disk. Just get a low end PC or server installed with Linux OS, attach the target hard disk to the IDE or SCSI bus, and run the badblocks command on the target hard disk. For example,

badblocks -svw -t random -p 3 /dev/sdb

get badblocks to perform three rounds of destructive write of random data to the second SCSI hard disk.

Be careful! The option switch -w performs destructive write. Never use this option switch on a partition with filesystem. Instead, use -n to perform non-destructive read-write on a partition with filesystem!

Related information:

  • Search more related info with Google Search engine built-in

Checklist To Tune DB2 Performance

DBA suggests few of the recommended database performance tuning tips for IBM DB2 database engine that is running on Linux server.

  • Linux kernel parameters tuning that applicable to DB2 version 8.1 and 8.2.

    Executing command sysctl -A to print out current kernel parameters setting. Some of the notable are

    • kernel.sem (Semaphore setting)
      Recommended Value : 250 256000 32 1024

    • kernel.msgmni (Maximum system-wide queues)
      Recommended Value : 1024

    • kernel.msgmax (Maximum size of messages in byte)
      Recommended Value : 65536

    • kernel.msgmnb (Default size of queue in byte)
      Recommended Value : 65536

    In order to retain these changes of kernel parameters on every system reboot, add the updated kernel parameters setting to /etc/sysctl.conf system file to do the great job.

  • DB2 database configurable parameters tuning.

    After connecting to database called my_test_db by executing db2 connect to my_test_db, running another DB2 command db2 autoconfigure apply none to get DB2 database engine calculate the best recommended value of DB2 database configurable parameters. Some of the notable are

    • LOGPRIMARY / LOGFILSIZ
      Larger log buffer required for OLTP workloads with high transaction rate.

    • CHNGPGS_THRESH
      For databases with heavy update transaction workloads, make sure there are enough clean pages in the buffer pool by setting the parameter value equal to or less than the best recommended value calculated by DB2 database engine.

    • LOCKLIST
      The amount of storage that is allocated to the lock list. Increase this value if lock escalations causing performance concerns, that logged as warnings in the db2diag.log file.

    • DBHEAP
      Database heap per database. Needs to be increased for larger buffer pools.

    • NUM_IOCLEANERS
      Large buffer pools require a higher number of asynchronous page cleaners.

  • Alternate page cleaning algorithm tuning.

    DB2 UDB ESE v8.2 introduces a new buffer pool page cleaning algorithm which is not turned on by default. It is necessary to test this new page cleaning algorithm with the database workload. To turn on this alternate page cleaning algorithm, executing DB2 command

    db2set DB2_USE_ALTERNATE_PAGE_CLEANING=YES
Related information:
  • Search more related info with Google Search engine built-in