Linux Tips

Cron Example 

45 7-19/2 * * * /admin/monitor.sh

above cron will run for every 2 hours from 7 to 19 @45 mins

NTP time sync with particular ntp server

Set the system time initially by executing:

#ntpdate -b 10.138.15.160

Dmidecode commands

dmidecode -t  bios
dmidecode -t  system
dmidecode -t  baseboard
dmidecode -t  chassis
dmidecode -t  processor
dmidecode -t  memory
dmidecode -t  cache
dmidecode -t  connector
dmidecode -t  slot

Find commands :

find . | xargs grep ‘mysql’ -sl

find /path/to/files* -mtime +90 -exec ls -l {} \;

find . -type f -printf %p”;” | xargs -d “;” ls -lt | head  ————latest files

SED Examples :

Using ‘sed’ to find and replace :

#sed -i -e 's/foo/bar/g' filename

Replace only if the file name matches another string / has a specific extension / is of a certain type etc :

#sed -i -- 's/foo/bar/g' *vrk* ## all files whose name contains vrk

#sed -i -- 's/foo/bar/g' *.pp ## files ending in .pp

Some more commands

useradd -p $(openssl passwd -1 $PASS) $USER

set the file time to 2 hours ago

touch -t 201509141120 t.tmp

How to list all files in the size order

#ls -lrS

Single user mode in Ubuntu

=======================
rw init=/bin/bash
ctrl+x

sync
reboot -f

==================

Ubuntu Network & Hostname config:-
^^^^^^^^^^^^^^^^^^^^^^^^^^
1)Config Static IP in “/etc/network/interfaces”
2)config hostname in “/etc/hostname & /etc/hosts”.

Samba Commands 

To see samba users : pdbedit -L -v
To test samba configuration : testparm

To flush DNS cache in Microsoft Windows (98, 2000, XP, Vista, 7):

  • Go to Start -> Run -> type in cmd
  • from command prompt, type ipconfig /flushdns
  • that will reset your DNS cache

To flush DNS cache on Mac OSX (Leopard):

  • type lookupd -flushcache in the terminal window
  • that will reset your DNS cache

To flush DNS cache on Mac OSX:

  • type dscacheutil -flushcache in your terminal window
  • that will reset your DNS cache

To flush DNS cache on a Linux box you need to restart the nscd service/daemon:

  • type /etc/rc.d/init.d/nscd restart the terminal window
  • that will reset your DNS cache