Merge branch 'master' into master

This commit is contained in:
Dylan Rees
2016-01-03 21:18:22 -05:00
69 changed files with 813 additions and 84 deletions

View File

@@ -2,10 +2,22 @@
> Create, modify, and extract from archives (.a .so .o)
- Extract members of the archive
- Extract all members from an archive
`ar -x libfoo.a`
`ar -x {{libfoo.a}}`
- List the content (files) of libfoo.a
- List the members of an archive
`ar -t libfoo.a`
`ar -t {{libfoo.a}}`
- Replace or add files to an archive
`ar -r {{libfoo.a}} {{foo.o}} {{bar.o}} {{baz.o}}`
- Insert an object file index (equivalent to using `ranlib`)
`ar -s {{libfoo.a}}`
- Create an archive with files and an accompanying object file index
`ar -rs {{libfoo.a}} {{foo.o}} {{bar.o}} {{baz.o}}`

23
pages/common/bashmarks.md Normal file
View File

@@ -0,0 +1,23 @@
# bashmarks
> Save and jump to commonly used directories using 1 character commands.
- List available bookmarks
`l`
- Save the current folder as "bookmark_name"
`s {{bookmark_name}}`
- Go to a bookmarked folder
`g {{bookmark_name}}`
- Print a bookmarked folder's contents
`p {{bookmark_name}}`
- Delete a bookmark
`d {{bookmark_name}}`

View File

@@ -2,10 +2,14 @@
> Print and concatenate files.
- Print the contents of *file1* to the standard output
- Print the contents of a file to the standard output
`cat {{file1}}`
`cat {{file}}`
- Concatenate several files into the target file.
`cat {{file1}} {{file2}} > {{target-file}}`
- Append serveral files into the target file.
`cat {{file1}} {{file2}} >> {{target-file}}`

23
pages/common/comm.md Normal file
View File

@@ -0,0 +1,23 @@
# comm
> Select or reject lines common to two files. Both files must be sorted.
- Produce three tab-separated columns: lines only in first file, lines only in second file and common lines.
`comm {{file1}} {{file2}}`
- Print only lines common to both files.
`comm -12 {{file1}} {{file2}}`
- Print only lines common to both files, read one file from stdin.
`cat {{file1}} | comm -12 - {{file2}}`
- Print lines only found in first file.
`comm -23 {{file1}} {{file2}}`
- Print lines only found in second file.
`comm -13 {{file1}} {{file2}}`

View File

@@ -10,6 +10,10 @@
`convert {{image.png}} -resize 50% {{image2.png}}`
- Scale an image keeping the original aspect ratio to a maximum dimension of 640x480.
`convert {{image.png}} -resize 640x480 {{image2.png}}`
- Horizontally append images
`convert {{image1.png}} {{image2.png}} {{image3.png}} +append {{image123.png}}`

15
pages/common/cowsay.md Normal file
View File

@@ -0,0 +1,15 @@
# cowsay
> Generate an ASCII character like a cow or sheep saying or thinking something
- Print an ASCII cow saying "Hello world!"
`cowsay "Hello world!"`
- Print an ASCII dragon saying "Hello!"
`echo "Hello!" | cowsay -f dragon`
- Print a stoned thinking ASCII cow
`cowthink -s "I'm just a cow, not a great thinker ..."`

View File

@@ -8,14 +8,20 @@
- Copy a file to a parent directory
`cp {{/path/to/original}} ../{{/path/to/copy}}`
`cp {{/path/to/original}} ../{{path/to/copy}}`
- Copy directories recursive using the option -r. Optionally showing files as they are copied.
- Copy directories recursive using the option -r
`cp -r {{/path/to/original}} {{/path/to/copy}}`
- Show files as they are copied
`cp -vr {{/path/to/original}} {{/path/to/copy}}`
- Make a copy of a file adding and extension or changing an extension
- Make a copy of a file, adding an extension
`cp {{file.html}}\{,.backup\}`
`cp file.\{html,backup\}`
`cp {{file.html}}{,.backup}`
- Make a copy of a file, changing the extension
`cp {{file.}}{html,backup}`

