(**Primarily for VMware, RHEL and CentOS systems)
(**This is a living document and will be updated as I find more tips I need to remember)
-----
Using tar to copy directories and files to another location on the same server or a different server.
Example to copy /opt/copyme to /data/copyme on the same server:
$ cd /opt
$ tar cvfp - copyme | (cd /data && tar xvfp -)
Example to copy a user bart’s home directory to a different server:$ tar cvfp - copyme | (cd /data && tar xvfp -)
$ cd /home
$ tar cvfp - bart | ssh root@targetserver ‘cd /home && tar xvfp -’
$ tar cvfp - bart | ssh root@targetserver ‘cd /home && tar xvfp -’
Clear out all messages in the postfix queue
$ postsuper -d ALL
Show what is using virtual memory.
$ ps -e -o pid,vsz,comm= | sort -n -k 2
A note about xargs.
If you have two arguments, say r1.txt and r2.txt from the command “ls r*.txt”:
$ ls r*.txt | xargs rm
will execute the rm command this way...
rm r1.txt r2.txt
However,
rm r1.txt r2.txt
$ ls -r*.txt | xargs -i{} rm {}
will execute the args separately, this way...
rm r1.txt
rm r2.txt
rm r1.txt
rm r2.txt
Using ssh keys for no-password root login to ESX hosts.
For ESX 5.x, place the public key (id_dsa.pub or id_rsa.pub) in:
<ESX 5 host>:/etc/ssh/keys-root/authorized_keys
For ESX 4.x, place the public key in:
<ESX 4 host>:/.ssh/authorized_keys
Various ways of listing disks / storage on a server.
fdisk - list disks
$ fdisk -l
lsscsi - list SCSI devices and various info (rpm lsscsi)
$ lsscsi
pvscan - list physical volumes that are part of the LVM
$ pvscan
Scan a live server for new scsi disk using scsi-rescan (included in sg3_utils rpm)
$ scsi-rescan
After running scsi-rescan, new disks will show up with “fdisk -l” and can be added to LVM with the pvcreate utility.
Remounting a read only file system as read write:
mount -o remount <file system>
Example:
$ mount -o remount /var
Show server port information and connected / listening ports.
netstat (included with net-tools rpm)
$ netstat -putlan
lsof (included with lsof rpm)
$ lsof -i
$ lsof -i -P #shows what is using which ports but doesn’t convert port numbers to names
$ lsof -i :80 #shows what is using port 80
Remove the virbr0 interfaces:
$ virsh net-destroy default
$ virsh net-undefine default
$ service libvirtd stop
$ chkconfig libvirtd off
$ virsh net-undefine default
$ service libvirtd stop
$ chkconfig libvirtd off
Search and replace in vi (starting at the first line through the entire file):
:1,$s/<text to match>/<replace with this>/g
Mail .forward and /etc/aliases
The aliases defined in /etc/aliases take precedence over user's .forward file settings.
No comments:
Post a Comment