date -d '1 day ago' +"%Y-%m-%d"
Linux administration , Unix administration , Vmware Vsphere administration , Oracle DBA ,apache, backup, dhcp, dns, kvm, xen, kernel, ldap, kvm, monitoring, ticketing, networking, Mail servers, SAN,troubleshooting
Labels
- Amanda (2)
- Ansible (2)
- Answer these Questions (2)
- antivirus (2)
- apache (3)
- Bash (16)
- Chef (3)
- Citrix (2)
- clusters (2)
- Concept (22)
- DatabaseAdminstration (11)
- DevOps (1)
- dhcp (2)
- Downloads (3)
- ELK (1)
- ELK stack (1)
- encryption (1)
- Free trainings (1)
- Frequently Used Commands (46)
- FTP (1)
- git (1)
- gpg (2)
- Hardware (1)
- httpd (2)
- Interview Questions (53)
- iptables (1)
- IT NEWS (3)
- java (1)
- kibana (2)
- knife (1)
- KVM (2)
- linux (17)
- Linux installations (22)
- Linux Jobs (4)
- Linux Links (2)
- logstash (1)
- Mac (1)
- MediaWiki (1)
- MySql (2)
- Nagios (2)
- Networking (3)
- open Nebula (5)
- Open Source tools (12)
- OpenNMS (1)
- openSSL (1)
- Oracle on Linux (5)
- Performance Monitoring (1)
- php (1)
- postfix (1)
- postgres (1)
- postgres-XL (1)
- Product Reviews (1)
- Python (2)
- rssh (1)
- Samba (2)
- Scripting (16)
- security (4)
- selinux (1)
- Server (1)
- SFTP (1)
- Social Awareness (1)
- Solaris (1)
- SSL (1)
- svn (1)
- TCP/IP (1)
- Technology (1)
- Tips and Tricks (32)
- Training and materials (8)
- Troubleshooting (6)
- Ubuntu (18)
- unix (1)
- virtualization (17)
- Vmware (25)
- Vyatta (1)
- windows7 (1)
- xml (1)
Linux list all processes based on memory consumption .
list top 5 processes
ps -eo pmem,pcpu,vsize,pid,cmd | sort -k 1 -nr | head -5
list all processes in assending order .
ps -e -orss=,args= | sort -b -k1,1n | pr -TW$COLUMNS
ps -eo pmem,pcpu,vsize,pid,cmd | sort -k 1 -nr | head -5
list all processes in assending order .
ps -e -orss=,args= | sort -b -k1,1n | pr -TW$COLUMNS
easy ntp time sync between servers
Choose one server from which time need to be synced .
then on clinet open /etc/ntp.conf
#server 0.rhel.pool.ntp.org ( comment these three lines )
#server 1.rhel.pool.ntp.org
#server 2.rhel.pool.ntp.org
server 10.10.10.180 ( this is the server which i choose so all other servers will be in sync with this server )
then on clinet open /etc/ntp.conf
#server 0.rhel.pool.ntp.org ( comment these three lines )
#server 1.rhel.pool.ntp.org
#server 2.rhel.pool.ntp.org
server 10.10.10.180 ( this is the server which i choose so all other servers will be in sync with this server )
/usr/sbin/ntpdate -s -b -p 8 -u 10.10.10.180
/etc/init.d/ntpd restart
Other commands that are used for NTP are
ntpdate -u 10.10.10.180
output : ntpdate[13786]: adjust time server 10.10.10.180 offset 0.000221 sec
ntpdate -d 10.10.10.180
output : output will be more in detail
ntpdate[13806]: ntpdate 4.2.2p1@1.1570-o Thu Nov 26 11:34:35 UTC 2009 (1)
Looking for host 10.10.10.180 and service ntp
host found : 10.10.10.180
transmit(10.10.10.180)
receive(10.10.10.180)
transmit(10.10.10.180)
receive(10.10.10.180)
transmit(10.10.10.180)
receive(10.10.10.180)
transmit(10.10.10.180)
receive(10.10.10.180)
transmit(10.10.10.180)
server 10.10.10.180, port 123
stratum 3, precision -20, leap 00, trust 000
refid [10.10.10.180], delay 0.02583, dispersion 0.00000
transmitted 4, in filter 4
reference time: d5b8497a.219236b6 Fri, Aug 16 2013 12:17:22.131
originate timestamp: d5b849c8.3769d786 Fri, Aug 16 2013 12:18:40.216
transmit timestamp: d5b849c8.37669489 Fri, Aug 16 2013 12:18:40.216
filter delay: 0.02588 0.02585 0.02585 0.02583
0.00000 0.00000 0.00000 0.00000
filter offset: -0.00006 -0.00007 -0.00006 -0.00007
0.000000 0.000000 0.000000 0.000000
delay 0.02583, dispersion 0.00000
offset -0.000070
16 Aug 12:18:40 ntpdate[13806]: adjust time server 10.10.10.180 offset -0.000070 sec
ntpq -p
How to copy directory structure in linux
Sometimes we need to copy only directory structure leaving content ( files )
find . -type d >dirs.txt
xargs mkdir -p
find . -type d >dirs.txt
xargs mkdir -p
Script to import csv into dhcpd.conf import multiple mac bindings
make sure your csv file is in this order MAC,IP,NAME and file name of csv is ips.csv
Once that is done just run the script and check mac_out.txt which is file to be imported in dhcpd.conf
!/bin/bash
INPUT=ips.csv
OUTPUT=mac_out.txt
OLDIFS=$IFS
IFS=","
[ ! -f $INPUT ] && { echo "$INPUT file not found"; exit 99; }
[ -f $OUTPUT ] && { rm $OUTPUT; }
[ ! -f $OUTPUT ] && { touch $OUTPUT; }
while read mac ip uname
do
echo "host $uname {" >> $OUTPUT
echo -e "\thardware ethernet $mac;" >> $OUTPUT
echo -e "\tfixed-address $ip;" >> $OUTPUT
echo "}" >> $OUTPUT
done < $INPUT
IFS=$OLDIFS
Once that is done just run the script and check mac_out.txt which is file to be imported in dhcpd.conf
!/bin/bash
INPUT=ips.csv
OUTPUT=mac_out.txt
OLDIFS=$IFS
IFS=","
[ ! -f $INPUT ] && { echo "$INPUT file not found"; exit 99; }
[ -f $OUTPUT ] && { rm $OUTPUT; }
[ ! -f $OUTPUT ] && { touch $OUTPUT; }
while read mac ip uname
do
echo "host $uname {" >> $OUTPUT
echo -e "\thardware ethernet $mac;" >> $OUTPUT
echo -e "\tfixed-address $ip;" >> $OUTPUT
echo "}" >> $OUTPUT
done < $INPUT
IFS=$OLDIFS
How to drop cache or in-memory cache on linux and free up some memory ?
$ echo 1 | sudo tee /proc/sys/vm/drop_caches # drop pagecache $ echo 2 | sudo tee /proc/sys/vm/drop_caches # drop dentries and inodes $ echo 3 | sudo tee /proc/sys/vm/drop_caches # drop pagecache, dentries and inod
Also we can use
echo 1 > /proc/sys/vm/drop_caches
echo 2 > /proc/sys/vm/drop_caches
echo 3 > /proc/sys/vm/drop_caches
This is also used when we take benchmarks of server.
Subscribe to:
Posts (Atom)