15
pages/common/emacs.md Normal file
View File

@@ -0,0 +1,15 @@
# emacs
> The extensible, customizable, self-documenting, real-time display editor
- Open emacs in console mode (without X window)
`emacs -nw`
- Open a file in emacs
`emacs {{filename}}`
- Exit emacs
`C-x C-c`

View File

@@ -6,6 +6,10 @@
`find {{root_path}} -name {{'*.py'}}`
- find files matching path pattern
`find {{root_path}} -path {{'**/lib/**/*.py'}}`
- run a command for each file, use {} within the command to access the filename
`find {{root_path}} -name {{'*.py'}} -exec {{wc -l {} }}\;`

View File

@@ -8,7 +8,7 @@
- Install specific version of a gem
`gem install -v={{0.0.15}}`
`gem install {{gemname}} -v {{1.0.0}}`
- Update a gem

View File

@@ -2,10 +2,14 @@
> Main command for working with branches
- List all existing branches
- List local branches. The current branch is highlighted by `*`.
`git branch`
- List all local and remote branches
`git branch -a`
- Create new branch based on current branch
`git branch {{BRANCH-NAME}}`

View File

@@ -13,3 +13,7 @@
- Output a condensed summary of extended header information.
`git diff --summary {{PATHSPEC}}`
- Show staged (added, but not yet committed) changes only.
`git diff --staged`

15
pages/common/gradle.md Normal file
View File

@@ -0,0 +1,15 @@
# Gradle
> Gradle is the official build system for Android Studio
- Compile a package
`gradle build`
- Clear the build folder
`gradle clean`
- Compile and Release package
`gradle assembleRelease`

View File

@@ -6,7 +6,7 @@
`gzip {{file.ext}}`
- decompress a file, replacing it with the original uncomrpessed version
- decompress a file, replacing it with the original uncompressed version
`gzip -d {{file.ext.gz}}`

15
pages/common/host.md Normal file
View File

@@ -0,0 +1,15 @@
# host
> Lookup Domain Name Server
- Lookup A, AAAA, and MX records of a domain
`host {{domain}}`
- Lookup a field (CNAME, TXT,...) of a domain
`host -t {{field}} {{domain}}`
- Reverse lookup an IP
`host {{ip_address}}`

23
pages/common/ifconfig.md Normal file
View File

@@ -0,0 +1,23 @@
# ifconfig
> ifconfig - Interface Configurator, used to configure network interfaces.
- View network settings of an ethernet adapter.
`ifconfig eth0`
- Display details of all interfaces, including disabled interfaces.
`ifconfig -a`
- Disable eth0 interface.
`ifconfig eth0 down`
- Enable eth0 interface.
`ifconfig eth0 up`
- Assign IP address to eth0 interface.
`ifconfig eth0 {{ip_address}}`

27
pages/common/last.md Normal file
View File

@@ -0,0 +1,27 @@
# last
> View the last logged in users
- view last logins, their duration and other information as read from /var/log/wtmp
`last`
- specify how many of the last logins to show
`last -n {{login_count}}`
- view full login times and dates
`last -F`
- view the last login by a specific user
`last {{user_name}}`
- view the last reboot (last login of the pseudo user reboot)
`last reboot`
- view the last shutdown (last login of the pseudo user shutdown)
`last shutdown`

View File

@@ -6,9 +6,9 @@
`mysql {{database_name}}`
- Connect to a database using credentials
- Connect to a database, user will be prompted for a password
`mysql -u {{user}} -p{{password}} {{database_name}}`
`mysql -u {{user}} --password {{database_name}}`
- Execute SQL statements in a script file (batch file)

View File

