Merge branch 'master' of https://github.com/kragniz/cheat into kragniz-master

* 'master' of https://github.com/kragniz/cheat:
  Don't split cheatpath for no reason
  Remove duplicates from the list of cheatsheets.
  Change indent level from 2 spaces to 4.
  Change most of the headers to h1's.
  Add a non-root section to the installation guide.
  Don't require the package to be available.
  Remove old install script
  Replace support for user's .cheat directories
  Update readme with setup.py
  Package with distutils
This commit is contained in:
Chris Lane
2013-08-18 14:57:55 -04:00
25 changed files with 81 additions and 45 deletions

3
cheatsheets/__init__.py Normal file
View File

@ -0,0 +1,3 @@
import os
cheat_dir, __init = os.path.split(__file__)

2
cheatsheets/apt-cache Normal file
View File

@ -0,0 +1,2 @@
To search for apt packages:
apt-cache search "whatever"

14
cheatsheets/bash Normal file
View File

@ -0,0 +1,14 @@
To implement a for loop:
for file in `ls .`;
do echo 'file';
echo 'found';
done
To implement a case command:
case "$1"
in
0) echo "zero found";;
1) echo "one found";;
2) echo "two found";;
3) echo "three found";;
esac

19
cheatsheets/convert Normal file
View File

@ -0,0 +1,19 @@
To resize an image to a fixed width and proportional height:
convert original-image.jpg -resize 100x converted-image.jpg
To resize an image to a fixed height and proportional width:
convert original-image.jpg -resize x100 converted-image.jpg
To resize an image to a fixed width and height:
convert original-image.jpg -resize 100x100 converted-image.jpg
To resize an image and simultaneously change its file type:
convert original-image.jpg -resize 100x converted-image.png
To resize all of the images within a directory:
To implement a for loop:
for file in `ls original/image/path/`;
do new_path=${file%.*};
new_file=`basename $new_path`;
convert $file -resize 150 conerted/image/path/$new_file.png;
done

2
cheatsheets/cut Normal file
View File

@ -0,0 +1,2 @@
To cut out the third field of text or stdoutput that is delimited by a #:
cut -d# -f3

7
cheatsheets/dhclient Normal file
View File

@ -0,0 +1,7 @@
To release the current IP address:
sudo dhclient -r
To obtain a new IP address:
sudo dhclient
Running the above in sequence is a common way of refreshing an IP.

14
cheatsheets/find Normal file
View File

@ -0,0 +1,14 @@
To find files by extension (ex: .jpg):
find . -iname "*.jpg"
To find directories:
find . -type d
To find files:
find . -type f
To find files by octal permission:
find . -type f -perm 777
To find files with setuid bit set:
find . -xdev \( -perm -4000 \) -type f -print0 | xargs -0 ls -l

6
cheatsheets/git Normal file
View File

@ -0,0 +1,6 @@
To set your identify:
git config --global user.name "John Doe"
git config --global user.email johndoe@example.com
To enable color:
git config --global color.ui true

2
cheatsheets/ln Normal file
View File

@ -0,0 +1,2 @@
To create a symlink:
ln -s path/to/the/target/directory name-of-symlink

8
cheatsheets/mysqldump Normal file
View File

@ -0,0 +1,8 @@
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

2
cheatsheets/netstat Normal file
View File

@ -0,0 +1,2 @@
To view which users/processes are listening to which ports:
sudo netstat -lnptu

4
cheatsheets/notify-send Normal file
View File

@ -0,0 +1,4 @@
To send a desktop notification via dbus:
notify-send -i 'icon-file/name' -a 'application_name' 'summary' 'body of message'
The -i and -a flags can be omitted if unneeded.

8
cheatsheets/sed Normal file
View File

@ -0,0 +1,8 @@
To replace all occurrences of "day" with "night" and write to stdout:
sed s/day/night file.txt
To replace all occurrences of "day" with "night" within file.txt:
sed s/day/night file.txt > file.txt
To replace all occurrences of "day" with "night" on stdin:
echo 'It is daytime' | sed s/day/night/

13
cheatsheets/shred Normal file
View File

@ -0,0 +1,13 @@
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.

2
cheatsheets/sockstat Normal file
View File

@ -0,0 +1,2 @@
To view which users/processes are listening to which ports:
sudo sockstat -l

8
cheatsheets/split Normal file
View File

@ -0,0 +1,8 @@
To split a large text file into smaller files of 1000 lines each:
split file.txt -l 1000
To split a large binary file into smaller files of 10M each:
split file.txt -b 10M
To consolidate split files into a single file:
cat x* > file.txt

11
cheatsheets/ssh Normal file
View File

@ -0,0 +1,11 @@
To execute a command on a remote server:
ssh -t user@example.com 'the-remote-command'
To tunnel an x session over SSH:
ssh -X user@example.com
To launch a specific x application over SSH:
ssh -X -t user@example.com 'chromium-browser'
For more information, see:
http://unix.stackexchange.com/q/12755/44856

5
cheatsheets/ssh-copy-id Normal file
View File

@ -0,0 +1,5 @@
To copy a key to a remote host:
ssh-copy-id username@host
To copy a key to a remote host on a non-standard port:
ssh-copy-id username@host -p 2222

11
cheatsheets/ssh-keygen Normal file
View File

@ -0,0 +1,11 @@
To generate an SSH key:
ssh-keygen -t rsa
To generate a 4096-bit SSH key:
ssh-keygen -t rsa -b 4096
To copy a key to a remote host:
ssh-copy-id username@host
To copy a key to a remote host on a non-standard port:
ssh-copy-id username@host -p 2222

5
cheatsheets/stdout Normal file
View File

@ -0,0 +1,5 @@
To redirect stderr to stdout:
some-command 2>&1
To redirect stderr to a file
some-command 2> errors.txt

17
cheatsheets/tar Normal file
View File

@ -0,0 +1,17 @@
To extract an uncompressed archive:
tar -xvf /path/to/foo.tar
To create an uncompressed archive:
tar -cvf /path/to/foo.tar /path/to/foo/
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/