grep -rl 'pc961' ./|xargs sed -i 's/pc961/pc/g'
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)
Showing posts with label Frequently Used Commands. Show all posts
Showing posts with label Frequently Used Commands. Show all posts
Three basic Git commands
1) git add -A
git add -A is equivalent to git add .; git add -u.
git add . ( This will add all files but does not remove files )
git add -u ( This will add only changes but will not add any new files created )
So we use
git add -A ( this will take care of both the commands )
2) git commit -m “Commit changes text ex: I have added new function xyz to the file
3) git push origin
example of branch name : develop
Another 3 frequently used commands include :
git pull
git status
git merge origin/Branchname
Get SSL certificate expire date / Openssl get certificate expire date
openssl x509 -in /home/certificates/certname.crt -noout -enddate
Linux grep a process and kill all process id's
kill -9 `ps -ef | grep ProcessName | grep -v grep | awk '{print $2}'`
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
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
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.
Get CPU RAM MEMORY of all the servers on the network
In order to accomplish this you have to have an account with password less login for all the server on the network you want to retrieve data
Here is my tutorial for password less login
Create a file "ips" which should contain all the ip's you want to retrive data for ( 1 ip per line )
for i in `cat ips`;do ssh -t $i 'echo -e -n `uname -n `" '$i' " ;cat /proc/cpuinfo | grep "cpu cores" | uniq';done > cpucores
( This one will not work in single core cpu's or vm's )
for i in `cat ips`;do ssh -t $i 'echo -e -n `uname -n `" '$i'" ;grep MemTotal /proc/meminfo ';done > Mem_details
for i in `cat ips`;do ssh -t $i 'echo -e -n `uname -n `" '$i' " ; sudo /sbin/fdisk -l | grep Disk ';done >hdd_details
( This one will not work in single core cup's or vm's )
After you run all the three commands you will have three files in your directory
1) cpucores - list servername ip-address and number of cores
2) Mem_details - list servername ip-address and memory details in kb
3) hdd_details - list servername ip-address and drive and size.
Single command to get CPU usage % in linux
top -bn1 | grep "Cpu(s)" | sed "s/.*, *\([0-9.]*\)%\id.*/\1/" | awk '{print 100 - $1"%"}'
How to check syntax of dhcpd (dhcpd.conf file )
/usr/sbin/dhcpd -t -cf /etc/dhcpd.conf
Some other quick tips:
1. Syntax checking for dhcpd files:
/usr/sbin/dhcpd -t -cf /etc/dhcpd.conf
This will do a basic syntax check to find those missing ; or other odd things.
2. host {} are global. You will see this warning if you place the host in a subnet zone. This is because when ISC will parse the file and make hostnames work globally (you can also make it do neat if then things but that makes my head hurt.) For the most part it is useful to put hosts in a group setting. This keeps them out of subnets, and also allows you to put common items with them (say for PXE booting with cobbler).
group {
next-server rhn.example.com;
filename “pxelinux.0″;
host noah {
hardware ethernet 00:11:00:11:00:11;
fixed-address 192.168.1.121;
}
}
Some other quick tips:
1. Syntax checking for dhcpd files:
/usr/sbin/dhcpd -t -cf /etc/dhcpd.conf
This will do a basic syntax check to find those missing ; or other odd things.
2. host {} are global. You will see this warning if you place the host in a subnet zone. This is because when ISC will parse the file and make hostnames work globally (you can also make it do neat if then things but that makes my head hurt.) For the most part it is useful to put hosts in a group setting. This keeps them out of subnets, and also allows you to put common items with them (say for PXE booting with cobbler).
group {
next-server rhn.example.com;
filename “pxelinux.0″;
host noah {
hardware ethernet 00:11:00:11:00:11;
fixed-address 192.168.1.121;
}
}
How to get list of all cron jobs ( crontab ) in a server
Run below as root :
for user in $(cut -f1 -d: /etc/passwd); do crontab -u $user -l; done
If you want to see who owns that cron job run below :
for user in $(cut -f1 -d: /etc/passwd); do echo $user; crontab -u $user -l; done
getent passwd cut -d: -f1 perl -e'while(<>){chomp;$l = `crontab -u $_ -l 2>/dev/null`;print "$_\n$l\n" if $l}'
for user in $(cut -f1 -d: /etc/passwd); do crontab -u $user -l; done
If you want to see who owns that cron job run below :
for user in $(cut -f1 -d: /etc/passwd); do echo $user; crontab -u $user -l; done
getent passwd cut -d: -f1 perl -e'while(<>){chomp;$l = `crontab -u $_ -l 2>/dev/null`;print "$_\n$l\n" if $l}'
Some Find commands regularly used for finding disk usage
find . -size +500000 -print
du -ch | grep total ( total size of directory)
du -sk * | sort -nr | head -3
find /home -type f | xargs ls -s | sort -rn | awk '{size=$1/1024; printf("%dMb %s\n", size,$2);}' | head
find / -type f -size +300000k -exec ls -lh {} \; | awk '{ print $9 ": " $5 }'
du -hs /home/* | grep G
du -hs /home/* | grep M
Command to import SSL certificate need for java applications
keytool -import -alias anotherdomainname -file /tmp/certificatename.cer -keystore $JAVA_HOME/jre/lib/security/cacerts
How to get home directory of a prticular user in bash scripting or a single command
The below command gets the home directory of user if at all the user exists
getent passwd naresh | cut -f6 -d:
getent passwd naresh | cut -f6 -d:
Rsync current directory using SSH port to remote host
/usr/bin/rsync -rave "ssh -p 22222 -l root" --delete . 192.168.1.111:/tmp
Subscribe to:
Posts (Atom)