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}}`
|
24
pages/linux/apt-get.md
Normal file
24
pages/linux/apt-get.md
Normal file
@@ -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`
|
19
pages/linux/du.md
Normal file
19
pages/linux/du.md
Normal file
@@ -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`
|
31
pages/linux/emerge.md
Normal file
31
pages/linux/emerge.md
Normal file
@@ -0,0 +1,31 @@
|
||||
# emerge
|
||||
|
||||
> Gentoo Linux package manager utility
|
||||
|
||||
- synchronize all packages
|
||||
|
||||
`emerge --sync`
|
||||
|
||||
- update all packages, including dependencies
|
||||
|
||||
`emerge -uDNav @world`
|
||||
|
||||
- resume a failed updated, skipping the failing package
|
||||
|
||||
`emerge --resume --skipfirst`
|
||||
|
||||
- install a new package, with confirmation
|
||||
|
||||
`emerge -av {{package-name}}`
|
||||
|
||||
- remove a package, with confirmation
|
||||
|
||||
`emerge -Cav {{package-name}}`
|
||||
|
||||
- remove orphaned packages (that were installed only as dependencies)
|
||||
|
||||
`emerge -avc`
|
||||
|
||||
- search the package database for a keyword
|
||||
|
||||
`emerge -S {{keyword}}`
|
23
pages/linux/findmnt.md
Normal file
23
pages/linux/findmnt.md
Normal file
@@ -0,0 +1,23 @@
|
||||
# findmnt
|
||||
|
||||
> Find your filesystem
|
||||
|
||||
- List all mounted filesystems
|
||||
|
||||
`findmnt`
|
||||
|
||||
- Search for a device
|
||||
|
||||
`findmnt {{/dev/sdb1}}`
|
||||
|
||||
- Search for a mountpoint
|
||||
|
||||
`findmnt {{/}}`
|
||||
|
||||
- Find filesystems in specific type
|
||||
|
||||
`findmnt -t {{ext4}}`
|
||||
|
||||
- Find filesystems with specific label
|
||||
|
||||
`findmnt LABEL={{BigStorage}}`
|
23
pages/linux/ip.md
Normal file
23
pages/linux/ip.md
Normal file
@@ -0,0 +1,23 @@
|
||||
# ip
|
||||
|
||||
> Show / manipulate routing, devices, policy routing and tunnels
|
||||
|
||||
- List interfaces with detailed info
|
||||
|
||||
`ip a`
|
||||
|
||||
- Display the routing table
|
||||
|
||||
`ip r`
|
||||
|
||||
- Make an interface up/down
|
||||
|
||||
`ip link set {{interface}} up/down`
|
||||
|
||||
- Add/Delete an ip address to an interface
|
||||
|
||||
`ip addr add/del {{ip}}/{{mask}} dev {{interface}}`
|
||||
|
||||
- Add an default route
|
||||
|
||||
`ip route add default via {{ip}} dev {{interface}}`
|
27
pages/linux/journalctl.md
Normal file
27
pages/linux/journalctl.md
Normal file
@@ -0,0 +1,27 @@
|
||||
# journalctl
|
||||
|
||||
> Query the systemd journal
|
||||
|
||||
- Show all messages from this boot
|
||||
|
||||
`journalctl -b`
|
||||
|
||||
- Show all messages from last boot
|
||||
|
||||
`journalctl -b -1`
|
||||
|
||||
- Follow new messages (like `tail -f` for traditional syslog)
|
||||
|
||||
`journalctl -f`
|
||||
|
||||
- Show all messages by a specific unit
|
||||
|
||||
`journalctl -u {{unit}}`
|
||||
|
||||
- Show all messages by a specific process
|
||||
|
||||
`journalctl _PID={{pid}}`
|
||||
|
||||
- Show all messages by a specific executable
|
||||
|
||||
`journalctl {{/path/to/executable}}`
|
13
pages/linux/md5sum.md
Normal file
13
pages/linux/md5sum.md
Normal file
@@ -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}}`
|
23
pages/linux/pacman.md
Normal file
23
pages/linux/pacman.md
Normal file
@@ -0,0 +1,23 @@
|
||||
# pacman
|
||||
|
||||
> Arch Linux package manager utility
|
||||
|
||||
- synchronize and update all packages
|
||||
|
||||
`pacman -Syyu`
|
||||
|
||||
- install a new package
|
||||
|
||||
`pacman -S package-name`
|
||||
|
||||
- remove a package and its dependencies
|
||||
|
||||
`pacman -Rs package-name`
|
||||
|
||||
- search the package database for a keyword
|
||||
|
||||
`pacman -Ss icon theme`
|
||||
|
||||
- list installed packages and versions
|
||||
|
||||
`pacman -Q`
|
19
pages/linux/shutdown.md
Normal file
19
pages/linux/shutdown.md
Normal file
@@ -0,0 +1,19 @@
|
||||
# shutdown
|
||||
|
||||
> Shutdown and reboot the system
|
||||
|
||||
- Power off (halt) immediately
|
||||
|
||||
`shutdown -h now`
|
||||
|
||||
- Reboot immediately
|
||||
|
||||
`shutdown -r now`
|
||||
|
||||
- Reboot in 5 minutes
|
||||
|
||||
`shutdown -r +{{5}} &`
|
||||
|
||||
- Cancel a pending shutdown/reboot operation
|
||||
|
||||
`shutdown -c`
|
27
pages/linux/ss.md
Normal file
27
pages/linux/ss.md
Normal file
@@ -0,0 +1,27 @@
|
||||
# ss
|
||||
|
||||
> Utility to investigate sockets
|
||||
|
||||
- Dump all TCP/UDP/RAW/UNIX sockets
|
||||
|
||||
`ss -a {{-t/-u/-w/-x}}`
|
||||
|
||||
- Show process(es) that using socket
|
||||
|
||||
`ss -p`
|
||||
|
||||
- Filter TCP sockets by states, only/exclude
|
||||
|
||||
`ss {{state/exclude}} {{bucket/big/connected/synchronized/...}}`
|
||||
|
||||
- Filter sockets by address and/or port
|
||||
|
||||
`ss -t dst 1.2.3.4:80`
|
||||
`ss -u src 127/8`
|
||||
`ss -t 'dport >= :1024'`
|
||||
`ss -x "src /tmp/.X11-unix/*"`
|
||||
`ss -t state established '( dport = :ssh or sport = :ssh )'`
|
||||
|
||||
- Only list IPv4 or IPv6 sockets
|
||||
|
||||
`ss {{-4/-6}}`
|
23
pages/linux/systemctl.md
Normal file
23
pages/linux/systemctl.md
Normal file
@@ -0,0 +1,23 @@
|
||||
# systemctl
|
||||
|
||||
> Control the systemd system and service manager
|
||||
|
||||
- List failed units
|
||||
|
||||
`systemctl --failed`
|
||||
|
||||
- Start/Stop/Restart a service
|
||||
|
||||
`systemctl start/stop/restart {{unit}}`
|
||||
|
||||
- Show the status of a unit
|
||||
|
||||
`systemctl status {{unit}}`
|
||||
|
||||
- Enable/Disable a unit to be started on bootup
|
||||
|
||||
`systemctl enable/disable {{unit}}`
|
||||
|
||||
- Reload systemd, scanning for new or changed units
|
||||
|
||||
`systemctl daemon-reload`
|
15
pages/osx/airport.md
Normal file
15
pages/osx/airport.md
Normal file
@@ -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`
|
27
pages/osx/brew.md
Normal file
27
pages/osx/brew.md
Normal file
@@ -0,0 +1,27 @@
|
||||
# brew
|
||||
|
||||
> Package manager for OS X
|
||||
|
||||
- Search formula
|
||||
|
||||
`brew search {{text}}`
|
||||
|
||||
- Install formula
|
||||
|
||||
`brew install {{formula}}`
|
||||
|
||||
- List installed formulae [with matching name]
|
||||
|
||||
`brew list {{[text]}}`
|
||||
|
||||
- Get latest version of installed formula (passing no formula updates all installed formulae)
|
||||
|
||||
`brew upgrade {{[formula]}}`
|
||||
|
||||
- Update brew
|
||||
|
||||
`brew update`
|
||||
|
||||
- Switch version of formula
|
||||
|
||||
`brew switch {{formula}} {{version}}`
|
13
pages/osx/caffeinate.md
Normal file
13
pages/osx/caffeinate.md
Normal file
@@ -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}}`
|
||||
|
||||
|
23
pages/osx/diskutil.md
Normal file
23
pages/osx/diskutil.md
Normal file
@@ -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}}`
|
12
pages/osx/drutil.md
Normal file
12
pages/osx/drutil.md
Normal file
@@ -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`
|
||||
|
19
pages/osx/du.md
Normal file
19
pages/osx/du.md
Normal file
@@ -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}}`
|
13
pages/osx/md5.md
Normal file
13
pages/osx/md5.md
Normal file
@@ -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}}`
|
19
pages/osx/networksetup.md
Normal file
19
pages/osx/networksetup.md
Normal file
@@ -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}}`
|
23
pages/osx/open.md
Normal file
23
pages/osx/open.md
Normal file
@@ -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`
|
12
pages/osx/pbcopy.md
Normal file
12
pages/osx/pbcopy.md
Normal file
@@ -0,0 +1,12 @@
|
||||
# pbcopy
|
||||
|
||||
> Place standard output in the clipboard
|
||||
|
||||
- Place the contents of a file in the clipboard.
|
||||
|
||||
`pbcopy < {{file}}`
|
||||
|
||||
- Place the results of a command in the clipboard
|
||||
|
||||
`find . -type t -name "*.png" | pbcopy`
|
||||
|
12
pages/osx/pbpaste.md
Normal file
12
pages/osx/pbpaste.md
Normal file
@@ -0,0 +1,12 @@
|
||||
# pbpaste
|
||||
|
||||
> Send the contents of the clipboard to standard output
|
||||
|
||||
- Write the contents of the clipboard to a file.
|
||||
|
||||
`pbpaste > {{file}}`
|
||||
|
||||
- Use the contents of the clipboard as input to a command.
|
||||
|
||||
`pbpaste | grep foo`
|
||||
|
11
pages/osx/qlmanage.md
Normal file
11
pages/osx/qlmanage.md
Normal file
@@ -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}}`
|
19
pages/osx/say.md
Normal file
19
pages/osx/say.md
Normal file
@@ -0,0 +1,19 @@
|
||||
# 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"`
|
||||
|
||||
- List the available voices
|
||||
|
||||
`say -v '?'`
|
19
pages/osx/shutdown.md
Normal file
19
pages/osx/shutdown.md
Normal file
@@ -0,0 +1,19 @@
|
||||
# shutdown
|
||||
|
||||
> Shutdown and reboot the system
|
||||
|
||||
- Power off (halt) immediately
|
||||
|
||||
`shutdown -h now`
|
||||
|
||||
- Sleep immediately
|
||||
|
||||
`shutdown -s now`
|
||||
|
||||
- Reboot immediately
|
||||
|
||||
`shutdown -r now`
|
||||
|
||||
- Reboot in 5 minutes
|
||||
|
||||
`shutdown -r +{{5}}`
|
12
pages/osx/sw_vers.md
Normal file
12
pages/osx/sw_vers.md
Normal file
@@ -0,0 +1,12 @@
|
||||
# sw_vers
|
||||
|
||||
> Print Mac OSX Software versioning information
|
||||
|
||||
- Print OSX Version
|
||||
|
||||
`sw_vers -productVersion`
|
||||
|
||||
- Print OSX Build
|
||||
|
||||
`sw_vers -buildVersion`
|
||||
|
24
pages/osx/sysctl.md
Normal file
24
pages/osx/sysctl.md
Normal file
@@ -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`
|
15
pages/osx/system_profiler.md
Normal file
15
pages/osx/system_profiler.md
Normal file
@@ -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}'`
|
24
pages/osx/systemsetup.md
Normal file
24
pages/osx/systemsetup.md
Normal file
@@ -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}}`
|
16
pages/osx/xed.md
Normal file
16
pages/osx/xed.md
Normal file
@@ -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}}`
|
16
pages/sunos/prctl.md
Normal file
16
pages/sunos/prctl.md
Normal file
@@ -0,0 +1,16 @@
|
||||
# prctl
|
||||
|
||||
> Get or set the resource controls of running processes,
|
||||
> tasks, and projects
|
||||
|
||||
- examine process limits and permissions
|
||||
|
||||
`prctl {{PID}}`
|
||||
|
||||
- examine process limits and permissions in machine parseable format
|
||||
|
||||
`prctl -P {{PID}}`
|
||||
|
||||
- Get specific limit for a running process
|
||||
|
||||
`prctl -n process.max-file-descriptor {{PID}}`
|
23
pages/sunos/prstat.md
Normal file
23
pages/sunos/prstat.md
Normal file
@@ -0,0 +1,23 @@
|
||||
# prstat
|
||||
|
||||
> Report active process statistics
|
||||
|
||||
- examine all processes and reports statistics sorted by CPU usage
|
||||
|
||||
`prstat`
|
||||
|
||||
- examine all processes and reports statistics sorted by memory usage
|
||||
|
||||
`prstat -s rss`
|
||||
|
||||
- report total usage summary for each user
|
||||
|
||||
`prstat -t`
|
||||
|
||||
- report microstate process accounting information
|
||||
|
||||
`prstat -m`
|
||||
|
||||
- Print out a list of top 5 cpu using processes every second.
|
||||
|
||||
`prstat -c -n 5 -s cpu 1`
|
23
pages/sunos/svcadm.md
Normal file
23
pages/sunos/svcadm.md
Normal file
@@ -0,0 +1,23 @@
|
||||
# svcadm
|
||||
|
||||
> Manipulate service instances
|
||||
|
||||
- enable a service in the service database
|
||||
|
||||
`svcadm enable {{service_name}}`
|
||||
|
||||
- disable service
|
||||
|
||||
`svcadm disable {{service_name}}`
|
||||
|
||||
- restart a running service
|
||||
|
||||
`svcadm restart {{service_name}}`
|
||||
|
||||
- command service to re-read configuration files
|
||||
|
||||
`svcadm refresh {{service_name}}`
|
||||
|
||||
- clear a service from maintenance state and command it to start
|
||||
|
||||
`svcadm clear {{service_name}}`
|
15
pages/sunos/svccfg.md
Normal file
15
pages/sunos/svccfg.md
Normal file
@@ -0,0 +1,15 @@
|
||||
# svccfg
|
||||
|
||||
> Import, export, and modify service configurations
|
||||
|
||||
- validate configuration file
|
||||
|
||||
`svccfg validate {{smf.xml}}`
|
||||
|
||||
- export service configurations to file
|
||||
|
||||
`svccfg export {{servicename}} > {{smf.xml}}`
|
||||
|
||||
- import/update service configurations from file.
|
||||
|
||||
`svccfg import {{smf.xml}}`
|
23
pages/sunos/svcs.md
Normal file
23
pages/sunos/svcs.md
Normal file
@@ -0,0 +1,23 @@
|
||||
# svcs
|
||||
|
||||
> List information about running services
|
||||
|
||||
- list all running services
|
||||
|
||||
`svcs`
|
||||
|
||||
- list services that are not running
|
||||
|
||||
`svcs -vx`
|
||||
|
||||
- list information about a service
|
||||
|
||||
`svcs apache`
|
||||
|
||||
- show location of service log file
|
||||
|
||||
`svcs -L apache`
|
||||
|
||||
- display end of a service log file
|
||||
|
||||
`tail $(svcs -L apache)`
|
Reference in New Issue
Block a user