Friday, March 25, 2011

Some Day to day tips on Linux

== Unix and Linux Tips for day to day trouble shooting ==

**To know your Linux Distro and the Version
 more /etc/redhat-release                                    

**memory information
 free -m

**Command to get the files based on size (Unit is blocks )
 find . -size +10000 -exec ls -l {} \;

**To find paTterns in Files
 find . -name "log_200812*" -exec grep FS8LM {} \; -print

**remote connecting to another machine and executing a command using telnet.
 (sleep 3; echo username; sleep 3; echo password; sleep 5; echo "ls -l"; sleep 3; echo "exit") | telnet hostname

**tar- the archive utility
 tar tvf filename.tar   ---  View the table of content of a tar archive
 tar xvf filename.tar   --- Extract content of a tar archive
 tar cvf filename.tar  file1 file2  file3 --- Create a tar archive called filename.tar using file1, file2,file3 .
 tar can't copy the special files , device files .Not suitable for taking root backup.

**VI editor - Find and replace
 To find & replace all occurances of a particular text string, use the command:
    :%s/text1/text2/g[RETURN]
 which replaces all occurances of text1 with text2.

**Advanced GREP
 To display all lines in the file1 file that match either the abc or xyz string, enter: grep -E "abc|xyz" file1

**the cut tab delimiter technique  to extract each field when doing an ls -l command
 ls -la |tr -s ' '|cut -d' ' -f5,8

**list all open files
 lsof

**list down the FolderSize of all the folders inside the current folder
 du -h -c --max-depth=1 2>/dev/null

**finding files more than a particularr size
find . -size +100000k -mtime +60 -exec ls -al '{}' \;
                   
**Tell how long the system has been running and list thee load average value.
 uptime
 e.g
 diham@diham] uptime                                                                        
 19:48:11  up 9 days, 19:56,  2 users,  load average: 0.00, 0.00, 0.00

**Copying file to host:
 scp SourceFile user@host:directory/TargetFile

**Copying file from host:
 scp user@host:directory/SourceFile TargetFile

**The Crontab : Master of UNIX scheduling
 crontab -e -> edit the crontab
 crontab -l -> list the crontab entries
 crontab -r -> remove the cron file
 crontab -v -> last edited time of cron file

 The entries in the file are
 *        *      *        *     *   command
 minute hour dayofmonth  month week command

 e.g
 0,15,30,45 * * * * /home/user/mycommand1        --> runs the mycommand1 every 15 mins

** '''Run Level Commands'''

The init process is the last step in the boot procedure and identified by process id "1". Init is responsible for starting system processes as defined in the /etc/inittab file.The init process is never shut down. It is a user process and not a kernel system process although it does run as root.

    *  Shutdown:
          o init 0
          o shutdown -h now
                + -a: Use file /etc/shutdown.allow
                + -c: Cancel scheduled shutdown.
          o halt -p
                + -p: Turn power off after shutdown.
          o poweroff
    * Reboot:
          o init 6
          o shutdown -r now
          o reboot
    * Enter single user mode:
          o init 1

** ldconfig
 ldconfig - Updates the Symbolic links in /usr/lib , /lib and and directories mentioned in the file  /etc/ld.so.conf

**Unpacking RPM
 rpm2cpio libstdc++-4.3.2-7.i386.rpm|cpio -i --make-directories

Friday, October 9, 2009

fstab

add the entires like this to the fstab /etc/fstab for mounting the disks automatically on logon.

/dev/sda3 /media/disk ntfs relatime,errors=remount-ro 0 1
/dev/sda2 /media/disk-1 ntfs relatime,errors=remount-ro 0 1

Friday, September 4, 2009

Saturday, August 15, 2009

GRUB Error 22

GRUB Error 22

This happens in a dual boot system where Windows and Linux is installed. If you would have deleted any of the linux partitions then, GRUB will be looking for that linux partitions while booting but wont be able to find it out. This is the solution that i could gather from the internet and it worked fine for me.

For those who are having this problem but have Vista instead of XP, you have to re-install Boot Loader.

Boot up from Vista Installation DVD and select Repair your Computer.(its below Install Icon).Select Windows Vista and select Command Prompt.

execute this code:

bootrec.exe /fixmbr
bootrec.exe /fixboot

close command prompt window and restart.

Courtesy : NeoForums

Monday, July 13, 2009

Enjoying the Freedom of Open Source with Fedora


My Fedora KDE 10 Desktop..Its a great feeling to use open source. Thanks a lot for the guys behind it!!