@@ -2,10 +2,10 @@
> Backups mysql databases
- creating a backup
- Create a backup, user will be prompted for a password
`mysqldump -u {{user}} -p{{password}} {{database_name}} > {{filename.sql}}`
`mysqldump -u {{user}} --password {{database_name}} > {{filename.sql}}`
- restoring a backup
- Restoring a backup, user will be prompted for a password
`mysql -u {{user}} -p{{password}} {{database_name}} < {{filename.sql}}`
`mysql -u {{user}} --password {{database_name}} < {{filename.sql}}`

8
pages/common/nice.md Normal file
View File

@@ -0,0 +1,8 @@
# nice
> Execute a program with a custom scheduling priority (niceness).
> Niceness values range from -20 (the highest priority) to 19 (the lowest).
- Launch a program with altered priority.
`nice -n {{niceness_value}} {{command}}`

View File

@@ -1,11 +1,28 @@
# nmap
> Network exploration tool and security / port scanner
> Network exploration tool and security / port scanner.
> Some features only activate when Nmap is run with privileges.
- scan open ports of a single host
- Try to determine whether the specified hosts are up and what are their names.
`nmap {{192.168.0.1}}`
`nmap -sn {{ip_or_hostname}} {{optional_another_address}}`
- discover hosts in the 192.168.0.X area (no port scan)
- Like above, but also run a default 1000-port TCP scan if host seems up.
`nmap -sn {{192.168.0.1/24}}`
`nmap {{ip_or_hostname}} {{optional_another_address}}`
- Also enable service detection, OS fingerprinting and traceroute.
`nmap -A {{address_or_addresses}}`
- Assume good network connection and speed up execution:
`nmap -T4 {{address_or_addresses}}`
- Scan a specific list of ports (use -p- for all ports 1-65535)
`nmap -p {{port1,port2,...,portN}} {{address_or_addresses}}`
- Perform TCP and UDP scanning (use -sU for UDP only, -sZ for SCTP, -sO for IP):
`nmap -sSU {{address_or_addresses}}`

View File

@@ -10,6 +10,10 @@
`npm install`
- Download and install a module globally
`npm install -g {{module_name}}`
- Download a given dependency, and add it to the package.json
`npm install {{module_name}}@{{version}} --save`
@@ -21,3 +25,7 @@
- Publish the current project
`npm publish`
- Cleanup packages (removes packages which are installed but are not listed in `package.json`)
`npm prune`

27
pages/common/parallel.md Normal file
View File

@@ -0,0 +1,27 @@
# GNU Parallel
> Run commands on multiple CPU cores
- gzip several files at once, using all cores
`parallel gzip ::: {{file1}} {{file2}} {{file3}}`
- read arguments from stdin, run 4 jobs at once
`ls *.txt | parallel -j4 gzip`
- Convert JPG images to PNG using replacement strings
`parallel convert {} {.}.png ::: *.jpg`
- parallel xargs, cram as many args as possible onto one command
`{{args}} | parallel -X {{command}}`
- break stdin into ~1M blocks, feed each block to stdin of new command
`cat {{bigfile.txt}} | parallel --pipe --block 1M {{command}}`
- run on multiple machines via SSH
`parallel -S {{machine1}},{{machine2}} {{command}} ::: {{arg1}} {{arg2}}`

View File

@@ -2,18 +2,18 @@
> passwd is a tool used to change a user's password.
* Change the password of the current user
- Change the password of the current user
`passwd {{new password}}`
* Change the password of the specified user
- Change the password of the specified user
`passwd {{username}} {{new password}}`
* Get the current statuts of the user
- Get the current statuts of the user
`passwd -S`
* Make the password of the account blank (it will set the named account passwordless)
- Make the password of the account blank (it will set the named account passwordless)
`passwd -d`

23
pages/common/paste.md Normal file
View File

@@ -0,0 +1,23 @@
# paste
> Merge lines of files.
- join all the lines into a single line, using TAB as delimiter.
`paste -s {{file}}`
- join all the lines into a single line, using the specified delimiter.
`paste -s -d {{delimiter}} {{file}}`
- merge two files side by side, each in its column, using TAB as delimiter.
`paste {{file1}} {{file2}}`
- merge two files side by side, each in its column, using the specified delimiter.
`paste -d {{delimiter}} {{file1}} {{file2}}`
- merge two files, with lines added alternatively.
`paste -d '\n' {{file1}} {{file2}}`

