Move pages back into a "pages" folder
This commit is contained in:
24
pages/common/alias.md
Normal file
24
pages/common/alias.md
Normal file
@@ -0,0 +1,24 @@
|
||||
# alias
|
||||
|
||||
> Creates an alias for a word when used
|
||||
> as the first word of a command
|
||||
|
||||
- creating a generic alias
|
||||
|
||||
`alias {{word}}="{{command}}"`
|
||||
|
||||
- remove an aliased command
|
||||
|
||||
`unalias {{word}}`
|
||||
|
||||
- full list of aliased words
|
||||
|
||||
`alias -p`
|
||||
|
||||
- turning rm an interative command
|
||||
|
||||
`alias {{rm}}="{{rm -i}}"`
|
||||
|
||||
- overriding la as ls -a
|
||||
|
||||
`alias {{la}}="{{ls -a}}"`
|
19
pages/common/cal.md
Normal file
19
pages/common/cal.md
Normal file
@@ -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`
|
19
pages/common/chown.md
Normal file
19
pages/common/chown.md
Normal file
@@ -0,0 +1,19 @@
|
||||
# chown
|
||||
|
||||
> Change the owning user/group of the specified files
|
||||
|
||||
- change the user of a file
|
||||
|
||||
`chown {{user}} {{path/to/file}}`
|
||||
|
||||
- change the user and group of a file
|
||||
|
||||
`chown {{user}}:{{group}} {{path/to/file}}`
|
||||
|
||||
- recursively change the owner of an entire folder
|
||||
|
||||
`chown -R {{user}} {{path/to/folder}}`
|
||||
|
||||
- change the owner of a symbolic link
|
||||
|
||||
`chown -h {{user}} {{path/to/symlink}}`
|
8
pages/common/cksum.md
Normal file
8
pages/common/cksum.md
Normal file
@@ -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}}`
|
21
pages/common/cp.md
Normal file
21
pages/common/cp.md
Normal file
@@ -0,0 +1,21 @@
|
||||
# cp
|
||||
|
||||
> Copy files
|
||||
|
||||
- Copy files in arbitrary locations
|
||||
|
||||
`cp {{/path/to/original}} {{/path/to/copy}}`
|
||||
|
||||
- Copy a file to a parent directory
|
||||
|
||||
`cp {{/path/to/original}} ../{{/path/to/copy}}`
|
||||
|
||||
- Copy directories recursive using the option -r. Optionally showing files as they are copied.
|
||||
|
||||
`cp -r {{/path/to/original}} {{/path/to/copy}}`
|
||||
`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\}`
|
24
pages/common/curl.md
Normal file
24
pages/common/curl.md
Normal file
@@ -0,0 +1,24 @@
|
||||
# curl
|
||||
|
||||
> 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}}`
|
||||
|
||||
- send JSON data
|
||||
|
||||
`curl -X POST -H "Content-Type: application/json" -d {{'{"name":"bob"}'}} {{http://localhost/login}}`
|
||||
|
||||
- specify an HTTP method
|
||||
|
||||
`curl -X {{DELETE}} {{http://localhost/item/123}}`
|
||||
|
||||
- head request
|
||||
|
||||
`curl --head {{http://localhost}}`
|
12
pages/common/date.md
Normal file
12
pages/common/date.md
Normal file
@@ -0,0 +1,12 @@
|
||||
# date
|
||||
|
||||
> Set or display the system date
|
||||
|
||||
- Display the date using the default locale
|
||||
|
||||
`date +"%c"`
|
||||
|
||||
- Display the date using a custom format
|
||||
|
||||
`date +"%d/%m/%Y %H:%M:%S"`
|
||||
|
12
pages/common/df.md
Normal file
12
pages/common/df.md
Normal file
@@ -0,0 +1,12 @@
|
||||
# df
|
||||
|
||||
> gives an overview of the file system disk space usage
|
||||
|
||||
- display all file systems and their disk usage
|
||||
|
||||
`df`
|
||||
|
||||
- display all file systems and their disk usage in human readable form
|
||||
|
||||
`df -h`
|
||||
|
23
pages/common/diff.md
Normal file
23
pages/common/diff.md
Normal file
@@ -0,0 +1,23 @@
|
||||
# diff
|
||||
|
||||
> Compare files and directories
|
||||
|
||||
- Compare files
|
||||
|
||||
`diff {{file1}} {{file2}}`
|
||||
|
||||
- Compare files, ignoring white spaces
|
||||
|
||||
`diff -w {{file1}} {{file2}}`
|
||||
|
||||
- Compare files, showing differences side by side
|
||||
|
||||
`diff -y {{file1}} {{file2}}`
|
||||
|
||||
- Compare directories recursively
|
||||
|
||||
`diff -r {{directory1}} {{directory2}}`
|
||||
|
||||
- Compare directories, only showing the names of files that differ
|
||||
|
||||
`diff -rq {{directory1}} {{directory2}}`
|
15
pages/common/dig.md
Normal file
15
pages/common/dig.md
Normal file
@@ -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}}`
|
31
pages/common/electrum.md
Normal file
31
pages/common/electrum.md
Normal file
@@ -0,0 +1,31 @@
|
||||
# electrum
|
||||
|
||||
> Ergonomic Bitcoin wallet and private key management
|
||||
|
||||
- Create a new wallet
|
||||
|
||||
`electrum -w {{new-wallet.dat}} create`
|
||||
|
||||
- Restore an existing wallet from seed offline
|
||||
|
||||
`electrum -w {{recovery-wallet.dat}} restore -o`
|
||||
|
||||
- Create a signed transaction offline
|
||||
|
||||
`electrum mktx {{recipient}} {{amount}} -f 0.0000001 -F {{from}} -o`
|
||||
|
||||
- Display all wallet receiving addresses
|
||||
|
||||
`electrum listaddresses -a`
|
||||
|
||||
- Sign a message
|
||||
|
||||
`electrum signmessage {{address}} {{message}}`
|
||||
|
||||
- Verify a message
|
||||
|
||||
`electrum verifymessage {{address}} {{signature}} {{message}}`
|
||||
|
||||
- Connect only to a specific electrum-server instance
|
||||
|
||||
`electrum -p socks5:{{127.0.0.1}}:9050 -s {{56ckl5obj37gypcu.onion}}:50001:t -1`
|
21
pages/common/find.md
Normal file
21
pages/common/find.md
Normal file
@@ -0,0 +1,21 @@
|
||||
# find
|
||||
|
||||
> Find files under the given directory tree, recursively
|
||||
|
||||
- find files by extension
|
||||
|
||||
`find {{root_path}} -name {{'*.py'}}`
|
||||
|
||||
- run a command for each file
|
||||
- use {} within the command to access the filename
|
||||
|
||||
`find {{root_path}} -name {{'*.py'}} -exec {{wc -l {} }}\;`
|
||||
`find {{root_path}} -name {{'*.py'}} -exec {{rm {} }}\;`
|
||||
|
||||
- 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'}}`
|
23
pages/common/gem.md
Normal file
23
pages/common/gem.md
Normal file
@@ -0,0 +1,23 @@
|
||||
#gem
|
||||
|
||||
> Interact with the package manager for the Ruby programming language.
|
||||
|
||||
- Install latest version of a gem
|
||||
|
||||
`gem install {{gemname}}`
|
||||
|
||||
- Install specific version of a gem
|
||||
|
||||
`gem install -v={{0.0.15}}`
|
||||
|
||||
- Update a gem
|
||||
|
||||
`gem update {{gemname}}`
|
||||
|
||||
- List all gems
|
||||
|
||||
`gem list`
|
||||
|
||||
- Uninstall a gem
|
||||
|
||||
`gem uninstall {{gemname}}`
|
15
pages/common/gifsicle.md
Normal file
15
pages/common/gifsicle.md
Normal file
@@ -0,0 +1,15 @@
|
||||
# gifsicle
|
||||
|
||||
> Create gifs
|
||||
|
||||
- Making a GIF animation with gifsicle
|
||||
|
||||
`gifsicle --delay={{10}} --loop *.gif > {{anim.gif}}`
|
||||
|
||||
- Extracting frames from an animation
|
||||
|
||||
`gifsicle {{anim.gif}} '#0' > {{firstframe.gif}}`
|
||||
|
||||
- You can also edit animations by replacing, deleting, or inserting frames
|
||||
|
||||
`gifsicle -b {{anim.gif}} --replace '#0' {{new.gif}}`
|
23
pages/common/git-stash.md
Normal file
23
pages/common/git-stash.md
Normal file
@@ -0,0 +1,23 @@
|
||||
# git stash
|
||||
|
||||
> Stash local Git changes in a temporary area
|
||||
|
||||
- stash current changes (except new files)
|
||||
|
||||
`git stash {{optional_stash_name}}`
|
||||
|
||||
- include new files in the stash (leaves the index completely clean)
|
||||
|
||||
`git stash -u {{optional_stash_name}}`
|
||||
|
||||
- list all stashes
|
||||
|
||||
`git stash list`
|
||||
|
||||
- re-apply the latest stash
|
||||
|
||||
`git stash pop`
|
||||
|
||||
- re-apply a stash by name
|
||||
|
||||
`git stash apply {{stash_name}}`
|
67
pages/common/git.md
Normal file
67
pages/common/git.md
Normal file
@@ -0,0 +1,67 @@
|
||||
#git
|
||||
|
||||
> Main command for all `git` commands
|
||||
|
||||
- Create a new local repository
|
||||
|
||||
`git init`
|
||||
|
||||
- Show changed files which are not yet added for commit
|
||||
|
||||
`git status`
|
||||
|
||||
- Show changes to tracked files
|
||||
|
||||
`git diff`
|
||||
|
||||
- Add all current changes to the next commit
|
||||
|
||||
`git add .`
|
||||
|
||||
- Commit staged files to the repository with comment
|
||||
|
||||
`git commit -am "Commit message"`
|
||||
|
||||
- Replace the last commit with currently staged changes
|
||||
|
||||
`git commit --amend`
|
||||
|
||||
- Show all commits
|
||||
|
||||
`git log`
|
||||
|
||||
- Clone an existing repository
|
||||
|
||||
`git clone {{remote-repository-location}}`
|
||||
|
||||
- List all existing branches
|
||||
|
||||
`git branch`
|
||||
|
||||
- Create new branch based on current branch
|
||||
|
||||
`git branch {{new-branch}}`
|
||||
|
||||
- Switch to another branch
|
||||
|
||||
`git checkout {{another-branch}}`
|
||||
|
||||
- Delete a local branch
|
||||
|
||||
`git branch -d {{branch-name}}`
|
||||
|
||||
- Download repository from remote location and merge with current local branch
|
||||
|
||||
`git pull {{remote-repository}} {{local-branch}}`
|
||||
|
||||
- Publish local changes on a remote location
|
||||
|
||||
`git push {{remote-repository}} {{local-branch}}`
|
||||
|
||||
- Merge a branch with your current HEAD branch
|
||||
|
||||
`git merge {{branch-name}}`
|
||||
|
||||
- Calling help
|
||||
|
||||
`git --help`
|
28
pages/common/grep.md
Normal file
28
pages/common/grep.md
Normal file
@@ -0,0 +1,28 @@
|
||||
# grep
|
||||
|
||||
> Matches patterns in input text
|
||||
> Supports simple patterns and regular expressions
|
||||
|
||||
- search for an exact string
|
||||
|
||||
`grep {{something}} {{file_path}}`
|
||||
|
||||
- search recursively in current directory for an exact string
|
||||
|
||||
`grep -r {{something}} .`
|
||||
|
||||
- use a regex
|
||||
|
||||
`grep -e {{^regex$}} {{file_path}}`
|
||||
|
||||
- see 3 lines of context
|
||||
|
||||
`grep -C 3 {{something}} {{file_path}}`
|
||||
|
||||
- print the count of matches instead of the matching text
|
||||
|
||||
`grep -c {{something}} {{file_path}}`
|
||||
|
||||
- use the standard input instead of a file
|
||||
|
||||
`cat {{file_path}} | grep {{something}}`
|
23
pages/common/gzip.md
Normal file
23
pages/common/gzip.md
Normal file
@@ -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`
|
12
pages/common/kill.md
Normal file
12
pages/common/kill.md
Normal file
@@ -0,0 +1,12 @@
|
||||
# kill
|
||||
|
||||
> Sends a signal to a process
|
||||
> Mostly used for stopping processes
|
||||
|
||||
- kill the process
|
||||
|
||||
`kill {{process_id}}`
|
||||
|
||||
- list signal names
|
||||
|
||||
`kill -l`
|
25
pages/common/less.md
Normal file
25
pages/common/less.md
Normal file
@@ -0,0 +1,25 @@
|
||||
# less
|
||||
|
||||
> Opens a file for reading
|
||||
> Allows movement and search
|
||||
> Doesn't read the entire file (suitable for logs)
|
||||
|
||||
- open a file
|
||||
|
||||
`less {{source_file}}`
|
||||
|
||||
- page up / down
|
||||
|
||||
`d (next), D (previous)`
|
||||
|
||||
- go to start / end of file
|
||||
|
||||
`g (start), G (end)`
|
||||
|
||||
- search for a string
|
||||
|
||||
`/{{something}} then n (next), N (previous)`
|
||||
|
||||
- exit
|
||||
|
||||
`q`
|
11
pages/common/ln.md
Normal file
11
pages/common/ln.md
Normal file
@@ -0,0 +1,11 @@
|
||||
# ln
|
||||
|
||||
> Creates links to files and folders
|
||||
|
||||
- create a symbolic link to a file or folder
|
||||
|
||||
`ln -s {{path/to/original/file}} {{path/to/link}}`
|
||||
|
||||
- create a hard link to a file or folder
|
||||
|
||||
`ln {{path/to/original/file}} {{path/to/link}}`
|
30
pages/common/ls.md
Normal file
30
pages/common/ls.md
Normal file
@@ -0,0 +1,30 @@
|
||||
# ls
|
||||
|
||||
> List directory contents
|
||||
|
||||
- List all files, even hidden
|
||||
|
||||
`ls -a`
|
||||
|
||||
- List all file names (no extra info)
|
||||
|
||||
`ls -A1`
|
||||
|
||||
- List all files with their rights, groups, owner
|
||||
|
||||
`ls -ls`
|
||||
|
||||
- List all files with a prefix/suffix
|
||||
|
||||
`ls {{prefix}}*`
|
||||
`ls *{{suffix}}`
|
||||
|
||||
- Sort the results size
|
||||
|
||||
`ls -s # by size`
|
||||
`ls -t # by last modified date`
|
||||
`ls -U # by creation date`
|
||||
|
||||
- Reverse the order of the results
|
||||
|
||||
`ls -r`
|
15
pages/common/lsof.md
Normal file
15
pages/common/lsof.md
Normal file
@@ -0,0 +1,15 @@
|
||||
# lsof
|
||||
|
||||
> Lists open files and the corresponding processes
|
||||
|
||||
- find the processes that have a given file open
|
||||
|
||||
`lsof {{/path/to/file}}`
|
||||
|
||||
- find the process that opened a local internet port
|
||||
|
||||
`lsof -i :{{8080}}`
|
||||
|
||||
- only output the process PID (e.g. to pipe into kill)
|
||||
|
||||
`lsof -t {{/path/to/file}} | xargs kill -9`
|
19
pages/common/man.md
Normal file
19
pages/common/man.md
Normal file
@@ -0,0 +1,19 @@
|
||||
# man
|
||||
|
||||
> Format and display manual pages
|
||||
|
||||
- Display man page for a command
|
||||
|
||||
`man {{command}}`
|
||||
|
||||
- Display path searched for manpages
|
||||
|
||||
`man --path`
|
||||
|
||||
- Display location of a manpage rather than the manpage itself
|
||||
|
||||
`man -w {{command}}`
|
||||
|
||||
- Do a keyword search for manpages containing a search string
|
||||
|
||||
`man -k {{keyword}}`
|
11
pages/common/mkdir.md
Normal file
11
pages/common/mkdir.md
Normal file
@@ -0,0 +1,11 @@
|
||||
# mkdir
|
||||
|
||||
> Creates a directory
|
||||
|
||||
- creates a directory in current folder or given path
|
||||
|
||||
`mkdir {{directory}}`
|
||||
|
||||
- creates directories recursively (useful for creating nested dirs)
|
||||
|
||||
`mkdir -p {{path}}`
|
23
pages/common/mount.md
Normal file
23
pages/common/mount.md
Normal file
@@ -0,0 +1,23 @@
|
||||
# mount
|
||||
|
||||
> Provides access to an entire filesystem in one directory.
|
||||
|
||||
- Show all mounted filesystems
|
||||
|
||||
`mount`
|
||||
|
||||
- Mount a device
|
||||
|
||||
`mount -t {{filesystem_type}} {{path_to_device_file}} {{directory_to_mount_to}}`
|
||||
|
||||
- Mount a CD-ROM device (with the filetype ISO9660) to /cdrom (readonly)
|
||||
|
||||
`mount -t {{iso9660}} -o ro {{/dev/cdrom}} {{/cdrom}}`
|
||||
|
||||
- Mount all the filesystem defined in /etc/fstab
|
||||
|
||||
`mount -a`
|
||||
|
||||
- Mount a specific filesystem described in /etc/fstab (e.g. "/dev/sda1 /my_drive ext2 defaults 0 2")
|
||||
|
||||
`mount {{/my_drive}}`
|
19
pages/common/mv.md
Normal file
19
pages/common/mv.md
Normal file
@@ -0,0 +1,19 @@
|
||||
# mv
|
||||
|
||||
> Move or rename files and directories
|
||||
|
||||
- Move files in abitrary locations
|
||||
|
||||
`mv {{source}} {{target}}`
|
||||
|
||||
- Do not prompt for confirmation before overwriting existing files
|
||||
|
||||
`mv -f {{source}} {{target}}`
|
||||
|
||||
- Do not prompt for confirmation before overwriting existing files but write to standard error before overriding
|
||||
|
||||
`mv -fi {{source}} {{target}}`
|
||||
|
||||
- Move files in verbose mode, showing files after they are moved
|
||||
|
||||
`mv -v {{source}} {{target}}`
|
23
pages/common/nc.md
Normal file
23
pages/common/nc.md
Normal file
@@ -0,0 +1,23 @@
|
||||
# nc
|
||||
|
||||
> reads and writes tcp or udp data
|
||||
|
||||
- listen on a specified port
|
||||
|
||||
`nc -l {{port}}`
|
||||
|
||||
- connect to a certain port (you can then write to this port)
|
||||
|
||||
`nc {{ip_address}} {{port}}`
|
||||
|
||||
- set a timeout
|
||||
|
||||
`nc -w {{timeout_in_seconds}} {{ipaddress}} {{port}}`
|
||||
|
||||
- serve a file
|
||||
|
||||
`cat somefile.txt | nc -l {{port}}`
|
||||
|
||||
- receive a file
|
||||
|
||||
`nc {{ip_address}} {{port}} > somefile.txt`
|
11
pages/common/nmap.md
Normal file
11
pages/common/nmap.md
Normal file
@@ -0,0 +1,11 @@
|
||||
# nmap
|
||||
|
||||
> Network exploration tool and security / port scanner
|
||||
|
||||
- scan open ports of a single host
|
||||
|
||||
`nmap {{192.168.0.1}}`
|
||||
|
||||
- discover hosts in the 192.168.0.X area (no port scan)
|
||||
|
||||
`nmap -sn {{192.168.0.1/24}}`
|
23
pages/common/npm.md
Normal file
23
pages/common/npm.md
Normal file
@@ -0,0 +1,23 @@
|
||||
# npm
|
||||
|
||||
> Node package manager, to manage Node.js projects and install module dependencies.
|
||||
|
||||
- Create a new project in the current folder
|
||||
|
||||
`npm init`
|
||||
|
||||
- Download all dependencies referenced in package.json
|
||||
|
||||
`npm install`
|
||||
|
||||
- Download a given dependency, and add it to the package.json
|
||||
|
||||
`npm install {{module_name}}@{{version}} --save`
|
||||
|
||||
- Set the version of the current project
|
||||
|
||||
`npm version {{1.2.3}}`
|
||||
|
||||
- Publish the current project
|
||||
|
||||
`npm publish`
|
19
pages/common/passwd.md
Normal file
19
pages/common/passwd.md
Normal file
@@ -0,0 +1,19 @@
|
||||
#passwd
|
||||
|
||||
> passwd is a tool used to change a user's password.
|
||||
|
||||
* Change the password of the current user
|
||||
|
||||
`passwd {{new password}}`
|
||||
|
||||
* Change the password of the specified user
|
||||
|
||||
`passwd {{username}} {{new password}}`
|
||||
|
||||
* Get the current statuts of the user
|
||||
|
||||
`passwd -S`
|
||||
|
||||
* Make the password of the account blank (it will set the named account passwordless)
|
||||
|
||||
`passwd -d`
|
23
pages/common/pgrep.md
Normal file
23
pages/common/pgrep.md
Normal file
@@ -0,0 +1,23 @@
|
||||
# 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}}`
|
||||
|
||||
- search full command line with parameters instead of just the process name
|
||||
|
||||
`pgrep -f "{{ssh root}}"`
|
||||
|
||||
- search for process run by a specific user
|
||||
|
||||
`pgrep -u root {{firefox}}`
|
||||
|
||||
- kill all processes which match
|
||||
|
||||
`pkill -9 {{Finder}}`
|
19
pages/common/php.md
Normal file
19
pages/common/php.md
Normal file
@@ -0,0 +1,19 @@
|
||||
# php
|
||||
|
||||
> PHP Command Line Interface 'CLI'
|
||||
|
||||
- Parse and execute a file
|
||||
|
||||
`php {{file}}`
|
||||
|
||||
- Check syntax (lint)
|
||||
|
||||
`php -l {{file}}`
|
||||
|
||||
- Run PHP interactively
|
||||
|
||||
`php -a`
|
||||
|
||||
- Run PHP code. Notes: a) Don't use <? ?> tags; b) Escape double quotes with backslash
|
||||
|
||||
`php -r "{{code}}"`
|
15
pages/common/ping.md
Normal file
15
pages/common/ping.md
Normal file
@@ -0,0 +1,15 @@
|
||||
# ping
|
||||
|
||||
> send ICMP ECHO_REQUEST packets to network hosts
|
||||
|
||||
- Ping host
|
||||
|
||||
`ping {{host}}`
|
||||
|
||||
- Ping host limiting the number of packages to be send to four
|
||||
|
||||
`ping -c 4 {{host}}`
|
||||
|
||||
- Ping host, waiting for 0.5 s between each request (default is 1 s)
|
||||
|
||||
`ping -i 0.5 {{host}}`
|
23
pages/common/pip.md
Normal file
23
pages/common/pip.md
Normal file
@@ -0,0 +1,23 @@
|
||||
# pip
|
||||
|
||||
> Python package manager
|
||||
|
||||
- Install a package
|
||||
|
||||
`pip install {{somepackage}}`
|
||||
|
||||
- Upgrade a package
|
||||
|
||||
`pip install -U {{somepackage}}`
|
||||
|
||||
- Uninstall a package
|
||||
|
||||
`pip uninstall {{somepackage}}`
|
||||
|
||||
- Save installed packages to file
|
||||
|
||||
`pip freeze > {{requirements.txt}}`
|
||||
|
||||
- Install packages from file
|
||||
|
||||
`pip install -r {{requirements.txt}}`
|
11
pages/common/ps.md
Normal file
11
pages/common/ps.md
Normal file
@@ -0,0 +1,11 @@
|
||||
# ps
|
||||
|
||||
> Information about running processes
|
||||
|
||||
- list all running processes
|
||||
|
||||
`ps aux`
|
||||
|
||||
- list all running processes including the full command string
|
||||
|
||||
`ps auxww`
|
20
pages/common/redis-cli.md
Normal file
20
pages/common/redis-cli.md
Normal file
@@ -0,0 +1,20 @@
|
||||
# redis-cli
|
||||
|
||||
> Opens a connection to a Redis server
|
||||
|
||||
- Connect to the local server
|
||||
|
||||
`redis-cli`
|
||||
|
||||
- Connect to a remote server
|
||||
|
||||
`redis-cli -h {{host}}`
|
||||
`redis-cli -h {{host}} -p {{port}}`
|
||||
|
||||
- Specify a password
|
||||
|
||||
`redis-cli -a {{password}}`
|
||||
|
||||
- Executes Redis command
|
||||
|
||||
`redis-cli {{redis command}}`
|
15
pages/common/rename.md
Normal file
15
pages/common/rename.md
Normal file
@@ -0,0 +1,15 @@
|
||||
# rename
|
||||
|
||||
> renames multiple files
|
||||
|
||||
- Change foo to bar in matching files
|
||||
|
||||
`rename {{'s/foo/bar/'}} {{*.txt}}`
|
||||
|
||||
- Convert to lower case
|
||||
|
||||
`rename -c {{*.txt}}`
|
||||
|
||||
- Replace whitespace with underscores
|
||||
|
||||
`rename --nows {{*.txt}}`
|
15
pages/common/rm.md
Normal file
15
pages/common/rm.md
Normal file
@@ -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 {{\*}}`
|
11
pages/common/rmdir.md
Normal file
11
pages/common/rmdir.md
Normal file
@@ -0,0 +1,11 @@
|
||||
# rmdir
|
||||
|
||||
> Removes a directory
|
||||
|
||||
- removes directory, provided it is empty. Use `rm` to remove not empty directories.
|
||||
|
||||
`rmdir {{directory}}`
|
||||
|
||||
- removes directories recursively (useful for nested dirs)
|
||||
|
||||
`rmdir -p {{path}}`
|
21
pages/common/rsync.md
Normal file
21
pages/common/rsync.md
Normal file
@@ -0,0 +1,21 @@
|
||||
# rsync
|
||||
|
||||
> Transfers a file either to or from a remote host
|
||||
> Does not allow transfer between two remote hosts
|
||||
> Can transfer single files or files matched by pattern
|
||||
|
||||
- transfer file from local to remote host
|
||||
|
||||
`rsync {{path_to_file}} {{remote_host_name}}:{{remote_host_location}}`
|
||||
|
||||
- transfer file from remote host to local
|
||||
|
||||
`rsync {{remote_host_name}}:{{remote_file_location}} {{local_file_location}}`
|
||||
|
||||
- transfer all *.js files in current directory to host 'devbox' as user 'mike'
|
||||
|
||||
`rsync *.js mike@devbox:~/projects/cakeStore/styles/`
|
||||
|
||||
- transfer a directory and all its children from a remote to local
|
||||
|
||||
`rsync -r mike@devbox:~/projects/cakeStore /Users/mike/devProjects/`
|
26
pages/common/scp.md
Normal file
26
pages/common/scp.md
Normal file
@@ -0,0 +1,26 @@
|
||||
# scp
|
||||
|
||||
> Copies files between hosts on a network
|
||||
> Works over a secure connection (SSH)
|
||||
|
||||
- upload a file, or upload and rename a file
|
||||
|
||||
`scp {{/local/file.txt}} {{10.0.0.1}}:{{/remote/path/}}`
|
||||
`scp {{/local/file.txt}} {{10.0.0.1}}:{{/remote/path/newname.txt}}`
|
||||
|
||||
- download a file
|
||||
|
||||
`scp {{10.0.0.1}}:{{/remote/path/file.txt}} {{/local/folder}}`
|
||||
|
||||
- upload or download a directory
|
||||
|
||||
`scp -r {{/local/folder}} {{10.0.0.1}}:{{/remote/path/}}`
|
||||
`scp -r {{10.0.0.1}}:{{/remote/path}} {{/local/folder}}`
|
||||
|
||||
- specify username on host
|
||||
|
||||
`scp {{/local/file.txt}} {{my_user}}@{{10.0.0.1}}:{{/remote/path}}`
|
||||
|
||||
- copy a file from one host to another
|
||||
|
||||
`scp {{10.0.0.1}}:{{/remote/path/file.txt}} {{20.0.0.2}}:{{/other/remote/path}}`
|
20
pages/common/screen.md
Normal file
20
pages/common/screen.md
Normal file
@@ -0,0 +1,20 @@
|
||||
# screen
|
||||
|
||||
> Hold a session open on a remote server. Manage multiple windows with a single SSH connection.
|
||||
|
||||
- Start a new screen session
|
||||
|
||||
`screen`
|
||||
|
||||
- Show open screen sessions
|
||||
|
||||
`screen -ls`
|
||||
|
||||
- Reattach to an open screen
|
||||
|
||||
`screen -r {{screen id}}`
|
||||
|
||||
- Detach from inside a screen
|
||||
|
||||
`ctrl+A D`
|
||||
|
16
pages/common/sed.md
Normal file
16
pages/common/sed.md
Normal file
@@ -0,0 +1,16 @@
|
||||
# sed
|
||||
|
||||
> Run replacements based on regular expressions
|
||||
|
||||
- replace all occurrences of a string in a file, and print the result
|
||||
|
||||
`sed 's/{{find}}/{{replace}}/g' {{filename}}`
|
||||
|
||||
- replace all occurrences of a string in a file, and overwrite the file
|
||||
contents
|
||||
|
||||
`sed -i '' 's/{{find}}/{{replace}}/g' {{filename}}`
|
||||
|
||||
- replace all occurrences of an extended regular expression in a file
|
||||
|
||||
`sed -E 's/{{regex}}/{{replace}}/g' {{filename}}`
|
15
pages/common/sort.md
Normal file
15
pages/common/sort.md
Normal file
@@ -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 `
|
18
pages/common/srm.md
Normal file
18
pages/common/srm.md
Normal file
@@ -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 {{\*}}`
|
28
pages/common/ssh.md
Normal file
28
pages/common/ssh.md
Normal file
@@ -0,0 +1,28 @@
|
||||
# SSH
|
||||
|
||||
> Secure Shell is a protocol used to securely log onto remote systems.
|
||||
> It can be used for logging or executing commands on a remote server.
|
||||
|
||||
- connecting to a remote server
|
||||
|
||||
`ssh {{username}}@{{remote_host}}`
|
||||
|
||||
- connecting to a remote server with a specific identity (private key)
|
||||
|
||||
`ssh -i {{/path/to/key_file}} {{username}}@{{remote_host}}`
|
||||
|
||||
- connecting to a remote server with specific port
|
||||
|
||||
`ssh {{username}}@{{remote_host}} -p {{2222}}`
|
||||
|
||||
- run a command on a remote server
|
||||
|
||||
`ssh {{remote_host}} "{{command -with -flags}}"`
|
||||
|
||||
- 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}}`
|
23
pages/common/svn.md
Normal file
23
pages/common/svn.md
Normal file
@@ -0,0 +1,23 @@
|
||||
# svn
|
||||
|
||||
> Subversion command line client tool
|
||||
|
||||
- Check out a working copy from a repository
|
||||
|
||||
`svn co {{url/to/repository}}`
|
||||
|
||||
- Bring changes from the repository into the working copy
|
||||
|
||||
`svn up`
|
||||
|
||||
- Put files and directories under version control, scheduling them for addition to repository. They will be added in next commit.
|
||||
|
||||
`svn add PATH...`
|
||||
|
||||
- Send changes from your working copy to the repository
|
||||
|
||||
`svn ci -m {{commit log message}} {{[PATH...]}}`
|
||||
|
||||
- Show detailed help
|
||||
|
||||
`svn help`
|
15
pages/common/tail.md
Normal file
15
pages/common/tail.md
Normal file
@@ -0,0 +1,15 @@
|
||||
# tail
|
||||
|
||||
> Display the last part of a file
|
||||
|
||||
- show last 'num' lines in file
|
||||
|
||||
`tail -n {{num}} {{file}}`
|
||||
|
||||
- show last 'num' bytes in file
|
||||
|
||||
`tail -c {{num}} {{file}}`
|
||||
|
||||
- keep reading file until ctrl-c
|
||||
|
||||
`tail -f {{file}}`
|
20
pages/common/tar.md
Normal file
20
pages/common/tar.md
Normal file
@@ -0,0 +1,20 @@
|
||||
# tar
|
||||
|
||||
> Archiving utility
|
||||
> Optional compression with gzip / bzip
|
||||
|
||||
- create an archive from files
|
||||
|
||||
`tar cf {{target.tar}} {{file1 file2 file3}}`
|
||||
|
||||
- create a gzipped archive
|
||||
|
||||
`tar czf {{target.tar.gz}} {{file1 file2 file3}}`
|
||||
|
||||
- extract an archive in a target folder
|
||||
|
||||
`tar xf {{source.tar}} -C {{folder}}`
|
||||
|
||||
- extract a gzipped archive in the current directory
|
||||
|
||||
`tar xzf {{source.tar.gz}}`
|
24
pages/common/tcpdump.md
Normal file
24
pages/common/tcpdump.md
Normal file
@@ -0,0 +1,24 @@
|
||||
# tcpdump
|
||||
|
||||
> Dump traffic on a network
|
||||
|
||||
- capture the traffic of a specific interface
|
||||
|
||||
`tcpdump -i {{eth0}}`
|
||||
|
||||
- capture all TCP traffic showing contents (ASCII) in console
|
||||
|
||||
`tcpdump -A tcp`
|
||||
|
||||
- capture the traffic from or to a host
|
||||
|
||||
`tcpdump host {{www.example.com}}`
|
||||
|
||||
- capture the traffic from a specific interface, source, destination and port
|
||||
|
||||
`tcpdump -i {{eth0}} src {{192.168.1.1}} dest {{192.168.1.2}} and port 80`
|
||||
|
||||
- capture the traffic of a network
|
||||
|
||||
`tcpdump net {{192.168.1.0/24}}`
|
||||
|
19
pages/common/telnet.md
Normal file
19
pages/common/telnet.md
Normal file
@@ -0,0 +1,19 @@
|
||||
# telnet
|
||||
|
||||
> telnet is used to connect to a specified port of a host
|
||||
|
||||
- telnet to a certain port
|
||||
|
||||
`telnet {{ip_address}} {{port}}`
|
||||
|
||||
- to exit a telnet session
|
||||
|
||||
`quit`
|
||||
|
||||
- default escape character
|
||||
|
||||
`CTRL` + `]`
|
||||
|
||||
- specify an escape character (x is the escape character)
|
||||
|
||||
`telnet -e x {{ip_address}} {{port}}`
|
8
pages/common/tldr.md
Normal file
8
pages/common/tldr.md
Normal file
@@ -0,0 +1,8 @@
|
||||
# tldr
|
||||
|
||||
> Simplified man pages
|
||||
|
||||
- get typical usages of a command
|
||||
- ps: this is how you got here :)
|
||||
|
||||
`tldr {{command}}`
|
16
pages/common/touch.md
Normal file
16
pages/common/touch.md
Normal file
@@ -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}}`
|
19
pages/common/traceroute.md
Normal file
19
pages/common/traceroute.md
Normal file
@@ -0,0 +1,19 @@
|
||||
# traceroute
|
||||
|
||||
> Print the route packets trace to network host
|
||||
|
||||
- Traceroute to a host
|
||||
|
||||
`traceroute {{host}}`
|
||||
|
||||
- Disable IP address and host name mapping
|
||||
|
||||
`traceroute -n {{host}}`
|
||||
|
||||
- Specify wait time for response
|
||||
|
||||
`traceroute -w 0.5 {{host}}`
|
||||
|
||||
- Specify number of queries per hop
|
||||
|
||||
`traceroute -q 5 {{host}}`
|
16
pages/common/umount.md
Normal file
16
pages/common/umount.md
Normal file
@@ -0,0 +1,16 @@
|
||||
# umount
|
||||
|
||||
> Revokes access to an entire filesystem mounted to a directory.
|
||||
> A filesystem cannot be unmounted when it is busy.
|
||||
|
||||
- Unmount a filesystem
|
||||
|
||||
`umount {{path_to_device_file}}`
|
||||
|
||||
- OR
|
||||
|
||||
`umount {{path_to_mounted_directory}}`
|
||||
|
||||
- Unmount all mounted filesystems (dangerous!)
|
||||
|
||||
`umount -a`
|
15
pages/common/uname.md
Normal file
15
pages/common/uname.md
Normal file
@@ -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`
|
15
pages/common/unzip.md
Normal file
15
pages/common/unzip.md
Normal file
@@ -0,0 +1,15 @@
|
||||
# unzip
|
||||
|
||||
> Extract compressed files in a ZIP archive
|
||||
|
||||
- extract zip file(s) (for multiple files, seperate file paths by spaces)
|
||||
|
||||
`unzip {{file(s)}}`
|
||||
|
||||
- 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}}`
|
16
pages/common/wc.md
Normal file
16
pages/common/wc.md
Normal file
@@ -0,0 +1,16 @@
|
||||
# wc
|
||||
|
||||
> Count words, bytes, or lines
|
||||
|
||||
- count lines in file
|
||||
|
||||
`wc -l {{file}}`
|
||||
|
||||
- count bytes in file
|
||||
|
||||
`wc -c {{file}}`
|
||||
|
||||
- count characters in file (taking multi-byte character sets into account)
|
||||
|
||||
`wc -m {{file}}`
|
||||
|
24
pages/common/wget.md
Normal file
24
pages/common/wget.md
Normal file
@@ -0,0 +1,24 @@
|
||||
# wget
|
||||
|
||||
> Download files from the Web
|
||||
> Supports HTTP, HTTPS, and FTP
|
||||
|
||||
- Download a URL to a file
|
||||
|
||||
`wget -O filename "{{url}}"`
|
||||
|
||||
- Limit download speed
|
||||
|
||||
`wget --limit-rate={{200k}} {{url}}`
|
||||
|
||||
- Continue an incomplete download
|
||||
|
||||
`wget -c {{url}}`
|
||||
|
||||
- Download a full website
|
||||
|
||||
`wget --mirror -p --convert-links -P {{target_folder}} {{url}}`
|
||||
|
||||
- FTP download with username and password
|
||||
|
||||
`wget --ftp-user={{username}} --ftp-password={{password}} {{url}}`
|
12
pages/common/which.md
Normal file
12
pages/common/which.md
Normal file
@@ -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}}`
|
27
pages/common/zfs.md
Normal file
27
pages/common/zfs.md
Normal file
@@ -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}}`
|
7
pages/common/zip.md
Normal file
7
pages/common/zip.md
Normal file
@@ -0,0 +1,7 @@
|
||||
# zip
|
||||
|
||||
> Package and compress (archive) files into zip file
|
||||
|
||||
- package and compress multiple directories & files
|
||||
|
||||
`zip -r {{compressed.zip}} {{/path/to/dir1 /path/to/dir2 /path/to/file}}`
|
33
pages/common/zpool.md
Normal file
33
pages/common/zpool.md
Normal file
@@ -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}}`
|
Reference in New Issue
Block a user