Linux
Lpstar and lpr commands
Configuring cups client
lpstar and lpr commands
Check if cups-client or cups-utils
# zypper in cups-client
# lpstat -p -v
# telnet <PrinterIP> 9100
# lpstat -p <printer_name> -l
# lpq -a
# lpstat -ato
From a network printer, print the file and check for idle state of the printer
# ..
Dryrun fsck
Boot the server in emergency mode with root password.
Dryrun will give you information on how many sectors are affected and how may fix will happen.
# fsck -N <Device Name>
Perform FSCK, handle with care
# fsck -p <Device Name>
Make you always have backup before performing this activity, reboot the ..
Extend striped lv
Find the disk with stripes
# lvs -o+lv_layout,stripes
# lvs +o+devices,lv_layout,stripes
# pvs | grep vg_volgroup002
# lsblk | grep '<disks which are present in VG or affected by LV>'
All the striped disk must extend equally
# pvresize /dev/sdp /dev/sdq
# vgs
# lvresize -L+200G /dev/vg_volgroup002/lv_mylv
# resize2fs /dev/vg_volgroup002/lv_mylv
once the disk is ..
Copy files using rsync
To copy hidden files, you must include --include
# rsync -av --include='.*' /opt/bluff/* /opt/linux/.
If you are not using "*" and "." at the end rsync will copy hidden files
# rsync -av --include='.*' /opt/bluff/ /opt/linux/
Below are few examples of rsync
# rsync -axHAX --progress --stats /opt/bluff/* /opt/linux/.
# rsync ..
Build an initramfs using dracut
Please be careful what you are doing, this can break you server or machine
sometimes the kernel might have updated but initramfs would have been broken, in such condition dracut -kver can be used
# dracut --kver 4.8.x.x86_64
Quick way to build initramfs for a specific kernel version is to invoke dracut ..
Avoid entering into fsck during boot
Reboot system and stop auto fsck on-boot
# shutdown -rf now
During boot press e and add fastboot
# /vmlinuz-.xx ro root=LABEL=/ console=tty0 console=ttyS1,19200n8 fastboot
press e during server boot and add fastboot at end of the boot kernel to skip fsck or avoid filesystem check during boot.
To avoid filesystem check permenantly, ..
Grub2-mkconfig is used to regenerate file
When you make changes in /etc/default/grub run below command to update /boot/grub2/grub.cfg
# cat /etc/default/grub
GRUB_HIDDEN_TIMEOUT=0
GRUB_TIMEOUT=20
Once you change timeout or add any additional parameter in CMDLINE
# grub2-mkconfig -o /boot/grub2/grub.cfg
why do we edit /etc/default/grub?
Changes or edit in grub.cfg will be lost anytime when grub2-mkconfig is ..
Simple handy commands for DNS check
check dns using dig or nslookup
# dig w3calculator.com
# nslookup techbluff.com
Check the connectivity of a domain or by resolving the domain with DNS Server
# nslookup myhostname <DNS-server-IP>
# dig domainname.com @DNSServerIP
How to check NS and SOA
# dig NS @<DNS-Server-IP> w3calculator.com
# dig SOA @<DNS-Server-IP> ..
Delete mount volume and detach disk
Before deleting a blockdevice make sure to backup/snapshot of the disk
check if the disk is mounted or added in any logical volume.
# pvs | grep vg_1-lv-backup
# fdisk -l | grep -i /dev/mapper/vg_1-lv-backup
# lvremove /dev/mapper/vg_1-lv-backup
# vgremove vg_1
# pvremove /dev/sde
Finding LUN in azure
# vgs
# pvs ..
Add swap disk
By using below commands, collect required disk information and mount points
# df -hT
# fdisk -l
# lvdisplay
# pvdisplay
# lvs
# lsblk -o NAME,KNAME,MAJ:MIN,FSTYPE,MOUNTPOINT
# lsblk -o NAME,KNAME,MAJ:MIN,FSTYPE,MOUNTPOINT | egrep 'dm-0|dm-1'
Once you see new disk visible on OS, create and mount swap disk using swapon ..
Systemctl daemon reload
Sometime if blockdevice is not visible to OS
# systemctl daemon-reload
Enable a service on boot
# systemctl is-active <servicename>
# systemctl is-enabled <service_name>
# systemctl enable <service_name>
..
Zypper and rpm handy commands
zypper commands
# zypper se -s 'kernel-def' | grep '4.12'
# zypper wp libc.s0.6
# zypper se --provides --match-exact 'libc.so.6'
# zypper in package-name
+i installed by user request
i installed automatically (by the resolver, see section Automatically installed packages)
se - search package
in - install package
..
Network troubleshooting commands
Below are few frequently used commands for my application troubleshooting
Check IP tables
# iptables -t nat -nL
Check how many simultaneous connections are present
# netstat -auntpl | grep 192.168.0.24 | grep 22 | wc -l
Part of active connections
# netstat -auntpl | egrep -i "active|proto|192.168.0.24" | head -20
Nmap ..
Add route and delete
Before making any changes in route always have backup of existing route tables and output. Its always good to proceed it with change, be cautious when you change or add routes.
Get route table information
# ip route show
# ip route show table bond0
# ip route show table main
..
Find and kill all defunct process in linux
how to find defunt process on linuxbox
Find and kill all defunct process in linux
To find all defunct process
# ps axo ppid,pid,stat,comm | grep -w defunct
-w, --word-regexp
Select only those lines containing matches that form whole words. The test is ..