View File

@@ -4,16 +4,12 @@
- return PIDs of any running processes with a matching command string
`pgrep {{Finder}}`
`pgrep {{process_name}}`
- search full command line with parameters instead of just the process name
`pgrep -f "{{ssh root}}"`
`pgrep -f "{{process_name}} {{parameter}}"`
- search for process run by a specific user
`pgrep -u root {{firefox}}`
- kill all processes which match
`pkill -9 {{Finder}}`
`pgrep -u root {{process_name}}`

19
pages/common/phpunit.md Normal file
View File

@@ -0,0 +1,19 @@
# phpunit
> PHPUnit command-line test runner
- Run tests in the current direcotry. Note: Expects you to have a 'phpunit.xml'
`phpunit`
- Run tests in a specific file.
`phpunit {{path/to/TestFile.php}}`
- Run tests annotated with the given group.
`phpunit --group {{name}}`
- Run tests and generate a coverage report in HTML.
`phpunit --coverage-html {{directory}}`

12
pages/common/pkill.md Normal file
View File

@@ -0,0 +1,12 @@
# pkill
> Signal process by name
> Mostly used for stopping processes
- kill all processes which match
`pkill -9 {{process_name}}`
- send SIGUSR1 signal to processes which match
`pkill -USR1 {{process_name}}`

23
pages/common/printf.md Normal file
View File

@@ -0,0 +1,23 @@
# printf
> Format and print text
- Print a text message
`printf {{"%s\n"}} {{"Hello world"}}`
- Print an integer in bold blue
`printf {{"\e[1;34m%.3d\e[0m\n"}} {{42}}`
- Print a float number with the unicode Euro sign
`printf {{"\u20AC %.2f\n"}} {{123.4}}`
- Print a text message composed with environment variables
`printf {{"var1: %s\tvar2: %s\n"}} {{"$VAR1"}} {{"$VAR2"}}`
- Store a formatted message in a variable (does not work on zsh)
`printf -v {{myvar}} {{"This is %s = %d\n" "a year" 2016}}`

View File

@@ -6,10 +6,14 @@
`psql {{database}}`
- Connect to *database* on given server *host* running on given *port* with *username* given
- Connect to *database* on given server *host* running on given *port* with *username* given, no password prompt
`psql -h {{host}} -p {{port}} -U {{username}} {{database}}`
- Connect to *database*, user will be prompted for password
`psql -h {{host}} -p {{port}} -U {{username}} -W {{database}}`
- Run single *query* against the given *database*. Note: useful in shell scripts
`psql -c '{{query}}' {{database}}`

View File

@@ -20,6 +20,10 @@
`rsync -r mike@devbox:~/projects/cakeStore /Users/mike/devProjects/`
- transfer only updated files from remote host
`rsync -ru mike@devbox:~/projects/ ./projects/`
- transfer file over SSH and show progress
`rsync -e ssh --progress {{remote_host_name}}:{{remote_file}} {{local_file}}`

View File

