Skip to content

Instantly share code, notes, and snippets.

@wazoox
Last active October 20, 2018 10:09
Show Gist options
  • Save wazoox/4885ef1b6d7efd92fdc88654694b5692 to your computer and use it in GitHub Desktop.
Save wazoox/4885ef1b6d7efd92fdc88654694b5692 to your computer and use it in GitHub Desktop.
Linux SysAdmin tricks
# network tricks
#identify a network card:
ethtool --identify eth7
#Copy a directory tree without the files:
rsync -a -f"+ */" -f"- *" source/ destination/
#monitor NFS traffic
watch -d "netstat -plaute | grep nfs | sort -k 4,5"
### IO Scheduler settings
# for servers NEVER use cfq. Use either deadline or noop
echo noop > /sys/block/sda/queue/scheduler
# for RAID controllers, use bigger request queues
# try values up to 2048
echo 512 > /sys/block/sda/queue/nr_requests
# for faster sequential performance, try bigger read-ahead
# up to 131072
echo 16384 > /sys/block/sda/queue/read_ahead_kb
###### DANGEROUS COMMANDS ##################
# use the MagicSysRq from an ssh connection
# see /usr/src/linux/Documentation/sysrq.txt
# enable MagicSysRq
echo 1 > /proc/sys/kernel/sysrq
# force disk sync
echo s > /proc/sysrq-trigger
# force reboot
echo b > /proc/sysrq-trigger
# force poweroff
echo o > /proc/sysrq-trigger
##### DESCTRUCTIVE COMMANDS ################
# copy partition table from a disk to
# another one (for instance to create md RAIDs)
sfdisk -d /dev/sdc | sfdisk /dev/sdd
# clean up all partitions from a disk
# (say bye bye to all data!)
wipefs -a /dev/sdz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment