diff --git a/common/cal.md b/common/cal.md new file mode 100644 index 0000000000..1733818a49 --- /dev/null +++ b/common/cal.md @@ -0,0 +1,19 @@ +# cal + +> Prints calendar information + +- Display a calendar for the current month or specified month + +`cal` +`cal -m {{12}}` +`cal -m {{Dec}}` + +- Display a calendar for the current year or a specified year + +`cal -y` +`cal 2013` + +- Display date of Easter (western churches) + +`ncal -e` +`ncal -e 2013` \ No newline at end of file diff --git a/common/cksum.md b/common/cksum.md new file mode 100644 index 0000000000..c813e8ae04 --- /dev/null +++ b/common/cksum.md @@ -0,0 +1,8 @@ +# cksum + +> Calculates CRC checksums and byte counts of a file +> Note, on old UNIX systems the CRC implementation may differ. + +- Display a 32 bit checksum, size in bytes and filename + +`chksum {{filename}}` diff --git a/common/cp.md b/common/cp.md index fe035a5776..d99ba9ee98 100644 --- a/common/cp.md +++ b/common/cp.md @@ -10,10 +10,12 @@ `cp {{/path/to/original}} ../{{/path/to/copy}}` -- Copy directories recursive using the option -r. +- Copy directories recursive using the option -r. Optionally showing files as they are copied. `cp -r {{/path/to/original}} {{/path/to/copy}}` - -- Copy files in verbose mode, showing files as they are copied. (Mostly interesting with -r option). - `cp -vr {{/path/to/original}} {{/path/to/copy}}` + +- Make a copy of a file adding and extension or changing an extension + +`cp {{file.html}}\{,.backup\}` +`cp file.\{html,backup\}` diff --git a/common/curl.md b/common/curl.md index fd01697dab..c3505a0744 100644 --- a/common/curl.md +++ b/common/curl.md @@ -3,6 +3,10 @@ > Transfers data from or to a server > Supports most protocols including HTTP, FTP, POP +- Download a URL to a file + +`curl "{{URL}}" -o filename` + - send form-encoded data `curl --data {{name=bob}} {{http://localhost/form}}` diff --git a/common/dig.md b/common/dig.md new file mode 100644 index 0000000000..1d9cfce6c6 --- /dev/null +++ b/common/dig.md @@ -0,0 +1,15 @@ +# dig + +> DNS Lookup utility + +- Lookup the IP(s) associated with a hostname (A records) + +``dig +short {{hostname.com}}` + +- Lookup the mail server associated with a given domain name (MX record) + +``dig +short {{hostname.com}} MX` + +- Specify an alternate DNS server to query (8.8.8.8 is google's public DNS) + +`dig @8.8.8.8 {{hostname.com}}` diff --git a/common/du.md b/common/du.md deleted file mode 100644 index f3f2bcff80..0000000000 --- a/common/du.md +++ /dev/null @@ -1,19 +0,0 @@ -# du - -> Estimate file space usage - -- get file sizes of directory's content - -`du {{file/directory}}` - -- get total size in human readable form - -`du -sh {{file/directory}}` - -- get recursively, individual file/folder sizes in human readable form - -`du -ah {{directory}}` - -- get file sizes till a specified depth - -`du --max-depth=1` diff --git a/common/find.md b/common/find.md index f5f1756eb1..98e8f9590f 100644 --- a/common/find.md +++ b/common/find.md @@ -15,3 +15,7 @@ - find files modified since a certain time `find {{root_path}} -name {{'*.py'}} -mtime {{-1d}}` + +- find files using case insensitive name matching, of a certain size + +`find {{root_path}} -size +500k -size -10MB -iname {{'*.TaR.gZ'}}` diff --git a/common/grep.md b/common/grep.md index cef3d8e5b1..c6cb5badba 100644 --- a/common/grep.md +++ b/common/grep.md @@ -19,7 +19,7 @@ `grep -C 3 {{something}} {{file_path}}` -- print the number of matches +- print the count of matches instead of the matching text `grep -c {{something}} {{file_path}}` diff --git a/common/gzip.md b/common/gzip.md new file mode 100644 index 0000000000..87e913caef --- /dev/null +++ b/common/gzip.md @@ -0,0 +1,23 @@ +# gzip + +> Compress/uncompress files with gzip compression (LZ77) + +- compress a file, replacing it with a gzipped compressed version + +`gzip {{file.ext}}` + +- decompress a file, replacing it with the original uncomrpessed version + +`gzip -d {{file.ext.gz}}` + +- compress a file specifying the output filename + +`gzip -c {{file.ext}} > compressed-file.ext.gz` + +- uncompress a gzipped file specifying the output filename + +`gzip -c -d {{file.ext.gz}} > uncompressed-file.ext` + +- specify the compression level. 1=Fastest (Worst), 9=Slowest (Best), Default level is 6 + +`gzip -9 -c {{file.ext}} > compressed-file.ext.gz` \ No newline at end of file diff --git a/common/ps.md b/common/ps.md index 6f472f5e50..15f7e5a851 100644 --- a/common/ps.md +++ b/common/ps.md @@ -5,3 +5,7 @@ - list all running processes `ps aux` + +- list all running processes including the full command string + +`ps auxww` diff --git a/common/rm.md b/common/rm.md new file mode 100644 index 0000000000..1d911e3153 --- /dev/null +++ b/common/rm.md @@ -0,0 +1,15 @@ +# rm + +> Remove files or directories + +- Remove files from arbitrary locations + +`rm {{/path/to/file}} {{/otherpath/to/file2}}` + +- Remove recursively a directory and all it's subdirectories + +`rm -r {{/path/to/folder}}` + +- Prompt before every removal + +`rm -i {{\*}}` \ No newline at end of file diff --git a/common/sort.md b/common/sort.md new file mode 100644 index 0000000000..62d6bcc361 --- /dev/null +++ b/common/sort.md @@ -0,0 +1,15 @@ +# sort + +> sort lines of text files + +- Sort a file in ascending order + +`sort {{filename}}` + +- Sort a file in descending order + +`sort -r {{filename}}` + +- Sort passwd file by the 3rd field + +`sort -t: -k 3n /etc/passwd ` diff --git a/common/srm.md b/common/srm.md new file mode 100644 index 0000000000..e589ffbe10 --- /dev/null +++ b/common/srm.md @@ -0,0 +1,18 @@ +# srm + +> Securely remove files or directories +> Overwrites the existing data one or multiple. Drop in replacement for rm. + +- Removes a file after overwriting (single pass, 7 pass, 35 pass) + +`srm -s {{/path/to/file}}` +`srm -m {{/path/to/file}}` +`srm {{/path/to/file}}` + +- Scurely remove recursively a directory and all it's subdirectories + +`srm -r {{/path/to/folder}}` + +- Prompt before every removal + +`srm -i {{\*}}` \ No newline at end of file diff --git a/common/ssh.md b/common/ssh.md index 06efdcb023..19c08159b9 100644 --- a/common/ssh.md +++ b/common/ssh.md @@ -11,6 +11,10 @@ `ssh {{username}}@{{remote_host}} -P {{2222}}` -- ssh tunneling +- ssh tunneling: dynamic port forwarding (SOCKS proxy on localhost:9999) `ssh -D {{9999}} -C {{username}}@{{remote_host}}` + +- ssh tunneling: forward a specific port (localhost:9999 to slashdot.org:80) + +`ssh -L {{9999}}:slashdot.org:80 {{username}}@{{remote_host}}` diff --git a/common/touch.md b/common/touch.md new file mode 100644 index 0000000000..beda030219 --- /dev/null +++ b/common/touch.md @@ -0,0 +1,16 @@ +# touch + +> Change a file access and modification times (atime, mtime) + +- Create a new empty file(s) or change the times for existing file(s) to current time.` + +`touch {{filename}}` + +- Set the times on a file to those specified + +`touch -t 201412250801.59 {{filename}} +`touch -t {{YYYYMMDDHHMM.SS}} {{filename}} + +- Set the times on a file to match those on second file + +`touch -r {{filename2}} {{filename}}` diff --git a/common/uname.md b/common/uname.md new file mode 100644 index 0000000000..bf89716a1c --- /dev/null +++ b/common/uname.md @@ -0,0 +1,15 @@ +# uname + +> Print operating system name + +- Print all available operating system and kernel information + +`uname -a` + +- Print the current operating system name (e.g. Linux, Darwin, SunOS, etc) + +`uname -s` + +- Print the nodename (hostname) of the system + +`uname -n` diff --git a/common/unzip.md b/common/unzip.md index a335b86187..0b394bdc66 100644 --- a/common/unzip.md +++ b/common/unzip.md @@ -9,3 +9,7 @@ - extract zip files(s) to given path `unzip {{files(s)}} -d {{/path/to/put/extracted/files}}` + +- list the contents of a zip file without extracting + +`unzip -l {{file}} diff --git a/common/which.md b/common/which.md new file mode 100644 index 0000000000..6d5327d30b --- /dev/null +++ b/common/which.md @@ -0,0 +1,12 @@ +# which + +> Locate the a program in the user's path + +- Display the path of an executable program + +`which {{ls}}` +`which {{executable}}` + +- If there are multiple executables which match, display all + +`which -a {{executable}}` diff --git a/common/zfs.md b/common/zfs.md new file mode 100644 index 0000000000..a7bc7d03d4 --- /dev/null +++ b/common/zfs.md @@ -0,0 +1,27 @@ +# zfs + +> Manage ZFS filesystems + +- List all available zfs filesystems + +`zfs list` + +- Create a new ZFS filesystem + +`zfs create poolname/newfsname` + +- Delete a ZFS filesystem + +`zfs destroy {{poolname/newfsname}}` + +- Create a Snapshot of a ZFS filesystem + +`zfs snapshot {{poolname/filesystem@snapshot-name}}` + +- Enable compression on a filesystem + +`zfs set compression=on {{poolname/fileystem}}` + +- Change mountpoint for a filesytem + +`zfs set mountpoint={{/my/mount/path}} {{poolname/filesystem}}` \ No newline at end of file diff --git a/common/zip.md b/common/zip.md index 2aea58557f..53d623b577 100644 --- a/common/zip.md +++ b/common/zip.md @@ -1,6 +1,6 @@ # zip -> package and compress (archive) files into zip file +> Package and compress (archive) files into zip file - package and compress multiple directories & files diff --git a/common/zpool.md b/common/zpool.md new file mode 100644 index 0000000000..7acdb9692f --- /dev/null +++ b/common/zpool.md @@ -0,0 +1,33 @@ +# zpool + +> Manage ZFS pools + +- Show the configuration and status of all ZFS zpools + +`zpool status [{{poolname}}]` + +- Check a ZFS pool for errors (verifies the checksum of EVERY block). Very CPU and disk intensive. + +`zpool scrub {{poolname}}` + +- List zpools available for import + +`zpool import` + +- Import a zpool, optionally specifying a new name + +`zpool import {{poolname}}` +`zpool import {{poolname}} {{newpoolname}}` + +- Export a zpool (unmount all filesystems) + +`zpool export {{poolname}}` + +- Show the history of all pool operations + +`zpool histrory {{poolname}}` + +- Create a mirrored pool. + +`zpool create {{poolname}} mirror {{disk1}} {{disk2}}` +`zpool create {{poolname}} mirror {{disk1}} {{disk2}} mirror {{disk3}} {{disk4}}` diff --git a/linux/apt-get.md b/linux/apt-get.md new file mode 100644 index 0000000000..30e18f3665 --- /dev/null +++ b/linux/apt-get.md @@ -0,0 +1,24 @@ +# apt-get + +> Debian and Ubuntu package management utility + +- Synchronize list of packages and versions available. This should be run first, before running subsequent apt-get commands. + +`apt-get update` + +- install a new package + +`apt-get install {{package}}` + + +- remove a package + +`apt-get remove {{package}}` + +- Upgrade installed packages to newest available versions + +`apt-get upgrade` + +- Upgrade installed packages (like `apt-get upgrade`) including removing obsolete packages and installing additional packages to meet new package dependencies. + +`apt-get dist-upgrade` diff --git a/linux/du.md b/linux/du.md new file mode 100644 index 0000000000..d956e744fe --- /dev/null +++ b/linux/du.md @@ -0,0 +1,19 @@ +# du + +> Estimate file space usage + +- get a sum of the total size of a file/folder in human readable units + +`du -sh {{file/directory}}` + +- list file sizes of a directory and any subdirectories in KB + +`du -k {{file/directory}}` + +- get recursively, individual file/folder sizes in human readable form + +`du -ah {{directory}}` + +- list the KB sizes of directories for N levels below the specified directory + +`du --max-depth=1` diff --git a/linux/md5sum.md b/linux/md5sum.md new file mode 100644 index 0000000000..cda2fb8775 --- /dev/null +++ b/linux/md5sum.md @@ -0,0 +1,13 @@ +# md5sum + +> Calculate MD5 cryptographic checksums + +- Calculate the MD5 checksum for file(s) or files in a directory, one checksum per file + +`md5sum {{filename1}}` +`md5sum {{filename1}} {{filename2}}` +`md5sum {{directory/\*}}` + +- Read a file of MD5SUMs and verify all files have matching checksums + +`md5sum -c {{filename.md5}}` diff --git a/linux/shutdown.md b/linux/shutdown.md new file mode 100644 index 0000000000..7e156721cf --- /dev/null +++ b/linux/shutdown.md @@ -0,0 +1,16 @@ +# shutdown + +> Shutdown and reboot the system + +- Reboot or poweroff (halt) the system immediately + +`shutdown -r now` +`shutdown -h now` + +- Reboot in 5 minutes. + +`shutodwn -r +5 &` + +- Cancel a pending shutdown/reboot operation + +`shutdown -c` \ No newline at end of file diff --git a/osx/airport.md b/osx/airport.md new file mode 100644 index 0000000000..141eb19a3d --- /dev/null +++ b/osx/airport.md @@ -0,0 +1,15 @@ +# Airport + +> Airport utility + +- Create a symlink so you can easily run 'airport' without specifying a path. + +`sudo ln -s /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport /usr/sbin/airport` + +- Scan for available wireless networks + +`airport -s` + +- Disassociate from current airport network + +`sudo airport -z` diff --git a/osx/caffeinate.md b/osx/caffeinate.md new file mode 100644 index 0000000000..eb05c2467f --- /dev/null +++ b/osx/caffeinate.md @@ -0,0 +1,13 @@ +# caffeinate + +> Prevent a system from sleeping + +- Prevent mac from sleeping for 1 hour (3600 seconds) + +`caffeinate -u -t 3600` + +- Prevent mac from sleeping until a command completes + +`caffeinate -s {{command}}` + + diff --git a/osx/diskutil.md b/osx/diskutil.md new file mode 100644 index 0000000000..0bbabe568f --- /dev/null +++ b/osx/diskutil.md @@ -0,0 +1,23 @@ +# diskutil + +> Utility to manage local disks and volumes + +- List all currently available disks, partitions and mounted volumes. + +`diskutil list` + +- Repair permissions on a volume + +`diskutil repairPermissions {{/Volumes/Name}}` + +- Repair the file system data structures of a volume + +`diskutil repairVolume {{/dev/diskX}} + +- Unmount a volume + +`diskutil unmountDisk {{/dev/diskX}}` + +- Eject a CD/DVD (unmount first) + +`diskutil eject {{/dev/disk1}}` diff --git a/osx/drutil.md b/osx/drutil.md new file mode 100644 index 0000000000..f3157d2230 --- /dev/null +++ b/osx/drutil.md @@ -0,0 +1,12 @@ +# drutil + +> Interact with DVD burners + +- Eject a disk from the drive + +`drutil eject` + +- Burn a folder as an ISO9660 filesystem onto a DVD. Don't verify and eject when complete. + +`drutil burn -noverify -eject -iso9660` + diff --git a/osx/du.md b/osx/du.md new file mode 100644 index 0000000000..32caa80f2f --- /dev/null +++ b/osx/du.md @@ -0,0 +1,19 @@ +# du + +> Estimate file space usage + +- get a sum of the total size of a file/folder in human readable units + +`du -sh {{file/directory}}` + +- list file sizes of a directory and any subdirectories in KB + +`du -k {{file/directory}}` + +- get recursively, individual file/folder sizes in human readable form + +`du -ah {{directory}}` + +- list the KB sizes of directories for N levels below the specified directory + +`du -k -depth=1 {{directory}}` diff --git a/osx/md5.md b/osx/md5.md new file mode 100644 index 0000000000..1b50f1c0a0 --- /dev/null +++ b/osx/md5.md @@ -0,0 +1,13 @@ +# md5 + +> Calculate MD5 cryptographic checksums + +- Calculate the MD5 checksum for file(s) or files in a directory, one checksum per file + +`md5 {{filename1}}` +`md5 {{filename1}} {{filename2}}` +`md5 {{directory/\*}}` + +- Output only the md5 checksum (no filename) + +`md5 -q {{filename}}` diff --git a/osx/networksetup.md b/osx/networksetup.md new file mode 100644 index 0000000000..7a64403a82 --- /dev/null +++ b/osx/networksetup.md @@ -0,0 +1,19 @@ +# networksetup + +> Configuration tool for Network System Preferences + +- List available network service providers (Ethernet, Wi-Fi, Bluetooth, etc) + +`networksetup -listallnetworkservices` + +- Show network settings for a particular networking device + +`networksetup -getinfo {{"Wi-Fi"}}` + +- Get currently connected Wi-Fi network name (Wi-Fi device usually en0 or en1) + +`networksetup -getairportnetwork {{en0}}` + +- Connect to a particular Wi-Fi network + +`networksetup -setairportnetwork {{en0}} {{"Airport Network SSID"}} {{password}} diff --git a/osx/open.md b/osx/open.md new file mode 100644 index 0000000000..317b48949e --- /dev/null +++ b/osx/open.md @@ -0,0 +1,23 @@ +# open + +> Opens files, directories and applications + +- Open a file with the associated application + +`open filename.ext` + +- Run a graphical MacOSX application + +`open /Applications/iTunes.app` + +- Open the current directory in Finder + +`open .` + +- Reveal a file in finder + +`open -R /path/dir/file` + +- Open all the word docs in the current directory with Microsoft Word + +`open *.doc` \ No newline at end of file diff --git a/osx/pgrep.md b/osx/pgrep.md new file mode 100644 index 0000000000..497c11c1c0 --- /dev/null +++ b/osx/pgrep.md @@ -0,0 +1,15 @@ +# pgrep + +> Find or signal process by name + +- return PIDs of any running processes with a matching command string + +`pgrep {{Finder}}` + +- case insensitive greping + +`pgrep -i {{fireFOx}}` + +- kill all processes which match + +`pkill -9 {{Finder}}` diff --git a/osx/qlmanage.md b/osx/qlmanage.md new file mode 100644 index 0000000000..db7b9a6b19 --- /dev/null +++ b/osx/qlmanage.md @@ -0,0 +1,11 @@ +# qlmanage + +> QuickLook server tool + +- displays QuickLook for one or multiple files + +`quicklook -p {{filename}} {{filename2}}` + +- Compute 300px wide PNG thumbnails of all JPEGs in the current directory and put them in a directory. + +`quicklook *.jpg -t -s 300 {{/existing//thumbnail/directory}}` diff --git a/osx/say.md b/osx/say.md new file mode 100644 index 0000000000..bd56d9a948 --- /dev/null +++ b/osx/say.md @@ -0,0 +1,14 @@ +# say + +> Uses text to speech to speak through the default sound device + +- Speak a phrase aloud + +`say "I like to ride my bike.` + +- Speak a file aloud + +`say -f {{filename}}` + +- Create an AAC compressed audio file with the spoken text +`say -o {{filename.m4a}} "Everyone loves iTunes"` diff --git a/osx/shutdown.md b/osx/shutdown.md new file mode 100644 index 0000000000..eb8a53d725 --- /dev/null +++ b/osx/shutdown.md @@ -0,0 +1,13 @@ +# shutdown + +> Shutdown and reboot the system + +- Reboot, poweroff (halt) or sleep immediately + +`shutdown -r now` +`shutdown -h now` +`shutdown -s now` + +- Reboot in 5 minutes. + +`shutodwn -r +5` diff --git a/osx/sw_vers.md b/osx/sw_vers.md new file mode 100644 index 0000000000..977636a856 --- /dev/null +++ b/osx/sw_vers.md @@ -0,0 +1,12 @@ +# sw_vers + +> Print Mac OSX Software versioning information + +- Print OSX Version + +`sw_vers -productVersion` + +- Print OSX Build + +`sw_vers -buildVersion` + diff --git a/osx/sysctl.md b/osx/sysctl.md new file mode 100644 index 0000000000..ca21de6b2d --- /dev/null +++ b/osx/sysctl.md @@ -0,0 +1,24 @@ +# sysctl + +> Access kernel state information + +- Show all available variables and their values + +`sysctl -a` + +- Show Apple model identifier + +`sysctl -n hw.model` + +- Show CPU model + +`sysctl -n machdep.cpu.brand_string` + +- Show available CPU features (MMX, SSE, SSE2, SSE3, AES, etc) + +`sysctl -n machdep.cpu.feature` + +- Set a changeable kernel state variable + +`sysctl -w name=value` +`sysctl -w kern.maxfiles=15000` diff --git a/osx/system_profiler.md b/osx/system_profiler.md new file mode 100644 index 0000000000..e2351dab85 --- /dev/null +++ b/osx/system_profiler.md @@ -0,0 +1,15 @@ +# system_profiler + +> Report system hardware and software configuration + +- Display a full system profiler report which can be opened by System Profiler.app + +`system_profiler -xml > MyReport.spx` + +- Display a hardware overview (Model, CPU, Memory, Serial, etc) + +`system_profiler SPHardwareDataType` + +- Print the system serial number + +`system_profiler SPHardwareDataType|grep "Serial Number (system)" |awk '{print $4}'` diff --git a/osx/systemsetup.md b/osx/systemsetup.md new file mode 100644 index 0000000000..49e3598173 --- /dev/null +++ b/osx/systemsetup.md @@ -0,0 +1,24 @@ +# systemsetup + +> Configure System Preferences machine settings + +- Enable remote login (SSH) + +`systemsetup -setremotelogin on` + +- Specify TimeZone, NTP Server and enable network time + +`systemsetup -settimezone {{US/Pacific}}` +`systemsetup -setnetworktimeserver {{us.pool.ntp.org}}` +`systemsetup -setusingnetworktime on` + +- Make the machine never sleep; restart on freeze & power failure + +`systemsetup -setsleep off` +`systemsetup -setrestartpowerfailure on` +`systemsetup -setrestartfreeze on` + +- List valid startup disks, specify a new startup disk + +`systemsetup -liststartupdisks` +`systemsetup -setstartupdisk {{path}}` diff --git a/osx/xed.md b/osx/xed.md new file mode 100644 index 0000000000..67431f407c --- /dev/null +++ b/osx/xed.md @@ -0,0 +1,16 @@ +# xed + +> Opens files for editing in XCode + +- Open file(s) in XCode + +`xed {{file1}}` +`xed {{/path/to/file1}} {{/path/to/file2}}` + +- Open file(s) in XCode, create if it doesn't exist + +`xed -c {{filename1}}` + +- Open a file in XCode and jump to line number 75 + +`xed -l 75 {{filename}}`