@@ -8,12 +8,12 @@
- Execute a highstate on all connected minions:
`salt '*' state.highstate
`salt '*' state.highstate`
- Upgrade packages using the OS package manager (apt, yum, brew) on a subset of minions
`salt '*.domain.com' pkg.upgrade
`salt '*.domain.com' pkg.upgrade`
- Execute an arbitrary command on a particular minion:
`salt '{{minion_id}}' cmd.run "ls "
`salt '{{minion_id}}' cmd.run "ls "`

View File

@@ -21,3 +21,7 @@
- Detach from inside a screen
`ctrl+A D`
- Kill a detached screen
`screen -X -S {{screen id}} quit`

View File

@@ -6,8 +6,7 @@
`sed 's/{{find}}/{{replace}}/g' {{filename}}`
- replace all occurrences of a string in a file, and overwrite the file
contents
- replace all occurrences of a string in a file, and overwrite the file contents
`sed -i 's/{{find}}/{{replace}}/g' {{filename}}`

15
pages/common/sl.md Normal file
View File

@@ -0,0 +1,15 @@
# sl
> Steam locomotive running through your terminal.
- Let a steam locomotive run through your terminal.
`sl`
- The train burns, people scream.
`sl -a`
- Let the train fly.
`sl -F`

19
pages/common/strings.md Normal file
View File

@@ -0,0 +1,19 @@
# strings
> Find printable strings in an object file or binary
- Print all strings in a binary
`strings {{file}}`
- Limit results to strings at least *length* characters long
`strings -n {{length}} {{file}}`
- Prefix each result with its offset within the file
`strings -t d {{file}}`
- Prefix each result with its offset within the file in hexadecimal
`strings -t x {{file}}`

11
pages/common/tac.md Normal file
View File

@@ -0,0 +1,11 @@
# tac
> Print and concatenate files in reverse.
- Print the contents of *file1* reversed to the standard output
`tac {{file1}}`
- Concatenate several files reversed into the target file.
`tac {{file1}} {{file2}} > {{target-file}}`

View File

@@ -29,4 +29,4 @@
- list the contents of a tar file
`tar -tvf {{source.tar}}`
`tar tvf {{source.tar}}`

View File

@@ -2,14 +2,14 @@
> 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.`
- 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}}
`touch -t 201412250801.59 {{filename}}`
`touch -t {{YYYYMMDDHHMM.SS}} {{filename}}`
- Set the times on a file to match those on second file

View File

@@ -17,3 +17,11 @@
- Print human readable size of files
`tree -h`
- Print the full path for each file
`tree -f`
- Print the tree without lines and indentation. Useful when used with -f
`tree -i`

View File

@@ -14,3 +14,7 @@
- Print the nodename (hostname) of the system
`uname -n`
- Print all available system information (hardware, software, nodename)
`uname -a`

View File

@@ -1,19 +0,0 @@
# useradd
> Create a new user
- Create new user
`useradd {{name}}`
- Create new user with a default home directory
`useradd -m {{name}}`
- Create new user with specified shell
`useradd -s {{/path/to/shell}} {{name}}`
- Create new user with supplementary groups (mind the lack of whitespace)
`useradd -G {{group1,group2}} {{name}}`

View File

@@ -1,7 +0,0 @@
# userdel
> Remove a user
- Remove a user and their home directory
`userdel -r {{name}}`

View File

@@ -1,15 +0,0 @@
# usermod
> Modifies a user account
- Change a user's name
`usermod -l {{newname}} {{user}}`
- Add user to supplementary groups (mind the whitespace)
`usermod -a -G {{group1,group2}} {{user}}`
- Create a new home directory for a user and move their files to it
`usermod -m -d {{/path/to/home}} {{user}}`

23
pages/common/vagrant.md Normal file
View File

@@ -0,0 +1,23 @@
# vagrant
> Manage lightweight, reproducible, and portable development environments
- Create Vagrantfile in current folder with the base Vagrant box
`vagrant init`
- Create Vagrantfile with the Ubuntu 14.04 (Trusty Tahr) box from HashiCorp Atlas
`vagrant init ubuntu/trusty32`
- Start and provision the vagrant environment
`vagrant up`
- Suspend the machine
`vagrant suspend`
- Connect to machine via SSH
`vagrant ssh`

View File

@@ -0,0 +1,16 @@
# virtualenv
> Create virtual isolated Python environments
- Create a new environment
`virtualenv {{path/to/venv}}`
- Start (select) the environment
`source {{path/to/venv}}/bin/activate`
- Stop the environment
`deactivate`

7
pages/common/whoami.md Normal file
View File

@@ -0,0 +1,7 @@
# whoami
> Show the username of the current user
- Display currently logged user name
`whoami`