├── .gitignore ├── LICENSE ├── README.md ├── bin ├── marker └── marker.sh ├── install.py ├── marker ├── __init__.py ├── ansi.py ├── command.py ├── core.py ├── filter.py ├── keys.py ├── readchar.py ├── renderer.py ├── string_score.py └── tldr.py └── tldr ├── common.txt ├── linux.txt ├── osx.txt └── sunos.txt /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | 5 | # C extensions 6 | *.so 7 | 8 | # Distribution / packaging 9 | .Python 10 | env/ 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | *.egg-info/ 23 | .installed.cfg 24 | *.egg 25 | 26 | # PyInstaller 27 | # Usually these files are written by a python script from a template 28 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 29 | *.manifest 30 | *.spec 31 | 32 | # Installer logs 33 | pip-log.txt 34 | pip-delete-this-directory.txt 35 | 36 | # Unit test / coverage reports 37 | htmlcov/ 38 | .tox/ 39 | .coverage 40 | .coverage.* 41 | .cache 42 | nosetests.xml 43 | coverage.xml 44 | *,cover 45 | 46 | # Translations 47 | *.mo 48 | *.pot 49 | 50 | # Django stuff: 51 | *.log 52 | 53 | # Sphinx documentation 54 | docs/_build/ 55 | 56 | # PyBuilder 57 | target/ 58 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 amine hajyoussef 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Marker 2 | 3 | ![marker](https://cloud.githubusercontent.com/assets/2557967/14209204/d99db934-f81a-11e5-910c-9d34ac155d18.gif) 4 | 5 | Marker is a command palette for the terminal. It lets you bookmark commands (or commands templates) and easily retreive them with the help of a real-time fuzzy matcher. 6 | 7 | It's also shipped with many commands common usage(Thanks to [tldr](https://github.com/tldr-pages/tldr)). 8 | 9 | ## Features: 10 | - A UI selector that lets you easily select the desired command if more than one command is matched. 11 | - Fuzzy matching (through commands and their descriptions). 12 | - Command template: You can bookmark commands with place-holders and place the cursor at those place-holders using a keyboard shortcut. 13 | - Portability across supported shells: you can use bookmarked commands in both Bash and Zshell. 14 | 15 | ## Usage 16 | - `Ctrl-space`: search for commands that match the current written string in the command-line. 17 | - `Ctrl-k` (or `marker mark`): Bookmark a command. 18 | - `Ctrl-t`: place the cursor at the next placeholder, identified by '{{anything}}' 19 | - `marker remove`: remove a bookmark 20 | 21 | You can customize key binding using environment variables, respectively with ```MARKER_KEY_GET```, ```MARKER_KEY_MARK``` and ```MARKER_KEY_NEXT_PLACEHOLDER```. 22 | 23 | ## Requirements 24 | - python (2.7+ or 3.0+) 25 | - Bash-4.3+ or Zshell. 26 | - Linux Or OSX 27 | 28 | ##### Note: 29 | In OSX, it seems like Bash 3.x is the default shell which is not supported. you have to [update your Bash to 4.3+](http://apple.stackexchange.com/a/24635) or [change your shell to zshell](http://stackoverflow.com/a/1822126/1117720) in order to use Marker. 30 | 31 | ## Installation 32 | 33 | `git clone --depth=1 https://github.com/pindexis/marker ~/.marker && ~/.marker/install.py` 34 | 35 | ## License 36 | [MIT](LICENSE) 37 | -------------------------------------------------------------------------------- /bin/marker: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | from __future__ import print_function 3 | import sys 4 | import argparse 5 | import os 6 | sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)),'..')) 7 | from marker import core 8 | 9 | def parse_arguments(): 10 | parser = argparse.ArgumentParser(description="Marker: a tool to quickly bookmark and retreive commands") 11 | subparsers = parser.add_subparsers(title="commands", dest="subparser_name") 12 | 13 | parser_mark = subparsers.add_parser("mark", help="mark a command") 14 | parser_mark.add_argument("--command", type=str, help="Command to mark") 15 | parser_mark.add_argument("--alias", type=str, help="an alias of the command") 16 | parser_mark.set_defaults(func=cmd_mark) 17 | 18 | parser_get = subparsers.add_parser("get", help="get marker commands that match a given search string") 19 | parser_get.add_argument("--search", type=str, help="Search string") 20 | parser_get.add_argument("--stdout", type=str, help="Where to store result(defaut to stdout)") 21 | parser_get.set_defaults(func=cmd_get) 22 | 23 | parser_get = subparsers.add_parser("remove", help="remove a marked command given an optionnal prefix") 24 | parser_get.add_argument("--search", type=str, help="Search string") 25 | parser_get.set_defaults(func=cmd_remove) 26 | 27 | parser_update = subparsers.add_parser("update", help="update tldr cache") 28 | parser_update.set_defaults(func=cmd_update) 29 | 30 | args = parser.parse_args() 31 | return args.func(args) 32 | 33 | 34 | def cmd_mark(args): 35 | core.mark_command(args.command, None) 36 | 37 | 38 | def cmd_get(args): 39 | output = core.get_selected_command_or_input(args.search) 40 | if args.stdout: 41 | with open(args.stdout,'w+') as save_file: 42 | # the newline character is to make sure 'wc -l' executes correctly 43 | if output: 44 | output+="\n" 45 | save_file.write(output) 46 | else: 47 | print(output) 48 | 49 | 50 | def cmd_remove(args): 51 | core.remove_command(args.search) 52 | 53 | def cmd_update(): 54 | core.update_cache() 55 | 56 | def marker_sourced(): 57 | if os.getenv('MARKER_DATA_HOME'): 58 | return True 59 | return False 60 | 61 | if __name__ == "__main__": 62 | if not marker_sourced(): 63 | print("Please source marker file in your shell's") 64 | sys.exit(1) 65 | parse_arguments() 66 | -------------------------------------------------------------------------------- /bin/marker.sh: -------------------------------------------------------------------------------- 1 | # I rather aliasing Marker than add it to the global variable $PATH or pollute /usr/local directory 2 | # this will make uninstalling easier and it's sufficient(for now) 3 | alias marker="${MARKER_HOME}/bin/marker" 4 | 5 | # default key bindings 6 | marker_key_mark="${MARKER_KEY_MARK:-\C-k}" 7 | marker_key_get="${MARKER_KEY_GET:-\C-@}" 8 | marker_key_next_placeholder="${MARKER_KEY_NEXT_PLACEHOLDER:-\C-t}" 9 | 10 | function get_cursor_position(){ 11 | # based on a script from http://invisible-island.net/xterm/xterm.faq.html 12 | exec < /dev/tty 13 | echo -en "\033[6n" > /dev/tty 14 | IFS=';' read -r -d R row col 15 | # change from one-based to zero based so they work with: tput cup $row $col 16 | row=$((${row:2} - 1)) # strip off the esc-[ 17 | col=$((${col} - 1)) 18 | echo "$row $col" 19 | } 20 | function get_col_position(){ 21 | echo $(get_cursor_position) | cut -f 2 -d " " 22 | } 23 | function get_row_position(){ 24 | echo $(get_cursor_position) | cut -f 1 -d " " 25 | } 26 | function place_cursor_next_line(){ 27 | = 32: 108 | state.set_input(state.input + chr(c)) 109 | renderer.refresh(state) 110 | return output 111 | 112 | class State(object): 113 | ''' The app State, including user written characters, matched commands, and selected one ''' 114 | 115 | def __init__(self, bookmarks, default_input): 116 | self.bookmarks = bookmarks 117 | self._selected_command_index = 0 118 | self.matches = [] 119 | self.default_input = default_input 120 | self.set_input(default_input) 121 | 122 | def get_matches(self): 123 | return self.matches 124 | 125 | def reset_input(self): 126 | self.input = self.default_input 127 | 128 | def set_input(self, input): 129 | self.input = input if input else "" 130 | self._update() 131 | 132 | def clear_input(self): 133 | self.set_input("") 134 | 135 | def clear_selection(self): 136 | self._selected_command_index = 0 137 | 138 | def select_next(self): 139 | self._selected_command_index = (self._selected_command_index + 1) % len(self.matches) if len(self.matches) else 0 140 | 141 | def select_previous(self): 142 | self._selected_command_index = (self._selected_command_index - 1) % len(self.matches) if len(self.matches) else 0 143 | 144 | def _update(self): 145 | self.matches = filter_commands(self.bookmarks, self.input) 146 | self._selected_command_index = 0 147 | 148 | def get_selected_match(self): 149 | if len(self.matches): 150 | return self.matches[self._selected_command_index] 151 | else: 152 | raise 'No matches found' 153 | -------------------------------------------------------------------------------- /marker/filter.py: -------------------------------------------------------------------------------- 1 | from . import string_score 2 | import re 3 | 4 | def filter_commands(marks, search_string): 5 | ''' return the list of marks that match a given search string 6 | A mark is considered a match if: 7 | - all words in the search string except the last one must have exact match, meaning they are present in either the command or the alias 8 | - for the last word, it can be contained in any word in the command or alias 9 | For example: 'cd tonowhere' will match 'c','cd n' but not 'c ', 'c t' 10 | ''' 11 | def sort_marks(marks, search_string): 12 | return sorted( 13 | marks, 14 | key=lambda m:(string_score.score(m.cmd, search_string)*2 + string_score.score(m.alias, search_string)), 15 | reverse=True 16 | ) 17 | def contained(candidate, container): 18 | tmp = container[:] 19 | try: 20 | for i, word in enumerate(candidate): 21 | if i == len(candidate) - 1: 22 | if any(word in c for c in tmp): 23 | return True 24 | else: 25 | return False 26 | else: 27 | tmp.remove(word) 28 | except ValueError: 29 | return False 30 | # Remove extra spaces 31 | # keep a space if it is at the end of string, since it means that a whole word must be matched 32 | search_string = search_string.lstrip() 33 | if not search_string: 34 | return sort_marks(marks, "") 35 | 36 | filtered_bookmarks = [] 37 | words_re = re.compile('\w+') 38 | search_words = words_re.findall(search_string.lower()) 39 | for mark in marks: 40 | mark_splitted = words_re.findall(mark.cmd.lower()) + words_re.findall(mark.alias.lower()) 41 | if contained(search_words, mark_splitted): 42 | filtered_bookmarks.append(mark) 43 | 44 | return sort_marks(filtered_bookmarks, search_string) 45 | -------------------------------------------------------------------------------- /marker/keys.py: -------------------------------------------------------------------------------- 1 | CTRL_C = 3 # Ctrl-c 2 | ENTER = 13 # Enter 3 | CTRL_U = 21 # Ctrl+u 4 | ESC = 27 # Escape 5 | BACKSPACE = 127 # Backspace 6 | TAB = 9 # Tab 7 | RIGHT = -1 # FAKE CODE to abstract away the fact that a multibyte string is needed to represent arrow keys 8 | DOWN = -2 # same 9 | UP = -3 # same 10 | LEFT = -4 # same 11 | -------------------------------------------------------------------------------- /marker/readchar.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import tty 3 | import termios 4 | import fcntl 5 | import os 6 | from . import keys 7 | 8 | def get_symbol(): 9 | ''' Read a symbol, which can be a single byte character or a multibyte string''' 10 | ch = read_char() 11 | ch_code = ord(ch) 12 | # check for multibyte string 13 | if ch_code == keys.ESC: 14 | ch = read_char_no_blocking() 15 | if ch == '': 16 | # ESC key pressed 17 | return keys.ESC 18 | elif ch != 'O' and ch != '[': 19 | return ord(ch) 20 | else: 21 | ch = read_char_no_blocking() 22 | if ch == 'A': 23 | return keys.UP 24 | elif ch == 'B': 25 | return keys.DOWN 26 | elif ch == 'C': 27 | return keys.RIGHT 28 | elif ch == 'D': 29 | return keys.LEFT 30 | return ch_code 31 | 32 | 33 | def read_char(): 34 | ''' Read a character ''' 35 | fd = sys.stdin.fileno() 36 | old_settings = termios.tcgetattr(fd) 37 | try: 38 | tty.setraw(fd, termios.TCSADRAIN) 39 | ch = sys.stdin.read(1) 40 | finally: 41 | termios.tcsetattr(fd, termios.TCSADRAIN, old_settings) 42 | return ch 43 | 44 | 45 | def read_char_no_blocking(): 46 | ''' Read a character in nonblocking mode, if no characters are present in the buffer, return an empty string ''' 47 | fd = sys.stdin.fileno() 48 | old_settings = termios.tcgetattr(fd) 49 | old_flags = fcntl.fcntl(fd, fcntl.F_GETFL) 50 | try: 51 | tty.setraw(fd, termios.TCSADRAIN) 52 | fcntl.fcntl(fd, fcntl.F_SETFL, old_flags | os.O_NONBLOCK) 53 | return sys.stdin.read(1) 54 | except IOError as e: 55 | ErrorNumber = e[0] 56 | # IOError with ErrorNumber 11(35 in Mac) is thrown when there is nothing to read(Resource temporarily unavailable) 57 | if (sys.platform.startswith("linux") and ErrorNumber != 11) or (sys.platform == "darwin" and ErrorNumber != 35): 58 | raise 59 | return "" 60 | finally: 61 | fcntl.fcntl(fd, fcntl.F_SETFL, old_flags) 62 | termios.tcsetattr(fd, termios.TCSADRAIN, old_settings) 63 | -------------------------------------------------------------------------------- /marker/renderer.py: -------------------------------------------------------------------------------- 1 | import os 2 | from . import ansi 3 | import re 4 | import math 5 | import sys 6 | '''Command line user interface''' 7 | 8 | def _get_terminal_columns(): 9 | ''' get the number of terminal columns, used to determine spanned lines of a mark(required for cursor placement) ''' 10 | rows, columns = os.popen('stty size', 'r').read().split() 11 | # the -1 is to keep the command prompt displayed 12 | return int(rows) - 1, int(columns) 13 | 14 | def unicode_length(string): 15 | if sys.version_info[0] == 2: 16 | return len(string.decode('utf-8')) 17 | else: 18 | return len(string) 19 | 20 | def erase(): 21 | ''' the commandline cursor is always at the first line (Marker prompt) 22 | Therefore, erasing the current and following lines clear all marker output 23 | ''' 24 | ansi.move_cursor_line_beggining() 25 | ansi.erase_from_cursor_to_end() 26 | 27 | def refresh(state): 28 | ''' Redraw the output, this function will be triggered on every user interaction(key pressed)''' 29 | erase() 30 | lines, num_rows = _construct_output(state) 31 | for line in lines[:-1]: 32 | print(line) 33 | # new new line for the last result 34 | if(lines): 35 | sys.stdout.write(lines[-1]) 36 | # go up 37 | ansi.move_cursor_previous_lines(num_rows - 1) 38 | # palce the cursor at the end of first line 39 | ansi.move_cursor_horizental(len(lines[0])+1) 40 | ansi.flush() 41 | 42 | def _construct_output(state): 43 | rows, columns = _get_terminal_columns() 44 | ansi_escape = re.compile(r'\x1b[^m]*m') 45 | def number_of_rows(line): 46 | line = ansi_escape.sub('', line) 47 | return int(math.ceil(float(unicode_length(line))/columns)) 48 | displayed_lines = [] 49 | # Number of terminal rows spanned by the output, used to determine how many lines we need to go up(to place the cursor after the prompt) after displaying the output 50 | num_rows = 0 51 | prompt_line = 'search for: ' + state.input 52 | displayed_lines.append(prompt_line) 53 | num_rows += number_of_rows(prompt_line) 54 | matches = state.get_matches() 55 | if matches: 56 | # display commands from Max(0,selected_command_index - 10 +1 ) to Max(10,SelectedCommandIndex + 1) 57 | selected_command_index = matches.index(state.get_selected_match()) 58 | num_results = 10 59 | matches_to_display = [] 60 | while (True): 61 | filtered_matches = matches[max(0, selected_command_index - num_results + 1):max(num_results, selected_command_index + 1)] 62 | filtered_matches_rows = sum(number_of_rows(' ' + str(el)) for el in filtered_matches) 63 | if rows - num_rows < filtered_matches_rows: 64 | num_results -= 1 65 | else: 66 | matches_to_display = filtered_matches 67 | break 68 | for index, m in enumerate(matches_to_display): 69 | fm = ' '+str(m) 70 | num_rows += number_of_rows(fm) 71 | # Formatting text(make searched word bold) 72 | for w in state.input.split(' '): 73 | if w: 74 | fm = fm.replace(w, ansi.bold_text(w)) 75 | # highlighting selected command 76 | if m == state.get_selected_match(): 77 | fm = ansi.select_text(fm) 78 | displayed_lines.append(fm) 79 | else: 80 | not_found_line = 'Nothing found' 81 | displayed_lines.append(not_found_line) 82 | num_rows += number_of_rows(not_found_line) 83 | return displayed_lines, num_rows 84 | 85 | -------------------------------------------------------------------------------- /marker/string_score.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | # stringslipper.py: Quicksilver-like string scoring. 4 | # Copyright (C) 2010 Yesudeep Mangalapilly 5 | # Copyright (C) 2009 Joshaven Potter 6 | # 7 | # Permission is hereby granted, free of charge, to any person obtaining a copy 8 | # of this software and associated documentation files (the "Software"), to deal 9 | # in the Software without restriction, including without limitation the rights 10 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | # copies of the Software, and to permit persons to whom the Software is 12 | # furnished to do so, subject to the following conditions: 13 | # 14 | # The above copyright notice and this permission notice shall be included in 15 | # all copies or substantial portions of the Software. 16 | # 17 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | # THE SOFTWARE. 24 | 25 | def first_valid_index(a, b): 26 | min_index = min(a, b) 27 | if min_index > -1: 28 | return min_index 29 | return max(a, b) 30 | 31 | def score(string, abbreviation): 32 | """ 33 | Doctests: 34 | # Exact match 35 | >>> assert score("Hello world", "Hello world") == 1.0 36 | 37 | # Not matching 38 | >>> assert score("Hello world", "hellx") == 0 # non-existent character in match should return 0 39 | >>> assert score("Hello world", "hello_world") == 0 # non-existent character in match should return 0 40 | 41 | # Match must be sequential 42 | >>> assert score("Hello world", "WH") == 0 43 | >>> assert score("Hello world", "HW") > 0 44 | 45 | # Same case should match better than wrong case 46 | >>> assert score("Hello world", "hello") < score("Hello world", "Hello") 47 | 48 | # FAIL: Closer matches should have higher scores 49 | # score("Hello world", "H") < score("Hello world", "He") 50 | # True 51 | 52 | # Should match first matchable character regardless of case 53 | >>> score("Hillsdale Michigan", "himi") > 0 54 | True 55 | 56 | # Advanced scoring methods 57 | # Consecutive letter bonus 58 | >>> score("Hello World", "Hel") > score("Hello World", "Hld") 59 | True 60 | 61 | # Acronym bonus 62 | >>> score("Hello World", "HW") > score("Hello World", "ho") 63 | True 64 | >>> score("yet another Hello World", "yaHW") > score("Hello World", "yet another") 65 | True 66 | 67 | # score("Hillsdale Michigan", "HiMi") > score("Hillsdale Michigan", "Hil") 68 | # True 69 | 70 | >>> score("Hillsdale Michigan", "HiMi") > score("Hillsdale Michigan", "illsda") 71 | True 72 | >>> score("Hillsdale Michigan", "HiMi") > score("Hillsdale Michigan", "hills") 73 | True 74 | 75 | # Beginning of string bonus 76 | >>> score("Hillsdale", "hi") > score("Chippewa", "hi") 77 | True 78 | 79 | # Proper string weights 80 | >>> score("Research Resources North", "res") > score("Mary Conces", "res") 81 | True 82 | >>> score("Research Resources North", "res") > score("Bonnie Strathern - Southwest Michigan Title Search", "res") 83 | True 84 | 85 | # Start of string bonus 86 | >>> score("Mary Large", "mar") > score("Large Mary", "mar") 87 | True 88 | >>> score("Silly Mary Large", "mar") == score("Silly Large Mary", "mar") 89 | True 90 | 91 | # Examples 92 | >>> assert score("hello world", "ax1") == 0 93 | >>> assert score("hello world", "ow") > 0.14 94 | >>> assert score("hello world", "h") >= 0.09 95 | >>> assert score("hello world", "he") >= 0.18 96 | >>> assert score("hello world", "hel") >= 0.27 97 | >>> assert score("hello world", "hell") >= 0.36 98 | >>> assert score("hello world", "hello") >= 0.45 99 | 100 | >>> assert score("hello world", "helloworld") >= 0.5 # FAIL: Not 0.9 JS 101 | >>> assert score("hello world", "hello worl") >= 0.5 # FAIL: Not 0.9 JS 102 | >>> assert score("hello world", "hello world") == 1 103 | 104 | >>> assert score("Hello", "h") >= 0.13 105 | >>> assert score("He", "h") > 0.35 106 | 107 | # Same case matches better than wrong case. 108 | >>> assert score("Hello", "h") >= 0.13 109 | >>> assert score("Hello", "H") >= 0.2 110 | 111 | # FAIL: Acronyms are not given more weight. 112 | # assert score("Hillsdale Michigan", "HiMi") > score("Hillsdale Michigan", "Hills") 113 | # assert score("Hillsdale Michigan", "Hillsd") > score("Hillsdale Michigan", "HiMi") 114 | """ 115 | if string == abbreviation or not abbreviation: 116 | return 1.0 117 | 118 | total_character_score = 0 119 | start_of_string_bonus = False 120 | abbreviation_length = len(abbreviation) 121 | string_length = len(string) 122 | 123 | # Walk through the abbreviation and add up scores. 124 | for i, c in enumerate(abbreviation): 125 | # Find the first case-insensitive match of a character. 126 | c_lower = c.lower() 127 | c_upper = c.upper() 128 | index_in_string = first_valid_index(string.find(c_lower), string.find(c_upper)) 129 | 130 | # Bail out if the character is not found in string. 131 | if index_in_string == -1: 132 | return 0 133 | 134 | # Set base score for matching 'c'. 135 | character_score = 0.09 136 | 137 | # Case bonus 138 | if string[index_in_string] == c: 139 | character_score += 0.09 140 | 141 | # Consecutive letter and start of string bonus. 142 | if not index_in_string: # 0 == index_in_string 143 | # increase the score when matching first char of the remainder of the string. 144 | character_score += 0.79 145 | # If the match is the first letter of the string and first letter of abbr. 146 | if not i: # 0 == i 147 | start_of_string_bonus = True 148 | 149 | # Acronym bonus 150 | if string[index_in_string - 1] == ' ': 151 | character_score += 0.79 # * Math.min(index_in_string, 5); # cap bonus at 0.4 * 5 152 | 153 | # Only remaining substring will be searched in the next iteration. 154 | string = string[index_in_string+1:] 155 | 156 | # Add up score. 157 | total_character_score += character_score 158 | 159 | # Uncomment to weigh smaller words higher. 160 | # return total_character_score / string_length 161 | 162 | abbreviation_score = total_character_score / abbreviation_length 163 | percentage_of_matched_string = abbreviation_length / string_length 164 | word_score = abbreviation_score * percentage_of_matched_string 165 | final_score = (word_score + abbreviation_score)/2 # softens the penalty for longer strings. 166 | if start_of_string_bonus and (final_score + 0.09 < 1): 167 | final_score += 0.09 168 | return final_score 169 | -------------------------------------------------------------------------------- /marker/tldr.py: -------------------------------------------------------------------------------- 1 | 2 | def update(): 3 | pass 4 | 5 | -------------------------------------------------------------------------------- /tldr/common.txt: -------------------------------------------------------------------------------- 1 | 7za -v{{part_size}}{{[b|k|m|g]}} {{compressed.7z}} {{directory_or_file_to_compress}}##Create multipart 7zip file; `part_size` specifies part size in Bytes, Kilobytes, Megabytes or Gigabytes 2 | 7za a -tzip {{compressed.zip}} {{directory_or_file_to_compress}}##Compress to zip format 3 | 7za a {{compressed.7z}} {{directory_or_file_to_compress}}##Compress directory or file 4 | 7za x {{compressed.7z}}##Decompress an existing 7z file with original directory structure 5 | AUTOSSH_DEBUG=1 AUTOSSH_LOGFILE={{log_file}} autossh -f -M {{monitor_port}} -v -E {{ssh_logfile}} {{ssh_command}}##Run autossh in the background with debug output logged to a file and ssh verbose output logged to a second file 6 | HandBrakeCLI --preset-list##List available presets 7 | HandBrakeCLI --preset="Android" -i {{input.ext}} -o {{output.mp4}}##Convert an AVI video to MP4 using the Android preset 8 | HandBrakeCLI -i {{input.avi}} -o {{output.mkv}} -e x264 -q 20 -B 160##Convert a video file to MKV (AAC 160kbit audio and x264 CRF20 video) 9 | HandBrakeCLI -i {{input.mp4}} -o {{output.mp4} -w 320 -l 240##Resize a video file to 320x240 10 | MP4Box -add {{input-subs.srt}}:lang=eng -add {{input.mp4}} {{output.mp4}}##Add an SRT subtitle file into an MP4 file 11 | MP4Box -add {{input1.mp4}}#audio -add {{input2.mp4}}#video {{output.mp4}##Combine audio from one file and video from another 12 | MP4Box -info {{filename}}##Display information about an existing MP4 file 13 | ab -n 100 -c 10 {{url}}##Execute 100 HTTP GET requests, processing up to 10 requests concurrently, to given URL 14 | ab -n 100 {{url}}##Execute 100 HTTP GET requests to given URL 15 | ack --ruby {{each_with_object}}##Find files in a specific language 16 | ack -ch {{foo}}##Count the total number of matches for the term "foo" 17 | ack -cl {{foo}}##Show the file names containing "foo" and number of matches in each file 18 | ack {{foo}}##Find files containing "foo" 19 | adb install -r {{apk.path}}##Push an Android application to an emulator/device 20 | adb kill-server##Terminate the adb server process 21 | adb shell##Start a remote shell in the target emulator/device instance 22 | adb start-server##Check whether the adb server process is running and start it 23 | ag '^ba(r|z)$'##Find files whose contents match a regular expression 24 | ag -g foo##Find files with a name matching "foo" 25 | ag -i FOO##Find files containing "FOO" case-insensitively 26 | ag foo -G bar##Find "foo" in files with a name matching "bar" 27 | ag foo##Find files containing "foo" 28 | alias -p##Full list of aliased words 29 | alias {{la}}="{{ls -a}}"##Override la as ls -a 30 | alias {{rm}}="{{rm -i}}"##Turn rm an interative command 31 | alias {{word}}="{{command}}"##Create a generic alias 32 | apm install {{package_name}}##Install packages from http://atom.io/packages and themes from http://atom.io/themes 33 | apm remove {{package_name}}##Remove packages/themes 34 | apm upgrade {{package_name}}##Upgrade packages/themes 35 | apropos -l {{regular_expression}}##Search without restricting output to terminal width 36 | apropos {{regular_expression}}##Search for keyword 37 | ar -r {{libfoo.a}} {{foo.o}} {{bar.o}} {{baz.o}}##Replace or add files to an archive 38 | ar -rs {{libfoo.a}} {{foo.o}} {{bar.o}} {{baz.o}}##Create an archive with files and an accompanying object file index 39 | ar -s {{libfoo.a}}##Insert an object file index (equivalent to using `ranlib`) 40 | ar -t {{libfoo.a}}##List the members of an archive 41 | ar -x {{libfoo.a}}##Extract all members from an archive 42 | aria2c --ftp-user={{username}} --ftp-passwd={{password}} {{url}}##FTP download with username and password 43 | aria2c -i {{filename}}##Download the URIs listed in a file 44 | aria2c -s {{connections_num}} {{url}}##Download with multiple connections 45 | aria2c {{url_1}} {{url_2}}##Download from multiple sources 46 | aria2c {{url}}##Download a URI to a file 47 | arp -a##Show current arp table 48 | arp -d {{address}}##Delete a specific entry 49 | arp -s {{address}} {{mac address}}##Create an entry 50 | atom -n {{path/to/file/or/folder}}##Open a file or folder in a new window 51 | atom {{path/to/file/or/folder}}##Open a file or folder 52 | autossh -M {{monitor_port}} -L {{local_port}}:localhost:{{remote_port}} {{user}}@{{host}}##Open an SSH session which forwards a local port to a remote one, restarting if necessary 53 | autossh -M {{monitor_port}} {{ssh_command}}##Open an SSH session, restarting when a monitoring port fails return data 54 | autossh -f -M 0 -N -o "ServerAliveInterval 10" -o "ServerAliveCountMax 3" {{ssh_command}}##Run autossh in the background, with no monitoring port, instead relying on SSH keep-alives every 10 seconds to detect failure 55 | autossh -f -M 0 -N -o "ServerAliveInterval 10" -o "ServerAliveCountMax 3" -o ExitOnForwardFailure=yes -L {{local_port}}:localhost:{{remote_port}} {{user}}@{{host}}##Run autossh in the background, with no monitoring port, no remote shell, exiting if the port forward fails 56 | autossh -f -M {{monitor_port}} -N {{ssh_command}}##Fork before executing ssh (runs in the background) and don't open a remote shell 57 | awk '/{{something}}/ {print $2}' {{filename}}##Print the second column of the lines containing "something" in a space separated file 58 | awk '{print $5}' {{filename}}##Print the fifth column in a space separated file 59 | awk '{s+=$1; print $1} END {print "--------"; print s}' {{filename}}##Sum the values in the first column and pretty-print the values and then the total 60 | awk '{s+=$1} END {print s}' {{filename}}##Sum the values in the first column and print the total 61 | awk -F ',' '{print $3}' {{filename}}##Print the third column in a comma separated file 62 | axel -S {{mirrors_num}} {{url}}##Search for mirrors 63 | axel -n {{connections_num}} {{url}}##Download with multiple connections 64 | axel -s {{speed}} {{url}}##Limit download speed (bytes per second) 65 | axel {{url}} -o {{filename}}##Download and specify filename 66 | axel {{url}}##Download a URL to a file 67 | base32 -d {{filename}}##Decode a file 68 | base32 {{filename}}##Encode a file 69 | base64 -d {{filename}}##Decode a file 70 | base64 {{filename}}##Encode a file 71 | basename {{path/to/file}} {{suffix}}##Show only the file name from a path, with a suffix removed 72 | basename {{path/to/file}}##Show only the file name from a path 73 | bash -c {{command}}##Execute a command 74 | bash -s##Run commands from STDIN 75 | bash {{file.sh}}##Run commands from a file 76 | bash##Start interactive shell 77 | bc -i##Run calculator in interactive mode 78 | bc -l <<< "s(1) + c(1)"##Calculate expression with sine and cosine using mathlib 79 | bc <<< "(1 + 2) * 2 ^ 2"##Calculate the result of an expression 80 | bc <<< "scale=10; 5 / 3"##Calculate with the given precision 81 | bmaptool copy --bmap {{blockmap.bmap}} {{source.img.gz}} {{/dev/sdb}}##Copy a compressed image file into sdb 82 | bmaptool copy --bmap {{blockmap.bmap}} {{source.img}} {{/dev/sdb}}##Copy an image file into sdb 83 | bmaptool copy --nobmap {{source.img}} {{/dev/sdb}}##Copy an image file into sdb without using a blockmap 84 | bmaptool create -o {{blockmap.bmap}} {{source.img}}##Create a blockmap from image file 85 | bundle gem {{gemname}}##Create a new gem skeleton 86 | bundle install##Install all gems defined in the gemfile expected in the working directory 87 | bundle update --source {{gemname}}##Update one specific gem defined in the gemfile 88 | bundle update##Update all gems by the rules defined in the gemfile and regenerate gemfile.lock 89 | c99 -c {{file.c}}##Compile source file(s) and create object file(s) 90 | c99 -o {{executable_name}} {{file.c}}##Compile source file(s) and create an executable with a custom name 91 | c99 {{file.c}} {{file.o}}##Compile source file(s), link with object file(s), and create an executable 92 | c99 {{file.c}}##Compile source file(s) and create an executable 93 | cal -m {{month_number}}##Display a calendar for a specific month 94 | cal -y##Display a 12 month calendar for the current year 95 | cal 2016##Display a 12 month calendar for a specific year 96 | cal##Display a calendar for the current month 97 | calibre-server --port {{port}}##Start server on different port. Access at http://localhost:port 98 | calibre-server --username {{username}} --password {{password}}##Password protect the server 99 | calibre-server##Start a server to distribute ebooks. Access at http://localhost:8080 100 | calibredb add {{file1 file2 …}}##Add one or more ebooks to the library 101 | calibredb list --search {{search-term}}##Search for ebooks displaying additional information 102 | calibredb list##List ebooks in the library with additional information 103 | calibredb remove {{id1 id2 …}}##Remove one or more ebooks from the library. You need ebook-ids (see above) 104 | calibredb search {{search term}}##Search for just ids of ebooks 105 | cat -n {{file}}##Number all output lines 106 | cat data.txt | http PUT example.org##Specify raw request body via stdin 107 | cat somefile.txt | nc -l {{port}}##Serve a file 108 | cat {{/path/to/file}} | lwp-request -m POST {{http://example.com/some/path}}##Upload a file with a POST request 109 | cat {{bigfile.txt}} | parallel --pipe --block 1M {{command}}##Break stdin into ~1M blocks, feed each block to stdin of new command 110 | cat {{data.json}} | in2csv -f json > {{data.csv}}##Pipe a JSON file to in2csv 111 | cat {{file1}} {{file2}} > {{target-file}}##Concatenate several files into the target file 112 | cat {{file1}} {{file2}} >> {{target-file}}##Append several files into the target file 113 | cat {{file1}} | comm -12 - {{file2}}##Print only lines common to both files, read one file from stdin 114 | cat {{file_path}} | grep {{something}}##Use the standard input instead of a file 115 | cat {{file}}##Print the contents of a file to the standard output 116 | cd -##Go to the previously chosen directory 117 | cd ..##Go up to the parent of the current directory 118 | cd {{/path/to/directory}}##Go to the given directory 119 | cd##Go to home directory of current user 120 | chgrp --reference={{path/to/reference_file}} {{path/to/file}}##Change the owner group of a file/folder to match a reference file 121 | chgrp -R {{group}} {{path/to/folder}}##Recursively change the owner group of a folder and its contents 122 | chgrp -h {{user}} {{path/to/symlink}}##Change the owner group of a symbolic link 123 | chgrp {{group}} {{path/to/file}}##Change the owner group of a file/folder 124 | chmod a+rx {{file}}##Give (a)ll users rights to read and execute 125 | chmod g-x {{file}}##Remove executable rights from the (g)roup 126 | chmod o=g {{file}}##Give (o)thers (not in the file owner's group) the same rights as the group 127 | chmod u+rw {{file}}##Give the user rights to (r)ead and (w)rite to a file/directory 128 | chmod u+x {{file}}##Give the (u)ser who owns a file the right to e(x)ecute it 129 | chown --reference={{path/to/reference_file}} {{path/to/file}}##Change the owner of a file/folder to match a reference file 130 | chown -R {{user}} {{path/to/folder}}##Recursively change the owner of a folder and its contents 131 | chown -h {{user}} {{path/to/symlink}}##Change the owner of a symbolic link 132 | chown {{user}} {{path/to/file}}##Change the owner user of a file/folder 133 | chown {{user}}:{{group}} {{path/to/file}}##Change the owner user and group of a file/folder 134 | chsh -s {{path/to/shell_binary}} {{username}}##Change shell 135 | cksum {{filename}}##Display a 32 bit checksum, size in bytes and filename 136 | clang {{input_source.c}} -Wall -o {{output_executable}}##Activate output of all errors and warnings 137 | clang {{input_source.c}} -o {{output_executable}} -I{{header_path}} -L{{library_path}} -l{{library_name}}##Include libraries located at a different path than the source file 138 | clang {{input_source.c}} -o {{output_executable}}##Compile a source code file into an executable binary 139 | cmp -l {{file1}} {{file2}}##Find the byte number and differing bytes of every difference 140 | cmp {{file1}} {{file2}}##Find the byte number and line number of the first difference between the files 141 | comm -12 {{file1}} {{file2}}##Print only lines common to both files 142 | comm -13 {{file1}} {{file2}}##Print lines only found in second file 143 | comm -23 {{file1}} {{file2}}##Print lines only found in first file 144 | comm {{file1}} {{file2}}##Produce three tab-separated columns: lines only in first file, lines only in second file and common lines 145 | command1 | pv -s {{expected_amount_of_data_for_eta}} | command2##Measure the speed and amount of data flow between pipes (`-s` is optional) 146 | convert {{image.jpg}} {{image.png}}##Convert an image from JPG to PNG 147 | convert {{image.png}} -resize 50% {{image2.png}}##Scale an image 50% it's original size 148 | convert {{image.png}} -resize 640x480 {{image2.png}}##Scale an image keeping the original aspect ratio to a maximum dimension of 640x480 149 | convert {{image1.png}} {{image2.png}} {{image3.png}} +append {{image123.png}}##Horizontally append images 150 | convmv -f {{from_encoding}} -t {{to_encoding}} --notest {{input_file}}##Convert filename encoding and rename the file to the new enconding 151 | convmv -f {{from_encoding}} -t {{to_encoding}} {{input_file}}##Test filename encoding conversion (don't actually change the filename) 152 | cordova create {{path}} {{package.name}} {{project.name}}##Create a cordova project 153 | cordova info##Display the current workspace status 154 | cordova platform add {{platform}}##Add a cordova platform 155 | cordova platform remove {{platform}}##Remove a cordova platform 156 | cordova plugin add {{pluginid}}##Add a cordova plugin 157 | cordova plugin remove {{pluginid}}##Remove a cordova plugin 158 | cowsay "Hello world!"##Print an ASCII cow saying "Hello world!" 159 | cowthink -s "I'm just a cow, not a great thinker ..."##Print a stoned thinking ASCII cow 160 | cp -r {{/path/to/original}} {{/path/to/copy}}##Copy directories recursive using the option -r 161 | cp -vr {{/path/to/original}} {{/path/to/copy}}##Show files as they are copied 162 | cp {{/path/to/original}} ../{{path/to/copy}}##Copy a file to a parent directory 163 | cp {{/path/to/original}} {{/path/to/copy}}##Copy files in arbitrary locations 164 | cp {{file.html}}{,.backup}##Make a copy of a file, adding an extension 165 | cp {{file.}}{html,backup}##Make a copy of a file, changing the extension 166 | crontab -e##Edit the crontab file for the current user 167 | crontab -l##View a list of existing cron jobs for current user 168 | crontab -r##Remove all cron jobs for the current user 169 | csvclean -n {{bad.csv}}##List locations of syntax errors in a CSV file 170 | csvclean {{bad.csv}}##Clean a CSV file 171 | csvcut -C {{4}} {{data.csv}}##Extract all columns **except** the fourth one 172 | csvcut -c {{1,3}} {{data.csv}}##Extract the first and third columns 173 | csvcut -c {{id,"first name"}} {{data.csv}}##Extract the columns named "id" and "first name" (in that order) 174 | csvcut -n {{data.csv}}##Print indices and names of all columns 175 | csvformat -D "{{custom_character}}" {{data.csv}}##Convert delimiters to a custom character 176 | csvformat -M "{{\r\n}}" {{data.csv}}##Convert line endings to carriage return (^M) + line feed 177 | csvformat -T {{data.csv}}##Convert to a tab-delimited file (TSV) 178 | csvformat -U 0 {{data.csv}}##Minimize use of quote characters 179 | csvformat -U 1 {{data.csv}}##Maximize use of quote characters 180 | csvgrep -c {{1}} -m {{string_to_match}} {{data.csv}}##Find rows that have a certain string in column 1 181 | csvgrep -c {{3,4}} -r {{regex_pattern}} {{data.csv}}##Find rows in which columns 3 or 4 match a certain regex pattern 182 | csvgrep -i -c {{name}} -m {{"John Doe"}} {{data.csv}}##Find rows in which the "name" column does NOT include the string "John Doe" 183 | csvlook {{data.csv}}##View a CSV file 184 | csvpy --dict {{data.csv}}##Load a CSV file into a `CSVKitDictReader` object 185 | csvpy {{data.csv}}##Load a CSV file into a `CSVKitReader` object 186 | csvsort --no-inference -c {{columns}} {{data.csv}}##Sort a CSV file without inferring data types 187 | csvsort -c {{2,4}} {{data.csv}}##Sort a CSV file by column 2, then by column 4 188 | csvsort -c {{9}} {{data.csv}}##Sort a CSV file by column 9 189 | csvsort -r -c {{name}} {{data.csv}}##Sort a CSV file by the "name" column in descending order 190 | csvstat --sum {{data.csv}}##Show sums for all columns 191 | csvstat -c {{2,4}} {{data.csv}}##Show all stats for columns 2 and 4 192 | csvstat -c {{3}} --len {{data.csv}}##Show the max value length for column 3 193 | csvstat -c {{name}} --unique {{data.csv}}##Show the number of unique values in the "name" column 194 | csvstat {{data.csv}}##Show all stats for all columns 195 | curl "{{URL}}" -o {{filename}}##Download a URL to a file 196 | curl --data {{name=bob}} {{http://localhost/form}}##Send form-encoded data 197 | curl --head {{http://localhost}}##Head request 198 | curl -H "{{X-MyHeader: 123}}" {{http://localhost}}##Include an extra header 199 | curl -X POST -H "Content-Type: application/json" -d {{'{"name":"bob"}'}} {{http://localhost/login}}##Send JSON data 200 | curl -X {{DELETE}} {{http://localhost/item/123}}##Specify an HTTP method 201 | curl -u myusername:mypassword {{http://localhost}}##Pass a user name and password for server authentication 202 | cut -c {{1-16}} {{file}}##Cut out the first sixteen characters of each line of the given files 203 | cut -c {{1-16}}##Cut out the first sixteen characters of each line of STDIN 204 | cut -c{{3-}}##Cut out everything from the 3rd character to the end of each line 205 | cut -d'{{:}}' -f{{5,10}}##Cut out the fields five and 10, split on the colon character of each line 206 | cut -d'{{:}}' -f{{5-10}}##Cut out the fields five through 10, split on the colon character of each line 207 | cut -d'{{:}}' -f{{5}}##Cut out the fifth field, split on the colon character of each line 208 | date +"%c"##Display the date using the default locale 209 | date -u +"%Y-%m-%dT%H:%M:%SZ"##Display the date in UTC and ISO 8601 format 210 | deactivate##Stop the environment 211 | deluser -r {{name}}##Remove a user along with their home directory and mail spool 212 | deluser {{name}} {{group}}##Remove a user from a group 213 | deluser {{name}}##Remove a user 214 | df -h##Display all file systems and their disk usage in human readable form 215 | df##Display all file systems and their disk usage 216 | dhcpwn --interface {{network_interface}} flood --count {{number_of_requests}}##Flood the network with IP requests 217 | dhcpwn --interface {{network_interface}} sniff##Sniff local DHCP traffic 218 | diff -r {{directory1}} {{directory2}}##Compare directories recursively 219 | diff -rq {{directory1}} {{directory2}}##Compare directories, only showing the names of files that differ 220 | diff -w {{file1}} {{file2}}##Compare files, ignoring white spaces 221 | diff -y {{file1}} {{file2}}##Compare files, showing differences side by side 222 | diff {{file1}} {{file2}}##Compare files 223 | dig +short {{hostname.com}} MX##Lookup the mail server associated with a given domain name (MX record) 224 | dig +short {{hostname.com}}##Lookup the IP(s) associated with a hostname (A records) 225 | dig @8.8.8.8 {{hostname.com}}##Specify an alternate DNS server to query (8.8.8.8 is google's public DNS) 226 | dirs +{{N}}##Display only the nth entry in the directory stack, starting at 0 227 | dirs -c##Clear the directory stack 228 | dirs -p##Display the directory stack with one entry per line 229 | dirs##Display the directory stack with a space between each entry 230 | docker exec {{container}} {{command}}##Run a command inside of an already running container 231 | docker ps -a##List all docker containers (running and stopped) 232 | docker ps##List of running docker containers 233 | docker run -it {{image}} bash##Start a container from an image and get a shell inside of it 234 | docker start {{container}}##Start a container 235 | docker stop {{container}}##Stop a container 236 | dokku apps##List runinng apps 237 | dokku apps:create {{app_name}}##Create an app 238 | dokku apps:destroy {{app_name}}##Remove an app 239 | dokku plugin:install {{full_repo_url}}##Install plugin 240 | dokku {{db}}:link {{db_name}} {{app_name}}##Link database to an app 241 | drush cc all##Clear all caches 242 | drush cc css-js##Clear CSS and JavaScript caches 243 | drush dis {{foo}}##Disable module "foo" 244 | drush dl {{foo}}##Download module "foo" 245 | drush dl {{foo}}-7.x-2.1-beta1##Download version 7.x-2.1-beta1 of module "foo" 246 | drush en {{foo}}##Enable module "foo" 247 | ebook-convert {{source}} {{destination}}##Convert an ebook into another format 248 | echo "Hello!" | cowsay -f dragon##Print an ASCII dragon saying "Hello!" 249 | echo "example" | tee -a {{FILE}}##Append to the given FILEs, do not overwrite 250 | echo "example" | tee {{FILE}}##Copy standard input to each FILE, and also to standard output 251 | echo "test" | lp##Print the output of a command to the default printer (see `lpstat` command) 252 | echo "{{content}}" | mailx -s "{{subject}}" {{to_addr}}##Send mail with short content 253 | echo '{{query1}}; {{query2}}' | psql {{database}}##Run several queries against the given *database*. Note: useful in shell scripts 254 | echo {{"Hello World"}}##Print a text message. Note: quotes are optional 255 | echo {{"My path is $PATH"}}##Print a message with environment variables 256 | electrum -p socks5:{{127.0.0.1}}:9050 -s {{56ckl5obj37gypcu.onion}}:50001:t -1##Connect only to a specific electrum-server instance 257 | electrum -w {{new-wallet.dat}} create##Create a new wallet 258 | electrum -w {{recovery-wallet.dat}} restore -o##Restore an existing wallet from seed offline 259 | electrum listaddresses -a##Display all wallet receiving addresses 260 | electrum mktx {{recipient}} {{amount}} -f 0.0000001 -F {{from}} -o##Create a signed transaction offline 261 | electrum signmessage {{address}} {{message}}##Sign a message 262 | electrum verifymessage {{address}} {{signature}} {{message}}##Verify a message 263 | emacs -nw##Open emacs in console mode (without X window) 264 | emacs {{filename}}##Open a file in emacs 265 | enca -L {{language}} -x {{to_encoding}} < {{original_file}} > {{new_file}}##Save original_file as new_file and convert new_file to specified encoding 266 | enca -L {{language}} -x {{to_encoding}} {{file(s)}}##Convert file(s) to specified encoding 267 | enca -L {{language}} {{file(s)}}##Detect file(s) encoding; -L option tells enca the current language; language is in the POSIX/C locale format, e.g. zh_CN, en_US etc 268 | enca {{file(s)}}##Detect file(s) encoding according to your system's locale 269 | env -i {{program}}##Clear the environment and run a program 270 | env -u {{variable}} {{program}}##Remove variable from the environment and run a program 271 | env {{program}}##Run a program. Often used in scripts after the shebang (#!) for looking up the path to the program 272 | env {{variable}}={{value}} {{program}}##Set a variable and run a program 273 | env##Show the environment 274 | espeak "I like to ride my bike."##Speak a phrase aloud 275 | espeak -f {{filename}}##Speak a file aloud 276 | espeak -v {{voice}}##Use a different voice 277 | espeak -w {{filename.wav}} "It's GNU plus Linux"##Save output to a WAV audio file, rather than speaking it directly 278 | exiftool "-AllDates+=0:0:0 1:0:0" {{directory}}##Increase time photo taken by 1 hour in directory 279 | exiftool "-AllDates-=0:0:1 2:0:0" -ext jpg##Decrease time photo taken by 1 day and 2 hours on JPEGs only 280 | exiftool '-filename {{filename}}##Select mutliple files with `Shift-TAB` and write to a file 299 | find {{path/to/search}} -type f | fzf##Start finder on all files from arbitrary locations 300 | find {{root_path}} -empty##Find empty files or directories 301 | find {{root_path}} -name {{'*.py'}} -exec {{wc -l {} }}\;##Run a command for each file, use {} within the command to access the filename 302 | find {{root_path}} -name {{'*.py'}} -mtime {{-180d}} -delete##Delete files by name, older than a certain number of days 303 | find {{root_path}} -name {{'*.py'}} -mtime {{-1d}}##Find files modified since a certain time 304 | find {{root_path}} -name {{'*.py'}} -or -name {{'*.r'}}##Find files matching more than one search criteria 305 | find {{root_path}} -name {{'*.py'}}##Find files by extension 306 | find {{root_path}} -path {{'**/lib/**/*.py'}}##Find files matching path pattern 307 | find {{root_path}} -size +500k -size -10MB -iname {{'*.TaR.gZ'}}##Find files using case insensitive name matching, of a certain size 308 | for argument in 1 2 3; do {{command $argument}}; done##Perform a command with different arguments 309 | for d in *; do (cd $d; {{command}}); done##Perform a command in every directory 310 | fortune -f##List the available quotation database files 311 | fortune -l##Print a long quotation 312 | fortune -o##Print an offensive quotation 313 | fortune -s##Print a short quotation 314 | fortune {{filename}}##Print a quotation from one of the database files listed by `fortune -f` 315 | fortune##Print a quotation 316 | fswebcam --timestamp {{timestamp}} {{filename}}##Take a picture with timestamp(timestamp string is formatted by strftime) 317 | fswebcam -d {{device}} {{filename}}##Take a picture from selected device(Default is /dev/vidoe0) 318 | fswebcam -r {{width}}x{{height}} {{filename}}##Take a picture with custom resolution 319 | fswebcam {{filename}}##Take a picture 320 | fusermount -u {{mountpoint}}##Unmount remote directory 321 | fzf -q "!pyc 'travis"##Start finder on entries that not match pyc and match exactly travis 322 | fzf -q "^core go$ | rb$ | py$"##Start finder on entries that start with core and end with either go, rb, or py 323 | fzf -q "{{query}}"##Start finder with a given query 324 | g (start), G (end)##Go to start / end of file 325 | g {{bookmark_name}}##Go to a bookmarked folder 326 | gcc -S {{source.c}}##Compile source code into Assembler instructions 327 | gcc {{source.c}} -Wall -Og -o {{executable}}##Allow warnings, debug symbols in output 328 | gcc {{source.c}} -o {{executable}} -I{{header_path}} -L{{library_path}} -l{{library_name}}##Include libraries from a different path 329 | gcc {{source1.c}} {{source2.c}} -o {{executable}}##Compile multiple source files into executable 330 | gdb --args {{executable}} {{argument1}} {{argument2}}##Start gdb and pass arguments 331 | gdb -ex "{{commands}}" {{executable}}##Execute given GDB commands upon start 332 | gdb -p {{procID}}##Attach a process to gdb 333 | gdb {{executable}}##Debug an executable 334 | gem install {{gemname}} -v {{1.0.0}}##Install specific version of a gem 335 | gem install {{gemname}}##Install latest version of a gem 336 | gem list##List all gems 337 | gem uninstall {{gemname}}##Uninstall a gem 338 | gem update {{gemname}}##Update a gem 339 | get {{/path/remote_file}}##Transfer remote file to the local system 340 | gifsicle --delay={{10}} --loop *.gif > {{anim.gif}}##Make a GIF animation with gifsicle 341 | gifsicle -b {{anim.gif}} --replace '#0' {{new.gif}}##You can also edit animations by replacing, deleting, or inserting frames 342 | gifsicle {{anim.gif}} '#0' > {{firstframe.gif}}##Extract frames from an animation 343 | git --help##Call general help 344 | git --version##Check the Git version 345 | git add -f##Also add ignored files 346 | git add -p {{path/to/file}}##Add parts of a file interactively 347 | git add -u##Only add already tracked files 348 | git add .##Add all files (tracked and untracked) 349 | git add {{path/to/file}}##Add a file to the index 350 | git blame -e {{file}}##Print file with author email and commit hash on each line 351 | git blame {{file}}##Print file with author name and commit hash on each line 352 | git branch -a##List all local and remote branches 353 | git branch -d {{BRANCH-NAME}}##Delete a local branch 354 | git branch -m##Move/Rename a branch 355 | git branch {{BRANCH-NAME}}##Create new branch based on current branch 356 | git branch##List local branches. The current branch is highlighted by `*` 357 | git checkout -b {{BRANCH-NAME}}##Create and switch to a new branch 358 | git checkout .##Undo unstaged local modification 359 | git checkout {{BRANCH-NAME}}##Switch to another branch 360 | git clone --depth 10 {{REMOTE-REPOSITORY-LOCATION}}##Clone an existing repository, and truncate to the specified number of revisions, save your time mostly 361 | git clone -l##For cloning from the local machine 362 | git clone -q##Do it quietly 363 | git clone {{REMOTE-REPOSITORY-LOCATION}}##Clone an existing repository 364 | git commit --amend##Replace the last commit with currently staged changes 365 | git commit -m {{MESSAGE}}##Commit staged files to the repository with comment 366 | git config --global --unset alias.st##Remove option alias.st from ~/.gitconfig 367 | git config --global alias.ls "status"##Set option alias.ls=status in file ~/.gitconfig 368 | git config --list --global##Print global list of options, set in ~/.gitconfig 369 | git config --list --local##Print list of options for current repository 370 | git config --list##Get full list of options 371 | git config alias.st##Get value of alias.ls option 372 | git diff --name-only {{PATHSPEC}}##Show only names of changed files 373 | git diff --staged##Show staged (added, but not yet committed) changes only 374 | git diff --summary {{PATHSPEC}}##Output a condensed summary of extended header information 375 | git diff {{PATHSPEC}}##Show changes to tracked files 376 | git fetch --all##Fetch the latest changes from all remote git servers 377 | git fetch origin; git rebase -i origin/master##Rebase your local branch interactively with the latest changes from upstream 378 | git fetch {{remote_name}}##Fetch new branches and update remote-tracking branches 379 | git help {{COMMAND}}##Call help on a command 380 | git init --bare##Initialize a barebones repository, suitable for use as a remote over ssh 381 | git init##Initialize a new local repository 382 | git log --oneline##Show only the first line of each commits 383 | git log -p {{path}}##Show the history of a particular file or directory, including differences 384 | git log##Show a history of commits 385 | git merge -e {{BRANCH-NAME}}##Edit the merge message 386 | git merge {{BRANCH-NAME}}##Merge a branch with your current branch 387 | git mv --force {{file}} {{target}}##Overwrite the file in the target path if it exists 388 | git mv {{filename}} {{new_filename}}##Rename file and add renaming to the next commit 389 | git mv {{path/to/file}} {{new/path/to/file}}##Move file inside the repo and add the movement to the next commit 390 | git pull --rebase##Download changes from default remote repository and use fast forward 391 | git pull {{remote_name}} {{branch}}##Download changes from given remote repository and branch, then merge them into HEAD 392 | git pull##Download changes from default remote repository and merge it 393 | git push --prune {{REMOTE-NAME}}##Remove remote branches which don't exist locally 394 | git push --tags##Publish tags 395 | git push {{REMOTE-NAME}} :{{REMOTE-BRANCH}}##Remove remote branch 396 | git push {{REMOTE-NAME}} {{LOCAL-BRANCH}}##Publish local changes on a remote branch 397 | git push {{REMOTE-NAME}} {{LOCAL-BRANCH}}:{{REMOTE-BRANCH}}##Publish local changes on a remote branch of different name 398 | git rebase --abort##Abort a rebase in-progress 399 | git rebase --continue##Handle an active rebase merge failure, after editing conflicting file(s) 400 | git rebase -i master##Rebase your local branch interactively with the latest changes in local master 401 | git remote -v##Show a list of existing remotes, their names and URL 402 | git remote add {{remote_name}} {{remote_url}}##Add a remote 403 | git remote remove {{remote_name}}##Remove a remote 404 | git remote rename {{old_name}} {{new_name}}##Rename a remote 405 | git remote set-url {{remote_name}} {{new_url}}##Change the URL of a remote 406 | git rm --cached {{file}}##Remove file from repository index but keep it untouched locally 407 | git rm -r {{directory}}##Remove directory 408 | git rm {{file}}##Remove file from repository index and filesystem 409 | git stash apply {{stash_name}}##Re-apply a stash by name 410 | git stash drop stash@{index}##Drop a stash by an index 411 | git stash list##List all stashes 412 | git stash pop##Re-apply the latest stash 413 | git stash save -u {{optional_stash_name}}##Include new files in the stash (leaves the index completely clean) 414 | git stash save {{optional_stash_name}}##Stash current changes (except new files) 415 | git status -s##Give output in short format 416 | git status##Show changed files which are not yet added for commit 417 | git svn clone {{http://example.com/my_subversion_repo}} {{local_dir}}##Clone an SVN repository 418 | git svn dcommit##Commit back to SVN repository 419 | git svn rebase##Update local clone from the upstream SVN repository 420 | git tag -d {{tag_name}}##Delete the tag with the given name 421 | git tag {{tag_name}} -m {{tag_message}}##Create an annotated tag with the given message 422 | git tag {{tag_name}}##Create a tag with the given name pointing to the current commit 423 | git tag##List all tags 424 | git {{COMMAND}}##Execute Git command 425 | glances -c {{hostname}}##Connect to a Glances server 426 | glances -s --password##Require a password in (web) server mode 427 | glances -s##Run in server mode to allow connections from other Glances clients 428 | glances -w##Run in web server mode to show results in browser 429 | glances##Run in terminal 430 | gpg --clearsign {{doc.txt}}##Sign doc.txt without encryption (writes output to doc.txt.asc) 431 | gpg --decrypt {{doc.txt.gpg}}##Decrypt doc.txt.gpg (output to STDOUT) 432 | gpg --encrypt --recipient {{alice@example.com}} {{doc.txt}}##Encrypt doc.txt for alice@example.com (output to doc.txt.gpg) 433 | gpg --import {{public.gpg}}##Import a public key 434 | gpg --symmetric {{doc.txt}}##Encrypt doc.txt with only a passphrase (output to doc.txt.gpg) 435 | gradle assembleRelease##Compile and Release package 436 | gradle build##Compile a package 437 | gradle clean##Clear the build folder 438 | grep -C 3 {{something}} {{file_path}}##See 3 lines of context 439 | grep -c {{something}} {{file_path}}##Print the count of matches instead of the matching text 440 | grep -e {{^regex$}} {{file_path}}##Use a regex 441 | grep -i {{something}} {{file_path}}##Search without case-sensitivity 442 | grep -n {{something}} {{file_path}}##Print line number for each match 443 | grep -r {{something}} .##Search recursively in current directory for an exact string 444 | grep -v {{something}}##Invert match for excluding specific strings 445 | grep {{something}} {{file_path}}##Search for an exact string 446 | gulp {{task}} {{othertask}}##Run individual tasks 447 | gulp##Run the default task 448 | gzip -9 -c {{file.ext}} > compressed-file.ext.gz##Specify the compression level. 1=Fastest (Worst), 9=Slowest (Best), Default level is 6 449 | gzip -c -d {{file.ext.gz}} > uncompressed-file.ext##Uncompress a gzipped file specifying the output filename 450 | gzip -c {{file.ext}} > compressed-file.ext.gz##Compress a file specifying the output filename 451 | gzip -d {{file.ext.gz}}##Decompress a file, replacing it with the original uncompressed version 452 | gzip {{file.ext}}##Compress a file, replacing it with a gzipped compressed version 453 | haxelib git {{libname}} {{GIT-URL}}##Install the development version of a library from a Git repository 454 | haxelib install {{libname}}##Install a Haxe library 455 | haxelib search {{keyword}}##Search for a Haxe library 456 | haxelib upgrade##Upgrade all installed Haxe libraries 457 | history -c##Clear the commands history list (only for current `bash` shell) 458 | history -w##Overwrite history file with history of current `bash` shell (often combined with `history -c` to purge history) 459 | history##Display the commands history list with line numbers 460 | hn --keep-open##View stories on Hacker News, and keep the list open after selecting a link 461 | hn --latest##View stories on Hacker News sorted by submission date 462 | hn --limit {{number}}##View _number_ of stories on Hacker News 463 | hn##View stories on Hacker News 464 | host -t {{field}} {{domain}}##Lookup a field (CNAME, TXT,...) of a domain 465 | host {{domain}}##Lookup A, AAAA, and MX records of a domain 466 | host {{ip_address}}##Reverse lookup an IP 467 | http -a {{username:password}} {{example.org}}##Pass a user name and password for server authentication 468 | http -d {{example.org}}##Download a URL to a file 469 | http -f {{example.org}} {{name='bob'}} {{profile-picture@'bob.png'}}##Send form-encoded data 470 | http {{HEAD}} {{example.org}}##Specify an HTTP method 471 | http {{example.org}} {{X-MyHeader:123}}##Include an extra header 472 | http {{example.org}} {{name='bob'}}##Send JSON object 473 | hub browse -- issues##Open the current project's issues page 474 | hub clone {{github_username}}/{{repo_name}}##Clone another user repository 475 | hub clone {{repo_name}}##Clone a repository you own 476 | iconv -f {{from_encoding}} -t {{to_encoding}} {{input_file}}##Convert file and print to stdout 477 | iconv -f {{from_encoding}} {{input_file}} > {{output_file}}##Convert file to current locale 478 | iconv -l##List supported encodings 479 | if {{condition}}; then echo "true"; else echo "false"; fi##Full if syntax 480 | ifconfig -a##Display details of all interfaces, including disabled interfaces 481 | ifconfig eth0 down##Disable eth0 interface 482 | ifconfig eth0 up##Enable eth0 interface 483 | ifconfig eth0 {{ip_address}}##Assign IP address to eth0 interface 484 | ifconfig eth0##View network settings of an ethernet adapter 485 | in2csv --sheet={{sheet_name}} {{data.xlsx}}##Convert a specific sheet from an XLSX file to CSV 486 | in2csv {{data.dbf}} > {{data.csv}}##Convert a DBF file to a CSV file 487 | in2csv {{data.xls}}##Convert an XLS file to CSV 488 | inkscape {{filename.svg}} --export-pdf=={{filename.pdf}} --export-text-to-path##Export an SVG document to PDF, converting all texts to paths 489 | inkscape {{filename.svg}} --select=path1555 --verb=EditDuplicate --verb=ObjectRotate90 --verb=FileSave --verb=FileClose##Duplicate the object with id="path1555", rotate the duplicate 90 degrees, save the SVG, and quit 490 | inkscape {{filename.svg}} -e {{filename.png}} -w {{600}} -h {{400}}##Export an SVG file into a bitmap of 600x400 pixels (aspect ratio distortion may occur) 491 | inkscape {{filename.svg}} -e {{filename.png}}##Export an SVG file into a bitmap with the default format (PNG) and the default resolution (90 DPI) 492 | inkscape {{filename.svg}} -i {{id}} -e {{object.png}}##Export a single object, given its ID, into a bitmap 493 | inkscape {{filename.svg}}##Open an SVG file in the Inkscape GUI 494 | ionice -c {{scheduling_class}} -n {{priority}} {{command}}##Run a command with custom I/O scheduling class and priority 495 | ionice -c {{scheduling_class}} -p {{pid}}##Set I/O scheduling class of a running process 496 | ionice -p {{pid}}##Print the I/O scheduling class and priority of a running process 497 | ioping -R /dev/sda##Measure disk seek rate on /dev/sda 498 | ioping -RL /dev/sda##Measure disk sequential speed on /dev/sda 499 | ioping -c 10 -s 1M /tmp##Measure latency on /tmp using 10 requests of 1 megabyte each 500 | ioping .##Show disk I/O latency using the default values and the current directory 501 | ipcs -a##General information about all the IPC 502 | ipcs -qi 32768##Specific information about the Message Queue which has the id 32768 503 | j --purge##Remove non-existing directories from the autojump database 504 | j -s##Show the entries in the autojump database 505 | j {{pattern}}##Jump to a directory that contains the given pattern 506 | jar -xvf *.jar##Unzip .jar/.war file to the current directory 507 | java -jar {{filename.jar}}##Execute a .jar program 508 | java -version##Display JDK, JRE and HotSpot versions 509 | java {{filename}}##Execute a java .class file that contains a main method by using just the class name 510 | javac -d {{path/to/some/directory}} {{filename.java}}##Compile a .java file and place the resulting class file in a specific directory 511 | javac {{*.java}}##Compile all .java files in current directory 512 | javac {{filename.java}}##Compile a .java file 513 | javac {{filename1.java}} {{filename2.java}} {{filename3.java}}##Compile several .java files 514 | jc {{pattern}}##Jump to a sub-directory (child) of the current directory that contains the given pattern 515 | jhat -J-mx8G {{dump_file.bin}}##Analyze a dump letting jhat use up to 8GB RAM (2-4x dump size recommended) 516 | jhat -p {{port}} {{dump_file.bin}}##Analyze a heap dump, specifying an alternate port for the http server 517 | jhat {{dump_file.bin}}##Analyze a heap dump (from jmap), view via http on port 7000 518 | jmap -dump:format=b,file={{filename}} {{java_pid}}##Dump contents of the heap into a binary file for analysis with jhat 519 | jmap -heap {{filename.jar}} {{java_pid}}##Print heap summary information 520 | jmap -histo {{java_pid}}##Print histogram of heap usage by type 521 | jmap {{java_pid}}##Print shared object mappings for a java process (output like pmap) 522 | jobs -l##Show status and process IDs of all jobs 523 | jobs -p##Show process IDs of all jobs 524 | jobs {{job_id}}##Show status of a particular job 525 | jobs##Show status of all jobs 526 | jstack -m {{java_pid}}##Print mixed mode (java/c++) stack traces for all threads in a java process 527 | jstack {{/usr/bin/java}} {{file.core}}##Print stack traces from java core dump 528 | jstack {{java_pid}}##Print java stack traces for all threads in a java process 529 | kill -l##List signal names 530 | kill {{process_id}}##Kill the process 531 | last -F##View full login times and dates 532 | last -n {{login_count}}##Specify how many of the last logins to show 533 | last reboot##View the last reboot (last login of the pseudo user reboot) 534 | last shutdown##View the last shutdown (last login of the pseudo user shutdown) 535 | last {{user_name}}##View the last login by a specific user 536 | last##View last logins, their duration and other information as read from /var/log/wtmp 537 | latexmk -C##Clean up temporary tex and output files 538 | latexmk -c {{source.tex}}##Clean up temporary tex files created for a specific tex file 539 | latexmk -c##Clean up all temporary tex files in the folder 540 | latexmk -pdf {{source.tex}}##Compile a pdf document 541 | latexmk {{source.tex}}##Compile a dvi document from a specific source file 542 | latexmk##Compile a dvi (DeVice Independent file) document from every source 543 | less {{source_file}}##Open a file 544 | license --name {{author}} --year {{release_year}} {{license_name}}##Create a license with explicitly-set name and year 545 | license -o {{filename.txt}} {{license_name}}##Create a license with custom filename 546 | license ls##List all locally available licenses 547 | license {{license_name}}##Create a license 548 | lls##Get list of files on local machine 549 | ln -s {{path/to/file}} {{path/to/symlink}}##Create a symbolic link to a file (or folder) 550 | ln -sf {{path/to/new/file}} {{path/to/symlink}}##Overwrite an existing symbolic to point to a different file 551 | ln {{path/to/file}} {{path/to/hardlink}}##Create a hard link to a file 552 | lp -P 1,3-5,16 {{path/to/filename}}##Print only certain pages to the default printer (print pages 1, 3-5, and 16) 553 | lp -d {{printer_name}} {{path/to/filename}}##Print a file to a named printer (see `lpstat` command) 554 | lp -n {{N}} {{path/to/filename}}##Print N copies of file to default printer (replace N with desired number of copies) 555 | lp {{path/to/filename}}##Print a file to the default printer 556 | lpstat -d##Show the default printer 557 | lpstat -p##List printers present on the machine and whether they are enabled for printing 558 | lpstat -t##Display all available status information 559 | lpstat -u {{user}}##Show a list of print jobs queued by the specified user 560 | ls *.txt | parallel -j4 gzip##Read arguments from stdin, run 4 jobs at once 561 | ls -1##List files one per line 562 | ls -a##List all files, including hidden files 563 | ls -lS##Long format list sorted by size (descending) 564 | ls -la##Long format list (permissions, ownership, size and modification date) of all files 565 | ls -lh##Long format list with size displayed using human readable units (KB, MB, GB) 566 | ls -ltr##Long format list of all files, sorted by modification date (oldest first) 567 | ls##Get list of files on remote machine 568 | lsof -c {{process_or_command_name}}##List files opened by the given command or process 569 | lsof -i :{{port}}##Find the process that opened a local internet port 570 | lsof -t {{/path/to/file}}##Only output the process PID 571 | lsof -u {{username}}##List files opened by the given user 572 | lsof {{/path/to/file}}##Find the processes that have a given file open 573 | lwp-request -C {{username}}:{{password}} -m {{METHOD}} {{http://example.com/some/path}}##Make a request with HTTP authentication 574 | lwp-request -E -m {{METHOD}} {{http://example.com/some/path}}##Make a request and print response headers and status chain 575 | lwp-request -H 'User-Agent: {{user_agent}} -m {{METHOD}} {{http://example.com/some/path}}##Make a request with a custom user agent 576 | lwp-request -U -m {{METHOD}} {{http://example.com/some/path}}##Make a request and print request headers 577 | lwp-request -m GET {{http://example.com/some/path}}##Make a simple GET request 578 | mailx -a {{file}} -s "{{subject}}" {{to_addr}}##Send mail with an attachment 579 | mailx -s "{{subject}}" -c {{cc_addr}} {{to_addr}}##Send mail to a recipient and CC to another address 580 | mailx -s "{{subject}}" -r {{from_addr}} {{to_addr}}##Send mail and set sender address 581 | mailx -s "{{subject}}" {{to_addr}} < {{content.txt}}##Send mail with content which written in a file 582 | mailx -s "{{subject}}" {{to_addr}}##To send mail, the content is typed after the command and ended with Control-D 583 | make -C {{directory}}##Execute make from another directory 584 | make -f {{file}}##Use specific Makefile 585 | make {{rule}}##Call a specific rule 586 | make##Call the all rule 587 | man --path##Display path searched for manpages 588 | man -k {{keyword}}##Do a keyword search for manpages containing a search string 589 | man -w {{command}}##Display location of a manpage rather than the manpage itself 590 | man {{command}}##Display man page for a command 591 | mitmdump -nc {{filename}}##Replay a saved traffic file 592 | mitmdump -nr {{input_filename}} -w {{output_filename}} {{"~m post"}}##Filter a saved traffic file to just POST requests 593 | mitmdump -w {{filename}}##Start a proxy and save all output to a file 594 | mitmproxy -b {{ip_address}} -p {{port}}##Start mitmproxy bound to custom address and port 595 | mitmproxy##Start mitmproxy with default settings 596 | mkdir -p {{path}}##Create directories recursively (useful for creating nested dirs) 597 | mkdir {{directory}}##Create a directory in current folder or given path 598 | mkfifo {{path/to/pipe}}##Create a named pipe at a given path 599 | mmv "*{{.old_extension}}" "#1{{.new_extension}}"##Rename all files with a certain extension to a different extension 600 | mmv -a {{"*.txt"}} {{"all.txt"}}##Append all .txt files into one file 601 | mmv -c {{"report*part*.txt"}} {{"./french/rapport#1partie#2.txt"}}##Copy report6part4.txt to ./french/rapport6partie4.txt along with all similarly named files 602 | mmv {{"[0-1][0-9]-[0-3][0-9]-[0-9][0-9][0-9][0-9].txt"}} {{"#3#4-#1#2-#5#6#7#8.txt"}}##Convert dates in filenames from "M-D-Y" format to "D-M-Y" format 603 | mocha --grep {{^regex$}}##Run tests that match a specific grep pattern 604 | mocha --reporter {{reporter}}##Run tests with a specific reporter 605 | mocha --watch##Run tests on changes to JavaScript files in the current directory and once initially 606 | mocha {{folder/with/tests}}##Run tests contained at a specific location 607 | mocha##Run tests with default configuration or as configured in `mocha.opts` 608 | montage {{image1.png}} {{image2.jpg}} {{imageN.png}} -geometry +0+0 -resize 640x480^ -gravity center -crop 640x480+0+0 montage.jpg##Resize and crop images to completely fill their grid cells before tiling 609 | montage {{image1.png}} {{image2.jpg}} {{imageN.png}} -geometry +0+0 -tile 2x3 montage_%d.jpg##Limit the number of rows and columns in the grid, causing input images to overflow into multiple output montages 610 | montage {{image1.png}} {{image2.jpg}} {{imageN.png}} -geometry +0+0 montage.jpg##Tile images into a grid, automatically calculating the grid cell size from the largest image 611 | montage {{image1.png}} {{image2.jpg}} {{imageN.png}} -geometry 640x480+0+0 montage.jpg##Set the grid cell size and resize images to fit it before tiling 612 | montage {{image1.png}} {{image2.jpg}} {{imageN.png}} montage.jpg##Tile images into a grid, automatically resizing images larger than the grid cell size 613 | more {{source_file}}##Open a file 614 | mount -a##Mount all the filesystem defined in /etc/fstab 615 | mount -t {{filesystem_type}} {{path_to_device_file}} {{directory_to_mount_to}}##Mount a device 616 | mount -t {{iso9660}} -o ro {{/dev/cdrom}} {{/cdrom}}##Mount a CD-ROM device (with the filetype ISO9660) to /cdrom (readonly) 617 | mount {{/my_drive}}##Mount a specific filesystem described in /etc/fstab (e.g. "/dev/sda1 /my_drive ext2 defaults 0 2") 618 | mount##Show all mounted filesystems 619 | mtr -4 {{host}}##Force IP IPv4 or IPV6 620 | mtr -n {{host}}##Disable IP address and host name mapping 621 | mtr -w {{host}}##Generate output after pinging each hop 10 times 622 | mtr {{host}}##Traceroute to a host and continuously ping all intermediary hops 623 | mv -f {{source}} {{target}}##Do not prompt for confirmation before overwriting existing files 624 | mv -fi {{source}} {{target}}##Do not prompt for confirmation before overwriting existing files but write to standard error before overriding 625 | mv -v {{source}} {{target}}##Move files in verbose mode, showing files after they are moved 626 | mv {{source}} {{target}}##Move files in abitrary locations 627 | mysql -h {{database_host}} {{database_name}}##Connect to a database on another host 628 | mysql -u {{user}} --password {{database_name}} < {{filename.sql}}##Restore a backup, user will be prompted for a password 629 | mysql -u {{user}} --password {{database_name}}##Connect to a database, user will be prompted for a password 630 | mysql {{database_name}} < {{script.sql}}##Execute SQL statements in a script file (batch file) 631 | mysql {{database_name}}##Connect to a database 632 | mysqldump -u {{user}} --password {{database_name}} > {{filename.sql}}##Create a backup, user will be prompted for a password 633 | nano -S {{filename}}##Enable smooth scrolling 634 | nano -i {{filename}}##Indent new lines to the previous lines' indentation 635 | nano {{filename}}##Start nano in terminal with {filename} 636 | nc -l {{port}}##Listen on a specified port 637 | nc -k -l {{port}}##Server stay up after client detach 638 | nc -q {{timeout}} {{ip_address}}##Client stay up after EOF 639 | nc -w {{timeout_in_seconds}} {{ipaddress}} {{port}}##Set a timeout 640 | nc {{ip_address}} {{port}} > somefile.txt##Receive a file 641 | nc {{ip_address}} {{port}}##Connect to a certain port (you can then write to this port) 642 | ncal -e {{year}}##Display date of Easter (western churches) 643 | nginx -c {{config_file}} -p {{prefix/for/relative/paths}}##Start server with a prefix for all relative paths in config file 644 | nginx -c {{config_file}}##Start server with custom config file 645 | nginx -s reload##Reload configuration by sending a signal with no downtime 646 | nginx -t##Test configuration without affecting the running server 647 | nginx##Start server with default config 648 | nice -n {{niceness_value}} {{command}}##Launch a program with altered priority 649 | nix-env -e {{pkg_name}}##Uninstall package 650 | nix-env -i {{pkg_name}}##Install package 651 | nix-env -qa {{pkg_name}}##Show available package with name or without name 652 | nix-env -qas##Show the status of available packages 653 | nix-env -u {{pkg_name}}##Upgrade one package 654 | nix-env -u##Upgrade all packages 655 | nmap -A {{address_or_addresses}}##Also enable scripts, service detection, OS fingerprinting and traceroute 656 | nmap -T4 {{address_or_addresses}}##Assume good network connection and speed up execution 657 | nmap -p {{port1,port2,...,portN}} {{address_or_addresses}}##Scan a specific list of ports (use -p- for all ports 1-65535) 658 | nmap -sSU {{address_or_addresses}}##Perform TCP and UDP scanning (use -sU for UDP only, -sZ for SCTP, -sO for IP) 659 | nmap -sn {{ip_or_hostname}} {{optional_another_address}}##Try to determine whether the specified hosts are up and what are their names 660 | nmap {{ip_or_hostname}} {{optional_another_address}}##Like above, but also run a default 1000-port TCP scan if host seems up 661 | node -e "{{code}}"##Evaluate JavaScript by passing it in the command 662 | node {{file}}.js##Run a JavaScript file 663 | node##Start a REPL (interactive shell) 664 | nohup {{command options}}##Run process that can live beyond the terminal 665 | npm init##Interactively create a package.json file 666 | npm install -g {{module_name}}##Download and install a module globally 667 | npm install {{module_name}}@{{version}} --save##Download a given dependency, and add it to the package.json 668 | npm install##Download all dependencies referenced in package.json 669 | npm list##List a tree of installed modules 670 | npm uninstall {{module_name}}##Uninstall a module 671 | nvm alias default {{node_version}}##Set the default NodeJS version 672 | nvm exec {{node_version}} node {{app.js}}##Run app in a specific version of NodeJS 673 | nvm install {{node_version}}##Install a specific version of NodeJS 674 | nvm list##List all available NodeJS versions and print the default one 675 | nvm run {{node_version}} --version##Run a specific version NodeJS REPL 676 | nvm use {{node_version}}##Use a specific version NodeJS in the current shell 677 | openssl genrsa -out {{filename.key}} 2048##Generate a 2048bit RSA private key and save it to a file 678 | openssl req -new -sha256 -key {{filename.key}} -out {{filename.csr}}##Generate a certificate signing request to be sent to a certificate authority 679 | openssl s_client -connect {{host}}:443 -showcerts {{output_file.dump}}##Dump a database into a custom-format archive file 713 | pg_dump -U {{username}} {{db_name}} > {{output_file.sql}}##Same as above, customize username 714 | pg_dump -h {{host}} -p {{port}} {{db_name}} > {{output_file.sql}}##Same as above, customize host and port 715 | pg_dump {{db_name}} > {{output_file.sql}}##Dump database into a SQL-script file 716 | pg_restore --clean -d {{db_name}} {{archive_file.dump}}##Clean database objects before creating them 717 | pg_restore -U {{username}} -d {{db_name}} {{archive_file.dump}}##Same as above, customize username 718 | pg_restore -d {{db_name}} {{archive_file.dump}}##Restore an archive into an existing database 719 | pg_restore -h {{host}} -p {{port}} -d {{db_name}} {{archive_file.dump}}##Same as above, customize host and port 720 | pg_restore -j {{2}} -d {{db_name}} {{archive_file.dump}}##Use multiple jobs to do the restoring 721 | pgrep -f "{{process_name}} {{parameter}}"##Search full command line with parameters instead of just the process name 722 | pgrep -u root {{process_name}}##Search for process run by a specific user 723 | pgrep {{process_name}}##Return PIDs of any running processes with a matching command string 724 | php -S {{host:port}}##Start a PHP built-in web server in the current directory 725 | php -a##Run PHP interactively 726 | php -l {{file}}##Check syntax (lint) 727 | php -r "{{code}}"##Run PHP code. Notes: a) Don't use tags; b) Escape double quotes with backslash 728 | php {{file}}##Parse and execute a file 729 | phpize --clean##Delete files previously created by phpize 730 | phpize##Prepare the PHP extension in the current directory for compiling 731 | phpunit --coverage-html {{directory}}##Run tests and generate a coverage report in HTML 732 | phpunit --group {{name}}##Run tests annotated with the given group 733 | phpunit {{path/to/TestFile.php}}##Run tests in a specific file 734 | phpunit##Run tests in the current direcotry. Note: Expects you to have a 'phpunit.xml' 735 | pigz -0 -p{{4}} {{filename}}##Compress a file using no compression and 4 processors 736 | pigz -9 {{filename}}##Compress a file using the best compression method 737 | pigz -d {{archive.gz}}##Decompress a file 738 | pigz -l {{archive.tar.gz}}##List the contents of an archive 739 | pigz {{filename}}##Compress a file with default options 740 | ping -c {{count}} {{host}}##Ping a host only a specific number of times 741 | ping -i {{seconds}} {{host}}##Ping host, specifying the interval in seconds between requests (default is 1 second) 742 | ping -n {{host}}##Ping host without trying to lookup symbolic names for addresses 743 | ping {{host}}##Ping host 744 | pip freeze > {{requirements.txt}}##Save installed packages to file 745 | pip install -U {{package_name}}##Upgrade a package 746 | pip install -r {{requirements.txt}}##Install packages from file 747 | pip install {{package_name}}##Install a package 748 | pip install {{package_name}}=={{package_version}}##Install a specific version of a package 749 | pip uninstall {{package_name}}##Uninstall a package 750 | pkill -9 -f "{{command_name}}"##Kill all processes which match their full command instead of just the process name 751 | pkill -9 {{process_name}}##Kill all processes which match 752 | pkill -USR1 {{process_name}}##Send SIGUSR1 signal to processes which match 753 | play {{audiofile1}} {{audiofile2}}##Play the given audio files 754 | play {{audiofile}} reverse##Play the given audio in reverse 755 | play {{audiofile}} speed 2.0##Play the given audio at twice the speed 756 | play {{audiofile}}##Play the given audio file 757 | pngcrush -d {{path/to/output}} *.png##Compress all PNGs and output to directory 758 | pngcrush -rem allb -brute -reduce {{in.png}} {{out.png}}##Compress PNG file with all 114 available algorithms and pick the best result 759 | pngcrush {{in.png}} {{out.png}}##Compress a PNG file 760 | printf -v {{myvar}} {{"This is %s = %d\n" "a year" 2016}}##Store a formatted message in a variable (does not work on zsh) 761 | printf {{"%s\n"}} {{"Hello world"}}##Print a text message 762 | printf {{"\e[1;34m%.3d\e[0m\n"}} {{42}}##Print an integer in bold blue 763 | printf {{"\u20AC %.2f\n"}} {{123.4}}##Print a float number with the unicode Euro sign 764 | printf {{"var1: %s\tvar2: %s\n"}} {{"$VAR1"}} {{"$VAR2"}}##Print a text message composed with environment variables 765 | ps aux | grep {{string}}##Search for a process that matches a string 766 | ps aux##List all running processes 767 | ps auxww##List all running processes including the full command string 768 | ps axu | fzf##Start finder on running processes 769 | psql -c '{{query}}' {{database}}##Run single *query* against the given *database*. Note: useful in shell scripts 770 | psql -h {{host}} -p {{port}} -U {{username}} -W {{database}}##Connect to *database*, user will be prompted for password 771 | psql -h {{host}} -p {{port}} -U {{username}} {{database}}##Connect to *database* on given server *host* running on given *port* with *username* given, no password prompt 772 | psql {{database}}##Connect to *database*. It connects to localhost using default port *5432* with default user 773 | pushd +4##Rotate stack by making the 5th element the top of the stack 774 | pushd < {{directory}}##Switch to directory and push it on the stack 775 | pushd##Switch first and second directories on the stack 776 | put {{/path/local_file}}##Transfer local file to the remote system 777 | pv -EE {{path_to_faulty_media}} > image.img##Read an erroneous file, skip errors as `dd conv=sync,noerror` would 778 | pv -L 1K -S {{maximum_file_size_to_be_read}}##Stop reading after reading specified amount of data, rate limit to 1K/s 779 | pv -cN in {{big_text_file}} | grep {{pattern}} | pv -cN out > {{filtered_file}}##Filter a file, see both progress and amount of output data 780 | pv -d {{PID}}##Attach to an already running process and see its file reading progress 781 | pv {{file}}##Print the contents of the file and display a progress bar 782 | pwd -P##Print the current directory, and resolve all symlinks (i.e. show the "physical" path) 783 | pwd##Print the current directory 784 | python -c {{command}}##Execute Python language single command 785 | python -m {{module}} {{arguments}}##Run library module as a script (terminates option list) 786 | python {{script.py}}##Execute script in a given Python file 787 | python##Call a Python interactive shell (REPL) 788 | read -a {{array}}##Store each of the next lines you enter as values of an array 789 | read -d {{new_delimiter}} {{variable}}##Use a specific character as a delimiter instead of a new line 790 | read -e {{variable}}##Enable backspace and GNU readline hotkeys when entering input with read 791 | read -n {{character_count}} {{variable}}##Specify the number of maximum characters to be read 792 | read {{variable}}##Store data that you type from the keyboard 793 | readlink -f {{filename}}##Get the absolute path to a file 794 | readlink {{filename}}##Get the actual file to which the symlink points 795 | redis-cli -a {{password}}##Specify a password 796 | redis-cli -h {{host}} -p {{port}}##Connect to a remote server specifying a port number 797 | redis-cli -h {{host}}##Connect to a remote server on the default port (6379) 798 | redis-cli {{redis command}}##Execute Redis command 799 | redis-cli##Connect to the local server 800 | redshift -O {{temperature}}##Turn on Redshift with a constant unchanging color temperature 801 | redshift -b {{0.7}}:{{0.4}}##Turn on Redshift with 70% screen brightness during day and 40% brightness at night 802 | redshift -g {{red}}:{{green}}:{{blue}}##Turn on Redshift with custom gamma levels (between 0 and 1) 803 | redshift -l {{latitude}}:{{longitude}}##Turn on Redshift with a manually-specified custom location 804 | redshift -t {{5700}}:{{3600}}##Turn on Redshift with 5700K temperature during day and 3600K at night 805 | rename 's/\s+/_/g' {{\*}}##Replace whitespace with underscores 806 | rename 'y/A-Z/a-z/' {{\*}}##Convert filenames to lower case 807 | rename -n {{'s/foo/bar/'}} {{\*}}##Dry-run - display which renames would occur without performing them 808 | rename {{'s/foo/bar/'}} {{\*}}##Rename files using a Perl Common Regular Expression (substitute 'foo' with 'bar' wherever found) 809 | renice -n {{niceness_value}} -g {{group}}##Change priority of all processes that belongs to a group 810 | renice -n {{niceness_value}} -p {{pid}}##Change priority of a running process 811 | renice -n {{niceness_value}} -u {{user}}##Change priority of all processes owned by a user 812 | rm -i {{\*}}##Prompt before every removal 813 | rm -r {{/path/to/folder}}##Remove recursively a directory and all its subdirectories 814 | rm -rf {{/path/to/folder}}##Remove directory without prompt 815 | rm {{/path/to/file}} {{/otherpath/to/file2}}##Remove files from arbitrary locations 816 | rmdir -p {{path}}##Remove directories recursively (useful for nested dirs) 817 | rmdir {{directory}}##Remove directory, provided it is empty. Use `rm` to remove not empty directories 818 | route -n##Display the information of route table 819 | rsync -az {{path/to/file}} {{remote_host_name}}:{{remote_host_location}}##Transfer file in archive (to preserve attributes) and compressed (zipped) mode 820 | rsync -e ssh --progress {{remote_host_name}}:{{remote_file}} {{local_file}}##Transfer file over SSH and show progress 821 | rsync -r {{remote_host_name}}:{{remote_folder_location}} {{local_folder_location}}##Transfer a directory and all its children from a remote to local 822 | rsync -ru {{remote_host_name}}:{{remote_folder_location}} {{local_folder_location}}##Transfer only updated files from remote host 823 | rsync {{path/to/file}} {{remote_host_name}}:{{remote_host_location}}##Transfer file from local to remote host 824 | rsync {{remote_host_name}}:{{remote_file_location}} {{local_file_location}}##Transfer file from remote host to local 825 | sails generate controller {{name}}##Generate Sails Controller 826 | sails generate model {{name}}##Generate Sails Model 827 | sails generate {{name}}##Generate Sails API 828 | sails lift##Start Sails 829 | sails new {{projectName}}##Create new Sails project 830 | salt '*' state.highstate##Execute a highstate on all connected minions 831 | salt '*' test.ping##List connected minions 832 | salt '*.domain.com' pkg.upgrade##Upgrade packages using the OS package manager (apt, yum, brew) on a subset of minions 833 | salt '{{minion_id}}' cmd.run "ls "##Execute an arbitrary command on a particular minion 834 | salt-call -l debug state.highstate##Perform a highstate with verbose debugging output 835 | salt-call grains.items##List this minion's grains 836 | salt-call state.highstate test=true##Perform a highstate dry-run, compute all changes but don't actually perform them 837 | salt-call state.highstate##Perform a highstate on this minion 838 | salt-key -F##Print fingerprints of all public keys 839 | salt-key -L##List all accepted, unaccepted and rejected minion keys 840 | salt-key -a {{MINION_ID}}##Accept a minion key by name 841 | salt-key -r {{MINION_ID}}##Reject a minion key by name 842 | salt-run manage.status##Show status of all minions 843 | salt-run manage.up##Show all minions which are disconnected 844 | sass --watch {{inputfile.(scss|sass)}}##Watch SCSS or Sass file for changes and output or update CSS file with same filename 845 | sass --watch {{inputfile.(scss|sass)}}:{{outputfile.css}}##Watch SCSS or Sass file for changes and output or update CSS file with specified filename 846 | sass {{inputfile.(scss|sass)}} {{outputfile.css}}##Immediately convert SCSS or Sass file to CSS to specified output file 847 | sass {{inputfile.(scss|sass)}}##Output converted file to stdout 848 | scp -3 {{host1}}:{{/path/remote_file.ext}} {{host2}}:{{/path/remote_dir}}##Copy a file between two remote hosts transferring through the local host 849 | scp -i {{~/.ssh/id_rsa}} {{local_file}} {{remote_host}}:{{/path/remote_file}}##Use a specific ssh private key for authentication with the remote host 850 | scp -r {{/path/local_dir}} {{remote_host}}:{{/path/remote_dir}}##Recursively copy the contents of a directory on a remote host to a local directory 851 | scp {{local_file}} {{remote_host}}:{{/path/remote_file}}##Copy a local file to a remote host 852 | scp {{local_file}} {{remote_username}}@{{remote_host}}:{{/remote/path}}##Use a specific username when connecting to the remote host 853 | scp {{remote_host}}:{{/path/remote_file}} {{/path/local_dir}}##Copy a file from a remote host to a local folder 854 | screen -S {{name}}##Start a new named screen session 855 | screen -X -S {{screen id}} quit##Kill a detached screen 856 | screen -ls##Show open screen sessions 857 | screen -r {{screen id}}##Reattach to an open screen 858 | screen##Start a new screen session 859 | sed '/{{line_pattern}}/s/{{find}}/{{replace}}/'##Replace only on lines matching the line pattern 860 | sed 's/{{find}}/{{replace}}/' {{filename}}##Replace the first occurrence of a string in a file, and print the result 861 | sed -e 's/{{find}}/{{replace}}/' -e 's/{{find}}/{{replace}}/' {{filename}}##Apply multiple find-replace expressions to a file 862 | sed -i 's/{{find}}/{{replace}}/g' {{filename}}##Replace all occurrences of a string in a file, overwriting the file (i.e. in-place) 863 | sed -r 's/{{regex}}/{{replace}}/g' {{filename}}##Replace all occurrences of an extended regular expression in a file 864 | seq -s " " 5 3 20##Separate the output with a space instead of a newline 865 | seq 10##Sequence from 1 to 10 866 | seq 5 3 20##Every 3rd number from 5 to 20 867 | sftp -P {{remote_port}} {{remote_user}}@{{remote_host}}##Connect using an alternate port 868 | sftp {{remote_user}}@{{remote_host}}##Connect to a remote server and enter an interactive command mode 869 | sh -c {{command}}##Execute a command 870 | sh -s##Run commands from STDIN 871 | sh {{file.sh}}##Run commands from a file 872 | sh##Start interactive shell 873 | shred --remove {{file}}##Overwrite a file and remove it 874 | shred --zero {{file}}##Overwrite a file, leaving zeroes instead of random data 875 | shred -n25 {{file}}##Overwrite a file 25 times 876 | shred {{file}}##Overwrite a file 877 | skicka download {{path/to/remote}} {{path/to/local}}##Download a file/folder from Google Drive 878 | skicka du {{path/to/parent/folder}}##Show amount of space used by children folders 879 | skicka ls {{path/to/folder}}##List files 880 | skicka mkdir {{path/to/folder}}##Create a folder 881 | skicka rm {{path/to/file}}##Delete a file 882 | skicka upload {{path/to/local}} {{path/to/remote}}##Upload a file/folder to Google Drive 883 | sl -F##Let the train fly 884 | sl -a##The train burns, people scream 885 | sl##Let a steam locomotive run through your terminal 886 | slackcat --channel {{channel_name}} --filename={{filename}} {{path/to/file}}##Post a file to Slack with a custom filename 887 | slackcat --channel {{channel_name}} {{path/to/file}}##Post a file to Slack 888 | sleep {{hours}}h##Delay in hours 889 | sleep {{minutes}}m##Delay in minutes 890 | sleep {{seconds}}##Delay in seconds 891 | socat - TCP-LISTEN:8080,fork##Listen to a port, wait for an incoming connection and transfer data to STDIO 892 | socat - TCP4:www.domain.com:80##Create a connection to a host and port, transfer data in STDIO to connected host 893 | socat TCP-LISTEN:80,fork TCP4:www.domain.com:80##Forward incoming data of a local port to another host and port 894 | sort -r {{filename}}##Sort a file in descending order 895 | sort -t: -k 3n /etc/passwd##Sort passwd file by the 3rd field 896 | sort {{filename}}##Sort a file in ascending order 897 | source {{path/to/venv}}/bin/activate##Start (select) the environment 898 | sox --norm {{input_audiofile}} {{output_audiofile}}##Normalize an audio file (adjust volume to the maximum peak level, without clipping) 899 | sox -m {{input_audiofile1}} {{input_audiofile2}} {{output_audiofile}}##Merge two audio files into one 900 | sox {{input_audiofile}} -n stat##Print statistical data of an audio file 901 | sox {{input_audiofile}} {{output_audiofile}} reverse##Reverse and save an audio file 902 | sox {{input_audiofile}} {{output_audiofile}} trim {{start}} {{end}}##Trim an audio file to the specified times 903 | split -C 512 {{filename}}##Split a file with at most 512 bytes of lines in each split 904 | split -l 10 {{filename}}##Split a file, each split having 10 lines (except the last split) 905 | split -n 5 {{filename}}##Split a file into 5 files. File is split such that each split has same size (except the last split) 906 | srm -i {{\*}}##Prompt before every removal 907 | srm -m {{/path/to/file}}##Remove a file after seven passes of overwriting with random data 908 | srm -r -s {{/path/to/folder}}##Recursively remove a directory and its contents overwriting each file with a single-pass of random data 909 | srm -s {{/path/to/file}}##Remove a file after a single-pass overwriting with random data 910 | ssh -A {{username}}@{{remote_host}}##SSH enable agent forward 911 | ssh -D {{9999}} -C {{username}}@{{remote_host}}##SSH tunneling: Dynamic port forwarding (SOCKS proxy on localhost:9999) 912 | ssh -L {{9999}}:slashdot.org:80 {{username}}@{{remote_host}}##SSH tunneling: Forward a specific port (localhost:9999 to slashdot.org:80) 913 | ssh -i {{/path/to/key_file}} {{username}}@{{remote_host}}##Connect to a remote server with a specific identity (private key) 914 | ssh {{remote_host}} {{command -with -flags}}##Run a command on a remote server 915 | ssh {{username}}@{{remote_host}} -p {{2222}}##Connect to a remote server using a specific port 916 | ssh {{username}}@{{remote_host}}##Connect to a remote server 917 | ssh-keygen -f ~/.ssh/{{filename}}##Specify file in which to save the key 918 | ssh-keygen -l -F {{remote_host}}##Retrieve the key fingerprint from a host (useful for confirming the authenticity of the host when first connecting to it via SSH) 919 | ssh-keygen -t dsa##Generate a DSA 2048 bit (default) key 920 | ssh-keygen -t rsa -b 4096 -C "{{email}}"##Generate an RSA 4096 bit key with your email as a comment 921 | ssh-keygen##Generate a key interactively 922 | sshfs {{username}}@{{remote_host}}:{{remote_directory}} -C##Use compression 923 | sshfs {{username}}@{{remote_host}}:{{remote_directory}} -p {{2222}}##Mount remote directory from server with specific port 924 | sshfs {{username}}@{{remote_host}}:{{remote_directory}} {{mountpoint}}##Mount remote directory 925 | strings -n {{length}} {{file}}##Limit results to strings at least *length* characters long 926 | strings -t d {{file}}##Prefix each result with its offset within the file 927 | strings -t x {{file}}##Prefix each result with its offset within the file in hexadecimal 928 | strings {{file}}##Print all strings in a binary 929 | su - {{username}}##Switch to user {{username}} and simulate a full login shell 930 | su {{username}}##Switch to user {{username}} (password required) 931 | su##Switch to superuser (admin password required) 932 | sudo -u {{www}} {{vi}} {{/var/www/index.html}}##To edit a file as user www 933 | sudo arp -a -d##Clear the entire cache 934 | sudo route add -net {{ip_address}} netmask {{netmask_address}} gw {{gw_address}}##Add route rule 935 | sudo route del -net {{ip_address}} netmask {{netmask_address}} dev {{gw_address}}##Delete route rule 936 | sudo visudo -c##Check sudoers file for errors 937 | sudo visudo##Edit sudoers file 938 | sudo {{!!}}##To repeat the last command as sudo 939 | sudo {{ls}} {{/usr/local/scrt}}##List of an unreadable directory 940 | sudo {{shutdown}} -r +10 {{"Cya soon!"}}##To shutdown the machine 941 | sum --sysv {{file}}##Compute a checksum with System V-compatible algorithm and 512-byte blocks 942 | sum {{file}}##Compute a checksum with BSD-compatible algorithm and 1024-byte blocks 943 | svn add PATH...##Put files and directories under version control, scheduling them for addition to repository. They will be added in next commit 944 | svn ci -m {{commit log message}} {{[PATH...]}}##Send changes from your working copy to the repository 945 | svn co {{url/to/repository}}##Check out a working copy from a repository 946 | svn help##Show detailed help 947 | svn up##Bring changes from the repository into the working copy 948 | tabula --format JSON -o {{file.json}} {{file.pdf}}##Extract all tables from a PDF to a JSON file 949 | tabula --guess --pages {{1}} {{file.pdf}}##Extract tables from page 1 of a PDF, guessing which portion of the page to examine 950 | tabula --no-spreadsheet {{file.pdf}}##Extract all tables from a PDF, using blank space to determine cell boundaries 951 | tabula --pages {{1-3,6}} {{file.pdf}}##Extract tables from pages 1, 2, 3, and 6 of a PDF 952 | tabula --spreadsheet {{file.pdf}}##Extract all tables from a PDF, using ruling lines to determine cell boundaries 953 | tabula -o {{file.csv}} {{file.pdf}}##Extract all tables from a PDF to a CSV file 954 | tac {{file1}} {{file2}} > {{target-file}}##Concatenate several files reversed into the target file 955 | tac {{file1}}##Print the contents of *file1* reversed to the standard output 956 | tail -c {{num}} {{file}}##Show last 'num' bytes in file 957 | tail -f {{file}}##Keep reading file until ctrl-c 958 | tail -n +{{num}} {{file}}##Show all file since line 'num' 959 | tail -n {{num}} {{file}}##Show last 'num' lines in file 960 | tar caf {{target.tar.xz}} {{file1 file2 file3}}##Create a compressed archive, using archive suffix to determine the compression program 961 | tar cf {{target.tar}} {{file1 file2 file3}}##Create an archive from files 962 | tar czf {{target.tar.gz}} {{file1 file2 file3}}##Create a gzipped archive 963 | tar tvf {{source.tar}}##List the contents of a tar file 964 | tar xf {{source.tar}} -C {{folder}}##Extract an archive in a target folder 965 | tar xjf {{source.tar.bz2}}##Extract a bzipped archive in the current directory 966 | tar xzf {{source.tar.gz}}##Extract a gzipped archive in the current directory 967 | tcpdump -A tcp##Capture all TCP traffic showing contents (ASCII) in console 968 | tcpdump -i {{eth0}} src {{192.168.1.1}} and dst {{192.168.1.2}} and dst port 80##Capture the traffic from a specific interface, source, destination and destination port 969 | tcpdump -i {{eth0}}##Capture the traffic of a specific interface 970 | tcpdump -w dumpfile.pcap not port 22##Capture all traffic except traffic over port 22 and save to a dump file 971 | tcpdump host {{www.example.com}}##Capture the traffic from or to a host 972 | tcpdump net {{192.168.1.0/24}}##Capture the traffic of a network 973 | telnet {{ip_address}} {{port}}##Telnet to a certain port 974 | telnet -e x {{ip_address}} {{port}}##Specify an escape character (x is the escape character) 975 | test ! -d {{path/to/directory}}##Test if directory not exists 976 | test $MY_VAR == '/bin/zsh'##Test if given variable is equal to given string 977 | test -e {{filename}}##Test if file exists 978 | test -z $GIT_BRANCH##Test if given variable is empty 979 | test {{condition}} && echo "true" || echo "false"##If-else statement 980 | time ls##Time "ls" 981 | tldr --update##Update the local cache of tldr pages 982 | tldr {{command}}##Get typical usages of a command (hint: this is how you got here!) 983 | tldrl -f {{page.md}}##Format a specific page to stdout 984 | tldrl -fi {{pages_directory}}##Format all pages in place 985 | tldrl {{pages_directory}}##Lint all pages 986 | tmux a -t {{name}}##Attach to a named session 987 | tmux a##Attach to a session 988 | tmux kill-session -t {{name}}##Kill session 989 | tmux ls##List sessions 990 | tmux new -s {{name}}##Start a new named tmux session 991 | tmux##Start a new tmux session 992 | touch -r {{filename}} {{filename2}}##Use the times from a file to set the times on a second file 993 | touch -t {{YYYYMMDDHHMM.SS}} {{filename}}##Set the times on a file to a specific date and time 994 | touch {{filename}}##Create a new empty file(s) or change the times for existing file(s) to current time 995 | tput bel##Ring the terminal bell 996 | tput cup {{y_coordinate}} {{x_coordinate}}##Move the cursor to a screen location 997 | tput sgr0##Reset all terminal attributes 998 | tput {{cols|lines|colors}}##Show number of columns, lines, or colors 999 | tput {{setaf|setab}} {{ansi_color_code}}##Set foreground (af) or background (ab) color 1000 | tr "[:lower:]" "[:upper:]" < {{filename}}##Translate the contents of the file to upper-case and print result 1001 | tr 'abcd' 'jkmn' < {{filename}}##Map each character of the first set to the corresponding character of the second set 1002 | tr -cd "[:print:]" < {{filename}}##Strip out non-printable characters from the file and print result 1003 | tr -d '{{input_characters}}'##Delete all occurances of the specified set of characters from the input 1004 | tr -s '\n'##Compress a series of identical characters to a single character 1005 | tr {{find_characters}} {{replace_characters}} < {{filename}}##Replace all occurrences of a character in a file, and print the result 1006 | traceroute -n {{host}}##Disable IP address and host name mapping 1007 | traceroute -q 5 {{host}}##Specify number of queries per hop 1008 | traceroute -w 0.5 {{host}}##Specify wait time for response 1009 | traceroute {{host}}##Traceroute to a host 1010 | transcode -J stabilize -i {{inputfile}}##Create stabilisation file to be able to remove camera shakes 1011 | transcode -J transform -i {{inputfile}} -y xvid -o {{outputfile}}##Remove camera shakes after creating stabilisation file, transform video using xvid 1012 | transcode -Z 640x480 -i {{inputfile}} -y xvid -o {{outputfile}}##Resize the video to 640x480 pixels and convert to MPEG4 codec using xvid 1013 | tree -L {{num}}##Show files and directories with a depth of 'num' 1014 | tree -a##Show hidden files too 1015 | tree -d##Show directories only 1016 | tree -f##Print the full path for each file 1017 | tree -h##Print human readable size of files 1018 | tree -i##Print the tree without lines and indentation. Useful when used with -f 1019 | tty##Print the file name of this terminal 1020 | ufraw-batch --embedded-image {{input-file(s)}}##Extract the preview image from the raw file 1021 | ufraw-batch --out-type=jpg {{input-file(s)}}##Simply convert RAW files to jpg 1022 | ufraw-batch --out-type=png {{input-file(s)}}##Simply convert RAW files to png 1023 | ufraw-batch --size=MAX1,MAX2 {{input-file(s)}}##Save the file with size up to the given maximums MAX1 and MAX2 1024 | umount -a##Unmount all mounted filesystems (dangerous!) 1025 | umount {{path_to_device_file}}##Unmount a filesystem 1026 | umount {{path_to_mounted_directory}}##OR 1027 | unalias {{word}}##Remove an aliased command 1028 | uname -a##Print all available system information (hardware, software, nodename) 1029 | uname -mp##Print hardware-related information: machine and processor 1030 | uname -n##Print the nodename (hostname) of the system 1031 | uname -srv##Print software-related information: operating system, release number, and version 1032 | uniq -c {{file}}##Display number of occurences of each line along with that line 1033 | uniq -d {{file}}##Display only duplicate lines 1034 | uniq -u {{file}}##Display only unique lines 1035 | uniq {{file}}##Display each line once 1036 | unrar e {{compressed.rar}}##Extract files into current directory, losing directory structure in the archive 1037 | unrar l {{compressed.rar}}##List files inside the archive file without decompressing it 1038 | unrar t {{compressed.rar}}##Test integrity of each file inside the archive file 1039 | unrar x {{compressed.rar}}##Extract files with original directory structure 1040 | unzip -l {{file}}##List the contents of a zip file without extracting 1041 | unzip {{file(s)}}##Extract zip file(s) (for multiple files, seperate file paths by spaces) 1042 | unzip {{files(s)}} -d {{/path/to/put/extracted/files}}##Extract zip files(s) to given path 1043 | uptime##Print current time, uptime, number of logged-in users and other information 1044 | vagrant init ubuntu/trusty32##Create Vagrantfile with the Ubuntu 14.04 (Trusty Tahr) box from HashiCorp Atlas 1045 | vagrant init##Create Vagrantfile in current folder with the base Vagrant box 1046 | vagrant ssh##Connect to machine via SSH 1047 | vagrant suspend##Suspend the machine 1048 | vagrant up##Start and provision the vagrant environment 1049 | view {{file}}##Open a file in read-only mode 1050 | vim -p {{file1}} {{file2}} {{file3}}##Open multiple files at once, each file in it's own tab page 1051 | vim {{file}} +{{linenumber}}##Open a file with cursor at the given line number 1052 | vimtutor {{language}}##Launch the vim tutor using the given language (en, fr, de, ...) 1053 | virtualenv {{path/to/venv}}##Create a new environment 1054 | w -h##Show logged-in users info without a header 1055 | w##Show logged-in users info 1056 | watch -d {{ls -l}}##Monitor the contents of a directory, highlighting differences as they appear 1057 | watch -n {{60}} {{command}}##Re-run a command every 60 seconds 1058 | watch {{command}}##Repeatedly run a command and show the result 1059 | wc -c {{file}}##Count characters (bytes) in file 1060 | wc -l {{file}}##Count lines in file 1061 | wc -m {{file}}##Count characters in file (taking multi-byte character sets into account) 1062 | wc -w {{file}}##Count words in file 1063 | wget --ftp-user={{username}} --ftp-password={{password}} {{url}}##FTP download with username and password 1064 | wget --limit-rate={{200k}} {{url}}##Limit download speed 1065 | wget --mirror -p --convert-links -P {{target_folder}} {{url}}##Download a full website 1066 | wget -O {{filename}} "{{url}}"##Download a URL to a file 1067 | wget -c {{url}}##Continue an incomplete download 1068 | which -a {{executable}}##If there are multiple executables which match, display all 1069 | which {{executable}}##Search the PATH environment variable and display the location of any matching executables 1070 | while :; do {{command}}; sleep 1; done##Execute a command forever once every second 1071 | while read line; do echo "$line"; done##Read stdin and perform an action on every line 1072 | who -a -H##Display all available information with table headers 1073 | who -a##Display all available information 1074 | who am i##Display information only for the current terminal session 1075 | who##Display the username, line, and time of all currently logged-in sessions 1076 | whoami##Display currently logged user name 1077 | x_x --delimiter={{';'}} --quotechar={{'|'}} {{file.csv}}##View a CSV file with unconventional delimiters 1078 | x_x -h {{0}} {{file.ext}}##View an XLSX or CSV file, using the first row as table headers 1079 | x_x {{file.ext}}##View an XLSX or CSV file 1080 | xcv c {{input_file}}##Copy a file 1081 | xcv l##List files available for pasting 1082 | xcv v {{output_file}}##Paste a file 1083 | xcv x {{input_file}}##Cut a file 1084 | xz -0 {{file}}##Compress a file using the fastest compression 1085 | xz -9 {{file}}##Compress a file using the best compression 1086 | xz -d {{file.xz}}##Decompress a file 1087 | xz -dc {{file.xz}}##Decompress a file and write to stdout 1088 | xz -k {{file}}##Compress a file, but don't delete the original 1089 | xz {{file}}##Compress a file 1090 | yes {{message}}##Repeatedly output "message" 1091 | yes##Repeatedly output "y" 1092 | youtube-dl --format {{mp4}} --output {{"%(title) by %(uploader) on %(upload_date) in %(playlist).%(ext)"}} {{url}}##Download video(s) as MP4 files with custom filenames 1093 | youtube-dl --match-title {{"let's play"}} --age-limit {{7}} --reject-title {{"nsfw"}} {{playlist_url}}##From a playlist, download all "Let's Play" videos that aren't marked "NSFW" or age-restricted for 7 year-olds 1094 | youtube-dl --write-description --write-info-json --write-annotations --write-sub --write-thumbnail {{url}}##Download a video and save its description, metadata, annotations, subtitles, and thumbnail 1095 | youtube-dl -x --audio-format {{mp3}} {{url}}##Download the audio from a video and convert it to an MP3 1096 | youtube-dl {{https://www.youtube.com/watch?v=oHg5SJYRHA0}}##Download a video or playlist 1097 | zbarimg {{image file}}##Process an image file 1098 | zcat {{file.txt.gz}}##Print the uncompressed contents of a gzipped file to the standard output 1099 | zdb -C {{poolname}}##Show detailed configuration for a specific ZFS pool 1100 | zdb -b {{poolname}}##Show statistics about number, size and deduplication of blocks 1101 | zdb##Show detailed configuration of all mounted ZFS zpools 1102 | zfs create {{pool_name/filesystem_name}}##Create a new ZFS filesystem 1103 | zfs destroy {{pool_name/filesystem_name}}##Delete a ZFS filesystem 1104 | zfs list##List all available zfs filesystems 1105 | zfs set compression=on {{pool_name/filesystem_name}}##Enable compression on a filesystem 1106 | zfs set mountpoint={{/my/mount/path}} {{pool_name/filesystem_name}}##Change mountpoint for a filesytem 1107 | zfs snapshot {{pool_name/filesystem_name}}@{{snapshot_name}}##Create a Snapshot of a ZFS filesystem 1108 | zip -d {{compressed.zip}} "{{foo/*.tmp}}"##Remove unwanted files from an existing zip file 1109 | zip -r {{compressed.zip}} {{/path/to/dir1 /path/to/dir2 /path/to/file}}##Package and compress multiple directories and files 1110 | zip -r {{compressed.zip}} {{path/to/dir}} -x \*.git\* \*node_modules\* ...##Exclude unwanted files from being added to the compressed archive 1111 | zip {{compressed.zip}} {{path/to/file}}##Add files to an existing zip file 1112 | zless {{file.txt.gz}}##Page through a compressed archive with `less` 1113 | zpool create {{pool_name}} mirror {{disk1}} {{disk2}} mirror {{disk3}} {{disk4}}##Create a mirrored pool 1114 | zpool export {{pool_name}}##Export a zpool (unmount all filesystems) 1115 | zpool histrory {{pool_name}}##Show the history of all pool operations 1116 | zpool import {{pool_name}}##Import a zpool 1117 | zpool import##List zpools available for import 1118 | zpool scrub {{pool_name}}##Check a ZFS pool for errors (verifies the checksum of EVERY block). Very CPU and disk intensive 1119 | zpool status##Show the configuration and status of all ZFS zpools 1120 | zsh -c {{command}}##Execute command passed as parameter 1121 | zsh -x {{file}}##Run commands from file and print them as they are executed 1122 | zsh {{file}}##Run commands from file (script) 1123 | zsh##Start interactive command line interpreter 1124 | {{args}} | parallel -X {{command}}##Parallel xargs, cram as many args as possible onto one command 1125 | {{arguments_null_terminated}} | xargs -0 {{command}}##Handle whitespace in arguments 1126 | {{arguments}} | xargs -I piped_arguments {{command}} piped_arguments {{rest_of_arguments}}##Insert arguments at chosen position 1127 | {{arguments}} | xargs {{command}}##Main use 1128 | {{command}} && echo "success" || echo "failure"##Echo a different thing depending on a command's success 1129 | {{command}} | slackcat --channel {{channel_name}} --filename={{snippet_name}}##Pipe command output to Slack as a text snippet 1130 | {{command}} | slackcat --channel {{channel_name}} --stream##Stream command output to Slack continuously 1131 | {{somecommand}} | base32 -d##Decode from stdin 1132 | {{somecommand}} | base32##Encode from stdin 1133 | {{somecommand}} | base64 -d##Decode from stdin 1134 | {{somecommand}} | base64##Encode from stdin 1135 | -------------------------------------------------------------------------------- /tldr/linux.txt: -------------------------------------------------------------------------------- 1 | apt-cache depends {{package}}##Show dependencies for a package 2 | apt-cache policy {{package}}##Show whether a package is installed and up to date 3 | apt-cache rdepends {{package}}##Show packages that depend on a particular package 4 | apt-cache search {{query}}##Search for a package in your current sources 5 | apt-cache show {{package}}##Show information about a package 6 | apt-get dist-upgrade##Upgrade installed packages (like "upgrade"), but remove obsolete packages and install additional packages to meet new dependencies 7 | apt-get install {{package}}##Install a new package 8 | apt-get remove {{package}}##Remove a package 9 | apt-get update##Synchronize list of packages and versions available. This should be run first, before running subsequent apt-get commands 10 | apt-get upgrade##Upgrade installed packages to newest available versions 11 | apt-key add {{public_key_file.asc}}##Add a key to the trusted keystore 12 | apt-key del {{key_id}}##Delete a key from the trusted keystore 13 | apt-key list##List trusted keys 14 | aptitude full-upgrade##Upgrade installed packages (like `aptitude upgrade`) including removing obsolete packages and installing additional packages to meet new package dependencies 15 | aptitude install {{package}}##Install a new package and its dependencies 16 | aptitude purge {{package}}##Do an `aptitude remove {{package}}` and remove all config files 17 | aptitude remove {{package}}##Remove a package and all packages depending on it 18 | aptitude search {{package}}##Search for a package 19 | aptitude update##Synchronize list of packages and versions available. This should be run first, before running subsequent aptitude commands 20 | aptitude upgrade##Upgrade installed packages to newest available versions 21 | archey##Show system information 22 | chattr +i {{path}}##Make a file or folder immutable to changes and deletion, even by superuser 23 | chattr -R +i {{folder}}##Recursively make an entire folder and contents immutable 24 | chattr -i {{path}}##Make a file or folder mutable 25 | chroot {{/path/to/new/root}} {{command}}##Run command as new root directory 26 | chroot --userspec={{user:group}}##Specify user and group (ID or name) to use 27 | compose {{filename}}##Compose action can be used to compose any existing file or new on default mailcap edit tool 28 | dd if=/dev/urandom of={{random_file}} bs=100 count=1##Generate a file of 100 random bytes by using kernel random driver 29 | dd if=/dev/zero of={{file_1GB}} bs=1024 count=1000000##Benchmark the write performance of a disk 30 | dd if=/dev/{{source_drive}} of=/dev/{{dest_drive}} bs=4M conv=noerror##Clone a drive to another drive with 4MB block and ignore error 31 | dd if={{file.iso}} of=/dev/{{usb_drive}}##Make a bootable usb drive from an isohybrid file (such like archlinux-xxx.iso) 32 | dnf -y install {{package}}##Install a new package and assume yes to all questions 33 | dnf install {{package}}##Install a new package 34 | dnf remove {{package}}##Remove a package 35 | dnf update##Synchronize list of packages and versions available. This should be run first, before running subsequent dnf commands 36 | dnf upgrade##Upgrade installed packages to newest available versions 37 | dpkg -L {{package_name}}##List package contents 38 | dpkg -i {{/path/to/file}}##Install a package 39 | dpkg -l {{pattern}}##List installed packages 40 | dpkg -r {{package_name}}##Remove a package 41 | dpkg-query -L {{package_name}}##List all files installed by a package 42 | dpkg-query -l '{{pattern}}'##List installed packages matching a pattern 43 | dpkg-query -l##List all installed packages 44 | dpkg-query -s {{package_name}}##Show information about a package 45 | du --max-depth=N##List the KB sizes of directories for N levels below the specified directory 46 | du -ah {{directory}}##Get recursively, individual file/folder sizes in human readable form 47 | du -k {{file_or_directory}}##List file sizes of a directory and any subdirectories in KB 48 | du -m {{file_or_directory}}##List file sizes of a directory and any subdirectories in MB 49 | du -sh {{file_or_directory}}##Get a sum of the total size of a file/folder in human readable units 50 | echo "{{message}}" | wall##Send a message 51 | echo 123 | xclip -i##Copy output to clipboard 52 | edit {{filename}}##Edit action can be used to view any file on default mailcap explorer 53 | emerge --resume --skipfirst##Resume a failed updated, skipping the failing package 54 | emerge --sync##Synchronize all packages 55 | emerge -Cav {{package-name}}##Remove a package, with confirmation 56 | emerge -S {{keyword}}##Search the package database for a keyword 57 | emerge -av {{package-name}}##Install a new package, with confirmation 58 | emerge -avc##Remove orphaned packages (that were installed only as dependencies) 59 | emerge -uDNav @world##Update all packages, including dependencies 60 | fc-match -s '{{Font Name}}'##Return a sorted list of best matching fonts 61 | fc-pattern -d '{{Font Name}}'##Display default infomation about a font 62 | findmnt -t {{ext4}}##Find filesystems in specific type 63 | findmnt LABEL={{BigStorage}}##Find filesystems with specific label 64 | findmnt {{/dev/sdb1}}##Search for a device 65 | findmnt {{/}}##Search for a mountpoint 66 | findmnt##List all mounted filesystems 67 | firewall-cmd --get-active-zones##View the available firewall zones 68 | firewall-cmd --list-all##View the rules which are currently applied 69 | firewall-cmd --permanent --zone={{public}} --add-service={{https}}##Permanently open the port for a service in the specified zone (like port `443` when in the `public` zone) 70 | firewall-cmd --permanent --zone={{public}} --remove-service={{http}}##Permanently close the port for a service in the specified zone (like port `80` when in the `public` zone) 71 | firewall-cmd --reload##Reload firewalld to force rule changes to take effect 72 | free -h##Display memory in human readable units 73 | free -s {{X}}##Continuous monitor memory (refresh every X seconds) 74 | free {{-b/-k/-m/-g}}##Display memory in Bytes/KB/MB/GB 75 | free##Display system memory 76 | fuser -n tcp {{port}}##Identify process using a TCP socket 77 | getenet group {{group_name}}##See the members of a group 78 | getent group##Get list of all groups 79 | getent hosts {{host}}##Perform a reverse DNS lookup 80 | getent passwd 1000##Find a username by UID 81 | getent services##Get list of all services 82 | head -c -{{size_in_bytes}} {{filename}}##Output everything but the last few bytes of a file 83 | head -c {{size_in_bytes}} {{filename}}##Output the first few bytes of a file 84 | head -n -{{count_of_lines}} {{filename}}##Output everything but the last few lines of a file 85 | head -n {{count_of_lines}} {{filename}}##Output the first few lines of a file 86 | hostname --fqdn##Show the FQDN (Fully Qualified Domain Name) 87 | hostname -I##Show all network addresses of the host 88 | hostname -i##Show the network address of the host name 89 | hostname {{new_hostname}}##Set current host name 90 | hostname##Show current host name 91 | iostat -Nh##Display disk statistics with disk names (including LVM) in human readable format 92 | iostat -c##Display CPU statistics 93 | iostat -h##Display disk statistics with disk IDs in human readable format 94 | iostat -xN##Display extended disk statistics with disk names 95 | ip a##List interfaces with detailed info 96 | ip addr add/del {{ip}}/{{mask}} dev {{interface}}##Add/Delete an ip address to an interface 97 | ip link set {{interface}} up/down##Make an interface up/down 98 | ip r##Display the routing table 99 | ip route add default via {{ip}} dev {{interface}}##Add an default route 100 | jobs -l##List jobs and their process ids 101 | jobs -n##Display information about jobs with changed status 102 | jobs -p##Display process id of process group leader 103 | jobs -r##Display running processes 104 | jobs -s##Display stopped processes 105 | jobs##View jobs spawned by the current shell 106 | journalctl -b -1##Show all messages from last boot 107 | journalctl -b##Show all messages from this boot 108 | journalctl -f##Follow new messages (like `tail -f` for traditional syslog) 109 | journalctl -u {{unit}}##Show all messages by a specific unit 110 | journalctl _PID={{pid}}##Show all messages by a specific process 111 | journalctl {{/path/to/executable}}##Show all messages by a specific executable 112 | locate {{pattern}}##Look for pattern in the database. Note: the database is recomputed periodically (usually weekly or daily) 113 | lsattr -R##List file attributes recursively in the current and subsequent directories 114 | lsattr -a##Show attributes of all the files in the current directory, including hidden ones 115 | lsattr -d##Display attributes of directories in the current directory 116 | lsattr {{path}}##List the attributes of files in a particular path 117 | lsattr##Display the attributes of the files in the current directory 118 | lsb_release -a##Print all available information 119 | lsb_release -d##Print a description (usually the full name) of the operating system 120 | lsb_release -i -s##Print only the operating system name (ID), suppressing the field name 121 | lsb_release -rcs##Print the release number and codename of the distribution, suppressing the field names 122 | lsblk -a##Also list empty devices 123 | lsblk -b##Print the SIZE column in bytes rather than in a human-readable format 124 | lsblk -f##Output info about filesystems 125 | lsblk -i##Use ASCII characters for tree formatting 126 | lsblk -t##Output info about block-device topology 127 | lsblk##List all storage devices in a tree-like format 128 | ltrace -c {{/path/to/program}}##Count library calls. Print a handy summary at the bottom 129 | ltrace -e malloc+free-@libc.so* {{/path/to/program}}##Trace calls to malloc and free, omit those done by libc 130 | ltrace -o {{file}} {{/path/to/program}}##Write to file instead of terminal 131 | ltrace ./{{program}}##Print (trace) library calls of a program binary 132 | md5sum -c {{filename.md5}}##Read a file of MD5SUMs and verify all files have matching checksums 133 | md5sum {{filename1}} {{filename2}}##Calculate MD5 checksums for multiple files 134 | md5sum {{filename1}}##Calculate the MD5 checksum for a file 135 | mdadm --create {{/path/to/raid_device_file}} --level {{ raid level }} --raid-devices {{ number of disks}} {{/path/to/disk_device_file}}##Create array 136 | mdadm -D {{/path/to/raid_device_file}}##Show RAID info 137 | mdadm -S {{/path/to/raid_device_file}}##Stop array 138 | mdadm {{/path/to/raid_device_file}} -a {{/path/to/disk_device_file}}##Add disk to array 139 | mdadm {{/path/to/raid_device_file}} -f {{/path/to/disk_device_file}}##Mark disk as failed 140 | mdadm {{/path/to/raid_device_file}} -r {{/path/to/disk_device_file}}##Remove disk 141 | mkfs.cramfs -n {{volume-name}} {{/dev/sdb1}}##Create a ROM filesystem with a volume-name 142 | mkfs.cramfs {{/dev/sdb1}}##Create a ROM filesystem inside partition 1 on device b (`sdb1`) 143 | mkfs.exfat -i {{volume-id}} {{/dev/sdb1}}##Create filesystem with a volume-id 144 | mkfs.exfat -n {{volume-name}} {{/dev/sdb1}}##Create filesystem with a volume-name 145 | mkfs.exfat {{/dev/sdb1}}##Create an exfat filesystem inside partition 1 on device b (`sdb1`) 146 | mkfs.ext2 {{/dev/sdb1}}##Create an ext2 filesystem in partition 1 of device b (`sdb1`) 147 | mkfs.ext3 {{/dev/sdb1}}##Create an ext3 filesystem in partition 1 of device b (`sdb1`) 148 | mkfs.fat -f 5 {{/dev/sdb1}}##Use 5 instead of 2 file allocation tables 149 | mkfs.fat -i {{volume-id}} {{/dev/sdb1}}##Create filesystem with a volume-id 150 | mkfs.fat -n {{volume-name}} {{/dev/sdb1}}##Create filesystem with a volume-name 151 | mkfs.fat {{/dev/sdb1}}##Create a fat filesystem inside partition 1 on device b (`sdb1`) 152 | mkfs.minix {{/dev/sdb1}}##Create a Minix filesystem inside partition 1 on device b (`sdb1`) 153 | mkfs.ntfs -L {{volume-label}} {{/dev/sdb1}}##Create filesystem with a volume-label 154 | mkfs.ntfs -U {{UUID}} {{/dev/sdb1}}##Create filesystem with specific UUID 155 | mkfs.ntfs {{/dev/sdb1}}##Create a NTFS filesystem inside partition 1 on device b (`sdb1`) 156 | mkfs.vfat -f 5 {{/dev/sdb1}}##Use 5 instead of 2 file allocation tables 157 | mkfs.vfat -i {{volume-id}} {{/dev/sdb1}}##Create filesystem with a volume-id 158 | mkfs.vfat -n {{volume-name}} {{/dev/sdb1}}##Create filesystem with a volume-name 159 | mkfs.vfat {{/dev/sdb1}}##Create a.vfat filesystem inside partition 1 on device b (`sdb1`) 160 | netstat -a##List all ports 161 | netstat -c##List information continuously 162 | netstat -l##List all listening ports 163 | netstat -lepunt##List listening TCP and UDP ports (+ user and process if you're root) 164 | netstat -p##Display PID and program names 165 | netstat -rn##List routes and do not resolve IP to hostname 166 | netstat -t##List listening TCP ports 167 | nm --demangle {{file.o}}##Demangle C++ symbols (make them readable) 168 | nm -a {{file.o}}##List all symbols, even debugging symbols 169 | nm -g {{file.o}}##List global (extern) functions in a file (prefixed with T) 170 | nm -u {{file.o}}##List only undefined symbols in a file 171 | notify-send -i {{icon.png}} {{"Test"}} {{"This is a test"}}##Show a notification with a custom icon 172 | notify-send -t 5000 {{"Test"}} {{"This is a test"}}##Show a notification for 5 seconds 173 | notify-send {{"Test"}} {{"This is a test"}}##Show a notification with the title "Test" and the content "This is a test" 174 | pacman -Q##List installed packages and versions 175 | pacman -Qe##List only the explicitly installed packages and versions 176 | pacman -Qo filename##Find which package owns a certain file 177 | pacman -Rs package-name##Remove a package and its dependencies 178 | pacman -S package-name##Install a new package 179 | pacman -Scc##Empty package cache to free up space 180 | pacman -Ss icon theme##Search the package database for a keyword 181 | pacman -Syu##Synchronize and update all packages 182 | pkgadd -u {{package-name}}##Update an already installed package from a local package 183 | pkgadd {{package-name}}##Install a local software package 184 | pkginfo -f {{file}}##Print the footprint of a file 185 | pkginfo -i##List installed packages and their versions 186 | pkginfo -l {{package-name}}##List files owned by a package 187 | pkginfo -o {{pattern}}##List the owner(s) of files matching a pattern 188 | pkgmk -d -i##Install the package after making it 189 | pkgmk -d -if##Ignore the footprint when making a package 190 | pkgmk -d -im##Ignore the MD5 sum when making a package 191 | pkgmk -d -u##Upgrade the package after making it 192 | pkgmk -d##Make and download a package 193 | pkgmk -uf##Update the package's footprint 194 | pkgrm {{package-name}}##Remove an installed package 195 | ports -d##Check the differences between installed packages and the ports tree 196 | ports -l##List the ports in the current tree 197 | ports -u##Update the ports tree 198 | print {{filename}}##Print action can be used to print any file on default run-mailcap tool 199 | prt-get depinst {{package-name}}##Install a package with dependency handling 200 | prt-get fsearch {{file}}##Search for a file in a package 201 | prt-get install {{package-name}}##Install a package 202 | prt-get remove {{package-name}}##Remove a package 203 | prt-get search {{package-name}}##Search the ports tree 204 | prt-get sysup##Upgrade the system from the local ports tree 205 | prt-get upgrade {{package-name}}##Update a package manually 206 | pwgen -c {{length}}##Generate password with at least one capital letter in them 207 | pwgen -s {{length}}##Generate hard-to-memorize passwords 208 | pwgen -y {{length}}##Generate random password with symbols 209 | reboot -f##Reboot immediately without gracefully shutdown 210 | reboot##Reboot immediately 211 | rpm -Va '{{php-*}}'##Show changed, missing and/or incorrectly installed files of matching packages 212 | rpm -q {{httpd}}##Show version of httpd package 213 | rpm -qa '{{mariadb*}}'##List versions of all matching packages 214 | rpm -qf {{/etc/postfix/main.cf}}##Identify owner of a file and show version of the package 215 | rpm -ql {{kernel}}##List package-owned files 216 | rpm -qp --scripts {{some.rpm}}##Show scriptlets from an RPM file 217 | run-mailcap --action=ACTION --debug {{filename}}##Turn on extra information 218 | run-mailcap --action=ACTION --nopager {{filename}}##Ignore any "copiousoutput" directive and forward output to STD‐OUT 219 | run-mailcap --action=ACTION --norun {{filename}}##Display the found command without actually executing it 220 | run-mailcap --action=ACTION [--option[=value]]##Individual actions/programs on run-mailcap can be invoked with action flag 221 | run-mailcap --action=ACTION {{filename}}##In simple language 222 | run-mailcap --action=compose {{filename}}##With `run-mailcap` 223 | run-mailcap --action=edit {{filename}}##With `run-mailcap` 224 | run-mailcap --action=print {{filename}}##With `run-mailcap` 225 | run-mailcap --action=view {{filename}}##Using with `run-mailcap` 226 | screenfetch -A '{{distribution_name}}'##Specify distribution logo 227 | screenfetch -D '{{distribution_name}}'##Specify distribution logo and text 228 | screenfetch -N##Strip all color 229 | screenfetch -s##Take a screenshot (requires 'scrot') 230 | screenfetch##Start screenfetch 231 | see {{filename}}##See action can be used to view any file (usually image) on default mailcap explorer 232 | sha1sum -c {{filename.sha1}}##Read a file of SHA1 sums and verify all files have matching checksums 233 | sha1sum {{filename1}} {{filename2}}##Calculate SHA1 checksums for multiple files 234 | sha1sum {{filename1}}##Calculate the SHA1 checksum for a file 235 | sha224sum -c {{filename.sha224}}##Read a file of SHA224 sums and verify all files have matching checksums 236 | sha224sum {{filename1}} {{filename2}}##Calculate SHA224 checksums for multiple files 237 | sha224sum {{filename1}}##Calculate the SHA224 checksum for a file 238 | sha256sum -c {{filename.sha256}}##Read a file of SHA256 sums and verify all files have matching checksums 239 | sha256sum {{filename1}} {{filename2}}##Calculate SHA224 checksums for multiple files 240 | sha256sum {{filename1}}##Calculate the SHA256 checksum for a file 241 | sha384sum -c {{filename.sha384}}##Read a file of SHA384 sums and verify all files have matching checksums 242 | sha384sum {{filename1}} {{filename2}}##Calculate SHA384 checksums for multiple files 243 | sha384sum {{filename1}}##Calculate the SHA384 checksum for a file 244 | sha512sum -c {{filename.sha512}}##Read a file of SHA512 sums and verify all files have matching checksums 245 | sha512sum {{filename1}} {{filename2}}##Calculate SHA384 checksums for multiple files 246 | sha512sum {{filename1}}##Calculate the SHA384 checksum for a file 247 | shuf -i {{low}}-{{high}}##Generate random numbers in range 248 | shuf -n {{n}} {{filename}}##Only output the first n entries of the result 249 | shuf -o {{another_filename}} {{filename}}##Write output to another file 250 | shuf {{filename}}##Randomize the order of lines in a file and output the result 251 | shutdown -c##Cancel a pending shutdown/reboot operation 252 | shutdown -h 13:00##Shutdown at 1:00 pm (Uses 24h clock) 253 | shutdown -h now##Power off (halt) immediately 254 | shutdown -r +{{5}} &##Reboot in 5 minutes 255 | shutdown -r now##Reboot immediately 256 | ss -4t src {{192.168/16}}##Show all TCP IPv4 sockets locally connected on the subnet 192.168.0.0/16 257 | ss -a {{-t|-u|-w|-x}}##Show all TCP/UDP/RAW/UNIX sockets 258 | ss -pt dst :{{ssh}}##Show all TCP sockets along with processes connected to a remote ssh port 259 | ss -t src :{{443}}##Show all TCP sockets connected to the local HTTPS port (443) 260 | ss -u 'sport == :{{source_port}} and dport == :{{destination_port}}'##Show all UDP sockets connected on specific source and destination ports 261 | ss {{state/exclude}} {{bucket/big/connected/synchronized/...}}##Filter TCP sockets by states, only/exclude 262 | ssh-copy-id -i {{path/to/certificate}} -p {{port}} {{username}}@{{remote_host}}##Copy the given public key to the remote with specific port 263 | ssh-copy-id -i {{path/to/certificate}} {{username}}@{{remote_host}}##Copy the given public key to the remote 264 | strace -p {{pid}} -T##Show the time spent in every system call 265 | strace -p {{pid}} -c##Count time, calls, and errors for each system call and report a summary on program exit 266 | strace -p {{pid}} -e {{system call name}}##Trace a process and filter output by system call 267 | strace -p {{pid}}##Start tracing a specific process by its PID 268 | sudo iptables -A {{chain}} -s {{ip}} -j {{rule}}##Append rule to chain policy for IP 269 | sudo iptables -A {{chain}} -s {{ip}} -p {{protocol}} --dport {{port}} -j {{rule}}##Append rule to chain policy for IP considering protocol and port 270 | sudo iptables -D {{chain}} {{rule_line_number}}##Delete chain rule 271 | sudo iptables -p {{chain}} {{rule}}##Set chain policy rule 272 | sudo iptables -t {{table_name}} -vnL##See chains and rules for specific table 273 | sudo iptables-save > {{path_to_iptables_file}}##Savin iptables configuration 274 | sudo nethogs -t {{seconds}}##Specify refresh rate 275 | sudo nethogs {{device1}} {{device2}}##Monitor bandwidth on multiple devices 276 | sudo nethogs {{device}}##Monitor bandwidth on specific device 277 | sudo nethogs##Start nethogs as root (default device is eth0) 278 | sudo updatedb##Recompute the database. You need to do it if you want to find recently added files 279 | sysctl -a##Show all available variables and their values 280 | sysctl -p##Apply changes from /etc/sysctl.conf 281 | sysctl -w {{section.tunable}}={{value}}##Set a changeable kernel state variable 282 | sysctl fs.file-max##Get limit for simultaneous open files 283 | sysctl fs.file-nr##Get currently open file handlers 284 | systemctl --failed##List failed units 285 | systemctl daemon-reload##Reload systemd, scanning for new or changed units 286 | systemctl enable/disable {{unit}}##Enable/Disable a unit to be started on bootup 287 | systemctl start/stop/restart {{unit}}##Start/Stop/Restart a service 288 | systemctl status {{unit}}##Show the status of a unit 289 | tcpflow -c -i {{eth0}} port {{80}}##Show all data on the given interface and port 290 | timedatectl list-timezones##To list available timezones 291 | timedatectl set-time {{"yyyy-MM-dd hh:mm:ss"}}##To set the local time of the system clock directly 292 | timedatectl set-timezone {{timezone}}##To change timezones 293 | timedatectl##To check the current system clock time 294 | top -i##Start top ignoring any idle or zombie processes 295 | top -u {{user-name}}##Start top displaying only processes owned by given user 296 | top##Start top 297 | ufw allow {{port}} {{service_name}}##Add ufw allow rule 298 | ufw deny {{port}} {{service_name}}##Add ufw deny rule 299 | ufw disable##Disable ufw 300 | ufw enable##Enable ufw 301 | ufw status##Show ufw rules 302 | ulimit -H -n##Get hard limit for the number of simultaneously opened files 303 | ulimit -S -n##Get soft limit for the number of simultaneously opened files 304 | ulimit -a##Get the properties of all the user limits 305 | ulimit -u 30##Set max per-user process limit 306 | useradd -G {{group1,group2}} {{name}}##Create new user with supplementary groups (mind the lack of whitespace) 307 | useradd -m {{name}}##Create new user with a default home directory 308 | useradd -s {{/path/to/shell}} {{name}}##Create new user with specified shell 309 | useradd {{name}}##Create new user 310 | userdel -r {{name}}##Remove a user and their home directory 311 | usermod -a -G {{group1,group2}} {{user}}##Add user to supplementary groups (mind the whitespace) 312 | usermod -l {{newname}} {{user}}##Change a user's name 313 | usermod -m -d {{/path/to/home}} {{user}}##Create a new home directory for a user and move their files to it 314 | wall -t {{seconds}} {{file}}##Send a message with timeout (default 300) 315 | wall {{file}}##Send a message from a file 316 | watch -d {{df}}##Monitor disk space and highlight the changes 317 | watch -n {{3}} "{{ps aux | grep node}}"##Monitor "node" processes, refreshing every 3 seconds 318 | watch {{ls}}##Monitor files in the current folder 319 | wget -qO - {{https://host.tld/filename.key}} | apt-key add -##Add a remote key to the trusted keystore 320 | wpa_cli add_network {{number}}##Add a network 321 | wpa_cli enable_network {{number}}##Enable network 322 | wpa_cli save_config##Save config 323 | wpa_cli scan##Scan for available networks 324 | wpa_cli scan_results##Show scan results 325 | wpa_cli set_network {{number}} ssid "{{SSID}}"##Set a network's SSID 326 | xclip -o > file.txt##Paste clipboard 327 | xinput float {{id}} {{master_id}}##Reattach an input as slave to a master 328 | xinput float {{id}}##Disconnect an input from its master 329 | xinput list##List all input devices 330 | xrandr --auto##Disable disconnected outputs and enable connected ones with default settings 331 | xrandr --output {{DP1}} --mode {{1920x1080}} --rate {{60}}##Change the resolution and update frequency of DisplayPort 1 to 1920x1080, 60Hz 332 | xrandr --output {{HDMI2}} --mode {{1280x1024}} --right-of {{DP1}}##Set the resolution of HDMI2 to 1280x1024 and put it on the right of DP1 333 | xrandr --output {{VGA1}} --off##Disable the VGA1 output 334 | xrandr --query##Display the current state of the system (known screens, resolutions, ...) 335 | xsetwacom list##List all the available wacom devices. The device name is in the first column 336 | xsetwacom set "{{device name}}" MapToOutput {{screen}}##Set Wacom area to specific screen. Get name of the screen with `xrandr` 337 | xsetwacom set "{{device name}}" Mode "{{Relative|Absolute}}"##Set mode to relative (like a mouse) or absolute (like a pen) mode 338 | xsetwacom set "{{device name}}" Rotate {{none|half|cw|ccw}}##Rotate the input (useful for tablet-PC when rotating screen) by 0|90|180|270 degrees from "natural" rotation 339 | xsetwacom set "{{device name}}" TabletPCButton "on"##Set button to only work when the tip of the pen is touching the tablet 340 | yaourt -Q##List installed packages, versions, and repositories (AUR packages will be listed under the repository name 'local') 341 | yaourt -Rs package-name##Remove a package and its dependencies (includes AUR packages) 342 | yaourt -S package-name##Install a new package (includes AUR) 343 | yaourt -Ss package-name##Search the package database for a keyword (including AUR) 344 | yaourt -Syua##Synchronize and update all packages (including AUR) 345 | yum -y install {{package}}##Install a new package and assume yes to all questions (also works with update, great for automated updates) 346 | yum install {{package}}##Install a new package 347 | yum remove {{package}}##Remove a package 348 | yum update##Synchronize list of packages and versions available. This should be run first, before running subsequent yum commands 349 | yum upgrade##Upgrade installed packages to newest available versions 350 | zypper install {{package}}##Install a new package 351 | zypper refresh##Synchronize list of packages and versions available 352 | zypper remove {{package}}##Remove a package 353 | zypper search {{keyword}}##Search package via keyword 354 | zypper update##Upgrade installed packages to newest available versions 355 | -------------------------------------------------------------------------------- /tldr/osx.txt: -------------------------------------------------------------------------------- 1 | airport -I##Show current wireless status information 2 | airport -s##Scan for available wireless networks 3 | airport sniff {{1}}##Sniff wireless traffic on channel 1 4 | archey --macports##Show system information, using MacPorts instead of Homebrew 5 | archey --nocolor##Show system information without colored output 6 | archey --offline##Show system information without IP address check 7 | archey##Show system information 8 | base64 -D -i {{base64_file}}##Decode a file 9 | base64 -i {{plain_file}}##Encode a file 10 | brew install {{formula}}##Install formula 11 | brew list {{[text]}}##List installed formulae [with matching name] 12 | brew search {{text}}##Search formula 13 | brew switch {{formula}} {{version}}##Switch version of formula 14 | brew update##Update brew 15 | brew upgrade {{[formula]}}##Get latest version of installed formula (passing no formula updates all installed formulae) 16 | caffeinate -s {{command}}##Prevent mac from sleeping until a command completes 17 | caffeinate -u -t 3600##Prevent mac from sleeping for 1 hour (3600 seconds) 18 | dd if=/dev/urandom of={{random_file}} bs=100 count=1##Generate a file of 100 random bytes by using kernel random driver 19 | dd if=/dev/zero of={{file_1GB}} bs=1024 count=1000000##Benchmark the write performance of a disk 20 | dd if=/dev/{{source_drive}} of=/dev/{{dest_drive}} bs=4m conv=noerror##Clone a drive to another drive with 4MB block and ignore error 21 | dd if={{file.iso}} of=/dev/{{usb_drive}}##Make a bootable usb drive from an isohybrid file (such like archlinux-xxx.iso) 22 | defaults delete {{application}}##Delete all defaults of an application 23 | defaults read -app {{application}} {{option}}##Read default values for an application option 24 | defaults read {{application}} {{option}}##Read system defaults for an application option 25 | defaults write com.apple.Dock expose-animation-duration -float 0.1##Speed up Mission Control animations 26 | defaults write {{application}} {{option}} {{-type}} {{value}}##Write the default value of an application option 27 | diskutil eject {{/dev/disk1}}##Eject a CD/DVD (unmount first) 28 | diskutil list##List all currently available disks, partitions and mounted volumes 29 | diskutil repairVolume {{/dev/diskX}}##Repair the file system data structures of a volume 30 | diskutil unmountDisk {{/dev/diskX}}##Unmount a volume 31 | ditto -V {{path/to/source}} {{path/to/destination}}##Print a line to the Terminal window for every file that’s being copied 32 | ditto -rsrc {{path/to/source}} {{path/to/destination}}##Copy a given file or folder, while retaining the original file permissions 33 | ditto {{path/to/source}} {{path/to/destination}}##Overwrite contents of destination folder with contents of source folder 34 | drutil burn -noverify -eject -iso9660##Burn a folder as an ISO9660 filesystem onto a DVD. Don't verify and eject when complete 35 | drutil eject##Eject a disk from the drive 36 | du -ah {{directory}}##Get recursively, individual file/folder sizes in human readable form 37 | du -k -depth=1 {{directory}}##List the KB sizes of directories for N levels below the specified directory 38 | du -k {{file/directory}}##List file sizes of a directory and any subdirectories in KB 39 | du -sh {{file/directory}}##Get a sum of the total size of a file/folder in human readable units 40 | echo {{base64_text}} | base64 -D##Decode from stdin 41 | echo {{plain_text}} | base64##Encode from stdin 42 | find . -type t -name "*.png" | pbcopy##Place the results of a command in the clipboard 43 | head -c {{number_in_bytes}} {{filename}}##Output the first few bytes of a file 44 | head -n {{count_of_lines}} {{filename}}##Output the first few lines of a file 45 | hostname {{new_hostname}}##Set current host name 46 | hostname##Show current host name 47 | locate {{pattern}}##Look for pattern in the database. Note: the database is recomputed periodically (usually weekly or daily) 48 | look -f {{prefix}} {{file}}##Look for lines ignoring case 49 | look {{prefix}} {{file}}##Look for lines which begins with the given prefix 50 | md5 -q {{filename}}##Output only the md5 checksum (no filename) 51 | md5 -s {{string}}##Print a checksum of the given string 52 | md5 {{filename1}} {{filename2}}##Calculate MD5 checksums for multiple files 53 | md5 {{filename}}##Calculate the MD5 checksum for a file 54 | mdfind -name {{file}}##Find a file by its name 55 | mdfind -onlyin {{directory}} {{query}}##Find a file containing a string, in a given directory 56 | mdfind {{query}}##Find a file by its content 57 | netstat -a##List all ports 58 | netstat -c##List information continuously 59 | netstat -l##List all listening ports 60 | netstat -p {PROTOCOL}##Display PID and program names for a specific port 61 | netstat -t##List listening TCP ports 62 | networksetup -getairportnetwork {{en0}}##Get currently connected Wi-Fi network name (Wi-Fi device usually en0 or en1) 63 | networksetup -getinfo {{"Wi-Fi"}}##Show network settings for a particular networking device 64 | networksetup -listallnetworkservices##List available network service providers (Ethernet, Wi-Fi, Bluetooth, etc) 65 | networksetup -setairportnetwork {{en0}} {{"Airport Network SSID"}} {{password}}##Connect to a particular Wi-Fi network 66 | nm -a {{file.o}}##List all symbols, even debugging symbols 67 | nm -g {{file.o}}##List global (extern) functions in a file (prefixed with T) 68 | nm -u {{file.o}}##List only undefined symbols in a file 69 | open -R /path/dir/{{file}}##Reveal a file in finder 70 | open .##Open the current directory in Finder 71 | open /Applications/{{Application.app}}##Run a graphical MacOSX application 72 | open {{*.ext}}##Open all the files of a given extension in the current directory with the associated application 73 | open {{file.ext}}##Open a file with the associated application 74 | pbcopy < {{file}}##Place the contents of a file in the clipboard 75 | pbpaste > {{file}}##Write the contents of the clipboard to a file 76 | pbpaste | grep foo##Use the contents of the clipboard as input to a command 77 | quicklook *.jpg -t -s 300 {{/existing//thumbnail/directory}}##Compute 300px wide PNG thumbnails of all JPEGs in the current directory and put them in a directory 78 | quicklook -p {{filename}} {{filename2}}##Display QuickLook for one or multiple files 79 | say -f {{filename.txt}}##Read a file aloud 80 | say -o {{filename.aiff}} {{"Here's to the Crazy Ones."}}##Create an audio file of the spoken text 81 | say -v ?##List the available voices 82 | say -v {{voice}} -r {{words_per_minute}} {{"I'm sorry Dave, I can't let you do that."}}##Say a phrase with a custom voice and speech rate 83 | say {{"I like to ride my bike."}}##Say a phrase aloud 84 | sed '/{{line_pattern}}/s/{{find}}/{{replace}}/'##Replace only on lines matching the line pattern 85 | sed 's/{{find}}/{{replace}}/' {{filename}}##Replace the first occurrence of a string in a file, and print the result 86 | sed -E 's/{{regex}}/{{replace}}/g' {{filename}}##Replace all occurrences of an extended regular expression in a file 87 | sed -e 's/{{find}}/{{replace}}/' -e 's/{{find}}/{{replace}}/' {{filename}}##Apply multiple find-replace expressions to a file 88 | sed -i '' 's/{{find}}/{{replace}}/g' {{filename}}##Replace all occurrences of a string in a file, overwriting the file (i.e. in-place) 89 | shutdown -h now##Power off (halt) immediately 90 | shutdown -r +{{5}}##Reboot in 5 minutes 91 | shutdown -r now##Reboot immediately 92 | shutdown -s now##Sleep immediately 93 | sudo /usr/libexec/locate.updatedb##Recompute the database. You need to do it if you want to find recently added files 94 | sudo airport -z##Disassociate from current airport network 95 | sudo route -t add {{dest_ip_address}}/24 {{gateway_address}}##Run in test mode (does not do anything, just print) 96 | sudo route add {{dest_ip_address}} {{gateway_address}}##Add a route to a destination through a gateway 97 | sudo route add {{subnet_ip_address}}/24 {{gateway_address}}##Add a route to a /24 subnet through a gateway 98 | sudo route delete {{dest_ip_address}}/24##Delete a specific route 99 | sudo route flush##Remove all routes 100 | sw_vers -buildVersion##Print OSX Build 101 | sw_vers -productVersion##Print OSX Version 102 | sysctl -a##Show all available variables and their values 103 | sysctl -n hw.model##Show Apple model identifier 104 | sysctl -n machdep.cpu.brand_string##Show CPU model 105 | sysctl -n machdep.cpu.feature##Show available CPU features (MMX, SSE, SSE2, SSE3, AES, etc) 106 | sysctl -w {{section.tunable}}={{value}}##Set a changeable kernel state variable 107 | system_profiler -xml > MyReport.spx##Display a full system profiler report which can be opened by System Profiler.app 108 | system_profiler SPHardwareDataType##Display a hardware overview (Model, CPU, Memory, Serial, etc) 109 | system_profiler SPHardwareDataType|grep "Serial Number (system)" |awk '{print $4}'##Print the system serial number 110 | systemsetup -liststartupdisks##List valid startup disks 111 | systemsetup -setremotelogin on##Enable remote login (SSH) 112 | systemsetup -setsleep off -setrestartpowerfailure on -setrestartfreeze on##Make the machine never sleep and automatically restart on power failure or kernel panic 113 | systemsetup -setstartupdisk {{path}}##Specify a new startup disk 114 | systemsetup -settimezone {{US/Pacific}} -setnetworktimeserver {{us.pool.ntp.org}} -setusingnetworktime on##Specify TimeZone, NTP Server and enable network time 115 | top -o cpu -O time##Start top sorting processes first by CPU, then by running time 116 | top -o mem##Start top sorting processes by internal memory size (default order - process ID) 117 | top -user {{user-name}}##Start top displaying only processes owned by given user 118 | top##Start top, all options are available in the interface 119 | w -h##Show logged-in users info without a header 120 | w -i##Show info about logged-in users, sorted by their idle time 121 | w##Show logged-in users info 122 | wacaw --to-clipboard##Copy image just taken to clipboard 123 | wacaw --video {{filename}} -D {{duration_in_seconds}}##Record a video 124 | wacaw -L##List the devices available 125 | wacaw -x {{width}} -y {{height}} {{filename}}##Take a picture with custom resolution 126 | wacaw {{filename}}##Take a picture from webcam 127 | xctool -workspace {{YourWorkspace.xcworkspace}} -scheme {{YourScheme}} build##Build a project that is part of a workspace 128 | xctool -workspace {{YourWorkspace.xcworkspace}} -scheme {{YourScheme}} clean build test##Clean, build and execute all the tests 129 | xctool.sh -project {{YourProject.xcodeproj}} -scheme {{YourScheme}} build##Build a single project without any workspace 130 | xed -c {{filename1}}##Open file(s) in XCode, create if it doesn't exist 131 | xed -l 75 {{filename}}##Open a file in XCode and jump to line number 75 132 | xed {{file1}}##Open file in XCode 133 | xsltproc --output {{output.html}} --stringparam {{name}} {{value}} {{stylesheet.xslt}} {{xmlfile.xml}}##Pass a value to a parameter in the stylesheet 134 | xsltproc --output {{output.html}} {{stylesheet.xslt}} {{xmlfile.xml}}##Transform an XML file with a specific XSLT stylesheet 135 | -------------------------------------------------------------------------------- /tldr/sunos.txt: -------------------------------------------------------------------------------- 1 | devfsadm -C -v -n##Dry-run - output what would be changed but make no modifications 2 | devfsadm -C -v##Cleanup any dangling /dev links and scan for new device 3 | devfsadm -c disk##Scan for new disks 4 | prctl -P {{PID}}##Examine process limits and permissions in machine parseable format 5 | prctl -n process.max-file-descriptor {{PID}}##Get specific limit for a running process 6 | prctl {{PID}}##Examine process limits and permissions 7 | prstat -c -n 5 -s cpu 1##Print out a list of top 5 cpu using processes every second 8 | prstat -m##Report microstate process accounting information 9 | prstat -s rss##Examine all processes and reports statistics sorted by memory usage 10 | prstat -t##Report total usage summary for each user 11 | prstat##Examine all processes and reports statistics sorted by CPU usage 12 | svcadm clear {{service_name}}##Clear a service from maintenance state and command it to start 13 | svcadm disable {{service_name}}##Disable service 14 | svcadm enable {{service_name}}##Enable a service in the service database 15 | svcadm refresh {{service_name}}##Command service to re-read configuration files 16 | svcadm restart {{service_name}}##Restart a running service 17 | svccfg export {{servicename}} > {{smf.xml}}##Export service configurations to file 18 | svccfg import {{smf.xml}}##Import/update service configurations from file 19 | svccfg validate {{smf.xml}}##Validate configuration file 20 | svcs -L apache##Show location of service log file 21 | svcs -vx##List services that are not running 22 | svcs apache##List information about a service 23 | svcs##List all running services 24 | tail $(svcs -L apache)##Display end of a service log file --------------------------------------------------------------------------------