Cherry-picking changes from #185

@zhujian0805 contributed some excellent cheatsheets in #185, but some
binary files seem to have gotten mixed into the commit as well. This
commit cherry-picks the cheatsheet file changes from that PR while
leaving behind the cruft.

Also performed minor editing on some of the cheatsheets.
This commit is contained in:
Chris Lane 2014-10-19 11:43:43 -04:00
parent 6efae113cf
commit 6b8ecd6b5c
8 changed files with 78 additions and 9 deletions

2
cheat/cheatsheets/du Normal file
View file

@ -0,0 +1,2 @@
# To sort directories/files by size
du -sk *| sort -rn

View file

@ -20,10 +20,10 @@ find ./path/ -name '*.txt' -exec rm '{}' \;
find ./path/ -name '*.txt' | xargs grep 'string' find ./path/ -name '*.txt' | xargs grep 'string'
# To find files with size bigger than 5 Mb and sort them by size: # To find files with size bigger than 5 Mb and sort them by size:
find ./ -size +5M -type f -print0 | xargs -0 ls -Ssh find . -size +5M -type f -print0 | xargs -0 ls -Ssh | sort -z
# To find files bigger thank 2 MB and list them: # To find files bigger thank 2 MB and list them:
find / -type f -size +20000k -exec ls -lh {} \; | awk '{ print $9 ": " $5 }' find . -type f -size +20000k -exec ls -lh {} \; | awk '{ print $9 ": " $5 }'
# To find files modified more than 7 days ago and list file information # To find files modified more than 7 days ago and list file information
find . -type f -mtime +7d -ls find . -type f -mtime +7d -ls
@ -41,4 +41,4 @@ find . -maxdepth 2 -name build -type d
find . ! -iwholename '*.git*' -type f find . ! -iwholename '*.git*' -type f
# Find all files that have the same node (hard link) as MY_FILE_HERE # Find all files that have the same node (hard link) as MY_FILE_HERE
find / -type f -samefile MY_FILE_HERE 2>/dev/null find . -type f -samefile MY_FILE_HERE 2>/dev/null

7
cheat/cheatsheets/lvm Normal file
View file

@ -0,0 +1,7 @@
#Exclusive Activation of a Volume Group in a Cluster
#Link --> https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/High_Availability_Add-On_Administration/s1-exclusiveactive-HAAA.html
1> vgs --noheadings -o vg_name
2> volume_list = [ "rhel_root", "rhel_home" ]
3> dracut -H -f /boot/initramfs-$(uname -r).img $(uname -r)
4> Reboot the node
5> uname -r to verify the correct initrd image

20
cheat/cheatsheets/nc Normal file
View file

@ -0,0 +1,20 @@
# To open a TCP connection to port 42 of host.example.com, using port 31337 as the source port, with a timeout of 5 seconds:
nc -p 31337 -w 5 host.example.com 42
# To open a UDP connection to port 53 of host.example.com:
nc -u host.example.com 53
# To open a TCP connection to port 42 of host.example.com using 10.1.2.3 as the IP for the local end of the connection:
nc -s 10.1.2.3 host.example.com 42
# To create and listen on a UNIX-domain stream socket:
nc -lU /var/tmp/dsocket
# To connect to port 42 of host.example.com via an HTTP proxy at 10.2.3.4, port 8080. This example could also be used by ssh(1); see the ProxyCommand directive in ssh_config(5) for more information.
nc -x10.2.3.4:8080 -Xconnect host.example.com 42
# The same example again, this time enabling proxy authentication with username "ruser" if the proxy requires it:
nc -x10.2.3.4:8080 -Xconnect -Pruser host.example.com 42
# To choose the source IP for the testing using the -s option
nc -zv -s source_IP target_IP Port

View file

@ -1,5 +1,29 @@
# Add a default gateway: # To display routing table IP addresses instead of host names:
route -n
# To add a default gateway:
route add default gateway 192.168.0.1 route add default gateway 192.168.0.1
# Display routing table IP addresses instead of host names: # To add the normal loopback entry, using netmask 255.0.0.0 and associated with the "lo" device (assuming this device was previously set up correctly with ifconfig(8)).
route -n route add -net 127.0.0.0 netmask 255.0.0.0 dev lo
# To add a route to the local network 192.56.76.x via "eth0". The word "dev" can be omitted here.
route add -net 192.56.76.0 netmask 255.255.255.0 dev eth0
# To delete the current default route, which is labeled "default" or 0.0.0.0 in the destination field of the current routing table.
route del default
# To add a default route (which will be used if no other route matches). All packets using this route will be gatewayed through "mango-gw". The device which will actually be used for that route depends on how we can reach "mango-gw" - the static route to "mango-gw" will have to be set up before.
route add default gw mango-gw
# To add the route to the "ipx4" host via the SLIP interface (assuming that "ipx4" is the SLIP host).
route add ipx4 sl0
# To add the net "192.57.66.x" to be gateway through the former route to the SLIP interface.
route add -net 192.57.66.0 netmask 255.255.255.0 gw ipx4
# To install a rejecting route for the private network "10.x.x.x."
route add -net 10.0.0.0 netmask 255.0.0.0 reject
# This is an obscure one documented so people know how to do it. This sets all of the class D (multicast) IP routes to go via "eth0". This is the correct normal configuration line with a multicasting kernel
route add -net 224.0.0.0 netmask 240.0.0.0 dev eth0

View file

@ -1,6 +1,14 @@
# copy files from remote to local, maintaining file propertires and sym-links (-a), zipping for faster transfer (-z), verbose (-v). # To copy files from remote to local, maintaining file properties and sym-links (-a), zipping for faster transfer (-z), verbose (-v).
rsync -avz host:file1 :file1 /dest/ rsync -avz host:file1 :file1 /dest/
rsync -avz /source host:/dest rsync -avz /source host:/dest
# Copy files using checksum (-c), rather than time, to detect if the file has changed. (Useful for validating backups). # Copy files using checksum (-c) rather than time to detect if the file has changed. (Useful for validating backups).
rsync -avc /source/ /dest/ rsync -avc /source/ /dest/
# Copy contents of /src/foo to destination:
# This command will create /dest/foo if it does not already exist
rsync -auv /src/foo /dest
# Explicitly copy /src/foo to /dest/foo
rsync -auv /src/foo/ /dest/foo

View file

@ -10,5 +10,8 @@ echo 'It is daytime' | sed 's/day/night/g'
# To remove leading spaces # To remove leading spaces
sed -i -r 's/^\s+//g' file.txt sed -i -r 's/^\s+//g' file.txt
# Remove empty lines and print results to stdout: # To remove empty lines and print results to stdout:
sed '/^$/d' file.txt sed '/^$/d' file.txt
# To replace newlines in multiple lines
sed ':a;N;$!ba;s/\n//g' file.txt

View file

@ -0,0 +1,5 @@
# To retrieve all of the variables under system for host zeus
snmpwalk -Os -c public -v 1 zeus system
# To retrieve the scalar values, but omit the sysORTable for host zeus
snmpwalk -Os -c public -v 1 -CE sysORTable zeus system