From e131dce6bb8883febfc5bc6eed13b8e184b6a0ad Mon Sep 17 00:00:00 2001 From: ImmortalPC Date: Tue, 7 Jan 2014 11:33:36 +0100 Subject: [PATCH 01/24] [Git:change] Add a command to show a file as it appeared at . --- cheatsheets/git | 1 + 1 file changed, 1 insertion(+) diff --git a/cheatsheets/git b/cheatsheets/git index 22b538c..63302bf 100644 --- a/cheatsheets/git +++ b/cheatsheets/git @@ -38,6 +38,7 @@ git checkout master # Checkout local master git checkout -b new_branch # Create and checkout a new branch git merge upstream/master # Merge remote into local repo git show 83fb499 # Show what a commit did. +git show 83fb499:path/fo/file.ext # Shows the file as it appeared at 83fb499. git diff branch_1 branch_2 # Check difference between branches git log # Show all the commits git status # Show the changes from last commit From 3b78250404611c18fab9bb6139481fb8da949fe0 Mon Sep 17 00:00:00 2001 From: Marlon Landaverde Date: Sun, 19 Jan 2014 15:06:42 -0500 Subject: [PATCH 02/24] adds how to wget a file into a specific directory --- cheatsheets/wget | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cheatsheets/wget b/cheatsheets/wget index d0bcd7b..ad04dd9 100644 --- a/cheatsheets/wget +++ b/cheatsheets/wget @@ -4,6 +4,9 @@ wget http://path.to.the/file # To download a file and change its name wget http://path.to.the/file -o newname +# To download a file into a directory +wget -P path/to/directory http://path.to.the/file + # To continue an aborted downloaded wget -c http://path.to.the/file From 0a240c6ab620f4ec01b6d41787e159e872045b8d Mon Sep 17 00:00:00 2001 From: David M Date: Wed, 5 Feb 2014 10:26:04 -0500 Subject: [PATCH 03/24] add cheat sheet for journalctl --- cheatsheets/journalctl | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 cheatsheets/journalctl diff --git a/cheatsheets/journalctl b/cheatsheets/journalctl new file mode 100644 index 0000000..6c00e7f --- /dev/null +++ b/cheatsheets/journalctl @@ -0,0 +1,21 @@ +# Actively follow log (like tail -f) +journalctl -f + +# Display all errors since last boot +journalctl -b -p err + +# Filter by time period +journalctl --since=2012-10-15 --until="2011-10-16 23:59:59" + +# Show list of systemd units logged in journal +journalctl -F _SYSTEMD_UNIT + +# Filter by specific unit +journalctl -u dbus + +# Filter by executable name +journalctl /usr/bin/dbus-daemon + +# Filter by PID +journalctl _PID=123 + From f3342373cd99afbdd15617d4ed3b93f833520a70 Mon Sep 17 00:00:00 2001 From: ImmortalPC Date: Sat, 15 Feb 2014 19:46:46 +0100 Subject: [PATCH 04/24] [TAR] Add a new command in tar --- cheatsheets/tar | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cheatsheets/tar b/cheatsheets/tar index ea12125..efa615f 100644 --- a/cheatsheets/tar +++ b/cheatsheets/tar @@ -21,3 +21,6 @@ tar -cjvf /path/to/foo.tgz /path/to/foo/ # To list the content of an .bz2 archive: tar -jtvf /path/to/foo.tgz + +# To create a .gz archive and exclude all jpg,gif,... from the tgz +tar czvf /path/to/foo.tgz --exclude=\*.{jpg,gif,png,wmv,flv,tar.gz,zip} /path/to/foo/ From 4512e5fc442a932a37c5211ecb5cbe826059bb5c Mon Sep 17 00:00:00 2001 From: Brutus Date: Wed, 26 Feb 2014 15:09:37 +0100 Subject: [PATCH 05/24] include commands to mirror locally maybe better use ``wget -mk -w 10 http://path.to.the/page.html`` to be nice? --- cheatsheets/wget | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cheatsheets/wget b/cheatsheets/wget index ad04dd9..60f7c2c 100644 --- a/cheatsheets/wget +++ b/cheatsheets/wget @@ -19,6 +19,12 @@ wget -i url_list.txt # To download files according to a pattern wget http://www.myserver.com/files-{1..15}.tar.bz2 +# To mirror a whole page locally +wget -pk http://path.to.the/page.html + +# To mirror a whole site locally +wget -mk http://path.to.the/page.html + # To download all the files in a directory with a specific extension if directory indexing is enabled wget -r -l1 -A.extension http://myserver.com/directory From b7347a9409b5b03d2b2b7cf7a83f7da0ea7f2f58 Mon Sep 17 00:00:00 2001 From: Sam Sherar Date: Tue, 4 Mar 2014 19:24:22 +0000 Subject: [PATCH 06/24] Adding two invaluable commands to tmux cheatsheet * Detaching an already attached tmux session - great for when you are moving from a phone for example to a laptop and want to utilise the whole real estate you have. * Reloading the configuration file on the fly by using the colon menu --- cheatsheets/tmux | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cheatsheets/tmux b/cheatsheets/tmux index e9b76ce..328ceaf 100644 --- a/cheatsheets/tmux +++ b/cheatsheets/tmux @@ -7,6 +7,9 @@ Ctrl-b d # Restore tmux session: tmux attach +# Detach an already attached session (great if you are moving devices with different screen resolutions) +tmux attach -d + # Display session: tmux ls @@ -20,6 +23,9 @@ Ctrl-b ? # Scroll in window: Ctrl-b PageUp/PageDown +# Reload configuation file +Ctrl-b : source-file /path/to/file + # Window management # ================= From af8eb721be09e25424b1d70070c838a29803bda9 Mon Sep 17 00:00:00 2001 From: Brutus Date: Thu, 6 Mar 2014 14:20:52 +0100 Subject: [PATCH 07/24] Update wget --- cheatsheets/wget | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cheatsheets/wget b/cheatsheets/wget index 60f7c2c..a815e62 100644 --- a/cheatsheets/wget +++ b/cheatsheets/wget @@ -23,7 +23,7 @@ wget http://www.myserver.com/files-{1..15}.tar.bz2 wget -pk http://path.to.the/page.html # To mirror a whole site locally -wget -mk http://path.to.the/page.html +wget -mk http://site.tl/ # To download all the files in a directory with a specific extension if directory indexing is enabled wget -r -l1 -A.extension http://myserver.com/directory From 87a594535a4e85f60163bd12d910b997f29dc231 Mon Sep 17 00:00:00 2001 From: Brutus Date: Thu, 6 Mar 2014 14:21:56 +0100 Subject: [PATCH 08/24] Update wget --- cheatsheets/wget | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cheatsheets/wget b/cheatsheets/wget index a815e62..fb9a45a 100644 --- a/cheatsheets/wget +++ b/cheatsheets/wget @@ -16,15 +16,15 @@ wget URL1 URL2 # To parse a file that contains a list of URLs to fetch each one wget -i url_list.txt -# To download files according to a pattern -wget http://www.myserver.com/files-{1..15}.tar.bz2 - # To mirror a whole page locally wget -pk http://path.to.the/page.html # To mirror a whole site locally wget -mk http://site.tl/ +# To download files according to a pattern +wget http://www.myserver.com/files-{1..15}.tar.bz2 + # To download all the files in a directory with a specific extension if directory indexing is enabled wget -r -l1 -A.extension http://myserver.com/directory From c0a51a2d0fca1486738803cfde6d2ab543f7348d Mon Sep 17 00:00:00 2001 From: ImmortalPC Date: Fri, 7 Mar 2014 14:52:50 +0100 Subject: [PATCH 09/24] [PS,GREP] Exclude grep from your grepped output of ps. --- cheatsheets/grep | 4 ++++ cheatsheets/ps | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/cheatsheets/grep b/cheatsheets/grep index 3a01723..fced336 100644 --- a/cheatsheets/grep +++ b/cheatsheets/grep @@ -20,3 +20,7 @@ grep -E "[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}" file #Find IP add # Find all files who contain {pattern} in the directory {directory}. # This will show: "file:line my research" grep -rnw 'directory' -e "pattern" + +# Exclude grep from your grepped output of ps. +# Add [] to the first letter. Ex: sshd -> [s]shd +ps aux | grep '[h]ttpd' diff --git a/cheatsheets/ps b/cheatsheets/ps index 3710a90..75d6155 100644 --- a/cheatsheets/ps +++ b/cheatsheets/ps @@ -9,3 +9,7 @@ ps -aufoouser # To list every process with a user-defined format: ps -eo pid,user,command + +# Exclude grep from your grepped output of ps. +# Add [] to the first letter. Ex: sshd -> [s]shd +ps aux | grep '[h]ttpd' From 60eff9308c8240b1dfa54f17184434f3e3b7067a Mon Sep 17 00:00:00 2001 From: Carl Unsworth Date: Fri, 7 Mar 2014 14:29:10 -0800 Subject: [PATCH 10/24] - Cheatsheets added for a couple of my favourite commands: - rsync: file copy and backup multi-tool - indent: one liner to nicely format C/C++ source. --- cheatsheets/indent | 2 ++ cheatsheets/rsync | 6 ++++++ 2 files changed, 8 insertions(+) create mode 100644 cheatsheets/indent create mode 100644 cheatsheets/rsync diff --git a/cheatsheets/indent b/cheatsheets/indent new file mode 100644 index 0000000..d8568e6 --- /dev/null +++ b/cheatsheets/indent @@ -0,0 +1,2 @@ +# format C/C++ source according to the style of Kernighan and Ritchie (K&R), no tabs, 3 spaces per indent, wrap lines at 120 characters. +indent -i3 -kr -nut -l120 diff --git a/cheatsheets/rsync b/cheatsheets/rsync new file mode 100644 index 0000000..617bf74 --- /dev/null +++ b/cheatsheets/rsync @@ -0,0 +1,6 @@ +# copy files from remote to local, maintaining file propertires and sym-links (-a), zipping for faster transfer (-z), verbose (-v). +rsync -avz host:file1 :file1 /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). +rsync -avc /source/ /dest/ From b2e5f6d2cf27472ab663b7587f79801b99e78849 Mon Sep 17 00:00:00 2001 From: ImmortalPC Date: Mon, 10 Mar 2014 21:47:19 +0100 Subject: [PATCH 11/24] [XARGS] Add xargs example --- cheatsheets/xargs | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 cheatsheets/xargs diff --git a/cheatsheets/xargs b/cheatsheets/xargs new file mode 100644 index 0000000..44bf20a --- /dev/null +++ b/cheatsheets/xargs @@ -0,0 +1,12 @@ +# find all file name ending with .pdf and remove them +find -name *.pdf | xargs rm -rf + +# if file name contains spaces you should use this instead +find -name *.pdf | xargs -I{} rm -rf '{}' + +# Will show every .pdf like: +# &toto.pdf= +# &titi.pdf= +# -n1 => One file by one file. ( -n2 => 2 files by 2 files ) + +find -name *.pdf | xargs -I{} -n1 echo '&{}=' From b4c5b7f2f9294a160be7cb63136ac588acb453fc Mon Sep 17 00:00:00 2001 From: ImmortalPC Date: Tue, 25 Mar 2014 14:29:53 +0100 Subject: [PATCH 12/24] [IPTABLES,TCPDUMP] Add cheats for iptables and tcpdump --- cheatsheets/iptables | 18 +++++++++++++ cheatsheets/tcpdump | 63 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 81 insertions(+) create mode 100644 cheatsheets/iptables create mode 100644 cheatsheets/tcpdump diff --git a/cheatsheets/iptables b/cheatsheets/iptables new file mode 100644 index 0000000..badc271 --- /dev/null +++ b/cheatsheets/iptables @@ -0,0 +1,18 @@ +# Show hit for rules with auto refresh +watch --interval 0 'iptables -nvL | grep -v "0 0"' + +# Show hit for rule with auto refresh and highlight any changes since the last refresh +watch -d -n 2 iptables -nvL + +# Block the port 902 and we hide this port from nmap. +iptables -A INPUT -i eth0 -p tcp --dport 902 -j REJECT --reject-with icmp-port-unreachable + +# Note, --reject-with accept: +# icmp-net-unreachable +# icmp-host-unreachable +# icmp-port-unreachable <- Hide a port to nmap +# icmp-proto-unreachable +# icmp-net-prohibited +# icmp-host-prohibited or +# icmp-admin-prohibited +# tcp-reset diff --git a/cheatsheets/tcpdump b/cheatsheets/tcpdump new file mode 100644 index 0000000..0011635 --- /dev/null +++ b/cheatsheets/tcpdump @@ -0,0 +1,63 @@ +# TCPDump is a packet analyzer. It allows the user to intercept and display TCP/IP +# and other packets being transmitted or received over a network. (cf Wikipedia). +# Note: 173.194.40.120 => google.com + +# Intercepts all packets on eth0 +tcpdump -i eth0 + +# Intercepts all packets from/to 173.194.40.120 +tcpdump host 173.194.40.120 + +# Intercepts all packets on all interfaces from / to 173.194.40.120 port 80 +# -nn => Disables name resolution for IP addresses and port numbers. +tcpdump -nn -i any host 173.194.40.120 and port 80 + +# Make a grep on tcpdump (ASCII) +# -A => Show only ASCII in packets. +# -s0 => By default, tcpdump only captures 68 bytes. +tcpdump -i -A any host 173.194.40.120 and port 80 | grep 'User-Agent' + +# With ngrep +# -d eth0 => To force eth0 (else ngrep work on all interfaces) +# -s0 => force ngrep to look at the entire packet. (Default snaplen: 65536 bytes) +ngrep 'User-Agent' host 173.194.40.120 and port 80 + +# Intercepts all packets on all interfaces from / to 8.8.8.8 or 173.194.40.127 on port 80 +tcpdump 'host ( 8.8.8.8 or 173.194.40.127 ) and port 80' -i any + +# Intercepts all packets SYN and FIN of each TCP session. +tcpdump 'tcp[tcpflags] & (tcp-syn|tcp-fin) != 0' + +# To display SYN and FIN packets of each TCP session to a host that is not on our network +tcpdump 'tcp[tcpflags] & (tcp-syn|tcp-fin) != 0 and not src and dst net local_addr' + +# To display all IPv4 HTTP packets that come or arrive on port 80 and that contain only data (no SYN, FIN no, no packet containing an ACK) +tcpdump 'tcp port 80 and (((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0)' + +# Saving captured data +tcpdump -w file.cap + +# Reading from capture file +tcpdump -r file.cap + +# Show content in hexa +# Change -x to -xx => show extra header (ethernet). +tcpdump -x + +# Show content in hexa and ASCII +# Change -X to -XX => show extra header (ethernet). +tcpdump -X + +# Note on packet maching: +# Port matching: +# - portrange 22-23 +# - not port 22 +# - port ssh +# - dst port 22 +# - src port 22 +# +# Host matching: +# - dst host 8.8.8.8 +# - not dst host 8.8.8.8 +# - src net 67.207.148.0 mask 255.255.255.0 +# - src net 67.207.148.0/24 From 65c50bc5b32fee384972fc36e363e6c6ce1af2d7 Mon Sep 17 00:00:00 2001 From: ImmortalPC Date: Thu, 27 Mar 2014 15:44:06 +0100 Subject: [PATCH 13/24] [SSH] add a cheat for ssh (encryption) --- cheatsheets/ssh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cheatsheets/ssh b/cheatsheets/ssh index ee40c57..ce11b52 100644 --- a/cheatsheets/ssh +++ b/cheatsheets/ssh @@ -16,5 +16,8 @@ ssh -X -t user@example.com 'chromium-browser' # To create a SOCKS proxy on localhost and port 9999 ssh -D 9999 user@example.com +# -X use an xsession, -C compress data, "-c blowfish" use the encryption blowfish +ssh user@example.com -C -c blowfish -X + # For more information, see: # http://unix.stackexchange.com/q/12755/44856 From c5f1d5c1acdd3d4922560cff34ff0506749449ee Mon Sep 17 00:00:00 2001 From: ImmortalPC Date: Mon, 31 Mar 2014 00:03:12 +0200 Subject: [PATCH 14/24] [IPTABLES] Add some cheats for iptables --- cheatsheets/iptables | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/cheatsheets/iptables b/cheatsheets/iptables index badc271..2e0a132 100644 --- a/cheatsheets/iptables +++ b/cheatsheets/iptables @@ -16,3 +16,25 @@ iptables -A INPUT -i eth0 -p tcp --dport 902 -j REJECT --reject-with icmp-port-u # icmp-host-prohibited or # icmp-admin-prohibited # tcp-reset + +# Add a comment to a rule: +iptables ... -m comment --comment "This rule is here for this reason" + + +# To remove or insert a rule: +# 1) Show all rules +iptables -L INPUT --line-numbers +# OR iptables -nL --line-numbers + +# Chain INPUT (policy ACCEPT) +# num target prot opt source destination +# 1 ACCEPT udp -- anywhere anywhere udp dpt:domain +# 2 ACCEPT tcp -- anywhere anywhere tcp dpt:domain +# 3 ACCEPT udp -- anywhere anywhere udp dpt:bootps +# 4 ACCEPT tcp -- anywhere anywhere tcp dpt:bootps + +# 2.a) REMOVE (-D) a rule. (here an INPUT rule) +iptables -D INPUT 2 + +# 2.b) OR INSERT a rule. +iptables -I INPUT {LINE_NUMBER} -i eth1 -p tcp --dport 21 -s 123.123.123.123 -j ACCEPT -m comment --comment "This rule is here for this reason" From 1e7ee5b7fa45b264c75f7e6f908040b7143aa18d Mon Sep 17 00:00:00 2001 From: ImmortalPC Date: Tue, 1 Apr 2014 19:18:19 +0200 Subject: [PATCH 15/24] [NMAP] Update nmap --- cheatsheets/nmap | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/cheatsheets/nmap b/cheatsheets/nmap index 68da56a..d4361ca 100644 --- a/cheatsheets/nmap +++ b/cheatsheets/nmap @@ -33,4 +33,22 @@ nmap -traceroute [target] # ARP ping: -PR # Example: Ping scan all machines on a class C network -nmap -sP 192.168.0.0/24 +nmap -sP 192.168.0.0/24* + +# Use some script: +nmap --script default,safe + +# Loads the script in the default category, the banner script, and all .nse files in the directory /home/user/customscripts. +nmap --script default,banner,/home/user/customscripts + +# Loads all scripts whose name starts with http-, such as http-auth and http-open-proxy. +nmap --script 'http-*' + +# Loads every script except for those in the intrusive category. +nmap --script "not intrusive" + +# Loads those scripts that are in both the default and safe categories. +nmap --script "default and safe" + +# Loads scripts in the default, safe, or intrusive categories, except for those whose names start with http-. +nmap --script "(default or safe or intrusive) and not http-*" From 041bcd2f6316b9da317ebdb26e0f0bd446a19a20 Mon Sep 17 00:00:00 2001 From: ImmortalPC Date: Wed, 2 Apr 2014 11:12:09 +0200 Subject: [PATCH 16/24] [FIND] add a cheat to find all files that have the same node (hard link) as MY_FILE --- cheatsheets/find | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cheatsheets/find b/cheatsheets/find index c6126b3..5cd262f 100644 --- a/cheatsheets/find +++ b/cheatsheets/find @@ -39,3 +39,6 @@ find . -maxdepth 2 -name build -type d # To search all files who are not in .git directory find . ! -iwholename '*.git*' -type f + +# Find all files that have the same node (hard link) as MY_FILE_HERE +find / -type f -samefile MY_FILE_HERE 2>/dev/null From 5805d2c52e6b17507878046132132f75320a15ee Mon Sep 17 00:00:00 2001 From: ImmortalPC Date: Wed, 2 Apr 2014 11:14:18 +0200 Subject: [PATCH 17/24] [NMAP] Correct a bug --- cheatsheets/nmap | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cheatsheets/nmap b/cheatsheets/nmap index d4361ca..afa46ef 100644 --- a/cheatsheets/nmap +++ b/cheatsheets/nmap @@ -33,7 +33,7 @@ nmap -traceroute [target] # ARP ping: -PR # Example: Ping scan all machines on a class C network -nmap -sP 192.168.0.0/24* +nmap -sP 192.168.0.0/24 # Use some script: nmap --script default,safe From bfaf39d7abf99a47b0fa41cb3d3cf52e37397b0c Mon Sep 17 00:00:00 2001 From: ImmortalPC Date: Fri, 18 Apr 2014 11:22:50 +0200 Subject: [PATCH 18/24] [NMAP] Speed up nmap scan --- cheatsheets/nmap | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cheatsheets/nmap b/cheatsheets/nmap index afa46ef..81c54a8 100644 --- a/cheatsheets/nmap +++ b/cheatsheets/nmap @@ -8,7 +8,7 @@ nmap -iL [list.txt] nmap -6 [target] # OS detection: -nmap -O [target] +nmap -O --osscan_guess [target] # Save output to text file: nmap -oN [output.txt] [target] @@ -22,6 +22,9 @@ nmap -source-port [port] [target] # Do an aggressive scan: nmap -A [target] +# Speedup your scan: +nmap -T5 --min-parallelism=50 [target] + # Traceroute: nmap -traceroute [target] From 1c79ab5ed6af94c2358ad5fb4454fc73a4d0c9f9 Mon Sep 17 00:00:00 2001 From: ImmortalPC Date: Fri, 18 Apr 2014 11:23:23 +0200 Subject: [PATCH 19/24] [APT-GET] Donwload deb withtou installing it --- cheatsheets/apt-get | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cheatsheets/apt-get b/cheatsheets/apt-get index 3888613..c18baf8 100644 --- a/cheatsheets/apt-get +++ b/cheatsheets/apt-get @@ -14,3 +14,9 @@ apt-get update && apt-get dist-upgrade # To install a new package(s) apt-get install package(s) + +# Download a package without installing it. (The package will be downloaded in your current working dir) +apt-get download modsecurity-crs + +# Change Cache dir and archive dir (where .deb are stored). +apt-get -o Dir::Cache="/path/to/destination/dir/" -o Dir::Cache::archives="./" install ... From 74c6c9b01bfd980a01cf9ea6cf32f8d9d3ff47da Mon Sep 17 00:00:00 2001 From: ImmortalPC Date: Fri, 18 Apr 2014 17:12:39 +0200 Subject: [PATCH 20/24] [DD] Add some tricks for dd --- cheatsheets/dd | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/cheatsheets/dd b/cheatsheets/dd index c1db5f3..b2a03c8 100644 --- a/cheatsheets/dd +++ b/cheatsheets/dd @@ -2,3 +2,13 @@ # Note: At the first iteration, we read 512 Bytes. # Note: At the second iteration, we read 512 Bytes. dd if=/dev/urandom of=/tmp/test.txt count=512 bs=2 + +# Watch the progress of 'dd' +dd if=/dev/zero of=/dev/null bs=4KB &; export dd_pid=`pgrep '^dd'`; while [[ -d /proc/$dd_pid ]]; do kill -USR1 $dd_pid && sleep 1 && clear; done + +# Watch the progress of 'dd' with `pv` and `dialog` (apt-get install pv dialog) +(pv -n /dev/zero | dd of=/dev/null bs=128M conv=notrunc,noerror) 2>&1 | dialog --gauge "Running dd command (cloning), please wait..." 10 70 0 + +# DD with "graphical" return +dcfldd if=/dev/zero of=/dev/null bs=500K + From d87cf0ae81ce8f1160fd8563a9f4ad34e1440720 Mon Sep 17 00:00:00 2001 From: ImmortalPC Date: Fri, 18 Apr 2014 18:04:25 +0200 Subject: [PATCH 21/24] =?UTF-8?q?[APT=E2=88=92GET]=20Show=20apt-get=20inst?= =?UTF-8?q?alled=20packages?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cheatsheets/apt-get | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cheatsheets/apt-get b/cheatsheets/apt-get index c18baf8..3208a53 100644 --- a/cheatsheets/apt-get +++ b/cheatsheets/apt-get @@ -20,3 +20,6 @@ apt-get download modsecurity-crs # Change Cache dir and archive dir (where .deb are stored). apt-get -o Dir::Cache="/path/to/destination/dir/" -o Dir::Cache::archives="./" install ... + +# Show apt-get installed packages. +cat /var/log/dpkg.log | grep 'install ' From 4703463a7cdf1622dbb55cb079d778d1bde83e5b Mon Sep 17 00:00:00 2001 From: ImmortalPC Date: Fri, 18 Apr 2014 18:04:57 +0200 Subject: [PATCH 22/24] [DD] Watch the progress of `dd` with `pv` and `zenity` --- cheatsheets/dd | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cheatsheets/dd b/cheatsheets/dd index b2a03c8..2db5aaa 100644 --- a/cheatsheets/dd +++ b/cheatsheets/dd @@ -9,6 +9,9 @@ dd if=/dev/zero of=/dev/null bs=4KB &; export dd_pid=`pgrep '^dd'`; while [[ -d # Watch the progress of 'dd' with `pv` and `dialog` (apt-get install pv dialog) (pv -n /dev/zero | dd of=/dev/null bs=128M conv=notrunc,noerror) 2>&1 | dialog --gauge "Running dd command (cloning), please wait..." 10 70 0 +# Watch the progress of 'dd' with `pv` and `zenity` (apt-get install pv zenity) +(pv -n /dev/zero | dd of=/dev/null bs=128M conv=notrunc,noerror) 2>&1 | zenity --title 'Running dd command (cloning), please wait...' --progress + # DD with "graphical" return dcfldd if=/dev/zero of=/dev/null bs=500K From 4c31138bbfff416f66d5583fe61276d02148fbe9 Mon Sep 17 00:00:00 2001 From: ImmortalPC Date: Fri, 18 Apr 2014 18:43:17 +0200 Subject: [PATCH 23/24] Make cheat working with python3 :) --- cheat | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cheat b/cheat index b4d00da..03f4dd8 100755 --- a/cheat +++ b/cheat @@ -151,7 +151,7 @@ class CheatSheets(object): new_sheet = os.path.join(DEFAULT_CHEAT_DIR, cheat) shutil.copy(sheet_path, new_sheet) subprocess.call(editor + [new_sheet]) - + # fail gracefully if the cheatsheet cannot be copied. This # can happen if DEFAULT_CHEAT_DIR does not exist except IOError: @@ -179,7 +179,7 @@ class CheatSheets(object): "Please retry usig sudo." % cheat) print >> sys.stderr, error_msg exit(1) - except OSError, errno: + except OSError as errno: print >> sys.stderr, ("Could not launch `%s` as your editor : %s" % (editor[0], errno.strerror)) exit(1) @@ -216,7 +216,7 @@ class CheatSheets(object): output += ''.join([" " + line + '\n' for line in block.split('\n')]) if output: - print output, + sys.stdout.write(output); # Custom action for argparse @@ -230,7 +230,7 @@ class ListDirectories(argparse.Action): class ListCheatsheets(argparse.Action): """List cheatsheets and exit""" def __call__(self, parser, namespace, values, option_string=None): - print sheets.list() + print(sheets.list()); parser.exit() From e5093db169fd9a834d256b1118f6787bf16883d6 Mon Sep 17 00:00:00 2001 From: ImmortalPC Date: Mon, 21 Apr 2014 23:15:09 +0200 Subject: [PATCH 24/24] [APT-GET] Change to grep [PACMAN] Change the AUR instructions --- cheatsheets/apt-get | 2 +- cheatsheets/pacman | 21 +++++++++++++-------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/cheatsheets/apt-get b/cheatsheets/apt-get index 3208a53..c7bc7f3 100644 --- a/cheatsheets/apt-get +++ b/cheatsheets/apt-get @@ -22,4 +22,4 @@ apt-get download modsecurity-crs apt-get -o Dir::Cache="/path/to/destination/dir/" -o Dir::Cache::archives="./" install ... # Show apt-get installed packages. -cat /var/log/dpkg.log | grep 'install ' +grep 'install ' /var/log/dpkg.log diff --git a/cheatsheets/pacman b/cheatsheets/pacman index 353f6c5..cb51fc6 100644 --- a/cheatsheets/pacman +++ b/cheatsheets/pacman @@ -32,12 +32,17 @@ pacman -Qdt # You can't directly install packages from the Arch User Database (AUR) with pacman. -# You need yaourt to perform that. But considering yaourt itself is in the AUR, here is how to -build a package from its tarball. -# First, get the .tar.gz archive and unpack it -wget -tar -xzf -cd -# Then build the package and install it +# You need yaourt to perform that. But considering yaourt itself is in the AUR, here is how to build a package from its tarball. +# Installing a package from AUR is a relatively simple process: +# - Retrieve the archive corresponding to your package from AUR website +# - Extract the archive (preferably in a folder for this purpose) +# - Run makepkg in the extracted directory. (makepkg-s allows you to install any dependencies automatically from deposits.) +# - Install the package created using pacman +# Assuming $pkgname contains the package name. +wget "https://aur.archlinux.org/packages/${pkgname::2}/$pkgname/$pkgname.tar.gz" +tar zxvf "$pkgname.tar.gz" +cd "$pkgname" +# Build the package makepkg -s -pacman -U +# Install +sudo pacman -U