mirror of
https://github.com/Erreur32/cheat.git
synced 2024-12-22 21:52:12 +01:00
Took a first stab at the README.
This commit is contained in:
parent
58c01320f8
commit
fa0843c337
2 changed files with 114 additions and 17 deletions
44
.cheat
44
.cheat
|
@ -1,5 +1,7 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
cheatsheets = {
|
cheatsheets = {
|
||||||
|
|
||||||
# @todo:
|
# @todo:
|
||||||
# - adb
|
# - adb
|
||||||
# - at
|
# - at
|
||||||
|
@ -9,18 +11,13 @@ cheatsheets = {
|
||||||
# - fdisk
|
# - fdisk
|
||||||
# - fstab
|
# - fstab
|
||||||
# - mount
|
# - mount
|
||||||
# - mysqldump
|
|
||||||
# - mysqlimport
|
|
||||||
# - mongodump
|
# - mongodump
|
||||||
# - mongoimport
|
# - mongoimport
|
||||||
# - nc
|
# - nc
|
||||||
# - rsync
|
# - rsync
|
||||||
# - shred
|
|
||||||
# - useradd / adduser
|
# - useradd / adduser
|
||||||
# - xargs
|
# - xargs
|
||||||
|
|
||||||
# @see: http://www.thegeekstuff.com/2010/11/50-linux-commands/
|
|
||||||
|
|
||||||
########## apt-cache ##########################################################
|
########## apt-cache ##########################################################
|
||||||
'apt-cache' : '''
|
'apt-cache' : '''
|
||||||
To search for apt packages:
|
To search for apt packages:
|
||||||
|
@ -111,6 +108,18 @@ To create a symlink:
|
||||||
ln -s path/to/the/target/directory name-of-symlink
|
ln -s path/to/the/target/directory name-of-symlink
|
||||||
''',
|
''',
|
||||||
|
|
||||||
|
########## mysqldump #########################################################
|
||||||
|
'mysqldump' : '''
|
||||||
|
To dump a database to a file:
|
||||||
|
mysqldump -uusername -ppassword the-database > db.sql
|
||||||
|
|
||||||
|
To dump a database to a .tgz file:
|
||||||
|
mysqldump -uusername -ppassword the-database | gzip -9 > db.sql
|
||||||
|
|
||||||
|
To dump all databases to a file:
|
||||||
|
mysqldump -uusername -ppassword --all-databases > all-databases.sql
|
||||||
|
''',
|
||||||
|
|
||||||
########## netstat ###########################################################
|
########## netstat ###########################################################
|
||||||
'netstat' : '''
|
'netstat' : '''
|
||||||
To view which users/processes are listening to which ports:
|
To view which users/processes are listening to which ports:
|
||||||
|
@ -137,6 +146,23 @@ To replace all occurrences of "day" with "night" on stdin:
|
||||||
echo 'It is daytime' | sed s/day/night/
|
echo 'It is daytime' | sed s/day/night/
|
||||||
''',
|
''',
|
||||||
|
|
||||||
|
########## shred ##############################################################
|
||||||
|
'shred' : '''
|
||||||
|
To shred a file (5 passes) and verbose output:
|
||||||
|
shred -n 5 -v file.txt
|
||||||
|
|
||||||
|
To shred a file (5 passes) and a final overwrite of zeroes:
|
||||||
|
shred -n 5 -vz file.txt
|
||||||
|
|
||||||
|
To do the above, and then truncate and rm the file:
|
||||||
|
shred -n 5 -vzu file.txt
|
||||||
|
|
||||||
|
To shred a partition:
|
||||||
|
shred -n 5 -vz /dev/sda
|
||||||
|
|
||||||
|
Remember that shred may not behave as expected on journaled file systems if file data is being journaled.
|
||||||
|
''',
|
||||||
|
|
||||||
########## split #############################################################
|
########## split #############################################################
|
||||||
'split' : '''
|
'split' : '''
|
||||||
To split a large text file into smaller files of 1000 lines each:
|
To split a large text file into smaller files of 1000 lines each:
|
||||||
|
@ -223,9 +249,7 @@ tar -cjvf /path/to/foo.tgz /path/to/foo/
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# Cheatsheets can be aliased under a different keyphrase like this:
|
# Cheatsheets can be aliased under a different keyphrase like this:
|
||||||
#cheatsheets['dbus'] = cheatsheets['notify-send']
|
cheatsheets['dbus'] = cheatsheets['notify-send']
|
||||||
#cheatsheets['imagick'] = cheatsheets['convert']
|
cheatsheets['imagick'] = cheatsheets['convert']
|
||||||
#cheatsheets['redirection'] = cheatsheets['stdout']
|
cheatsheets['redirection'] = cheatsheets['stdout']
|
||||||
|
|
||||||
|
|
87
README.md
87
README.md
|
@ -1,9 +1,82 @@
|
||||||
Cheat
|
Cheat
|
||||||
=====
|
=====
|
||||||
- overview
|
`cheat` allows you to create and view interactive cheatsheets on the
|
||||||
- obligatory xkcd (http://xkcd.com/1168/)(Embed: http://imgs.xkcd.com/comics/tar.png)
|
command-line. It was designed to help \*nix system administrators remember
|
||||||
- examples
|
options for commands that they use frequently, but not frequently enough to
|
||||||
- subcommands
|
remember.
|
||||||
- anything, really
|
|
||||||
- Installing (link to dotfiles.github.com)
|
![The obligatory xkcd](http://imgs.xkcd.com/comics/tar.png 'The obligatory xkcd')
|
||||||
- help
|
|
||||||
|
`cheat` depends only on python.
|
||||||
|
|
||||||
|
Examples
|
||||||
|
--------
|
||||||
|
The next time you're forced to disarm a nuclear weapon without consulting
|
||||||
|
Google, you may run:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
cheat tar
|
||||||
|
```
|
||||||
|
|
||||||
|
You will be presented with a cheatsheet resembling:
|
||||||
|
|
||||||
|
```text
|
||||||
|
To extract an uncompressed archive:
|
||||||
|
tar -xvf /path/to/foo.tar
|
||||||
|
|
||||||
|
To extract a .gz archive:
|
||||||
|
tar -xzvf /path/to/foo.tgz
|
||||||
|
|
||||||
|
To create a .gz archive:
|
||||||
|
tar -czvf /path/to/foo.tgz /path/to/foo/
|
||||||
|
|
||||||
|
To extract a .bz2 archive:
|
||||||
|
tar -xjvf /path/to/foo.tgz
|
||||||
|
|
||||||
|
To create a .bz2 archive:
|
||||||
|
tar -cjvf /path/to/foo.tgz /path/to/foo/
|
||||||
|
```
|
||||||
|
|
||||||
|
To see what cheatsheets are availble, run `cheat` with no arguments.
|
||||||
|
|
||||||
|
Note that, while `cheat` was designed primarily for *nix system administrators,
|
||||||
|
it is agnostic as to what content it stores. If you would like to use `cheat`
|
||||||
|
to store notes on your favorite cookie recipes, feel free.
|
||||||
|
|
||||||
|
|
||||||
|
Installing
|
||||||
|
----------
|
||||||
|
Do the following to install `cheat`:
|
||||||
|
|
||||||
|
1. Clone this repository and `cd` into it
|
||||||
|
2. Run `sudo ./install`
|
||||||
|
|
||||||
|
The `install` script will copy a python file into `/usr/local/bin/`, and will
|
||||||
|
also create a hidden file (containing the cheatsheet content) in your home
|
||||||
|
directory.
|
||||||
|
|
||||||
|
|
||||||
|
Modifying Cheatsheets
|
||||||
|
---------------------
|
||||||
|
The value of `cheat` is that it allows you to create your own cheatsheets - the
|
||||||
|
defaults are meant to serve only as a starting point, and can and should be
|
||||||
|
modified.
|
||||||
|
|
||||||
|
To modify your cheatsheets, edit the `~/.cheat` file, which simply contains a
|
||||||
|
python dictionary. To add new cheatsheets, you need only append new key/value
|
||||||
|
pairs to the dictionary.
|
||||||
|
|
||||||
|
Note that `cheat` supports subcommands, such that (for example) `git` and `git
|
||||||
|
commit` may each be assigned their own cheat sheets.
|
||||||
|
|
||||||
|
After you've customized your cheatsheets, I urge you to track `.cheat` along
|
||||||
|
with your [dotfiles][].
|
||||||
|
|
||||||
|
|
||||||
|
Contributing
|
||||||
|
------------
|
||||||
|
If you would like to contribute additional cheatsheets for basic \*nix
|
||||||
|
commands, please modify the `.cheat` file and send me a pull request.
|
||||||
|
|
||||||
|
|
||||||
|
[dotfiles]: http://dotfiles.github.io/
|
||||||
|
|
Loading…
Reference in a new issue