From 538aeee2b213c5cd2882579599f732e78a0be5d2 Mon Sep 17 00:00:00 2001 From: Charley Peng Date: Thu, 29 May 2014 09:40:58 +1000 Subject: [PATCH 001/126] adding creation of batch file --- setup.py | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 50 insertions(+), 4 deletions(-) diff --git a/setup.py b/setup.py index 72eec5d..7e1a232 100644 --- a/setup.py +++ b/setup.py @@ -1,10 +1,54 @@ from distutils.core import setup import os +from os.path import join as pjoin, splitext, split as psplit +from distutils.command.install_scripts import install_scripts +from distutils import log + +BAT_TEMPLATE = \ +r"""@echo off +REM wrapper to use shebang first line of {FNAME} +set mypath=%~dp0 +set pyscript="%mypath%{FNAME}" +set /p line1=<%pyscript% +if "%line1:~0,2%" == "#!" (goto :goodstart) +echo First line of %pyscript% does not start with "#!" +exit /b 1 +:goodstart +set py_exe=%line1:~2% +call %py_exe% %pyscript% %* +""" + + +class my_install_scripts(install_scripts): + def run(self): + install_scripts.run(self) + if not os.name == "nt": + return + for filepath in self.get_outputs(): + # If we can find an executable name in the #! top line of the script + # file, make .bat wrapper for script. + with open(filepath, 'rt') as fobj: + first_line = fobj.readline() + if not (first_line.startswith('#!') and + 'python' in first_line.lower()): + log.info("No #!python executable found, skipping .bat " + "wrapper") + continue + pth, fname = psplit(filepath) + froot, ext = splitext(fname) + bat_file = pjoin(pth, froot + '.bat') + bat_contents = BAT_TEMPLATE.replace('{FNAME}', fname) + log.info("Making %s wrapper for %s" % (bat_file, filepath)) + if self.dry_run: + continue + with open(bat_file, 'wt') as fobj: + fobj.write(bat_contents) + data = [ - ('/usr/share/zsh/site-functions', ['cheat/autocompletion/_cheat.zsh']), - ('/etc/bash_completion.d' , ['cheat/autocompletion/cheat.bash']), - ('/usr/share/fish/completions' , ['cheat/autocompletion/cheat.fish']) + ('/usr/share/zsh/site-functions', ['cheat/autocompletion/_cheat.zsh']), + ('/etc/bash_completion.d' , ['cheat/autocompletion/cheat.bash']), + ('/usr/share/fish/completions' , ['cheat/autocompletion/cheat.fish']) ] if os.name == 'nt': @@ -34,5 +78,7 @@ setup( install_requires = [ 'docopt >= 0.6.1', 'pygments >= 1.6.0', - ] + ], + cmdclass = {'install_scripts': my_install_scripts} + ) From d68fb456ba898c6b417842913259770f4d6c1d3a Mon Sep 17 00:00:00 2001 From: Charley Peng Date: Thu, 29 May 2014 11:59:40 +1000 Subject: [PATCH 002/126] Added PyPi Badge Added Badge --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index e201f15..edcc5dc 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,10 @@ remember. `cheat` depends only on `python` and `pip`. +PyPI status: + +[![Latest Version](https://pypip.in/version/cheat/badge.png)](https://pypi.python.org/pypi/cheat/) +[![Downloads](https://pypip.in/download/cheat/badge.png)](https://pypi.python.org/pypi/cheat/) Example ------- From b77b9e854126eb83784e8e218136b30dfe5f6ca2 Mon Sep 17 00:00:00 2001 From: Charley Peng Date: Thu, 29 May 2014 12:01:25 +1000 Subject: [PATCH 003/126] Update README.md --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index edcc5dc..c3a9eeb 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,13 @@ to store notes on your favorite cookie recipes, feel free. Installing ---------- + +The easy way + + sudo pip install cheat + +The old way + First install the required python dependencies with: sudo pip install docopt pygments From 301203f2685770c94b9fe5a7b20d203992dbc43a Mon Sep 17 00:00:00 2001 From: Charley Peng Date: Fri, 30 May 2014 12:20:09 +1000 Subject: [PATCH 004/126] version bump as requested --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 65fcf53..26b0013 100644 --- a/setup.py +++ b/setup.py @@ -46,7 +46,7 @@ class my_install_scripts(install_scripts): setup( name = 'cheat', - version = '2.0.7', + version = '2.0.8', author = 'Chris Lane', author_email = 'chris@chris-allen-lane.com', license = 'GPL3', From ccfe2a9cbd164ae08c05fe5b8e76b36640f9e036 Mon Sep 17 00:00:00 2001 From: Charley Peng Date: Fri, 30 May 2014 12:24:39 +1000 Subject: [PATCH 005/126] missing file in version bump --- bin/cheat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/cheat b/bin/cheat index a995dac..83e7780 100755 --- a/bin/cheat +++ b/bin/cheat @@ -38,7 +38,7 @@ from docopt import docopt if __name__ == '__main__': # parse the command-line options - options = docopt(__doc__, version='cheat 2.0.7') + options = docopt(__doc__, version='cheat 2.0.8') # list directories if options['--directories']: From eda53cccd6d9ce9f080eb5071c34e12b090f4873 Mon Sep 17 00:00:00 2001 From: Chris Lane Date: Tue, 3 Jun 2014 22:34:50 -0400 Subject: [PATCH 006/126] Minor tweaks on PR #163 - Backed out Windows-related work in `setup.py`, because it is still in-progress - Minor changes to the `README` --- README.md | 5 +++-- setup.py | 47 +---------------------------------------------- 2 files changed, 4 insertions(+), 48 deletions(-) diff --git a/README.md b/README.md index 3b3ba5d..27d2919 100644 --- a/README.md +++ b/README.md @@ -50,11 +50,12 @@ to store notes on your favorite cookie recipes, feel free. Installing ---------- -The easy way +### Using pip ### sudo pip install cheat -The old way + +### Manually ### First install the required python dependencies with: diff --git a/setup.py b/setup.py index 26b0013..6be950e 100644 --- a/setup.py +++ b/setup.py @@ -1,48 +1,5 @@ from distutils.core import setup import os -from os.path import join as pjoin, splitext, split as psplit -from distutils.command.install_scripts import install_scripts -from distutils import log - -BAT_TEMPLATE = \ -r"""@echo off -REM wrapper to use shebang first line of {FNAME} -set mypath=%~dp0 -set pyscript="%mypath%{FNAME}" -set /p line1=<%pyscript% -if "%line1:~0,2%" == "#!" (goto :goodstart) -echo First line of %pyscript% does not start with "#!" -exit /b 1 -:goodstart -set py_exe=%line1:~2% -call %py_exe% %pyscript% %* -""" - - -class my_install_scripts(install_scripts): - def run(self): - install_scripts.run(self) - if not os.name == "nt": - return - for filepath in self.get_outputs(): - # If we can find an executable name in the #! top line of the script - # file, make .bat wrapper for script. - with open(filepath, 'rt') as fobj: - first_line = fobj.readline() - if not (first_line.startswith('#!') and - 'python' in first_line.lower()): - log.info("No #!python executable found, skipping .bat " - "wrapper") - continue - pth, fname = psplit(filepath) - froot, ext = splitext(fname) - bat_file = pjoin(pth, froot + '.bat') - bat_contents = BAT_TEMPLATE.replace('{FNAME}', fname) - log.info("Making %s wrapper for %s" % (bat_file, filepath)) - if self.dry_run: - continue - with open(bat_file, 'wt') as fobj: - fobj.write(bat_contents) setup( name = 'cheat', @@ -67,7 +24,5 @@ setup( install_requires = [ 'docopt >= 0.6.1', 'pygments >= 1.6.0', - ], - cmdclass = {'install_scripts': my_install_scripts} - + ] ) From e4417b2d6528189944f7669244e18c28cbc35f1c Mon Sep 17 00:00:00 2001 From: Chris Lane Date: Tue, 3 Jun 2014 22:38:24 -0400 Subject: [PATCH 007/126] Version bump Realized a 2.0.8 had already been pushed to PyPi, so I just version-bumped this to 2.0.9. --- bin/cheat | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/cheat b/bin/cheat index 83e7780..909dd4a 100755 --- a/bin/cheat +++ b/bin/cheat @@ -38,7 +38,7 @@ from docopt import docopt if __name__ == '__main__': # parse the command-line options - options = docopt(__doc__, version='cheat 2.0.8') + options = docopt(__doc__, version='cheat 2.0.9') # list directories if options['--directories']: diff --git a/setup.py b/setup.py index 6be950e..fd98281 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ import os setup( name = 'cheat', - version = '2.0.8', + version = '2.0.9', author = 'Chris Lane', author_email = 'chris@chris-allen-lane.com', license = 'GPL3', From 95636f5433acb470bb474f499fa2dfb3d55b52f8 Mon Sep 17 00:00:00 2001 From: Jonathan Dahan Date: Mon, 9 Jun 2014 00:49:19 -0400 Subject: [PATCH 008/126] Add homebrew install instructions to readme Could close https://github.com/chrisallenlane/cheat/issues/167 , thanks @xu-cheng for making the formula --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 27d2919..ef0843a 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,11 @@ to store notes on your favorite cookie recipes, feel free. Installing ---------- +### Using homebrew ### + + brew install cheat + + ### Using pip ### sudo pip install cheat From 191a5e6e849c373d03443c984c919fb7b1ce8128 Mon Sep 17 00:00:00 2001 From: Chris Lane Date: Sun, 22 Jun 2014 17:17:27 -0400 Subject: [PATCH 009/126] Trivial changes on jedahan/patch-1 --- README.md | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index ef0843a..95178fa 100644 --- a/README.md +++ b/README.md @@ -49,17 +49,15 @@ to store notes on your favorite cookie recipes, feel free. Installing ---------- + +### Using pip ### + + sudo pip install cheat ### Using homebrew ### brew install cheat - -### Using pip ### - - sudo pip install cheat - - ### Manually ### First install the required python dependencies with: From d1fb8414f80b2eaf6be8d7c5220af6ce83a4eb89 Mon Sep 17 00:00:00 2001 From: Chris Lane Date: Sun, 22 Jun 2014 17:24:09 -0400 Subject: [PATCH 010/126] Added a `tee` cheatsheet --- cheat/cheatsheets/tee | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 cheat/cheatsheets/tee diff --git a/cheat/cheatsheets/tee b/cheat/cheatsheets/tee new file mode 100644 index 0000000..301d4df --- /dev/null +++ b/cheat/cheatsheets/tee @@ -0,0 +1,5 @@ +# To tee stdout to a file: +ls | tee outfile.txt + +# To tee stdout and append to a file: +ls | tee -a outfile.txt From 7bd603cf234ccc57cce68fbf77319c6b2a240995 Mon Sep 17 00:00:00 2001 From: Julius Haertl Date: Tue, 29 Jul 2014 00:40:21 +0200 Subject: [PATCH 011/126] Add cheat for iproute2 --- cheat/cheatsheets/ip | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 cheat/cheatsheets/ip diff --git a/cheat/cheatsheets/ip b/cheat/cheatsheets/ip new file mode 100644 index 0000000..aae2057 --- /dev/null +++ b/cheat/cheatsheets/ip @@ -0,0 +1,32 @@ +# Display all interfaces with addresses +ip addr + +# Take down / up the wireless adapter +ip link set dev wlan0 {up|down} + +# Set a static IP and netmask +ip addr add 192.168.1.100/32 dev eth0 + +# Remove a IP from an interface +ip addr del 192.168.1.100/32 dev eth0 + +# Remove all IPs from an interface +ip address flush dev eth0 + +# Display all routes +ip route + +# Display all routes for IPv6 +ip -6 route + +# Add route via gateway IP +ip route add 192.168.0.0/24 via 192.168.1.1 + +# Add route via interface +ip route add 192.168.0.0/24 dev eth0 + +# Change your mac address +ip link set dev eth0 address aa:bb:cc:dd:ee:ff + +# View neighbors (using ARP and NDP) +ip neighbor show From 22a33dc5d335c819287fdf2c444fa8a2fce7bc9a Mon Sep 17 00:00:00 2001 From: ImmortalPC Date: Tue, 29 Jul 2014 18:01:04 +0200 Subject: [PATCH 012/126] [GREP,NMAP,RM,WGET] Add new cheats --- cheatsheets/grep | 3 +++ cheatsheets/nmap | 16 ++++++++++++++-- cheatsheets/rm | 5 ++++- cheatsheets/wget | 3 +++ 4 files changed, 24 insertions(+), 3 deletions(-) diff --git a/cheatsheets/grep b/cheatsheets/grep index fced336..cb004e9 100644 --- a/cheatsheets/grep +++ b/cheatsheets/grep @@ -24,3 +24,6 @@ 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' + +# Colour in red {bash} and keep all other lines +ps aux | grep -E --color 'bash|$' diff --git a/cheatsheets/nmap b/cheatsheets/nmap index 81c54a8..f46a01c 100644 --- a/cheatsheets/nmap +++ b/cheatsheets/nmap @@ -23,13 +23,15 @@ nmap -source-port [port] [target] nmap -A [target] # Speedup your scan: -nmap -T5 --min-parallelism=50 [target] +# -n => disable ReverseDNS +# --min-rate=X => min 300 packets / sec +nmap -T5 --min-parallelism=50 -n --min-rate=300 [target] # Traceroute: nmap -traceroute [target] # Ping scan only: -sP -# Don't ping: -PN +# Don't ping: -PN <- Use full if a host don't reply to a ping. # TCP SYN ping: -PS # TCP ACK ping: -PA # UDP ping: -PU @@ -38,6 +40,9 @@ nmap -traceroute [target] # Example: Ping scan all machines on a class C network nmap -sP 192.168.0.0/24 +# Force TCP scan: -sT +# Force UDP scan: -sU + # Use some script: nmap --script default,safe @@ -55,3 +60,10 @@ 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-*" + +# Scan for the heartbleed +# -pT:443 => Scan only port 443 with TCP (T:) +nmap -T5 --min-parallelism=50 -n --script "ssl-heartbleed" -pT:443 127.0.0.1 + +# Show all informations (debug mode) +nmap -d ... diff --git a/cheatsheets/rm b/cheatsheets/rm index d119df2..2a8fc02 100644 --- a/cheatsheets/rm +++ b/cheatsheets/rm @@ -1,5 +1,8 @@ # Remove files and subdirs rm -rf path/to/the/target/ -# Ignore non existent files +# Ignore non existent files rm -f path/to/the/target + +# Remove a file with his inode +find /tmp/ -inum 6666 -exec rm -i '{}' \; diff --git a/cheatsheets/wget b/cheatsheets/wget index fb9a45a..0439650 100644 --- a/cheatsheets/wget +++ b/cheatsheets/wget @@ -30,3 +30,6 @@ wget -r -l1 -A.extension http://myserver.com/directory # Allows you to download just the headers of responses (-S --spider) and display them on Stdout (-O -). wget -S --spider -O - http://google.com + +# Change the User-Agent to 'User-Agent: toto' +wget -U 'toto' http://google.com From f125db6f45927d4c9f7161f6238d0394e39546bf Mon Sep 17 00:00:00 2001 From: "Baptiste D." Date: Wed, 6 Aug 2014 09:25:08 +0200 Subject: [PATCH 013/126] Update apt-get Mistake on #7 --- cheat/cheatsheets/apt-get | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cheat/cheatsheets/apt-get b/cheat/cheatsheets/apt-get index c7bc7f3..f46e1ef 100644 --- a/cheat/cheatsheets/apt-get +++ b/cheat/cheatsheets/apt-get @@ -4,7 +4,7 @@ apt-get update # To download and install updates without installing new package. -apt-get update +apt-get upgrade # To download and install the updates AND install new necessary packages apt-get dist-upgrade From e391cf2f01b01fa7dcf980c6a4044e047c95e050 Mon Sep 17 00:00:00 2001 From: Chris Lane Date: Wed, 6 Aug 2014 21:39:10 -0400 Subject: [PATCH 014/126] Issue #172 Previously, `cheat` would exit if run by `root`. The rationale was: If `cheat` was run by an unprivileged user (`chris`, for example), the `$DEFAULT_CHEAT_DIR` would default to `/home/chris/.cheat`. If cheat was run via `sudo`, however, the `$DEFAULT_CHEAT_DIR` would suddenly be `/root/.cheat`. Presuming that those individual user cheat dirs actually contained cheat sheets, this could cause confusion, because cheat sheets accessible to one user (`chris`) would not be accessible to the other (`root`). Thus, cheatsheets would appear and disappear, depending on which user was running `cheat`. (This would only be an issue, of course, for cheat sheets that existed within the respective users' cheat dirs. System-wide cheat sheets would be unaffected.) `cheat` was thus programmed to gracefully fail when run as `root` to prevent that possible confusion. However, I'm backing away from that reasoning, because: 1. It's causing a headache for real users who'd like to run `cheat` as root 2. Other venerable programs (`vim`, etc.) suffer from the same problem, but nobody seems to mind enough to do anything about it. Thus, I suppose the laissez-faire approach is essentially the sanctioned "solution" to this problem. 3. Users sufficently troubled by this confusion may rememdy the problem manually by setting environment variables (`$DEFAULT_CHEAT_DIR`, etc.) Thus, `cheat` no longer complains if run by `root`. Version-bumped to 2.1.0. --- cheat/sheets.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/cheat/sheets.py b/cheat/sheets.py index 24c556c..d9fbc91 100644 --- a/cheat/sheets.py +++ b/cheat/sheets.py @@ -12,12 +12,6 @@ cheats = {} def default_path(): """ Returns the default cheatsheet path """ - # the default path becomes confused when cheat is run as root, so fail - # under those circumstances. (There is no good reason to need to run cheat - # as root.) - if os.name != 'nt' and os.geteuid() == 0: - die('Please do not run this application as root.'); - # determine the default cheatsheet dir default_sheets_dir = os.environ.get('DEFAULT_CHEAT_DIR') or os.path.join(os.path.expanduser('~'), '.cheat') From 6a8e3f7fc68911762ef18d72f169e7eb48a9f518 Mon Sep 17 00:00:00 2001 From: Chris Lane Date: Wed, 6 Aug 2014 22:01:06 -0400 Subject: [PATCH 015/126] Version bump. --- bin/cheat | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/cheat b/bin/cheat index 909dd4a..ec1717e 100755 --- a/bin/cheat +++ b/bin/cheat @@ -38,7 +38,7 @@ from docopt import docopt if __name__ == '__main__': # parse the command-line options - options = docopt(__doc__, version='cheat 2.0.9') + options = docopt(__doc__, version='cheat 2.1.0') # list directories if options['--directories']: diff --git a/setup.py b/setup.py index fd98281..d791f64 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ import os setup( name = 'cheat', - version = '2.0.9', + version = '2.1.0', author = 'Chris Lane', author_email = 'chris@chris-allen-lane.com', license = 'GPL3', From f9f1c5b3e46f27029287a48b6d7232d00c35eb57 Mon Sep 17 00:00:00 2001 From: Chris Lane Date: Wed, 6 Aug 2014 22:04:19 -0400 Subject: [PATCH 016/126] Issue #175 Noted `tldr` as a closely-related project in the `README`. --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 95178fa..04ffb5c 100644 --- a/README.md +++ b/README.md @@ -141,6 +141,8 @@ Related Projects - [`cheat` RubyGem][3]: A clever gem from 2006 that clearly had similar motivations. It is unclear whether or not it is currently maintained. +- [`tldr`][tldr]: "Simplified and community-driven man pages". + [dotfiles]: http://dotfiles.github.io/ [jahendrie]: https://github.com/jahendrie @@ -148,3 +150,4 @@ Related Projects [2]: https://github.com/jahendrie/cheat [3]: http://errtheblog.com/posts/21-cheat [4]: https://github.com/chrisallenlane/cheat/pull/77 +[tldr]: https://github.com/tldr-pages/tldr From db92b4c5d86958a8e0b92f96375e4d601218030e Mon Sep 17 00:00:00 2001 From: quentin Date: Thu, 7 Aug 2014 11:59:59 +0200 Subject: [PATCH 017/126] Add new 'rpm' cheatsheet --- cheat/cheatsheets/rpm | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 cheat/cheatsheets/rpm diff --git a/cheat/cheatsheets/rpm b/cheat/cheatsheets/rpm new file mode 100644 index 0000000..93e2ecf --- /dev/null +++ b/cheat/cheatsheets/rpm @@ -0,0 +1,14 @@ +# To install a package: +rpm -ivh + +# To remove a package: +rpm -e + +# To find what package installs a file: +rpm -qf + +# To find what files are installed by a package: +rpm -qpl + +# To list all installed packages: +rpm -qa From b193112a13089ceafc8256ec630394896c6d490c Mon Sep 17 00:00:00 2001 From: quentin Date: Thu, 7 Aug 2014 12:00:48 +0200 Subject: [PATCH 018/126] Add new ['hub'](https://hub.github.com/) cheatsheet --- cheat/cheatsheets/hub | 74 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 cheat/cheatsheets/hub diff --git a/cheat/cheatsheets/hub b/cheat/cheatsheets/hub new file mode 100644 index 0000000..22cfeab --- /dev/null +++ b/cheat/cheatsheets/hub @@ -0,0 +1,74 @@ +As a contributor to open-source +------------------------------- + +# clone your own project +$ git clone dotfiles +→ git clone git://github.com/YOUR_USER/dotfiles.git + +# clone another project +$ git clone github/hub +→ git clone git://github.com/github/hub.git + +# see the current project's issues +$ git browse -- issues +→ open https://github.com/github/hub/issues + +# open another project's wiki +$ git browse mojombo/jekyll wiki +→ open https://github.com/mojombo/jekyll/wiki + +## Example workflow for contributing to a project: +$ git clone github/hub +$ cd hub +# create a topic branch +$ git checkout -b feature +→ ( making changes ... ) +$ git commit -m "done with feature" +# It's time to fork the repo! +$ git fork +→ (forking repo on GitHub...) +→ git remote add YOUR_USER git://github.com/YOUR_USER/hub.git +# push the changes to your new remote +$ git push YOUR_USER feature +# open a pull request for the topic branch you've just pushed +$ git pull-request +→ (opens a text editor for your pull request message) + + +As an open-source maintainer +---------------------------- + +# fetch from multiple trusted forks, even if they don't yet exist as remotes +$ git fetch mislav,cehoffman +→ git remote add mislav git://github.com/mislav/hub.git +→ git remote add cehoffman git://github.com/cehoffman/hub.git +→ git fetch --multiple mislav cehoffman + +# check out a pull request for review +$ git checkout https://github.com/github/hub/pull/134 +→ (creates a new branch with the contents of the pull request) + +# directly apply all commits from a pull request to the current branch +$ git am -3 https://github.com/github/hub/pull/134 + +# cherry-pick a GitHub URL +$ git cherry-pick https://github.com/xoebus/hub/commit/177eeb8 +→ git remote add xoebus git://github.com/xoebus/hub.git +→ git fetch xoebus +→ git cherry-pick 177eeb8 + +# `am` can be better than cherry-pick since it doesn't create a remote +$ git am https://github.com/xoebus/hub/commit/177eeb8 + +# open the GitHub compare view between two releases +$ git compare v0.9..v1.0 + +# put compare URL for a topic branch to clipboard +$ git compare -u feature | pbcopy + +# create a repo for a new project +$ git init +$ git add . && git commit -m "It begins." +$ git create -d "My new thing" +→ (creates a new project on GitHub with the name of current directory) +$ git push origin master From ab2d96edb47a6ca505e3ce0ff2dbe6ee8cc56b86 Mon Sep 17 00:00:00 2001 From: quentin Date: Thu, 7 Aug 2014 12:32:34 +0200 Subject: [PATCH 019/126] Add new `readline` cheatsheet --- cheat/cheatsheets/readline | 49 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 cheat/cheatsheets/readline diff --git a/cheat/cheatsheets/readline b/cheat/cheatsheets/readline new file mode 100644 index 0000000..ef82e1a --- /dev/null +++ b/cheat/cheatsheets/readline @@ -0,0 +1,49 @@ + Moving around +Ctrl-b Move the cursor one character ⇦ to the left +Ctrl-f Move the cursor one character ⇨ to the right +Alt-b Move the cursor one word ⇦ to the left +Alt-f Move the cursor one word ⇨ to the right +Ctrl-a Move the cursor ⇤ to the start of the line +Ctrl-e Move the cursor ⇥ to the end of the line +Ctrl-x-x Move the cursor ⇤⇥ to the start, and to the end again + + Cut, copy and paste +Backspace Delete the character ⇦ to the left of the cursor +DEL +Ctrl-d Delete the character underneath the cursor +Ctrl-u Delete everything ⇤ from the cursor back to the line start +Ctrl-k Delete everything ⇥ from the cursor to the end of the line +Alt-d Delete word ⇨ until before the next word boundary +Ctrl-w Delete word ⇦ until after the previous word boundary +Ctrl-y Yank/Paste prev. killed text at the cursor position +Alt-y Yank/Paste prev. prev. killed text at the cursor position + + History +Ctrl-p Move in history one line ⇧ before this line +Ctrl-n Move in history one line ⇩ after this line +Alt-> Move in history all the lines ⇩ to the line currently being entered +Ctrl-r Incrementally search the line history ⇧ backwardly +Ctrl-s Incrementally search the line history ⇩ forwardly +Ctrl-J End an incremental search +Ctrl-G Abort an incremental search and restore the original line +Alt-Ctrl-y Yank/Paste arg. 1 of prev. cmnd at the cursor position +Alt-. +Alt-_ Yank/Paste last arg of prev. cmnd at the cursor position + + Undo +Ctrl-_ +Ctrl-x +Ctrl-u Undo the last editing command; you can undo all the way back to an empty line +Alt-r Undo all changes made to this line +Ctrl-l Clear the screen, reprinting the current line at the top +Ctrl-l Clear the screen, reprinting the current line at the top + + Completion +TAB Auto-complete a name +Alt-/ Auto-complete a name (without smart completion) +Alt-? List the possible completions of the preceeding text +Alt-* Insert all possible completions of the preceeding text + + Transpose +Ctrl-t Transpose/drag char. before the cursor ↷ over the character at the cursor +Alt-t Transpose/drag word before the cursor ↷ over the word at/after the cursor From ce611eaceb29198442c61715352297e37d32db3d Mon Sep 17 00:00:00 2001 From: barhamd Date: Fri, 8 Aug 2014 11:52:43 -0600 Subject: [PATCH 020/126] Never parse ls. http://mywiki.wooledge.org/ParsingLs It's about the only thing I really know about bash. --- cheat/cheatsheets/bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cheat/cheatsheets/bash b/cheat/cheatsheets/bash index 3b601d3..e74a768 100644 --- a/cheat/cheatsheets/bash +++ b/cheat/cheatsheets/bash @@ -1,5 +1,5 @@ # To implement a for loop: -for file in `ls .`; +for file in *; do echo $file found; done From 41d2a810e609c58364ac401225b66c1f27f90fd7 Mon Sep 17 00:00:00 2001 From: Brandon Pierce Date: Wed, 13 Aug 2014 10:49:56 -0700 Subject: [PATCH 021/126] add debugging examples for bash add new command route --- cheat/cheatsheets/bash | 6 ++++++ cheat/cheatsheets/route | 5 +++++ 2 files changed, 11 insertions(+) create mode 100644 cheat/cheatsheets/route diff --git a/cheat/cheatsheets/bash b/cheat/cheatsheets/bash index e74a768..5b7a702 100644 --- a/cheat/cheatsheets/bash +++ b/cheat/cheatsheets/bash @@ -12,3 +12,9 @@ in 2) echo "two found";; 3*) echo "something beginning with 3 found";; esac + +# Turn on debugging: +set -x + +# Turn off debugging: +set +x diff --git a/cheat/cheatsheets/route b/cheat/cheatsheets/route new file mode 100644 index 0000000..032dcac --- /dev/null +++ b/cheat/cheatsheets/route @@ -0,0 +1,5 @@ +# Add a default gateway: +route add default gateway 192.168.0.1 + +# Display routing table IP addresses instead of host names: +route -n From d1d5d84e4cb0c223bf07c4f7019e68aad0888c33 Mon Sep 17 00:00:00 2001 From: Erik Cox Date: Sat, 13 Sep 2014 15:09:40 -0700 Subject: [PATCH 022/126] First attempt at making utils.py compatible with Python 2 and 3. --- cheat/utils.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cheat/utils.py b/cheat/utils.py index 4010c15..b2ea17f 100644 --- a/cheat/utils.py +++ b/cheat/utils.py @@ -1,3 +1,4 @@ +from __future__ import print_function import os import sys @@ -53,4 +54,4 @@ def prompt_yes_or_no(question): def warn(message): """ Prints a message to stderr """ - print >> sys.stderr, (message) + print((message), file=sys.stderr) From dde3acf109d48d0cc25213e14e1582169c68a160 Mon Sep 17 00:00:00 2001 From: Erik Cox Date: Sat, 13 Sep 2014 15:46:57 -0700 Subject: [PATCH 023/126] Added a condition in prompt_yes_or_no() to use input or raw_input --- cheat/utils.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/cheat/utils.py b/cheat/utils.py index b2ea17f..28ba2eb 100644 --- a/cheat/utils.py +++ b/cheat/utils.py @@ -48,8 +48,16 @@ def editor(): def prompt_yes_or_no(question): """ Prompts the user with a yes-or-no question """ + # Support Python 2 and 3 input + # Default to Python 2's input() + get_input = raw_input + + # If this is Python 3, use input() + if sys.version_info[:2] >= (3, 0): + get_input = input + print(question) - return raw_input('[y/n] ') == 'y' + return get_input('[y/n] ') == 'y' def warn(message): From 873968903ae3386a1e78bbfd34d9523ed343a76d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Sun, 12 Oct 2014 13:16:53 +0200 Subject: [PATCH 024/126] mount: add bind mount --- cheat/cheatsheets/mount | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cheat/cheatsheets/mount b/cheat/cheatsheets/mount index 7b81d93..233c0e3 100644 --- a/cheat/cheatsheets/mount +++ b/cheat/cheatsheets/mount @@ -1,6 +1,9 @@ # To mount / partition as read-write in repair mode: mount -o remount,rw / +# Bind mount path to a second location +mount --bind /origin/path /destination/path + # To mount Usb disk as user writable: mount -o uid=username,gid=usergroup /dev/sdx /mnt/xxx From 6b8ecd6b5cefbb290f4901d0d1e6aff9b907468d Mon Sep 17 00:00:00 2001 From: Chris Lane Date: Sun, 19 Oct 2014 11:43:43 -0400 Subject: [PATCH 025/126] 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. --- cheat/cheatsheets/du | 2 ++ cheat/cheatsheets/find | 6 +++--- cheat/cheatsheets/lvm | 7 +++++++ cheat/cheatsheets/nc | 20 ++++++++++++++++++++ cheat/cheatsheets/route | 30 +++++++++++++++++++++++++++--- cheat/cheatsheets/rsync | 12 ++++++++++-- cheat/cheatsheets/sed | 5 ++++- cheat/cheatsheets/snmpwalk | 5 +++++ 8 files changed, 78 insertions(+), 9 deletions(-) create mode 100644 cheat/cheatsheets/du create mode 100644 cheat/cheatsheets/lvm create mode 100644 cheat/cheatsheets/nc create mode 100644 cheat/cheatsheets/snmpwalk diff --git a/cheat/cheatsheets/du b/cheat/cheatsheets/du new file mode 100644 index 0000000..61c625d --- /dev/null +++ b/cheat/cheatsheets/du @@ -0,0 +1,2 @@ +# To sort directories/files by size +du -sk *| sort -rn diff --git a/cheat/cheatsheets/find b/cheat/cheatsheets/find index 5cd262f..f97ce77 100644 --- a/cheat/cheatsheets/find +++ b/cheat/cheatsheets/find @@ -20,10 +20,10 @@ find ./path/ -name '*.txt' -exec rm '{}' \; find ./path/ -name '*.txt' | xargs grep 'string' # 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: -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 find . -type f -mtime +7d -ls @@ -41,4 +41,4 @@ find . -maxdepth 2 -name build -type d 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 +find . -type f -samefile MY_FILE_HERE 2>/dev/null diff --git a/cheat/cheatsheets/lvm b/cheat/cheatsheets/lvm new file mode 100644 index 0000000..492be2e --- /dev/null +++ b/cheat/cheatsheets/lvm @@ -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 diff --git a/cheat/cheatsheets/nc b/cheat/cheatsheets/nc new file mode 100644 index 0000000..8dc9b53 --- /dev/null +++ b/cheat/cheatsheets/nc @@ -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 diff --git a/cheat/cheatsheets/route b/cheat/cheatsheets/route index 032dcac..5997ebd 100644 --- a/cheat/cheatsheets/route +++ b/cheat/cheatsheets/route @@ -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 -# Display routing table IP addresses instead of host names: -route -n +# 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 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 diff --git a/cheat/cheatsheets/rsync b/cheat/cheatsheets/rsync index 617bf74..43343b6 100644 --- a/cheat/cheatsheets/rsync +++ b/cheat/cheatsheets/rsync @@ -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 /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/ + +# 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 diff --git a/cheat/cheatsheets/sed b/cheat/cheatsheets/sed index f60b269..e22c97a 100644 --- a/cheat/cheatsheets/sed +++ b/cheat/cheatsheets/sed @@ -10,5 +10,8 @@ echo 'It is daytime' | sed 's/day/night/g' # To remove leading spaces 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 + +# To replace newlines in multiple lines +sed ':a;N;$!ba;s/\n//g' file.txt diff --git a/cheat/cheatsheets/snmpwalk b/cheat/cheatsheets/snmpwalk new file mode 100644 index 0000000..90c86ea --- /dev/null +++ b/cheat/cheatsheets/snmpwalk @@ -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 From 4ea583503b7eaf706c8bc52df50283eb75ac9458 Mon Sep 17 00:00:00 2001 From: ImmortalPC Date: Mon, 20 Oct 2014 19:31:31 +0200 Subject: [PATCH 026/126] [NMAP] Change comment "300" => X --- cheat/cheatsheets/nmap | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cheat/cheatsheets/nmap b/cheat/cheatsheets/nmap index f46a01c..90efccb 100644 --- a/cheat/cheatsheets/nmap +++ b/cheat/cheatsheets/nmap @@ -24,7 +24,7 @@ nmap -A [target] # Speedup your scan: # -n => disable ReverseDNS -# --min-rate=X => min 300 packets / sec +# --min-rate=X => min X packets / sec nmap -T5 --min-parallelism=50 -n --min-rate=300 [target] # Traceroute: From 77429d9ccc810d18f744a08539dfc1fc6895401b Mon Sep 17 00:00:00 2001 From: Amit Saha Date: Thu, 23 Oct 2014 14:48:25 +1000 Subject: [PATCH 027/126] Add cheat for docker --- cheat/cheatsheets/docker | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 cheat/cheatsheets/docker diff --git a/cheat/cheatsheets/docker b/cheat/cheatsheets/docker new file mode 100644 index 0000000..8dc66c5 --- /dev/null +++ b/cheat/cheatsheets/docker @@ -0,0 +1,26 @@ +# Start docker daemon +docker -d + +# start a container with an interactive shell +docker run -ti /bin/bash + +# inspect a running container +docker inspect (or ) + +# Get the process ID for a container +# Source: https://github.com/jpetazzo/nsenter +docker inspect --format {{.State.Pid}} + +# List the current mounted volumes for a container (and pretty print) +# Source: +# http://nathanleclaire.com/blog/2014/07/12/10-docker-tips-and-tricks-that-will-make-you-sing-a-whale-song-of-joy/ +docker inspect --format='{{json .Volumes}}' | python -mjson.tool + +# list currently running containers +docker ps + +# list all containers +docker ps -a + +# list all images +docker images \ No newline at end of file From 6f579f9234a563c0735a3b4c87b5e8e3e6de39a8 Mon Sep 17 00:00:00 2001 From: poliveira89 Date: Sat, 22 Nov 2014 17:09:58 +0000 Subject: [PATCH 028/126] New cheatsheet added: support for Bower (frontend package manager) --- cheat/cheatsheets/bower | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 cheat/cheatsheets/bower diff --git a/cheat/cheatsheets/bower b/cheat/cheatsheets/bower new file mode 100644 index 0000000..da29ebd --- /dev/null +++ b/cheat/cheatsheets/bower @@ -0,0 +1,26 @@ +# Install a package locally +bower install + +# Install a package locally directly from github +bower install / + +# Install a specific package locally +bower install # + +# Install a package locally and save installed package into bower.json +bower install --save + +# Retrieve info of a particular package +bower info + +# List local packages +bower list + +# Search for a package by name +bower search + +# Update a package to their newest version +bower update + +# Remove a local package +bower uninstall From 61458933ebefd6403d672a32ea42eaebcb3e9ab6 Mon Sep 17 00:00:00 2001 From: poliveira89 Date: Sat, 22 Nov 2014 17:15:51 +0000 Subject: [PATCH 029/126] SSH cheatsheet updated: support for SSH tunnels between local host and remote host --- cheat/cheatsheets/ssh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cheat/cheatsheets/ssh b/cheat/cheatsheets/ssh index ce11b52..e9ba18f 100644 --- a/cheat/cheatsheets/ssh +++ b/cheat/cheatsheets/ssh @@ -10,6 +10,9 @@ ssh -t user@example.com 'the-remote-command' # To tunnel an x session over SSH: ssh -X user@example.com +# Redirect traffic with a tunnel between local host (port 8080) and a remote host (remote.example.com:5000) through a proxy (personal.server.com): +ssh -f -L 8080:remote.example.com:5000 user@personal.server.com -N + # To launch a specific x application over SSH: ssh -X -t user@example.com 'chromium-browser' From 603bc360c0123d134401d2478f65d68688eaf7af Mon Sep 17 00:00:00 2001 From: Chris Lane Date: Tue, 9 Dec 2014 20:58:15 -0500 Subject: [PATCH 030/126] Version bump --- bin/cheat | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/cheat b/bin/cheat index ec1717e..449891e 100755 --- a/bin/cheat +++ b/bin/cheat @@ -38,7 +38,7 @@ from docopt import docopt if __name__ == '__main__': # parse the command-line options - options = docopt(__doc__, version='cheat 2.1.0') + options = docopt(__doc__, version='cheat 2.1.1') # list directories if options['--directories']: diff --git a/setup.py b/setup.py index d791f64..d611ece 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ import os setup( name = 'cheat', - version = '2.1.0', + version = '2.1.1', author = 'Chris Lane', author_email = 'chris@chris-allen-lane.com', license = 'GPL3', From 2d67038188cf48b7198d17a51e7a526beaf045c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Wed, 24 Dec 2014 12:13:29 +0100 Subject: [PATCH 031/126] smbclient --- cheat/cheatsheets/smbclient | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 cheat/cheatsheets/smbclient diff --git a/cheat/cheatsheets/smbclient b/cheat/cheatsheets/smbclient new file mode 100644 index 0000000..4231fd8 --- /dev/null +++ b/cheat/cheatsheets/smbclient @@ -0,0 +1,5 @@ +# To display public shares on the server: +smbclient -L -U% + +# To connect to a share: +smbclient /// -U% From c412cd0534a38af40309b18a3ab1d4917d9b1c4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Wed, 24 Dec 2014 12:15:03 +0100 Subject: [PATCH 032/126] ping6 --- cheat/cheatsheets/ping6 | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 cheat/cheatsheets/ping6 diff --git a/cheat/cheatsheets/ping6 b/cheat/cheatsheets/ping6 new file mode 100644 index 0000000..a07dd00 --- /dev/null +++ b/cheat/cheatsheets/ping6 @@ -0,0 +1,2 @@ +# get all ipv6 neighbor via broadcast ping +ping6 -I eth0 ff02::1 From 54e30022f060f29d061de6510b6dcbe389e38b1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Wed, 24 Dec 2014 18:08:56 +0100 Subject: [PATCH 033/126] ping6: fix typo --- cheat/cheatsheets/ping6 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cheat/cheatsheets/ping6 b/cheat/cheatsheets/ping6 index a07dd00..39e121e 100644 --- a/cheat/cheatsheets/ping6 +++ b/cheat/cheatsheets/ping6 @@ -1,2 +1,2 @@ -# get all ipv6 neighbor via broadcast ping +# get all ipv6 neighbors via broadcast ping ping6 -I eth0 ff02::1 From 58abb16ca18c37eb4178df4215b9abeb356fa090 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Wed, 24 Dec 2014 21:42:16 +0100 Subject: [PATCH 034/126] ss --- cheat/cheatsheets/ss | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 cheat/cheatsheets/ss diff --git a/cheat/cheatsheets/ss b/cheat/cheatsheets/ss new file mode 100644 index 0000000..8925108 --- /dev/null +++ b/cheat/cheatsheets/ss @@ -0,0 +1,18 @@ +ss +Utility to investigate sockets + +Args +-4/-6 list ipv4/ipv6 sockets +-n numeric addresses instead of hostnames +-l list listing sockets +-u/-t/-x list udp/tcp/unix sockets +-p Show process(es) that using socket + +# show all listing tcp sockets including the corresponding process +ss -tlp + +# show all sockets connecting to 192.168.2.1 on port 80 +ss -t dst 192.168.2.1:80 + +# show all ssh related connection +ss -t state established '( dport = :ssh or sport = :ssh )' From 57876ed0e7a10c1930c12020fa24c158791db3fe Mon Sep 17 00:00:00 2001 From: thylong Date: Fri, 26 Dec 2014 15:46:48 -0500 Subject: [PATCH 035/126] Add cheat for gzip --- cheat/cheatsheets/gzip | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 cheat/cheatsheets/gzip diff --git a/cheat/cheatsheets/gzip b/cheat/cheatsheets/gzip new file mode 100644 index 0000000..05269d8 --- /dev/null +++ b/cheat/cheatsheets/gzip @@ -0,0 +1,14 @@ +# To create a *.gz compressed file +gzip test.txt + +# To create a *.gz compressed file to a specific location using -c option (standard out) +gzip -c test.txt > test_custom.txt.gz + +# To uncompress a *.gz file +gzip -d test.txt.gz + +# Discplay compression ratio of the compressed file using gzip -l +gzip -l *.gz + +# Recursively compress all the files under a specified directory +gzip -r documents_directory \ No newline at end of file From 956ce7fadd569b5579919c6f8e85d9ae54e39c22 Mon Sep 17 00:00:00 2001 From: thylong Date: Fri, 26 Dec 2014 15:57:01 -0500 Subject: [PATCH 036/126] Update cheat ssh --- cheat/cheatsheets/ssh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cheat/cheatsheets/ssh b/cheat/cheatsheets/ssh index ce11b52..e484673 100644 --- a/cheat/cheatsheets/ssh +++ b/cheat/cheatsheets/ssh @@ -4,6 +4,9 @@ ssh -i /path/to/file.pem user@example.com # To connect on an non-standard port: ssh -p 2222 user@example.com +# To connect and forward the authentication agent +ssh -A user@example.com + # To execute a command on a remote server: ssh -t user@example.com 'the-remote-command' From 03bb651bf0c2a507799d0662d237f6b11c3cc053 Mon Sep 17 00:00:00 2001 From: Chris Lane Date: Mon, 29 Dec 2014 21:45:46 -0500 Subject: [PATCH 037/126] Version bump --- bin/cheat | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/cheat b/bin/cheat index 449891e..469f27d 100755 --- a/bin/cheat +++ b/bin/cheat @@ -38,7 +38,7 @@ from docopt import docopt if __name__ == '__main__': # parse the command-line options - options = docopt(__doc__, version='cheat 2.1.1') + options = docopt(__doc__, version='cheat 2.1.2') # list directories if options['--directories']: diff --git a/setup.py b/setup.py index d611ece..a27ffb0 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ import os setup( name = 'cheat', - version = '2.1.1', + version = '2.1.2', author = 'Chris Lane', author_email = 'chris@chris-allen-lane.com', license = 'GPL3', From 27482cbabd28448177aa3c4a17300c274de6fbfb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Tue, 30 Dec 2014 10:07:13 +0100 Subject: [PATCH 038/126] ip: better route example Assigning a subnet is already covered in the example below. Setting a default route via a router is the most common use case of ip route IMHO. --- cheat/cheatsheets/ip | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cheat/cheatsheets/ip b/cheat/cheatsheets/ip index aae2057..a0f20cd 100644 --- a/cheat/cheatsheets/ip +++ b/cheat/cheatsheets/ip @@ -19,8 +19,8 @@ ip route # Display all routes for IPv6 ip -6 route -# Add route via gateway IP -ip route add 192.168.0.0/24 via 192.168.1.1 +# Add default route via gateway IP +ip route add default via 192.168.1.1 # Add route via interface ip route add 192.168.0.0/24 dev eth0 From 9506167af817b35a881894f370c68efb02186b07 Mon Sep 17 00:00:00 2001 From: thylong Date: Fri, 26 Dec 2014 15:46:48 -0500 Subject: [PATCH 039/126] Add cheat for gzip --- cheat/cheatsheets/gzip | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 cheat/cheatsheets/gzip diff --git a/cheat/cheatsheets/gzip b/cheat/cheatsheets/gzip new file mode 100644 index 0000000..74cd174 --- /dev/null +++ b/cheat/cheatsheets/gzip @@ -0,0 +1,17 @@ +# To create a *.gz compressed file +gzip test.txt + +# To create a *.gz compressed file to a specific location using -c option (standard out) +gzip -c test.txt > test_custom.txt.gz + +# To uncompress a *.gz file +gzip -d test.txt.gz + +# Display compression ratio of the compressed file using gzip -l +gzip -l *.gz + +# Recursively compress all the files under a specified directory +gzip -r documents_directory + +# To create a *.gz compressed file and keep the original +gzip < test.txt > test.txt.gz \ No newline at end of file From be2cb6e6320a4507562ee5ed5c45978ce86a5b29 Mon Sep 17 00:00:00 2001 From: Chris Lane Date: Mon, 5 Jan 2015 20:44:25 -0500 Subject: [PATCH 040/126] Version 2.1.3 - Added new cheatsheets - Appended to `.gitignore` --- .gitignore | 2 ++ bin/cheat | 2 +- cheat/cheatsheets/ssh | 3 ++- setup.py | 2 +- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 27ffc2f..37dca56 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ *.pyc +MANIFEST build +dist diff --git a/bin/cheat b/bin/cheat index 469f27d..46af2a2 100755 --- a/bin/cheat +++ b/bin/cheat @@ -38,7 +38,7 @@ from docopt import docopt if __name__ == '__main__': # parse the command-line options - options = docopt(__doc__, version='cheat 2.1.2') + options = docopt(__doc__, version='cheat 2.1.3') # list directories if options['--directories']: diff --git a/cheat/cheatsheets/ssh b/cheat/cheatsheets/ssh index fef550c..1f11907 100644 --- a/cheat/cheatsheets/ssh +++ b/cheat/cheatsheets/ssh @@ -13,7 +13,8 @@ ssh -t user@example.com 'the-remote-command' # To tunnel an x session over SSH: ssh -X user@example.com -# Redirect traffic with a tunnel between local host (port 8080) and a remote host (remote.example.com:5000) through a proxy (personal.server.com): +# Redirect traffic with a tunnel between local host (port 8080) and a remote +# host (remote.example.com:5000) through a proxy (personal.server.com): ssh -f -L 8080:remote.example.com:5000 user@personal.server.com -N # To launch a specific x application over SSH: diff --git a/setup.py b/setup.py index a27ffb0..a747c6d 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ import os setup( name = 'cheat', - version = '2.1.2', + version = '2.1.3', author = 'Chris Lane', author_email = 'chris@chris-allen-lane.com', license = 'GPL3', From 76a91ce3587517d92fc6d60825008702ebf80a45 Mon Sep 17 00:00:00 2001 From: Alessio Bogon Date: Thu, 8 Jan 2015 23:54:12 +0100 Subject: [PATCH 041/126] Use setuptools insted of distutils. Distutils is old and basic, setuptools is the current preferred way. See https://python-packaging-user-guide.readthedocs.org/en/latest/current.html --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index a747c6d..09e17ed 100644 --- a/setup.py +++ b/setup.py @@ -1,4 +1,4 @@ -from distutils.core import setup +from setuptools import setup import os setup( From fdbc8909cc481fbf337240b994ab1e68e5e11487 Mon Sep 17 00:00:00 2001 From: Alessio Bogon Date: Thu, 8 Jan 2015 23:58:35 +0100 Subject: [PATCH 042/126] Use find_packages from setuptools to identify packages --- setup.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/setup.py b/setup.py index 09e17ed..b3f5034 100644 --- a/setup.py +++ b/setup.py @@ -1,4 +1,4 @@ -from setuptools import setup +from setuptools import setup, find_packages import os setup( @@ -12,11 +12,7 @@ setup( 'administrators of options for commands that they use frequently, but not ' 'frequently enough to remember.', url = 'https://github.com/chrisallenlane/cheat', - packages = [ - 'cheat', - 'cheat.cheatsheets', - 'cheat.test', - ], + packages = find_packages(), package_data = { 'cheat.cheatsheets': [f for f in os.listdir('cheat/cheatsheets') if '.' not in f] }, From 69f91e0cf42f846fb0829a7c9ffa35653c3dd66f Mon Sep 17 00:00:00 2001 From: Alessio Bogon Date: Fri, 9 Jan 2015 00:08:38 +0100 Subject: [PATCH 043/126] Exploit setuptools package_data to include cheats --- setup.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/setup.py b/setup.py index b3f5034..b9207dc 100644 --- a/setup.py +++ b/setup.py @@ -1,5 +1,4 @@ from setuptools import setup, find_packages -import os setup( name = 'cheat', @@ -14,7 +13,7 @@ setup( url = 'https://github.com/chrisallenlane/cheat', packages = find_packages(), package_data = { - 'cheat.cheatsheets': [f for f in os.listdir('cheat/cheatsheets') if '.' not in f] + 'cheat.cheatsheets': ['*'], }, scripts = ['bin/cheat'], install_requires = [ From 5caa8fed38c16d897a5ecc1c7f5490e87e269682 Mon Sep 17 00:00:00 2001 From: Alessio Bogon Date: Fri, 9 Jan 2015 00:22:57 +0100 Subject: [PATCH 044/126] Improve setup.py description --- setup.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/setup.py b/setup.py index b9207dc..26f3f02 100644 --- a/setup.py +++ b/setup.py @@ -1,3 +1,13 @@ +"""cheat + ~~~~~~~~ + + cheat allows you to create and view interactive cheatsheets on the + command-line. It was designed to help remind *nix system administrators of + options for commands that they use frequently, but not frequently enough + to remember. + :license: GPL3 +""" + from setuptools import setup, find_packages setup( @@ -6,10 +16,8 @@ setup( author = 'Chris Lane', author_email = 'chris@chris-allen-lane.com', license = 'GPL3', - description = 'cheat allows you to create and view interactive cheatsheets ' - 'on the command-line. It was designed to help remind *nix system ' - 'administrators of options for commands that they use frequently, but not ' - 'frequently enough to remember.', + description = 'cheat allows you to create and view interactive cheatsheets on the command-line', + long_description = __doc__, url = 'https://github.com/chrisallenlane/cheat', packages = find_packages(), package_data = { From 4d57f529c93e9074caa99796d3438bad1174fa73 Mon Sep 17 00:00:00 2001 From: Alessio Bogon Date: Fri, 9 Jan 2015 00:36:49 +0100 Subject: [PATCH 045/126] Use entry_points instead of scripts in setup.py This allows a fine-grained control of the dependencies, because it generates a wrapper script that calls the specifiend function (i.e., main inside cheat/app.py) --- bin/cheat => cheat/app.py | 10 +++++++--- setup.py | 6 +++++- 2 files changed, 12 insertions(+), 4 deletions(-) rename bin/cheat => cheat/app.py (95%) diff --git a/bin/cheat b/cheat/app.py similarity index 95% rename from bin/cheat rename to cheat/app.py index 46af2a2..50fddea 100755 --- a/bin/cheat +++ b/cheat/app.py @@ -31,12 +31,13 @@ Options: """ # require the dependencies -from cheat import * -from cheat.utils import * +import sheet +import sheets +from utils import * from docopt import docopt -if __name__ == '__main__': +def main(): # parse the command-line options options = docopt(__doc__, version='cheat 2.1.3') @@ -59,3 +60,6 @@ if __name__ == '__main__': # print the cheatsheet else: print(colorize(sheet.read(options['']))) + +if __name__ == '__main__': + main() diff --git a/setup.py b/setup.py index 26f3f02..91aa692 100644 --- a/setup.py +++ b/setup.py @@ -23,7 +23,11 @@ setup( package_data = { 'cheat.cheatsheets': ['*'], }, - scripts = ['bin/cheat'], + entry_points = { + 'console_scripts': [ + 'cheat = cheat.app:main', + ], + }, install_requires = [ 'docopt >= 0.6.1', 'pygments >= 1.6.0', From a96bd229a6d44651e5f2d1fbf4f9d9208fc6dbd4 Mon Sep 17 00:00:00 2001 From: shigemk2 Date: Sat, 10 Jan 2015 00:28:18 +0900 Subject: [PATCH 046/126] uniq: add examples --- cheat/cheatsheets/uniq | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 cheat/cheatsheets/uniq diff --git a/cheat/cheatsheets/uniq b/cheat/cheatsheets/uniq new file mode 100644 index 0000000..994b706 --- /dev/null +++ b/cheat/cheatsheets/uniq @@ -0,0 +1,12 @@ +# show all lines without duplication +sort file | uniq +# show not duplicated lines +sort file | uniq -u +# show duplicated lines only +sort file | uniq -d +# count all lines +sort file | uniq -c +# count not duplicated lines +sort file | uniq -uc +# count only duplicated lines +sort file | uniq -c From 353fe48d60df4a85e30cdf32ce73440a2732430d Mon Sep 17 00:00:00 2001 From: shigemk2 Date: Mon, 12 Jan 2015 21:17:55 +0900 Subject: [PATCH 047/126] Fix dc option --- cheat/cheatsheets/uniq | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cheat/cheatsheets/uniq b/cheat/cheatsheets/uniq index 994b706..a2bcfc5 100644 --- a/cheat/cheatsheets/uniq +++ b/cheat/cheatsheets/uniq @@ -9,4 +9,4 @@ sort file | uniq -c # count not duplicated lines sort file | uniq -uc # count only duplicated lines -sort file | uniq -c +sort file | uniq -dc From 2e1cda114a7ef0f8ad0ce47756f42e196a1be8cd Mon Sep 17 00:00:00 2001 From: shigemk2 Date: Mon, 12 Jan 2015 21:29:35 +0900 Subject: [PATCH 048/126] Refer sort -u --- cheat/cheatsheets/uniq | 1 + 1 file changed, 1 insertion(+) diff --git a/cheat/cheatsheets/uniq b/cheat/cheatsheets/uniq index a2bcfc5..18ee084 100644 --- a/cheat/cheatsheets/uniq +++ b/cheat/cheatsheets/uniq @@ -1,4 +1,5 @@ # show all lines without duplication +# "sort -u" and "uniq" is the same effect. sort file | uniq # show not duplicated lines sort file | uniq -u From da63c5d27f12014f2a8a191bca4013c15d6eb135 Mon Sep 17 00:00:00 2001 From: Amit Saha Date: Tue, 13 Jan 2015 13:51:35 +1000 Subject: [PATCH 049/126] docker: add 'docker exec' --- cheat/cheatsheets/docker | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cheat/cheatsheets/docker b/cheat/cheatsheets/docker index 8dc66c5..d803ccc 100644 --- a/cheat/cheatsheets/docker +++ b/cheat/cheatsheets/docker @@ -4,6 +4,9 @@ docker -d # start a container with an interactive shell docker run -ti /bin/bash +# "shell" into a running container (docker-1.3+) +docker exec -ti bash + # inspect a running container docker inspect (or ) From 95774db7c5e43fa1fb38d26c4c36826a5902b1da Mon Sep 17 00:00:00 2001 From: Aayush Kasurde Date: Wed, 14 Jan 2015 21:12:23 +0530 Subject: [PATCH 050/126] Added zoneadm commands --- cheat/cheatsheets/zoneadm | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 cheat/cheatsheets/zoneadm diff --git a/cheat/cheatsheets/zoneadm b/cheat/cheatsheets/zoneadm new file mode 100644 index 0000000..b33fbfb --- /dev/null +++ b/cheat/cheatsheets/zoneadm @@ -0,0 +1,22 @@ +# Halt zone +zoneadm -z halt + +# Delete Zone +zoneadm -z halt +zoneadm -z uninstall + +# Verify Zone +zoneadm -z verify + +# Installing Zone +zoneadm -z install + +# Boot Zone +zoneadm -z boot + +# Reboot Zone +zoneadm -z reboot + +# List Zones +zoneadm list -cv + From efba736aeeb66259e32be18583dbe4272812cf8b Mon Sep 17 00:00:00 2001 From: Aayush Kasurde Date: Sun, 18 Jan 2015 20:03:42 +0530 Subject: [PATCH 051/126] Added Journalctl commands --- cheat/cheatsheets/journalctl | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/cheat/cheatsheets/journalctl b/cheat/cheatsheets/journalctl index 6c00e7f..793dd18 100644 --- a/cheat/cheatsheets/journalctl +++ b/cheat/cheatsheets/journalctl @@ -19,3 +19,14 @@ journalctl /usr/bin/dbus-daemon # Filter by PID journalctl _PID=123 +# Filter by Command, e.g., sshd +journalctl _COMM=sshd + +# Filter by Command and time period +journalctl _COMM=crond --since '10:00' --until '11:00' + +# List all available boots +journalctl --list-boots + +# Filter by specific User ID e.g., user id 1000 +journalctl _UID=1000 \ No newline at end of file From 710c7bcf705f12d1cbe6e214be302a01101676e1 Mon Sep 17 00:00:00 2001 From: Theotime LEVEQUE Date: Tue, 20 Jan 2015 01:42:26 +0100 Subject: [PATCH 052/126] Add cheat for dpkg --- cheat/cheatsheets/dpkg | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 cheat/cheatsheets/dpkg diff --git a/cheat/cheatsheets/dpkg b/cheat/cheatsheets/dpkg new file mode 100644 index 0000000..212ac31 --- /dev/null +++ b/cheat/cheatsheets/dpkg @@ -0,0 +1,11 @@ +# Install the package or upgrade it +dpkg -i test.deb + +# Remove a package including configuration files +dpkg -P test.deb + +# List all installed packages with versions and details +dpkg -I + +# Find out if a Debian package is installed or not +dpkg -s test.deb | grepStatus \ No newline at end of file From d9df28e3f2b7edcffdf5e76cae502dd7ee25972f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9otime=20L=C3=A9v=C3=AAque?= Date: Tue, 20 Jan 2015 12:22:47 +0100 Subject: [PATCH 053/126] Update dpkg --- cheat/cheatsheets/dpkg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cheat/cheatsheets/dpkg b/cheat/cheatsheets/dpkg index 212ac31..76eca1b 100644 --- a/cheat/cheatsheets/dpkg +++ b/cheat/cheatsheets/dpkg @@ -8,4 +8,4 @@ dpkg -P test.deb dpkg -I # Find out if a Debian package is installed or not -dpkg -s test.deb | grepStatus \ No newline at end of file +dpkg -s test.deb | grep Status From 55492c50acf802bf4db20c74d9e955a064a3c76d Mon Sep 17 00:00:00 2001 From: Aayush Kasurde Date: Tue, 20 Jan 2015 21:34:11 +0530 Subject: [PATCH 054/126] Added udisksctl --- cheat/cheatsheets/udisksctl | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 cheat/cheatsheets/udisksctl diff --git a/cheat/cheatsheets/udisksctl b/cheat/cheatsheets/udisksctl new file mode 100644 index 0000000..2cd929b --- /dev/null +++ b/cheat/cheatsheets/udisksctl @@ -0,0 +1,11 @@ +# Get info about block device +udisksctl info -b + +# Mounting device +udisksctl mount --block-device + +# Unmounting device +udisksctl unmount --block-device + +# Get help +udisksctl help From c2327211195e60a33106f0c53db934f10b9a8790 Mon Sep 17 00:00:00 2001 From: Amit Saha Date: Thu, 22 Jan 2015 16:30:49 +1000 Subject: [PATCH 055/126] Add cheatsheet for dnf --- cheat/cheatsheets/dnf | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 cheat/cheatsheets/dnf diff --git a/cheat/cheatsheets/dnf b/cheat/cheatsheets/dnf new file mode 100644 index 0000000..99b6548 --- /dev/null +++ b/cheat/cheatsheets/dnf @@ -0,0 +1,16 @@ +# To install the latest version of a package: +dnf install + +# To search package details for the given string +dnf search + +# To find which package provides a binary +dnf provides + +# The following are available after installing "dnf-plugins-core" + +# Download a package +dnf download + +# install the build dependencies for a SRPM or from a .spec file +dnf builddep \ No newline at end of file From 250a265b255def84837ccb34e05cf28e26a6c09f Mon Sep 17 00:00:00 2001 From: Aayush Kasurde Date: Tue, 27 Jan 2015 22:07:43 +0530 Subject: [PATCH 056/126] Added perforce commands --- cheat/cheatsheets/p4 | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 cheat/cheatsheets/p4 diff --git a/cheat/cheatsheets/p4 b/cheat/cheatsheets/p4 new file mode 100644 index 0000000..0ec6a25 --- /dev/null +++ b/cheat/cheatsheets/p4 @@ -0,0 +1,5 @@ +# Print details related to Client and server configuration +p4 info + +# Open a file and add it to depot +p4 add \ No newline at end of file From 96e26a38d426b58666322a95bdeb098b5ecafa37 Mon Sep 17 00:00:00 2001 From: Chris Lane Date: Mon, 9 Feb 2015 18:01:40 -0500 Subject: [PATCH 057/126] Added newline to end of dnf file. --- cheat/cheatsheets/dnf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cheat/cheatsheets/dnf b/cheat/cheatsheets/dnf index 99b6548..10c3766 100644 --- a/cheat/cheatsheets/dnf +++ b/cheat/cheatsheets/dnf @@ -13,4 +13,4 @@ dnf provides dnf download # install the build dependencies for a SRPM or from a .spec file -dnf builddep \ No newline at end of file +dnf builddep From e64babc97232fbef5eeca9453e267dd28114db2e Mon Sep 17 00:00:00 2001 From: Chris Lane Date: Mon, 9 Feb 2015 18:05:13 -0500 Subject: [PATCH 058/126] Trivial edits to cheatsheets. --- cheat/cheatsheets/journalctl | 2 +- cheat/cheatsheets/p4 | 2 +- cheat/cheatsheets/zoneadm | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/cheat/cheatsheets/journalctl b/cheat/cheatsheets/journalctl index 793dd18..0a28bc4 100644 --- a/cheat/cheatsheets/journalctl +++ b/cheat/cheatsheets/journalctl @@ -29,4 +29,4 @@ journalctl _COMM=crond --since '10:00' --until '11:00' journalctl --list-boots # Filter by specific User ID e.g., user id 1000 -journalctl _UID=1000 \ No newline at end of file +journalctl _UID=1000 diff --git a/cheat/cheatsheets/p4 b/cheat/cheatsheets/p4 index 0ec6a25..dc4c2eb 100644 --- a/cheat/cheatsheets/p4 +++ b/cheat/cheatsheets/p4 @@ -2,4 +2,4 @@ p4 info # Open a file and add it to depot -p4 add \ No newline at end of file +p4 add diff --git a/cheat/cheatsheets/zoneadm b/cheat/cheatsheets/zoneadm index b33fbfb..0dee119 100644 --- a/cheat/cheatsheets/zoneadm +++ b/cheat/cheatsheets/zoneadm @@ -19,4 +19,3 @@ zoneadm -z reboot # List Zones zoneadm list -cv - From a5352ad9e52c1657301ef116e684a34ad1d3c52b Mon Sep 17 00:00:00 2001 From: Chris Lane Date: Mon, 9 Feb 2015 18:07:17 -0500 Subject: [PATCH 059/126] Trivial edits to uniq cheatsheet --- cheat/cheatsheets/uniq | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cheat/cheatsheets/uniq b/cheat/cheatsheets/uniq index 18ee084..b9abd3d 100644 --- a/cheat/cheatsheets/uniq +++ b/cheat/cheatsheets/uniq @@ -1,13 +1,18 @@ # show all lines without duplication -# "sort -u" and "uniq" is the same effect. +# `sort -u` and `uniq` is the same effect. sort file | uniq + # show not duplicated lines sort file | uniq -u + # show duplicated lines only sort file | uniq -d + # count all lines sort file | uniq -c + # count not duplicated lines sort file | uniq -uc + # count only duplicated lines sort file | uniq -dc From 3d8343a87845994c40967f2846dbcbb3597f5e6a Mon Sep 17 00:00:00 2001 From: Chris Lane Date: Mon, 9 Feb 2015 18:10:08 -0500 Subject: [PATCH 060/126] Version bump --- bin/cheat | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/cheat b/bin/cheat index 46af2a2..25fd4dd 100755 --- a/bin/cheat +++ b/bin/cheat @@ -38,7 +38,7 @@ from docopt import docopt if __name__ == '__main__': # parse the command-line options - options = docopt(__doc__, version='cheat 2.1.3') + options = docopt(__doc__, version='cheat 2.1.4') # list directories if options['--directories']: diff --git a/setup.py b/setup.py index a747c6d..73f34e1 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ import os setup( name = 'cheat', - version = '2.1.3', + version = '2.1.4', author = 'Chris Lane', author_email = 'chris@chris-allen-lane.com', license = 'GPL3', From 718ec4f6856a7c1a7f1ddb3dbccdba569b424c29 Mon Sep 17 00:00:00 2001 From: Chris Lane Date: Tue, 10 Feb 2015 19:35:14 -0500 Subject: [PATCH 061/126] Resolves #207 - Solves issue whereby global cheatsheets fail to save after editing - `cheat` no longer asks a user if a global cheatsheet should be copied locally before editing, and instead just silently does so. --- .gitignore | 1 + bin/cheat | 2 +- cheat/sheet.py | 18 +++--------------- cheat/sheets.py | 13 +------------ setup.py | 2 +- 5 files changed, 7 insertions(+), 29 deletions(-) diff --git a/.gitignore b/.gitignore index 37dca56..52c5521 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ *.pyc MANIFEST build +cheat.egg-info dist diff --git a/bin/cheat b/bin/cheat index 25fd4dd..20b634b 100755 --- a/bin/cheat +++ b/bin/cheat @@ -38,7 +38,7 @@ from docopt import docopt if __name__ == '__main__': # parse the command-line options - options = docopt(__doc__, version='cheat 2.1.4') + options = docopt(__doc__, version='cheat 2.1.5') # list directories if options['--directories']: diff --git a/cheat/sheet.py b/cheat/sheet.py index 1038aef..8218278 100644 --- a/cheat/sheet.py +++ b/cheat/sheet.py @@ -32,21 +32,9 @@ def create_or_edit(sheet): # if the cheatsheet exists but is not writable... elif exists(sheet) and not is_writable(sheet): - # ... ask the user if we should copy the cheatsheet to her home directory for editing - yes = prompt_yes_or_no( - 'The ' + sheet + ' sheet is not editable. Do you want to copy it to ' - 'your user cheatsheets directory before editing? Keep in mind that ' - 'your sheet will always be used before system-wide one.' - ) - - # if yes, copy the cheatsheet to the home directory before editing - if yes: - copy(path(sheet), os.path.join(sheets.default_path(), sheet)) - edit(sheet) - - # if no, just abort - else: - die('Aborting.') + # copy the cheatsheet to the home directory before editing + copy(path(sheet), os.path.join(sheets.default_path(), sheet)) + edit(sheet) def create(sheet): diff --git a/cheat/sheets.py b/cheat/sheets.py index d9fbc91..26e6ce2 100644 --- a/cheat/sheets.py +++ b/cheat/sheets.py @@ -2,13 +2,6 @@ from cheat import cheatsheets from cheat.utils import * import os -# @kludge: it breaks the functional paradigm to a degree, but declaring this -# var here (versus within get()) gives us a "poor man's" memoization on the -# call to get(). This, in turn, spares us from having to call out to the -# filesystem more than once. -cheats = {} - - def default_path(): """ Returns the default cheatsheet path """ @@ -37,11 +30,7 @@ def default_path(): def get(): """ Assembles a dictionary of cheatsheets as name => file-path """ - - # if we've already reached out to the filesystem, just return the result - # from memory - if cheats: - return cheats + cheats = {} # otherwise, scan the filesystem for cheat_dir in reversed(paths()): diff --git a/setup.py b/setup.py index 73f34e1..1e39c54 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ import os setup( name = 'cheat', - version = '2.1.4', + version = '2.1.5', author = 'Chris Lane', author_email = 'chris@chris-allen-lane.com', license = 'GPL3', From c70dc002fa995d7c4a0e134b3b47a187b07589ad Mon Sep 17 00:00:00 2001 From: Chris Lane Date: Wed, 11 Feb 2015 21:02:45 -0500 Subject: [PATCH 062/126] Issue #180 Now, whenever a cheatsheet is to be edited, if that cheatsheet does not exist on the `DEFAULT_SHEET_PATH`, it is first copied there before being opened for editing. This prevents system-wide cheatsheets from being edited when using `cheat` as `root`. --- bin/cheat | 2 +- cheat/sheet.py | 16 +++++++++------- setup.py | 2 +- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/bin/cheat b/bin/cheat index 20b634b..1dfedf4 100755 --- a/bin/cheat +++ b/bin/cheat @@ -38,7 +38,7 @@ from docopt import docopt if __name__ == '__main__': # parse the command-line options - options = docopt(__doc__, version='cheat 2.1.5') + options = docopt(__doc__, version='cheat 2.1.6') # list directories if options['--directories']: diff --git a/cheat/sheet.py b/cheat/sheet.py index 8218278..f4e380f 100644 --- a/cheat/sheet.py +++ b/cheat/sheet.py @@ -25,14 +25,10 @@ def create_or_edit(sheet): # if the cheatsheet does not exist if not exists(sheet): create(sheet) - - # if the cheatsheet exists and is writeable... - elif exists(sheet) and is_writable(sheet): - edit(sheet) - # if the cheatsheet exists but is not writable... - elif exists(sheet) and not is_writable(sheet): - # copy the cheatsheet to the home directory before editing + # if the cheatsheet exists but not in the default_path, copy it to the + # default path before editing + elif exists(sheet) and not exists_in_default_path(sheet): copy(path(sheet), os.path.join(sheets.default_path(), sheet)) edit(sheet) @@ -63,6 +59,12 @@ def exists(sheet): return sheet in sheets.get() and os.access(path(sheet), os.R_OK) +def exists_in_default_path(sheet): + """ Predicate that returns true if the sheet exists in default_path""" + default_path_sheet = os.path.join(sheets.default_path(), sheet) + return sheet in sheets.get() and os.access(default_path_sheet, os.R_OK) + + def is_writable(sheet): """ Predicate that returns true if the sheet is writeable """ return sheet in sheets.get() and os.access(path(sheet), os.W_OK) diff --git a/setup.py b/setup.py index 1e39c54..6a81c99 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ import os setup( name = 'cheat', - version = '2.1.5', + version = '2.1.6', author = 'Chris Lane', author_email = 'chris@chris-allen-lane.com', license = 'GPL3', From e9b8f04c2452ae7eb48351d462a84f3f913fba32 Mon Sep 17 00:00:00 2001 From: Chris Lane Date: Wed, 11 Feb 2015 21:45:32 -0500 Subject: [PATCH 063/126] Bug fix A bug was introduced in 2.1.6 that would prevent user-defined cheatsheets from being edited more than once. --- bin/cheat | 2 +- cheat/sheet.py | 4 ++++ setup.py | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/bin/cheat b/bin/cheat index 1dfedf4..2222fa0 100755 --- a/bin/cheat +++ b/bin/cheat @@ -38,7 +38,7 @@ from docopt import docopt if __name__ == '__main__': # parse the command-line options - options = docopt(__doc__, version='cheat 2.1.6') + options = docopt(__doc__, version='cheat 2.1.7') # list directories if options['--directories']: diff --git a/cheat/sheet.py b/cheat/sheet.py index f4e380f..f2f4e6d 100644 --- a/cheat/sheet.py +++ b/cheat/sheet.py @@ -32,6 +32,10 @@ def create_or_edit(sheet): copy(path(sheet), os.path.join(sheets.default_path(), sheet)) edit(sheet) + # if it exists and is in the default path, then just open it + else: + edit(sheet) + def create(sheet): """ Creates a cheatsheet """ diff --git a/setup.py b/setup.py index 6a81c99..cb4972c 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ import os setup( name = 'cheat', - version = '2.1.6', + version = '2.1.7', author = 'Chris Lane', author_email = 'chris@chris-allen-lane.com', license = 'GPL3', From e27ce3f1f94b4da82b08f5f0075aa5320ae54954 Mon Sep 17 00:00:00 2001 From: Aayush Kasurde Date: Tue, 10 Mar 2015 08:04:47 +0530 Subject: [PATCH 064/126] Added yum list command cheat --- cheat/cheatsheets/yum | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cheat/cheatsheets/yum b/cheat/cheatsheets/yum index 8cc52f7..c5eb136 100644 --- a/cheat/cheatsheets/yum +++ b/cheat/cheatsheets/yum @@ -22,6 +22,9 @@ yum info # List currently enabled repositories: yum repolist +# List packages containing a certain keyword: +yum list + # To download the source RPM for a package: yumdownloader --source From afcd74c8bfdb025b6cd54681deb452a0b794b701 Mon Sep 17 00:00:00 2001 From: Kai KANG Date: Tue, 31 Mar 2015 17:52:08 +0800 Subject: [PATCH 065/126] Add cheatsheet for paste. --- cheat/cheatsheets/paste | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 cheat/cheatsheets/paste diff --git a/cheat/cheatsheets/paste b/cheat/cheatsheets/paste new file mode 100644 index 0000000..065f3f2 --- /dev/null +++ b/cheat/cheatsheets/paste @@ -0,0 +1,15 @@ +# Concat columns from files +paste file1 file2 ... + +# List the files in the current directory in three columns: +ls | paste - - - + +# Combine pairs of lines from a file into single lines: +paste -s -d '\t\n' myfile + +# Number the lines in a file, similar to nl(1): +sed = myfile | paste -s -d '\t\n' - - + +# Create a colon-separated list of directories named bin, +# suitable for use in the PATH environment variable: +find / -name bin -type d | paste -s -d : - \ No newline at end of file From 417f47f037b48bf9f81f97fb87db8be0a3da5a28 Mon Sep 17 00:00:00 2001 From: Chris Lane Date: Wed, 15 Apr 2015 16:43:47 -0400 Subject: [PATCH 066/126] Version bump --- bin/cheat | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/cheat b/bin/cheat index 2222fa0..464857e 100755 --- a/bin/cheat +++ b/bin/cheat @@ -38,7 +38,7 @@ from docopt import docopt if __name__ == '__main__': # parse the command-line options - options = docopt(__doc__, version='cheat 2.1.7') + options = docopt(__doc__, version='cheat 2.1.8') # list directories if options['--directories']: diff --git a/setup.py b/setup.py index cb4972c..b5c4c9e 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ import os setup( name = 'cheat', - version = '2.1.7', + version = '2.1.8', author = 'Chris Lane', author_email = 'chris@chris-allen-lane.com', license = 'GPL3', From fd7f31bf16cce2309fff4576c3be5a41a921d6ff Mon Sep 17 00:00:00 2001 From: Salvo Rapisarda Date: Mon, 4 May 2015 15:14:07 +0200 Subject: [PATCH 067/126] First version of nova cheat --- cheat/cheatsheets/nova | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 cheat/cheatsheets/nova diff --git a/cheat/cheatsheets/nova b/cheat/cheatsheets/nova new file mode 100644 index 0000000..de3e6e8 --- /dev/null +++ b/cheat/cheatsheets/nova @@ -0,0 +1,20 @@ +# To list VMs on current tenant: +nova list + +# To list VMs of all tenants (admin user only): +nova list --all-tenants + +# To boot a VM on a specific host: +nova boot --nic net-id= \ + --image \ + --flavor \ + --availability-zone nova: + +# To stop a server +nova stop + +# To start a server +nova start + +# To attach a network interface to a specific VM: +nova interface-attach --net-id \ No newline at end of file From 86d1ce58a90e6d81b0d8ce456afbcd39a2f0a9c9 Mon Sep 17 00:00:00 2001 From: agxcul Date: Wed, 6 May 2015 15:14:49 +0800 Subject: [PATCH 068/126] add command [more] and some more example for command [awk] --- cheat/cheatsheets/awk | 6 ++++++ cheat/cheatsheets/more | 3 +++ 2 files changed, 9 insertions(+) create mode 100644 cheat/cheatsheets/more diff --git a/cheat/cheatsheets/awk b/cheat/cheatsheets/awk index bf554bc..dbc670e 100644 --- a/cheat/cheatsheets/awk +++ b/cheat/cheatsheets/awk @@ -1,2 +1,8 @@ # sum integers from a file or stdin, one integer per line: printf '1\n2\n3\n' | awk '{ sum += $1} END {print sum}' + +# using specific character as separator to sum integers from a file or stdin +printf '1:2:3' | awk -F ":" '{print $1+$2+$3}' + +# print a multiplication table +seq 9 | sed 'H;g' | awk -v RS='' '{for(i=1;i<=NF;i++)printf("%dx%d=%d%s", i, NR, i*NR, i==NR?"\n":"\t")}' diff --git a/cheat/cheatsheets/more b/cheat/cheatsheets/more new file mode 100644 index 0000000..c1ee9d9 --- /dev/null +++ b/cheat/cheatsheets/more @@ -0,0 +1,3 @@ +# To show the file start at line number 5 +more +5 file + From aba6fe5043b700d65510911de11337777c9c1f01 Mon Sep 17 00:00:00 2001 From: "Daniel D. Zhang" Date: Sun, 10 May 2015 13:54:49 +0800 Subject: [PATCH 069/126] fix typo reference: -O file --output-document=file The documents will not be written to the appropriate files, but all will be concatenated together and written to file. If - is used as file, documents will be printed to standard output, disabling link conversion. (Use ./- to print to a file literally named -.) Use of -O is not intended to mean simply "use the name file instead of the one in the URL;" rather, it is analogous to shell redirection: wget -O file http://foo is intended to work like wget -O - http://foo > file; file will be truncated immediately, and all downloaded content will be written there. For this reason, -N (for timestamp-checking) is not supported in combination with -O: since file is always newly created, it will always have a very new timestamp. A warning will be issued if this combination is used. Similarly, using -r or -p with -O may not work as you expect: Wget won't just download the first file to file and then download the rest to their normal names: all downloaded content will be placed in file. This was disabled in version 1.11, but has been reinstated (with a warning) in 1.11.2, as there are some cases where this behavior can actually have some use. Note that a combination with -k is only permitted when downloading a single document, as in that case it will just convert all relative URIs to external ones; -k makes no sense for multiple URIs when they're all being downloaded to a single file; -k can be used only when the output is a regular file. --- cheat/cheatsheets/wget | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cheat/cheatsheets/wget b/cheat/cheatsheets/wget index 0439650..db754a0 100644 --- a/cheat/cheatsheets/wget +++ b/cheat/cheatsheets/wget @@ -2,7 +2,7 @@ wget http://path.to.the/file # To download a file and change its name -wget http://path.to.the/file -o newname +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 From 434802341e36ada35eeec4e60147a502bd20f910 Mon Sep 17 00:00:00 2001 From: Shadab Zafar Date: Wed, 20 May 2015 00:17:55 +0530 Subject: [PATCH 070/126] jq is a command line json processor Here is the awesome manual: http://stedolan.github.io/jq/manual/ --- cheat/cheatsheets/jq | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 cheat/cheatsheets/jq diff --git a/cheat/cheatsheets/jq b/cheat/cheatsheets/jq new file mode 100644 index 0000000..d57cc13 --- /dev/null +++ b/cheat/cheatsheets/jq @@ -0,0 +1,13 @@ +# Pretty print the json +jq "." < filename.json + +# Access the value at key "foo" +jq '.foo' + +# Access first list item +jq '.[0]' + +# Slice & Dice +jq '.[2:4]' +jq '.[:3]' +jq '.[-2:]' From 889c8ef8fe839845aa20eef4d693dc20ebabc6b7 Mon Sep 17 00:00:00 2001 From: Shadab Zafar Date: Wed, 20 May 2015 00:27:14 +0530 Subject: [PATCH 071/126] Added two funky git cheats! --- cheat/cheatsheets/git | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cheat/cheatsheets/git b/cheat/cheatsheets/git index a31f4de..c52df05 100644 --- a/cheat/cheatsheets/git +++ b/cheat/cheatsheets/git @@ -51,3 +51,9 @@ git show 83fb499:path/fo/file.ext # Shows the file as it a git diff branch_1 branch_2 # Check difference between branches git log # Show all the commits git status # Show the changes from last commit + +# Commit history of a set of files +git log --pretty=email --patch-with-stat --reverse --full-index -- Admin\*.py > Sripts.patch + +# Import commits from another repo +git --git-dir=../some_other_repo/.git format-patch -k -1 --stdout | git am -3 -k From 33f0dc346b52f66e246aa0fa3b904636d479c3eb Mon Sep 17 00:00:00 2001 From: Shadab Zafar Date: Wed, 20 May 2015 00:53:24 +0530 Subject: [PATCH 072/126] jrnl is an application to store your life journal ...in plain text files https://github.com/maebert/jrnl --- cheat/cheatsheets/jrnl | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 cheat/cheatsheets/jrnl diff --git a/cheat/cheatsheets/jrnl b/cheat/cheatsheets/jrnl new file mode 100644 index 0000000..c3540e2 --- /dev/null +++ b/cheat/cheatsheets/jrnl @@ -0,0 +1,25 @@ +# Add entry to default jrnl (from your configured text editor) +jrnl + +# Add entry to default jrnl +jrnl Write entry here. + +# List of tags +jrnl --tags + +# Entries per tag +jrnl @tag + +# Export jrnl as json +jrnl --export json + +# Entries in a timeframe +jrnl -from 2009 -until may + +# Add Sublime text to .jrnl_config + +# Windows +"editor": "F:\\Powerpack\\Sublime\\sublime_text.exe -w" + +# Linux +"editor": "/usr/bin/sublime -w" From 820de5dba81b90da5a57d6bfbe3aa6d09cbfd71f Mon Sep 17 00:00:00 2001 From: Shadab Zafar Date: Wed, 20 May 2015 00:58:39 +0530 Subject: [PATCH 073/126] Add Image syntax to markdown --- cheat/cheatsheets/markdown | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cheat/cheatsheets/markdown b/cheat/cheatsheets/markdown index 8b551a6..917fcf1 100644 --- a/cheat/cheatsheets/markdown +++ b/cheat/cheatsheets/markdown @@ -35,6 +35,9 @@ ___ # links This is [an example](http://example.com "Title") inline link. +# image +![Alt Text](/path/to/file.png) + # emphasis *em* _em_ From 86ba1ad9e6876a5705b12cf8411448d08839ad93 Mon Sep 17 00:00:00 2001 From: quentin Date: Thu, 21 May 2015 23:17:34 +0200 Subject: [PATCH 074/126] cheat/cheatsheets/rpm: small enhancements --- cheat/cheatsheets/rpm | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cheat/cheatsheets/rpm b/cheat/cheatsheets/rpm index 93e2ecf..5a0d0ff 100644 --- a/cheat/cheatsheets/rpm +++ b/cheat/cheatsheets/rpm @@ -8,7 +8,12 @@ rpm -e rpm -qf # To find what files are installed by a package: +rpm -ql rpm -qpl +# To find what packages require a package or file: +rpm -q --whatrequires +rpm -q --whatrequires + # To list all installed packages: rpm -qa From 30a49d3596fba17e81e72f8995eec74506038352 Mon Sep 17 00:00:00 2001 From: Kai KANG Date: Thu, 28 May 2015 13:46:28 +0800 Subject: [PATCH 075/126] Add the cheat sheet for pip. --- cheat/cheatsheets/pip | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 cheat/cheatsheets/pip diff --git a/cheat/cheatsheets/pip b/cheat/cheatsheets/pip new file mode 100644 index 0000000..0894962 --- /dev/null +++ b/cheat/cheatsheets/pip @@ -0,0 +1,17 @@ +# Search for packages +pip search SomePackage + +# Install some packages +pip install SomePackage + +# Show details of a package +pip show SomePackage + +# List outdated packages +pip list --outdated + +# Upgrade all outdated packages, thanks to http://stackoverflow.com/a/3452888 +pip freeze --local | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 pip install -U + +# Install specific version of a package +pip install -I SomePackage1==1.1.0 'SomePackage2>=1.0.4' From b2e1400bb68dd35a20eb1454e072e3bf0fc9bf86 Mon Sep 17 00:00:00 2001 From: Kai KANG Date: Tue, 2 Jun 2015 07:30:34 +0800 Subject: [PATCH 076/126] Update pip: dealing with requirement files add `pip freeze > requirements.txt` and `pip install -r requirements.txt`. --- cheat/cheatsheets/pip | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cheat/cheatsheets/pip b/cheat/cheatsheets/pip index 0894962..edc122c 100644 --- a/cheat/cheatsheets/pip +++ b/cheat/cheatsheets/pip @@ -4,6 +4,10 @@ pip search SomePackage # Install some packages pip install SomePackage +# Output and install packages in a requirement file +pip freeze > requirements.txt +pip install -r requirements.txt + # Show details of a package pip show SomePackage From 2166a57ccdd13c3ed58877cc65940e8b487aa94a Mon Sep 17 00:00:00 2001 From: raizo62 Date: Thu, 4 Jun 2015 17:53:48 +0000 Subject: [PATCH 077/126] remove useless blank --- cheat/cheatsheets/mysqldump | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cheat/cheatsheets/mysqldump b/cheat/cheatsheets/mysqldump index f9f34a3..61c809c 100644 --- a/cheat/cheatsheets/mysqldump +++ b/cheat/cheatsheets/mysqldump @@ -1,16 +1,16 @@ - # To dump a database to a file (Note that your password will appear in your command history!): +# To dump a database to a file (Note that your password will appear in your command history!): mysqldump -uusername -ppassword the-database > db.sql # To dump a database to a file: mysqldump -uusername -p the-database > db.sql - # To dump a database to a .tgz file (Note that your password will appear in your command history!): +# To dump a database to a .tgz file (Note that your password will appear in your command history!): mysqldump -uusername -ppassword the-database | gzip -9 > db.sql # To dump a database to a .tgz file: mysqldump -uusername -p the-database | gzip -9 > db.sql - # To dump all databases to a file (Note that your password will appear in your command history!): +# To dump all databases to a file (Note that your password will appear in your command history!): mysqldump -uusername -ppassword --all-databases > all-databases.sql # To dump all databases to a file: From c18e475fd13f28856f4591d9b23acefd50fd8dcf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Mon, 8 Jun 2015 21:03:33 +0200 Subject: [PATCH 078/126] Add weechat --- cheat/cheatsheets/weechat | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 cheat/cheatsheets/weechat diff --git a/cheat/cheatsheets/weechat b/cheat/cheatsheets/weechat new file mode 100644 index 0000000..f001b4c --- /dev/null +++ b/cheat/cheatsheets/weechat @@ -0,0 +1,16 @@ +# Set unread marker on all windows +Ctrl-s Ctrl-u + +# Switch buffer left +Ctrl-p, Alt-left +# Switch buffer right +Ctrl-n, Alt-right +# Next buffer with activity +Alt-a +# Switch buffers +Alt-0...9 + +# Scroll buffer title +F9/F10 +# Scroll nick list +F11/F12 From 59accc64f7d3291d4eecff16ea4858030b224a3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Sat, 13 Jun 2015 09:40:39 +0200 Subject: [PATCH 079/126] add zip/unzip --- cheat/cheatsheets/unzip | 8 ++++++++ cheat/cheatsheets/zip | 5 +++++ 2 files changed, 13 insertions(+) create mode 100644 cheat/cheatsheets/unzip create mode 100644 cheat/cheatsheets/zip diff --git a/cheat/cheatsheets/unzip b/cheat/cheatsheets/unzip new file mode 100644 index 0000000..6d8a792 --- /dev/null +++ b/cheat/cheatsheets/unzip @@ -0,0 +1,8 @@ +# Extract archive +unzip archive.zip + +# Test integrity of archive +unzip -tq archive.zip + +# List files and directories in a file +unzip -l archive.zip diff --git a/cheat/cheatsheets/zip b/cheat/cheatsheets/zip new file mode 100644 index 0000000..ad22773 --- /dev/null +++ b/cheat/cheatsheets/zip @@ -0,0 +1,5 @@ +# Create zip file +zip archive.zip file1 directory/ + +# To list, test and extract zip archives, see unzip +cheat unzip From e75e9bb211bcab4a3d8c44abaedcdb30a61f99b4 Mon Sep 17 00:00:00 2001 From: Chris Lane Date: Thu, 18 Jun 2015 18:06:25 -0400 Subject: [PATCH 080/126] Whitespace edit --- cheat/cheatsheets/nova | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cheat/cheatsheets/nova b/cheat/cheatsheets/nova index de3e6e8..94720d8 100644 --- a/cheat/cheatsheets/nova +++ b/cheat/cheatsheets/nova @@ -17,4 +17,4 @@ nova stop nova start # To attach a network interface to a specific VM: -nova interface-attach --net-id \ No newline at end of file +nova interface-attach --net-id From 8a07a1e96c84d4974c94960fd16b22ed16ee9470 Mon Sep 17 00:00:00 2001 From: Chris Lane Date: Thu, 18 Jun 2015 18:30:06 -0400 Subject: [PATCH 081/126] Version bump --- bin/cheat | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/cheat b/bin/cheat index 464857e..c1ded66 100755 --- a/bin/cheat +++ b/bin/cheat @@ -38,7 +38,7 @@ from docopt import docopt if __name__ == '__main__': # parse the command-line options - options = docopt(__doc__, version='cheat 2.1.8') + options = docopt(__doc__, version='cheat 2.1.9') # list directories if options['--directories']: diff --git a/setup.py b/setup.py index b5c4c9e..b3239cf 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ import os setup( name = 'cheat', - version = '2.1.8', + version = '2.1.9', author = 'Chris Lane', author_email = 'chris@chris-allen-lane.com', license = 'GPL3', From 402d15e8d818b8fc8ca448e215a9e1be19463597 Mon Sep 17 00:00:00 2001 From: Shadab Zafar Date: Fri, 19 Jun 2015 23:11:48 +0530 Subject: [PATCH 082/126] More git cheats --- cheat/cheatsheets/git | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/cheat/cheatsheets/git b/cheat/cheatsheets/git index c52df05..951c0d8 100644 --- a/cheat/cheatsheets/git +++ b/cheat/cheatsheets/git @@ -1,4 +1,4 @@ -# To set your identify: +# To set your identity: git config --global user.name "John Doe" git config --global user.email johndoe@example.com @@ -17,9 +17,16 @@ git commit -m "Your commit message" # To edit previous commit message git commit --amend +# Git commit in the past +git commit --date="`date --date='2 day ago'`" +git commit --date="Jun 13 18:30:25 IST 2015" + # To removed staged and working directory changes git reset --hard +# To go 2 commits back +git reset --hard HEAD~2 + # To remove untracked files git clean -f -d @@ -35,6 +42,9 @@ git push git@github.com:username/project.git # To delete the branch "branch_name" git branch -D branch_name +# To make an exisiting branch track a remote branch +git branch -u upstream/foo + # To see who commited which line in a file git blame filename @@ -57,3 +67,21 @@ git log --pretty=email --patch-with-stat --reverse --full-index -- Admin\*.py > # Import commits from another repo git --git-dir=../some_other_repo/.git format-patch -k -1 --stdout | git am -3 -k + +# View commits that will be pushed +git log @{u}.. + +# View changes that are new on a feature branch +git log -p feature --not master +git diff master...feature + +# Interactive rebase for the last 7 commits +git rebase -i @~7 + +# Diff files WITHOUT considering them a part of git +# This can be used to diff files that are not in a git repo! +git diff --no-index path/to/file/A path/to/file/B + +# To pull changes while overwriting any local commits +git fetch --all +git reset --hard origin/master From 97dd0375389811a0cd0521be8f18edfab19722d4 Mon Sep 17 00:00:00 2001 From: Shadab Zafar Date: Fri, 19 Jun 2015 23:16:06 +0530 Subject: [PATCH 083/126] Fixup grammar in grep cheatsheet --- cheat/cheatsheets/grep | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cheat/cheatsheets/grep b/cheat/cheatsheets/grep index cb004e9..8c41057 100644 --- a/cheat/cheatsheets/grep +++ b/cheat/cheatsheets/grep @@ -1,13 +1,13 @@ -# Basic: +# Search a file for a pattern grep pattern file -# case nonsensitive research: -grep -i pattern file +# Case insensitive search (with line numbers) +grep -in pattern file # Recursively grep for string in folder: grep -R pattern folder -# Getting pattern from file (one by line): +# Read search patterns from a file (one per line) grep -f pattern_file file # Find lines NOT containing pattern @@ -17,7 +17,7 @@ grep -v pattern file grep "^00" file #Match lines starting with 00 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}. +# Find all files which match {pattern} in {directory} # This will show: "file:line my research" grep -rnw 'directory' -e "pattern" From ae452653172b26042de5b28b14ea1de17319ed19 Mon Sep 17 00:00:00 2001 From: Shadab Zafar Date: Fri, 19 Jun 2015 23:18:59 +0530 Subject: [PATCH 084/126] Two new cheats in date and ln sheets --- cheat/cheatsheets/date | 5 ++++- cheat/cheatsheets/ln | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/cheat/cheatsheets/date b/cheat/cheatsheets/date index aa3a767..05cebbf 100644 --- a/cheat/cheatsheets/date +++ b/cheat/cheatsheets/date @@ -1,2 +1,5 @@ -# Printout date in format suitable for affixing to file names +# Print date in format suitable for affixing to file names date +"%Y%m%d_%H%M%S" + +# Convert Unix timestamp to Date +date -d @1440359821 diff --git a/cheat/cheatsheets/ln b/cheat/cheatsheets/ln index 441c3a9..5a02f76 100644 --- a/cheat/cheatsheets/ln +++ b/cheat/cheatsheets/ln @@ -1,2 +1,5 @@ # To create a symlink: ln -s path/to/the/target/directory name-of-symlink + +# Symlink, while overwriting existing destination files +ln -sf /some/dir/exec /usr/bin/exec From 51b0b12663c224d640630c2e7eaf8bd1560a2533 Mon Sep 17 00:00:00 2001 From: Chris Lane Date: Thu, 9 Jul 2015 18:41:00 -0400 Subject: [PATCH 085/126] Minor addition to git cheatsheet --- cheat/cheatsheets/git | 1 + 1 file changed, 1 insertion(+) diff --git a/cheat/cheatsheets/git b/cheat/cheatsheets/git index 951c0d8..9aa57ca 100644 --- a/cheat/cheatsheets/git +++ b/cheat/cheatsheets/git @@ -20,6 +20,7 @@ git commit --amend # Git commit in the past git commit --date="`date --date='2 day ago'`" git commit --date="Jun 13 18:30:25 IST 2015" +# more recent versions of Git also support --date="2 days ago" directly # To removed staged and working directory changes git reset --hard From 74dfd51601bd368e03b9651641e0cfe173c6d232 Mon Sep 17 00:00:00 2001 From: Chris Lane Date: Thu, 9 Jul 2015 18:42:00 -0400 Subject: [PATCH 086/126] Version bump --- bin/cheat | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/cheat b/bin/cheat index c1ded66..06eebbc 100755 --- a/bin/cheat +++ b/bin/cheat @@ -38,7 +38,7 @@ from docopt import docopt if __name__ == '__main__': # parse the command-line options - options = docopt(__doc__, version='cheat 2.1.9') + options = docopt(__doc__, version='cheat 2.1.10') # list directories if options['--directories']: diff --git a/setup.py b/setup.py index b3239cf..fbf88b4 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ import os setup( name = 'cheat', - version = '2.1.9', + version = '2.1.10', author = 'Chris Lane', author_email = 'chris@chris-allen-lane.com', license = 'GPL3', From bc40ced2c1c9ac606822d568af22c6a5448ac481 Mon Sep 17 00:00:00 2001 From: Shadab Zafar Date: Fri, 24 Jul 2015 18:51:55 +0530 Subject: [PATCH 087/126] New Sheet: csplit - used to split a file into parts --- cheat/cheatsheets/csplit | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 cheat/cheatsheets/csplit diff --git a/cheat/cheatsheets/csplit b/cheat/cheatsheets/csplit new file mode 100644 index 0000000..6d7d8ef --- /dev/null +++ b/cheat/cheatsheets/csplit @@ -0,0 +1,5 @@ +# Split a file based on pattern +csplit input.file '/PATTERN/' + +# Use prefix/suffix to improve resulting file names +csplit -f 'prefix-' -b '%d.extension' input.file '/PATTERN/' '{*}' From 6304a65399d28343a5e78d913c9ff93720dce9be Mon Sep 17 00:00:00 2001 From: Shadab Zafar Date: Fri, 24 Jul 2015 18:53:50 +0530 Subject: [PATCH 088/126] New Sheet: numfmt - convert numbers from/to human-readable strings --- cheat/cheatsheets/numfmt | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 cheat/cheatsheets/numfmt diff --git a/cheat/cheatsheets/numfmt b/cheat/cheatsheets/numfmt new file mode 100644 index 0000000..0b9bbc4 --- /dev/null +++ b/cheat/cheatsheets/numfmt @@ -0,0 +1,2 @@ +# Convert bytes to Human readable format +numfmt --to=iec --suffix=B --padding=7 1048576 From b477df20b246a9447f4d8676aaff274c709a6435 Mon Sep 17 00:00:00 2001 From: Shadab Zafar Date: Fri, 24 Jul 2015 18:54:41 +0530 Subject: [PATCH 089/126] New Sheet: man - an interface to reference manuals --- cheat/cheatsheets/man | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 cheat/cheatsheets/man diff --git a/cheat/cheatsheets/man b/cheat/cheatsheets/man new file mode 100644 index 0000000..6d95d0b --- /dev/null +++ b/cheat/cheatsheets/man @@ -0,0 +1,5 @@ +# Convert a man page to pdf +man -t bash | ps2pdf - bash.pdf + +# View the ascii chart +man 7 ascii From 6b736083c39fa23346015ad616e4fec634b51381 Mon Sep 17 00:00:00 2001 From: Chris Lane Date: Fri, 31 Jul 2015 15:19:22 -0400 Subject: [PATCH 090/126] v2.1.11 - Merged PR #227 - Patch version bump --- bin/cheat | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/cheat b/bin/cheat index 06eebbc..253dc39 100755 --- a/bin/cheat +++ b/bin/cheat @@ -38,7 +38,7 @@ from docopt import docopt if __name__ == '__main__': # parse the command-line options - options = docopt(__doc__, version='cheat 2.1.10') + options = docopt(__doc__, version='cheat 2.1.11') # list directories if options['--directories']: diff --git a/setup.py b/setup.py index fbf88b4..986ea18 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ import os setup( name = 'cheat', - version = '2.1.10', + version = '2.1.11', author = 'Chris Lane', author_email = 'chris@chris-allen-lane.com', license = 'GPL3', From 6cf69bc190c4f821a42ab6eb057e6531fb5e2e06 Mon Sep 17 00:00:00 2001 From: Shadab Zafar Date: Mon, 3 Aug 2015 17:44:58 +0530 Subject: [PATCH 091/126] Git cheats: Change date of existing commit --- cheat/cheatsheets/git | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cheat/cheatsheets/git b/cheat/cheatsheets/git index 9aa57ca..469ee5d 100644 --- a/cheat/cheatsheets/git +++ b/cheat/cheatsheets/git @@ -22,6 +22,14 @@ git commit --date="`date --date='2 day ago'`" git commit --date="Jun 13 18:30:25 IST 2015" # more recent versions of Git also support --date="2 days ago" directly +# To change the date of an existing commit +git filter-branch --env-filter \ + 'if [ $GIT_COMMIT = 119f9ecf58069b265ab22f1f97d2b648faf932e0 ] + then + export GIT_AUTHOR_DATE="Fri Jan 2 21:38:53 2009 -0800" + export GIT_COMMITTER_DATE="Sat May 19 01:01:01 2007 -0700" + fi' + # To removed staged and working directory changes git reset --hard From 196875a828ca6ac0b6e9ab00d08d5b6db21ac95a Mon Sep 17 00:00:00 2001 From: Shadab Zafar Date: Mon, 3 Aug 2015 17:45:38 +0530 Subject: [PATCH 092/126] Git cheats: Shallow clones & Submodule update --- cheat/cheatsheets/git | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/cheat/cheatsheets/git b/cheat/cheatsheets/git index 469ee5d..b5c142b 100644 --- a/cheat/cheatsheets/git +++ b/cheat/cheatsheets/git @@ -94,3 +94,13 @@ git diff --no-index path/to/file/A path/to/file/B # To pull changes while overwriting any local commits git fetch --all git reset --hard origin/master + +# Update all your submodules +git submodule update --init --recursive + +# Perform a shallow clone to only get latest commits +# (helps save data when cloning large repos) +git clone --depth 1 + +# To unshallow a clone +git pull --unshallow From af354ba6a3df94e46333c55a645d637a5d26cb61 Mon Sep 17 00:00:00 2001 From: Shadab Zafar Date: Mon, 3 Aug 2015 17:48:15 +0530 Subject: [PATCH 093/126] New Sheet: ffmpeg - fast audio video encoder --- cheat/cheatsheets/ffmpeg | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 cheat/cheatsheets/ffmpeg diff --git a/cheat/cheatsheets/ffmpeg b/cheat/cheatsheets/ffmpeg new file mode 100644 index 0000000..952c45b --- /dev/null +++ b/cheat/cheatsheets/ffmpeg @@ -0,0 +1,12 @@ +# Print file metadata etc. +ffmpeg -i path/to/file.ext + +# Convert all m4a files to mp3 +for f in *.m4a; do ffmpeg -i "$f" -acodec libmp3lame -ab 320k "${f%.m4a}.mp3"; done + +# Listen to 10 seconds of audio from a video file +# +# -ss : start time +# -t : seconds to cut +# -autoexit : closes ffplay as soon as the audio finishes +ffmpeg -ss 00:34:24.85 -t 10 -i path/to/file.mp4 -f mp3 pipe:play | ffplay -i pipe:play -autoexit From 9c696cc430bb41ad47587de879d1b2faf0968a03 Mon Sep 17 00:00:00 2001 From: Chris Lane Date: Tue, 4 Aug 2015 20:56:23 -0400 Subject: [PATCH 094/126] v2.1.12 --- bin/cheat | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/cheat b/bin/cheat index 253dc39..e00a38f 100755 --- a/bin/cheat +++ b/bin/cheat @@ -38,7 +38,7 @@ from docopt import docopt if __name__ == '__main__': # parse the command-line options - options = docopt(__doc__, version='cheat 2.1.11') + options = docopt(__doc__, version='cheat 2.1.12') # list directories if options['--directories']: diff --git a/setup.py b/setup.py index 986ea18..10707ec 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ import os setup( name = 'cheat', - version = '2.1.11', + version = '2.1.12', author = 'Chris Lane', author_email = 'chris@chris-allen-lane.com', license = 'GPL3', From 6ca4b6c8e7a1240c56caaa17377557f3f8b97e13 Mon Sep 17 00:00:00 2001 From: Josef Glatz Date: Thu, 6 Aug 2015 14:39:22 +0200 Subject: [PATCH 095/126] [DOCUMENTATION] Cmd 'du' cumulative size cheat --- cheat/cheatsheets/du | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cheat/cheatsheets/du b/cheat/cheatsheets/du index 61c625d..57b6ac3 100644 --- a/cheat/cheatsheets/du +++ b/cheat/cheatsheets/du @@ -1,2 +1,5 @@ # To sort directories/files by size du -sk *| sort -rn + +# To show cumulative humanreadable size +du -sh From 511c57f5829cb506bcf63666acc4c451271a6987 Mon Sep 17 00:00:00 2001 From: Josef Glatz Date: Thu, 6 Aug 2015 14:46:21 +0200 Subject: [PATCH 096/126] [DOCUMENTATION] Cmd 'ssh' copy files with gzipped on the fly --- cheat/cheatsheets/ssh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cheat/cheatsheets/ssh b/cheat/cheatsheets/ssh index 1f11907..e83bcce 100644 --- a/cheat/cheatsheets/ssh +++ b/cheat/cheatsheets/ssh @@ -28,3 +28,7 @@ ssh user@example.com -C -c blowfish -X # For more information, see: # http://unix.stackexchange.com/q/12755/44856 + +# Copy files and folders through ssh from remote host to pwd with tar.gz compression +# when there is no rsync command available +ssh user@example.com "cd /var/www/Shared/; tar zcf - asset1 asset2" | tar zxf - From 8096ca7f90ea210027e87dd5b2e61530a7682d74 Mon Sep 17 00:00:00 2001 From: Chris Lane Date: Thu, 6 Aug 2015 21:15:26 -0400 Subject: [PATCH 097/126] Version bump 2.1.13 --- bin/cheat | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/cheat b/bin/cheat index e00a38f..82f1915 100755 --- a/bin/cheat +++ b/bin/cheat @@ -38,7 +38,7 @@ from docopt import docopt if __name__ == '__main__': # parse the command-line options - options = docopt(__doc__, version='cheat 2.1.12') + options = docopt(__doc__, version='cheat 2.1.13') # list directories if options['--directories']: diff --git a/setup.py b/setup.py index 10707ec..9d7394e 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ import os setup( name = 'cheat', - version = '2.1.12', + version = '2.1.13', author = 'Chris Lane', author_email = 'chris@chris-allen-lane.com', license = 'GPL3', From 4512a61086d116eab73fc04f2b70844dad991326 Mon Sep 17 00:00:00 2001 From: Aravinth Panchadcharam Date: Mon, 24 Aug 2015 21:07:55 +0200 Subject: [PATCH 098/126] New Sheet Added: Vagrant - A portable development environment --- cheat/cheatsheets/vagrant | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 cheat/cheatsheets/vagrant diff --git a/cheat/cheatsheets/vagrant b/cheat/cheatsheets/vagrant new file mode 100644 index 0000000..92f22d2 --- /dev/null +++ b/cheat/cheatsheets/vagrant @@ -0,0 +1,33 @@ +# Initate Vagrant +mkdir vag-vm; cd vag-vm +vagrant init + +# Add a box to vagrant repo +vagrant box add hashicorp/precise32 + +# Add a box Vagrant file +config.vm.box = "hashicorp/precise32" + +# Add vm to public network as host +config.vm.network "public_network" + +# Add provision script to vagrant file +config.vm.provision :shell, path: "provision.sh" + +# Start vm +vagrant up + +# Connect to started instance +vagrant ssh + +# Shutdown vm +vagrant halt + +# Hibernate vm +vagrant suspend + +# Set vm to initial state by cleaning all data +vagrant destroy + +# Restart vm with new provision script +vagran reload --provision From 2d7fdb5425e0523d6e7d97c7e7de8b21ef038627 Mon Sep 17 00:00:00 2001 From: Chris Lane Date: Tue, 25 Aug 2015 19:10:28 -0400 Subject: [PATCH 099/126] Patch version bump --- bin/cheat | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/cheat b/bin/cheat index 82f1915..dfe9450 100755 --- a/bin/cheat +++ b/bin/cheat @@ -38,7 +38,7 @@ from docopt import docopt if __name__ == '__main__': # parse the command-line options - options = docopt(__doc__, version='cheat 2.1.13') + options = docopt(__doc__, version='cheat 2.1.14') # list directories if options['--directories']: diff --git a/setup.py b/setup.py index 9d7394e..212f401 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ import os setup( name = 'cheat', - version = '2.1.13', + version = '2.1.14', author = 'Chris Lane', author_email = 'chris@chris-allen-lane.com', license = 'GPL3', From 705601f0b19fe529e82b09b5916666f66752c7f1 Mon Sep 17 00:00:00 2001 From: Cedric Dufour Date: Fri, 4 Sep 2015 10:06:37 +0200 Subject: [PATCH 100/126] Added parallel (multi-threaded) processing --- cheat/cheatsheets/tar | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cheat/cheatsheets/tar b/cheat/cheatsheets/tar index efa615f..088137a 100644 --- a/cheat/cheatsheets/tar +++ b/cheat/cheatsheets/tar @@ -24,3 +24,8 @@ 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/ + +# To use parallel (multi-threaded) implementation of compression algorithms: +tar -z ... -> tar -Ipigz ... +tar -j ... -> tar -Ipbzip2 ... +tar -J ... -> tar -Ipixz ... From ac445388d98e4362076d23dc88c50b57308d3c05 Mon Sep 17 00:00:00 2001 From: Cedric Dufour Date: Fri, 4 Sep 2015 10:08:42 +0200 Subject: [PATCH 101/126] Keep old configuration during update --- cheat/cheatsheets/apt-get | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cheat/cheatsheets/apt-get b/cheat/cheatsheets/apt-get index f46e1ef..b0347ce 100644 --- a/cheat/cheatsheets/apt-get +++ b/cheat/cheatsheets/apt-get @@ -23,3 +23,6 @@ apt-get -o Dir::Cache="/path/to/destination/dir/" -o Dir::Cache::archives="./" i # Show apt-get installed packages. grep 'install ' /var/log/dpkg.log + +# Silently keep old configuration during batch updates +apt-get update -o DPkg::Options::='--force-confold' ... From 4c2d0d2d8e81e5680c5668a5bc460912452d6b20 Mon Sep 17 00:00:00 2001 From: Cedric Dufour Date: Fri, 4 Sep 2015 10:10:32 +0200 Subject: [PATCH 102/126] Generate Diffie-Hellman parameters --- cheat/cheatsheets/openssl | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cheat/cheatsheets/openssl b/cheat/cheatsheets/openssl index 74a2511..46b14ed 100644 --- a/cheat/cheatsheets/openssl +++ b/cheat/cheatsheets/openssl @@ -19,3 +19,6 @@ openssl x509 -text -noout -in server.crt echo | openssl s_client -connect :443 2> /dev/null | \ awk '/-----BEGIN/,/END CERTIFICATE-----/' | \ openssl x509 -noout -enddate + +# Generate Diffie-Hellman parameters: +openssl dhparamm -outform PEM -out dhparams.pem 2048 From 8f0d2e9fc3d0bf712b6ab2fe7c724b7c723cd310 Mon Sep 17 00:00:00 2001 From: Cedric Dufour Date: Fri, 4 Sep 2015 10:12:46 +0200 Subject: [PATCH 103/126] Specify output separator character --- cheat/cheatsheets/awk | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cheat/cheatsheets/awk b/cheat/cheatsheets/awk index dbc670e..14d07de 100644 --- a/cheat/cheatsheets/awk +++ b/cheat/cheatsheets/awk @@ -6,3 +6,6 @@ printf '1:2:3' | awk -F ":" '{print $1+$2+$3}' # print a multiplication table seq 9 | sed 'H;g' | awk -v RS='' '{for(i=1;i<=NF;i++)printf("%dx%d=%d%s", i, NR, i*NR, i==NR?"\n":"\t")}' + +# Specify output separator character +printf '1 2 3' | awk 'BEGIN {OFS=":"}; {print $1,$2,$3}' From b3a93bc128f9918bd6c60b7571ba4c81006626cd Mon Sep 17 00:00:00 2001 From: Cedric Dufour Date: Fri, 4 Sep 2015 10:16:54 +0200 Subject: [PATCH 104/126] Retrieve N-th piped command exit status --- cheat/cheatsheets/bash | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cheat/cheatsheets/bash b/cheat/cheatsheets/bash index 5b7a702..c19f599 100644 --- a/cheat/cheatsheets/bash +++ b/cheat/cheatsheets/bash @@ -18,3 +18,7 @@ set -x # Turn off debugging: set +x + +# Retrieve N-th piped command exit status +printf 'foo' | fgrep 'foo' | sed 's/foo/bar/' +echo ${PIPESTATUS[0]} # replace 0 with N From f63406bc3e5a871703bc5fc9f08f64a2373ab899 Mon Sep 17 00:00:00 2001 From: Cedric Dufour Date: Fri, 4 Sep 2015 11:09:39 +0200 Subject: [PATCH 105/126] Lock file --- cheat/cheatsheets/bash | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cheat/cheatsheets/bash b/cheat/cheatsheets/bash index c19f599..571b3ca 100644 --- a/cheat/cheatsheets/bash +++ b/cheat/cheatsheets/bash @@ -22,3 +22,6 @@ set +x # Retrieve N-th piped command exit status printf 'foo' | fgrep 'foo' | sed 's/foo/bar/' echo ${PIPESTATUS[0]} # replace 0 with N + +# Lock file: +( set -o noclobber; echo > my.lock ) || echo 'Failed to create lock file' From 90f66ccaf3004ab3ef4db7511ed9ce75d0ca50f9 Mon Sep 17 00:00:00 2001 From: Cedric Dufour Date: Fri, 4 Sep 2015 11:16:18 +0200 Subject: [PATCH 106/126] (fixed typo) --- cheat/cheatsheets/openssl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cheat/cheatsheets/openssl b/cheat/cheatsheets/openssl index 46b14ed..9254c1c 100644 --- a/cheat/cheatsheets/openssl +++ b/cheat/cheatsheets/openssl @@ -21,4 +21,4 @@ awk '/-----BEGIN/,/END CERTIFICATE-----/' | \ openssl x509 -noout -enddate # Generate Diffie-Hellman parameters: -openssl dhparamm -outform PEM -out dhparams.pem 2048 +openssl dhparam -outform PEM -out dhparams.pem 2048 From ab86ac970d2fe41cd3d4dc421dd2ef38f98d6281 Mon Sep 17 00:00:00 2001 From: Blake Huber Date: Mon, 7 Sep 2015 20:56:09 -0500 Subject: [PATCH 107/126] new cheatsheets --- cheat/cheatsheets/cups | 22 ++++++++++++++++++++++ cheat/cheatsheets/hardware-info | 32 ++++++++++++++++++++++++++++++++ cheat/cheatsheets/lib | 23 +++++++++++++++++++++++ cheat/cheatsheets/ntp | 33 +++++++++++++++++++++++++++++++++ cheat/cheatsheets/ping | 5 +++++ cheat/cheatsheets/rss2email | 21 +++++++++++++++++++++ cheat/cheatsheets/systemd | 18 ++++++++++++++++++ 7 files changed, 154 insertions(+) create mode 100644 cheat/cheatsheets/cups create mode 100644 cheat/cheatsheets/hardware-info create mode 100644 cheat/cheatsheets/lib create mode 100644 cheat/cheatsheets/ntp create mode 100644 cheat/cheatsheets/ping create mode 100644 cheat/cheatsheets/rss2email create mode 100644 cheat/cheatsheets/systemd diff --git a/cheat/cheatsheets/cups b/cheat/cheatsheets/cups new file mode 100644 index 0000000..b1b7924 --- /dev/null +++ b/cheat/cheatsheets/cups @@ -0,0 +1,22 @@ +# Manage printers through CUPS: +http://localhost:631 (in web browser) + +# Print file from command line +lp myfile.txt + +# Display print queue +lpq + +# Remove print job from queue +lprm 545 +or +lprm - + +# Print log location +/var/log/cups + +# Reject new jobs +cupsreject printername + +# Accept new jobs +cupsaccept printername diff --git a/cheat/cheatsheets/hardware-info b/cheat/cheatsheets/hardware-info new file mode 100644 index 0000000..0bf4e57 --- /dev/null +++ b/cheat/cheatsheets/hardware-info @@ -0,0 +1,32 @@ +# Display all hardware details +sudo lshw + +# List currently loaded kernel modules +lsmod + +# List all modules available to the system +find /lib/modules/$(uname -r) -type f -iname "*.ko" + +# Load a module into kernel +modprobe modulename + +# Remove a module from kernel +modprobe -r modulename + +# List devices connected via pci bus +lspci + +# Debug output for pci devices (hex) +lspci -vvxxx + +# Display cpu hardware stats +cat /proc/cpuinfo + +# Display memory hardware stats +cat /proc/meminfo + +# Output the kernel ring buffer +dmesg + +# Ouput kernel messages +dmesg --kernel diff --git a/cheat/cheatsheets/lib b/cheat/cheatsheets/lib new file mode 100644 index 0000000..6854482 --- /dev/null +++ b/cheat/cheatsheets/lib @@ -0,0 +1,23 @@ +# Display available libraries +ldconfig -p + +# Update library resources +ldconfig + +# Display libraries and file location +ldd + +# Libraries available to apps in real-time +"Dynamic Libraries" (.so.) + +# Libraries only available to apps when installed (imported) +"Static Libraries" (.a.) + +# Standard (usual) library file location +/lib + +# Sofware-accessible source for library info +/etc/ld.so.cache # (binary) + +# Human-readable source for library info +/etc/ld.so.conf # (points to /etc/ld.so.conf.d) diff --git a/cheat/cheatsheets/ntp b/cheat/cheatsheets/ntp new file mode 100644 index 0000000..f578c54 --- /dev/null +++ b/cheat/cheatsheets/ntp @@ -0,0 +1,33 @@ +# Verify ntpd running: +service ntp status + +# Start ntpd if not running: +service ntp start + +# Display current hardware clock value: +sudo hwclock -r + +# Apply system time to hardware time: +sudo hwclock --systohc + +# Apply hardware time to system time: +sudo hwclock --hctosys + +# Set hwclock to local time: +sudo hwclock --localtime + +# Set hwclock to UTC: +sudo hwclock --utc + +# Set hwclock manually: +sudo hwclock --set --date="8/10/15 13:10:05" + +# Query surrounding stratum time servers +ntpq -pn + +# Config file: +/etc/ntp.conf + +# Driftfile: +location of "drift" of your system clock compared to ntp servers +/var/lib/ntp/ntp.drift diff --git a/cheat/cheatsheets/ping b/cheat/cheatsheets/ping new file mode 100644 index 0000000..dc2e479 --- /dev/null +++ b/cheat/cheatsheets/ping @@ -0,0 +1,5 @@ +# ping a host with a total count of 15 packets overall. +ping -c 15 www.example.com + +# ping a host with a total count of 15 packets overall, one every .5 seconds (faster ping). +ping -c 15 -i .5 www.example.com diff --git a/cheat/cheatsheets/rss2email b/cheat/cheatsheets/rss2email new file mode 100644 index 0000000..5d5cc77 --- /dev/null +++ b/cheat/cheatsheets/rss2email @@ -0,0 +1,21 @@ +'rss2email -- converts rss feeds and emails them to your inbox' + +# List all feeds +r2e list + +# Convert RSS entries to email +r2e run + +# Add a new feed +r2e add + +# Add a new feed with new email address +r2e add [newemail address] + +# Delete a feed +r2e delete <# of feed in list/> + +# Help +r2e -h + + diff --git a/cheat/cheatsheets/systemd b/cheat/cheatsheets/systemd new file mode 100644 index 0000000..ff56eb5 --- /dev/null +++ b/cheat/cheatsheets/systemd @@ -0,0 +1,18 @@ +# Display process startup time +systemd-analyze + +# Display process startup time at service level +systemd-analyze blame + +# List running units +systemctl list-units + +# Load a unit at startup +systemctl enable foo.service + +# Start or Stop a unit +systemctl foo.service + +# Unit file locations +/etc/systemd/system +/usr/lib/systemd/system From e1aec49ed6479c84a70ba37ed1a182b7ceed333b Mon Sep 17 00:00:00 2001 From: t-stark Date: Mon, 7 Sep 2015 20:57:17 -0500 Subject: [PATCH 108/126] modified cheatsheets --- cheat/cheatsheets/rpm | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/cheat/cheatsheets/rpm b/cheat/cheatsheets/rpm index 5a0d0ff..63227bc 100644 --- a/cheat/cheatsheets/rpm +++ b/cheat/cheatsheets/rpm @@ -4,6 +4,9 @@ rpm -ivh # To remove a package: rpm -e +# To remove a package, but not its dependencies +rpm -e --nodeps + # To find what package installs a file: rpm -qf @@ -17,3 +20,12 @@ rpm -q --whatrequires # To list all installed packages: rpm -qa + +# To find a pkg's dependencies +rpm -i --test + +# Display checksum against source +rpm -K + +# Verify a package +rpm -V From cafa2fb2fd12f958f2b7cfb2efc49d74a36e5856 Mon Sep 17 00:00:00 2001 From: Chris Lane Date: Wed, 9 Sep 2015 18:06:23 -0400 Subject: [PATCH 109/126] Version 2.1.15 Added new cheatsheets. --- bin/cheat | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/cheat b/bin/cheat index dfe9450..a75fc4b 100755 --- a/bin/cheat +++ b/bin/cheat @@ -38,7 +38,7 @@ from docopt import docopt if __name__ == '__main__': # parse the command-line options - options = docopt(__doc__, version='cheat 2.1.14') + options = docopt(__doc__, version='cheat 2.1.15') # list directories if options['--directories']: diff --git a/setup.py b/setup.py index 212f401..ca8868b 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ import os setup( name = 'cheat', - version = '2.1.14', + version = '2.1.15', author = 'Chris Lane', author_email = 'chris@chris-allen-lane.com', license = 'GPL3', From 47fd7c90f49c7af42d695face0a7327a2f73c9f9 Mon Sep 17 00:00:00 2001 From: bmaca Date: Tue, 22 Sep 2015 01:42:40 -0500 Subject: [PATCH 110/126] Added one more MySql cheat --- cheat/cheatsheets/mysql | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cheat/cheatsheets/mysql b/cheat/cheatsheets/mysql index 610d395..83b5add 100644 --- a/cheat/cheatsheets/mysql +++ b/cheat/cheatsheets/mysql @@ -12,3 +12,8 @@ CREATE DATABASE owa CHARACTER SET utf8 COLLATE utf8_general_ci; # To add a user and give rights on the given database GRANT ALL PRIVILEGES ON database.* TO 'user'@'localhost'IDENTIFIED BY 'password' WITH GRANT OPTION; + +# To list the privileges granted to the account that you are using to connect to the server. Any of the 3 statements will work. +SHOW GRANTS FOR CURRENT_USER(); +SHOW GRANTS; +SHOW GRANTS FOR CURRENT_USER; From 8eda2266bc26d4abc81db48b9ce5a0d56a66ddea Mon Sep 17 00:00:00 2001 From: summer-wu Date: Wed, 7 Oct 2015 11:34:01 +0800 Subject: [PATCH 111/126] Create tr --- cheat/cheatsheets/tr | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 cheat/cheatsheets/tr diff --git a/cheat/cheatsheets/tr b/cheat/cheatsheets/tr new file mode 100644 index 0000000..b462467 --- /dev/null +++ b/cheat/cheatsheets/tr @@ -0,0 +1,21 @@ +#replace : with new line +echo $PATH|tr ":" "\n" #equivalent to: +echo $PATH|tr -t ":" \n + +#complement "aa" +echo aabbccd |tr -c "aa" 1 +#output: aa11111% +#tip: Complement meaning keep aa,all other is replace with 1 + +#complement "ab\n" +echo aabbccd |tr -c "ab\n" 1 +#output: aabb111 with new line + +#preserve all alpha(-c),sequeeze mode instead of character mode +echo $PATH|tr -cs "[:alpha:]" "\n" + +#ordered list to unordered list +echo "1 /usr/bin\n2 /bin" |tr -cs "/\n[:alpha:]" "+" + +#remove all occurance of "ab" +echo aabbcc |tr -d "ab" From 91c28712e6358d3f34f7e391d22655b5e61677d0 Mon Sep 17 00:00:00 2001 From: summer-wu Date: Wed, 7 Oct 2015 11:39:27 +0800 Subject: [PATCH 112/126] Update tr --- cheat/cheatsheets/tr | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cheat/cheatsheets/tr b/cheat/cheatsheets/tr index b462467..c5efd47 100644 --- a/cheat/cheatsheets/tr +++ b/cheat/cheatsheets/tr @@ -1,5 +1,5 @@ #replace : with new line -echo $PATH|tr ":" "\n" #equivalent to: +echo $PATH|tr ":" "\n" #equivalent with: echo $PATH|tr -t ":" \n #complement "aa" @@ -11,7 +11,7 @@ echo aabbccd |tr -c "aa" 1 echo aabbccd |tr -c "ab\n" 1 #output: aabb111 with new line -#preserve all alpha(-c),sequeeze mode instead of character mode +#Preserve all alpha(-c). ":-[:digit:] etc" will translate to "\n". sequeeze mode. echo $PATH|tr -cs "[:alpha:]" "\n" #ordered list to unordered list From 84df17a0f6ee3328119d622c1cdc6d1562809d74 Mon Sep 17 00:00:00 2001 From: summer-wu Date: Wed, 7 Oct 2015 21:14:45 +0800 Subject: [PATCH 113/126] fix some typo --- cheat/cheatsheets/tr | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/cheat/cheatsheets/tr b/cheat/cheatsheets/tr index c5efd47..50f617f 100644 --- a/cheat/cheatsheets/tr +++ b/cheat/cheatsheets/tr @@ -2,20 +2,20 @@ echo $PATH|tr ":" "\n" #equivalent with: echo $PATH|tr -t ":" \n +#remove all occurance of "ab" +echo aabbcc |tr -d "ab" + #complement "aa" echo aabbccd |tr -c "aa" 1 -#output: aa11111% -#tip: Complement meaning keep aa,all other is replace with 1 +#output: aa11111 without new line +#tip: Complement meaning keep aa,all others are replaced with 1 #complement "ab\n" echo aabbccd |tr -c "ab\n" 1 #output: aabb111 with new line -#Preserve all alpha(-c). ":-[:digit:] etc" will translate to "\n". sequeeze mode. +#Preserve all alpha(-c). ":-[:digit:] etc" will be translated to "\n". sequeeze mode. echo $PATH|tr -cs "[:alpha:]" "\n" #ordered list to unordered list -echo "1 /usr/bin\n2 /bin" |tr -cs "/\n[:alpha:]" "+" - -#remove all occurance of "ab" -echo aabbcc |tr -d "ab" +echo "1. /usr/bin\n2. /bin" |tr -cs " /[:alpha:]\n" "+" From f3ecf76239e20309207737f72c1ac31bd7fb4b00 Mon Sep 17 00:00:00 2001 From: summer-wu Date: Wed, 7 Oct 2015 21:20:06 +0800 Subject: [PATCH 114/126] Update tr --- cheat/cheatsheets/tr | 1 + 1 file changed, 1 insertion(+) diff --git a/cheat/cheatsheets/tr b/cheat/cheatsheets/tr index 50f617f..09849e4 100644 --- a/cheat/cheatsheets/tr +++ b/cheat/cheatsheets/tr @@ -4,6 +4,7 @@ echo $PATH|tr -t ":" \n #remove all occurance of "ab" echo aabbcc |tr -d "ab" +#ouput: cc #complement "aa" echo aabbccd |tr -c "aa" 1 From 2ebc8c9faca366e53bc91aea39a01e26f8201ed6 Mon Sep 17 00:00:00 2001 From: thor andreas Date: Wed, 7 Oct 2015 20:21:01 +0200 Subject: [PATCH 115/126] Add two cheats for ls-command Display directories only --- cheat/cheatsheets/ls | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cheat/cheatsheets/ls b/cheat/cheatsheets/ls index 9d85600..41a116a 100644 --- a/cheat/cheatsheets/ls +++ b/cheat/cheatsheets/ls @@ -9,3 +9,9 @@ ls -lh # Display files, sorted by size ls -S + +# Display directories only +ls -d */ + +# Display directories only, include hidden +ls -d .*/ */ From 905f12a27981c18f2b72a1602c1a94d427595b29 Mon Sep 17 00:00:00 2001 From: Chris Lane Date: Thu, 15 Oct 2015 18:30:25 -0400 Subject: [PATCH 116/126] Patch version bump. --- bin/cheat | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/cheat b/bin/cheat index a75fc4b..e91f73c 100755 --- a/bin/cheat +++ b/bin/cheat @@ -38,7 +38,7 @@ from docopt import docopt if __name__ == '__main__': # parse the command-line options - options = docopt(__doc__, version='cheat 2.1.15') + options = docopt(__doc__, version='cheat 2.1.16') # list directories if options['--directories']: diff --git a/setup.py b/setup.py index ca8868b..6be7354 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ import os setup( name = 'cheat', - version = '2.1.15', + version = '2.1.16', author = 'Chris Lane', author_email = 'chris@chris-allen-lane.com', license = 'GPL3', From a8f91d4224b623ad2edc1fa403700edd7fea471d Mon Sep 17 00:00:00 2001 From: Chris Lane Date: Thu, 15 Oct 2015 18:37:02 -0400 Subject: [PATCH 117/126] Minor tweaks. --- setup.py | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/setup.py b/setup.py index 508f1b4..03078eb 100644 --- a/setup.py +++ b/setup.py @@ -1,26 +1,25 @@ """cheat - ~~~~~~~~ - - cheat allows you to create and view interactive cheatsheets on the - command-line. It was designed to help remind *nix system administrators of - options for commands that they use frequently, but not frequently enough - to remember. - :license: GPL3 +~~~~~~~~ +cheat allows you to create and view interactive cheatsheets on the +command-line. It was designed to help remind *nix system administrators of +options for commands that they use frequently, but not frequently enough +to remember. +:license: GPL3 """ from setuptools import setup, find_packages setup( - name = 'cheat', - version = '2.1.16', - author = 'Chris Lane', - author_email = 'chris@chris-allen-lane.com', - license = 'GPL3', - description = 'cheat allows you to create and view interactive cheatsheets on the command-line', + name = 'cheat', + version = '2.1.16', + author = 'Chris Lane', + author_email = 'chris@chris-allen-lane.com', + license = 'GPL3', + description = 'cheat allows you to create and view interactive cheatsheets on the command-line', long_description = __doc__, - url = 'https://github.com/chrisallenlane/cheat', - packages = find_packages(), - package_data = { + url = 'https://github.com/chrisallenlane/cheat', + packages = find_packages(), + package_data = { 'cheat.cheatsheets': ['*'], }, entry_points = { From 3b2848668a6989534f817113dec2d7f2028fa5a2 Mon Sep 17 00:00:00 2001 From: Chris Lane Date: Thu, 15 Oct 2015 18:40:18 -0400 Subject: [PATCH 118/126] patch version bump. --- cheat/app.py | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cheat/app.py b/cheat/app.py index 9c8a7a8..bd40dd8 100755 --- a/cheat/app.py +++ b/cheat/app.py @@ -39,7 +39,7 @@ from docopt import docopt def main(): # parse the command-line options - options = docopt(__doc__, version='cheat 2.1.16') + options = docopt(__doc__, version='cheat 2.1.17') # list directories if options['--directories']: diff --git a/setup.py b/setup.py index 03078eb..0cda828 100644 --- a/setup.py +++ b/setup.py @@ -11,7 +11,7 @@ from setuptools import setup, find_packages setup( name = 'cheat', - version = '2.1.16', + version = '2.1.17', author = 'Chris Lane', author_email = 'chris@chris-allen-lane.com', license = 'GPL3', From 20d52376f9b82d9cc193955961e45bc51a9ba166 Mon Sep 17 00:00:00 2001 From: Chris Lane Date: Thu, 15 Oct 2015 18:56:34 -0400 Subject: [PATCH 119/126] Undid packaging refactoring. --- cheat/app.py => bin/cheat | 12 ++++------ setup.py | 46 +++++++++++++++++---------------------- 2 files changed, 24 insertions(+), 34 deletions(-) rename cheat/app.py => bin/cheat (91%) diff --git a/cheat/app.py b/bin/cheat similarity index 91% rename from cheat/app.py rename to bin/cheat index bd40dd8..e91f73c 100755 --- a/cheat/app.py +++ b/bin/cheat @@ -31,15 +31,14 @@ Options: """ # require the dependencies -import sheet -import sheets -from utils import * +from cheat import * +from cheat.utils import * from docopt import docopt -def main(): +if __name__ == '__main__': # parse the command-line options - options = docopt(__doc__, version='cheat 2.1.17') + options = docopt(__doc__, version='cheat 2.1.16') # list directories if options['--directories']: @@ -60,6 +59,3 @@ def main(): # print the cheatsheet else: print(colorize(sheet.read(options['']))) - -if __name__ == '__main__': - main() diff --git a/setup.py b/setup.py index 0cda828..6be7354 100644 --- a/setup.py +++ b/setup.py @@ -1,32 +1,26 @@ -"""cheat -~~~~~~~~ -cheat allows you to create and view interactive cheatsheets on the -command-line. It was designed to help remind *nix system administrators of -options for commands that they use frequently, but not frequently enough -to remember. -:license: GPL3 -""" - -from setuptools import setup, find_packages +from distutils.core import setup +import os setup( - name = 'cheat', - version = '2.1.17', - author = 'Chris Lane', - author_email = 'chris@chris-allen-lane.com', - license = 'GPL3', - description = 'cheat allows you to create and view interactive cheatsheets on the command-line', - long_description = __doc__, - url = 'https://github.com/chrisallenlane/cheat', - packages = find_packages(), - package_data = { - 'cheat.cheatsheets': ['*'], - }, - entry_points = { - 'console_scripts': [ - 'cheat = cheat.app:main', - ], + name = 'cheat', + version = '2.1.16', + author = 'Chris Lane', + author_email = 'chris@chris-allen-lane.com', + license = 'GPL3', + description = 'cheat allows you to create and view interactive cheatsheets ' + 'on the command-line. It was designed to help remind *nix system ' + 'administrators of options for commands that they use frequently, but not ' + 'frequently enough to remember.', + url = 'https://github.com/chrisallenlane/cheat', + packages = [ + 'cheat', + 'cheat.cheatsheets', + 'cheat.test', + ], + package_data = { + 'cheat.cheatsheets': [f for f in os.listdir('cheat/cheatsheets') if '.' not in f] }, + scripts = ['bin/cheat'], install_requires = [ 'docopt >= 0.6.1', 'pygments >= 1.6.0', From 6a2eda80d4f877ec555370ae61a487f43563d38d Mon Sep 17 00:00:00 2001 From: Chris Lane Date: Thu, 15 Oct 2015 18:57:33 -0400 Subject: [PATCH 120/126] patch version bump. --- bin/cheat | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/cheat b/bin/cheat index e91f73c..3caafc5 100755 --- a/bin/cheat +++ b/bin/cheat @@ -38,7 +38,7 @@ from docopt import docopt if __name__ == '__main__': # parse the command-line options - options = docopt(__doc__, version='cheat 2.1.16') + options = docopt(__doc__, version='cheat 2.1.18') # list directories if options['--directories']: diff --git a/setup.py b/setup.py index 6be7354..6cf4dd2 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ import os setup( name = 'cheat', - version = '2.1.16', + version = '2.1.18', author = 'Chris Lane', author_email = 'chris@chris-allen-lane.com', license = 'GPL3', From a519ea163ee9a3b22ef9d7c1cd66248cbb5ebbe6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20P=C3=B6ck?= Date: Mon, 2 Nov 2015 14:28:30 +0100 Subject: [PATCH 121/126] 20151102 - Adding a cheatsheet for at (apt vs apt-get) --- cheat/cheatsheets/apt | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 cheat/cheatsheets/apt diff --git a/cheat/cheatsheets/apt b/cheat/cheatsheets/apt new file mode 100644 index 0000000..adab055 --- /dev/null +++ b/cheat/cheatsheets/apt @@ -0,0 +1,16 @@ +# Desc: Allows to update the operating system + +# To fetch package list: +apt update + +# To download and install updates without installing new package: +apt upgrade + +# To download and install the updates AND install new necessary packages: +apt dist-upgrade + +# Full command: +apt update && apt dist-upgrade + +# To install a new package(s): +apt install package(s) \ No newline at end of file From 22eb1f2df48d4a149bed758a44e043aa103065aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20P=C3=B6ck?= Date: Mon, 2 Nov 2015 14:51:37 +0100 Subject: [PATCH 122/126] 20151102 - Added 3 more cheats into the new apt cheatsheet --- cheat/cheatsheets/apt | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/cheat/cheatsheets/apt b/cheat/cheatsheets/apt index adab055..fa0df27 100644 --- a/cheat/cheatsheets/apt +++ b/cheat/cheatsheets/apt @@ -1,5 +1,11 @@ # Desc: Allows to update the operating system +# To search a package: +apt search package + +# To show package informations: +apt show package + # To fetch package list: apt update @@ -13,4 +19,7 @@ apt dist-upgrade apt update && apt dist-upgrade # To install a new package(s): -apt install package(s) \ No newline at end of file +apt install package(s) + +# To uninstall package(s) +apt remove package(s) From aabaab1185a6942f533df748fb6fd024ea9f02d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Wed, 11 Nov 2015 21:21:24 +0100 Subject: [PATCH 123/126] ping: MTU check --- cheat/cheatsheets/ping | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cheat/cheatsheets/ping b/cheat/cheatsheets/ping index dc2e479..a50198b 100644 --- a/cheat/cheatsheets/ping +++ b/cheat/cheatsheets/ping @@ -3,3 +3,6 @@ ping -c 15 www.example.com # ping a host with a total count of 15 packets overall, one every .5 seconds (faster ping). ping -c 15 -i .5 www.example.com + +# test if a packet size of 1500 bytes is supported (to check the MTU for example) +ping -s 1500 -c 10 -M do www.example.com From 6670785a2a49673907cef60ec241f23a8276d7de Mon Sep 17 00:00:00 2001 From: Vasiliy Yorkin Date: Tue, 17 Nov 2015 15:35:03 +0300 Subject: [PATCH 124/126] Update docker --- cheat/cheatsheets/docker | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cheat/cheatsheets/docker b/cheat/cheatsheets/docker index d803ccc..6224d7b 100644 --- a/cheat/cheatsheets/docker +++ b/cheat/cheatsheets/docker @@ -19,6 +19,9 @@ docker inspect --format {{.State.Pid}} # http://nathanleclaire.com/blog/2014/07/12/10-docker-tips-and-tricks-that-will-make-you-sing-a-whale-song-of-joy/ docker inspect --format='{{json .Volumes}}' | python -mjson.tool +# Copy files/folders between a container and your host +docker cp foo.txt mycontainer:/foo.txt + # list currently running containers docker ps @@ -26,4 +29,4 @@ docker ps docker ps -a # list all images -docker images \ No newline at end of file +docker images From 711fd02195f1096daf6c3a62a5f9725e86d0ee05 Mon Sep 17 00:00:00 2001 From: Chris Lane Date: Sun, 22 Nov 2015 11:26:15 -0500 Subject: [PATCH 125/126] Trivial edit to cheatsheet --- cheat/cheatsheets/apt | 2 -- 1 file changed, 2 deletions(-) diff --git a/cheat/cheatsheets/apt b/cheat/cheatsheets/apt index fa0df27..07ae3f4 100644 --- a/cheat/cheatsheets/apt +++ b/cheat/cheatsheets/apt @@ -1,5 +1,3 @@ -# Desc: Allows to update the operating system - # To search a package: apt search package From b6137cac8bc7591fc3ec780a42ea50dd5acc1b24 Mon Sep 17 00:00:00 2001 From: Chris Lane Date: Sun, 22 Nov 2015 11:28:32 -0500 Subject: [PATCH 126/126] patch version bump --- bin/cheat | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/cheat b/bin/cheat index 3caafc5..88bd3c5 100755 --- a/bin/cheat +++ b/bin/cheat @@ -38,7 +38,7 @@ from docopt import docopt if __name__ == '__main__': # parse the command-line options - options = docopt(__doc__, version='cheat 2.1.18') + options = docopt(__doc__, version='cheat 2.1.19') # list directories if options['--directories']: diff --git a/setup.py b/setup.py index 6cf4dd2..727c671 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ import os setup( name = 'cheat', - version = '2.1.18', + version = '2.1.19', author = 'Chris Lane', author_email = 'chris@chris-allen-lane.com', license = 'GPL3',