Tuesday, December 25, 2007

Linux Commands

Linux commands which is necessary to knew :
man, ls, locate, find, grep, tail, less, tar, scp, dpkg, which, crontab

To read the detail about commands :
man <command>

To view installed linux version in local system:
cat /etc/issue

About Crontab:
crontab - Schedule a command to run at a later time

Each line in the cron table follows the following format: 7 fields left to right
Field Meaning
1 Minute (0-59)
2 Hour (2-24)
3 Day of month (1-31)
4 Month (1-12, Jan, Feb, ...)
5 Day of week (0-6) 0=Sunday, 1=Monday ...or Sun, Mon, Tue, Wed, Thur, Fri
6 User that the command will run as
7 Command to execute

Example

Run /usr/bin/somecommand at 12.59 every day and supress the output (redirect to null)

59 12 * * * simon /usr/bin/somecommand >> /dev/null 2>&1

Fix bad sector problem in linux  '
http://www.howtogeek.com/howto/37659/the-beginners-guide-to-linux-disk-utilities/

List the partitions in your linux box using command below 
fdisk -l

diagnose the health of our hard disk (S.M.A.R.T System GUI tool does fsck task)

fsck (Before you run fsck do unmount on the paritition) 

sudo umount /dev/sdb (Replace /dev/sdb1 with your paritition)

This command checks an ext4 file system (/dev/sdb) for inconsistencies
sudo fsck -t ext4 /dev/sdb (Replace /dev/sdb1 with your paritition)

Bad blocks:
Badblock will give us the number of bad sectors in our hard disk.

sudo badblocks -v /dev/sdb1 (Replace /dev/sdb1 with your paritition)

Once you found bad blocks you have 2 options :
1. Buy a new hard disk
2. mark these bad blocks as unusable hard disk sectors

First we have to write the location of the bad sectors into a flat file.
sudo badblocks /dev/sdb > /home/zainul/bad-blocks

After that, we need to feed the flat file into the FSCK command to mark these bad sectors as ‘unusable’ sectors.
sudo fsck -l bad-blocks /dev/sdb 

No comments :

// Below script tag for SyntaxHighLighter