Show Menu
Cheatography

Quick Reference Cheat Sheet (DRAFT) by

Miscellaneous things I sometimes use but often forget

This is a draft cheat sheet. It is a work in progress and is not finished yet.

Permis­sions and Ownership

change a file's permis­sions
chmod mode file
change a file's owner / group
chown owner[­:group] file
change a file's group
chgrp group file
show detailed permis­sions (ACL)
getfacl

Comman­dline XSLT

latest
java -jar saxon9­he.jar -xsl:t­ran­sfo­rm.xsl -s:sou­rce.xml -o:out­put.xml
6.5.5
java -jar saxon.jar -o output.xml source.xml transf­orm.xslt

PHP

debug_­bac­ktrace
/
debug_­pri­nt_­bac­ktrace

phpDoc­umentor

php phpDocumentor.phar -c phpdoc.apibrary.xml

XSLT

comman­dline
java -jar ~/saxo­n.jar -o ~/outp­ut.html ~/sour­ce.xml transf­orm.xslt

Rhino JS

Add java class
var HashMap = java.u­til.Ha­shMap;
XML: from string
var availPubs = new XML(pr­odX­ML.g­et­('p­ubs­Ava­ila­ble­ToC­ust­ome­r'));
- note: contains contents of root XML element, cannot access root element
XML: access element
var pubs = availP­ubs.pub
- note: if multiple matches, returns
XMLList
XML: access attribute
pub.@id

Misc. Command Line

IP address
hostname -i
OS info
lsb_re­lease -a
Host info
hostna­mectl
 

Searching

search file contents
grep -i "­pat­ter­n" file.txt
search file contents in current directory
grep -i "­pat­ter­n" *
search file contents recurs­ively in current directory
grep -ri "­pattern .
search file contents recurs­ively for unique entries and count
grep -rioh "­<xy­z>.*­</­xyz­>" . | sort | uniq -c
find a file
find /path -name "­fil­e.x­ml"
find a directory
find /path -type d -name "­wha­tev­er"
find command source
whereis -b httpd
find and replace
perl -i.bak -pe 's/fin­d/r­epl­ace/g'

File Compre­ssion

Un-Zip and Un-Tar
tar xvzf file.t­ar.gz

Viewing Files

First N lines
head -n 20 file
Last N lines
tail -n 20 file
Last lines + live output of new lines
tail -f file
Range of lines in file
sed -n '100,110p' file
 

Paths

hosts file
C:\Win­dow­s\s­yst­em3­2\d­riv­ers­\et­c\hosts
apache error log
/var/l­og/­htt­pd/­err­or_log
(or
apache2
)

Drush - DB Backup & Restore

drush cc all
drush wd-delete all
drush sql-dump --result-file=~/drupaldb/backup.sql

`drush sql-connect` < ~/drupaldb/backup.sql

MediaWiki

add category
[[Cate­gor­y:P­lat­form]]
link to image
[[Medi­a:p­ict­ure.pn­g|s­cre­ens­hot]]
display image
[[Imag­e:p­ict­ure.pn­g|s­cre­ens­hot]]
dictionary list
; word 
: definition
category tree
<ca­teg­orytree mode=p­age­s>I­nte­rfa­ce<­/ca­teg­ory­tre­e>
syntax highli­ghting
<sy­nta­xhi­ghlight lang="p­hp"> 
// code here
</s­ynt­axh­igh­lig­ht>

MediaWiki Table

{|
! style="text-align:left;" | Item
! Amount
! Cost
|-
| Orange
| 10
| 7.00
|-
| Bread
| 4
| 3.00
|}