From 9b88afec332555b4a7a9636943676d85ac8f18be Mon Sep 17 00:00:00 2001 From: John Shanahan Date: Mon, 2 Sep 2013 07:39:43 -0400 Subject: [PATCH 01/30] Added GPL3 license to top of 'cheat' as required. --- cheat | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/cheat b/cheat index 6d1bddc..9aa85e0 100755 --- a/cheat +++ b/cheat @@ -1,4 +1,22 @@ #!/usr/bin/env python +""" +cheat.py -- Quick, abridged man pages with examples (main routines) + Copyright (C) 2013, Chris Lane + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +""" + import os import sys import subprocess From d9acba7f14d8caebcfd8250a16d0f395e860bac3 Mon Sep 17 00:00:00 2001 From: Matthieu Keller Date: Mon, 2 Sep 2013 16:04:10 +0200 Subject: [PATCH 02/30] correct and add vim shortcuts --- cheatsheets/vim | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/cheatsheets/vim b/cheatsheets/vim index 3b79d77..22b8bf5 100644 --- a/cheatsheets/vim +++ b/cheatsheets/vim @@ -1,8 +1,14 @@ -# Appending -a - drops vim into append mode -i - enters append mode without character skip +# Insertion +a - enters insertion mode, append after the cursor. +A - enters insertion mode, at the end of the line. +i - enters insertion mode, insert before the cursor. +I - enters insertion mode, at the beginning of the line. +o - enters insertion mode, creating a new line under the cursor. +O - enters insertion mode, creating a mew line above the cursor. +C - enters insertion mode, cut the end of the line. # File management :w - writes (saves) file +:x - writes (saves) file ans exit :q - quits -;q! - quits without saving changes +:q! - quits without saving changes From ec5123d21edaf1e9c9e5e9d312a5cdeacebbcafc Mon Sep 17 00:00:00 2001 From: Matthieu Keller Date: Mon, 2 Sep 2013 16:05:43 +0200 Subject: [PATCH 03/30] Create aptitude --- cheatsheets/aptitude | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 cheatsheets/aptitude diff --git a/cheatsheets/aptitude b/cheatsheets/aptitude new file mode 100644 index 0000000..26d0af7 --- /dev/null +++ b/cheatsheets/aptitude @@ -0,0 +1,5 @@ +# To search for packages: +aptitude search "whatever" + +# To display package records for the named package(s): +aptitude show pkg(s) From 221c1ce1909daf63fd4583d5a0d050ca371690ba Mon Sep 17 00:00:00 2001 From: Manu Date: Tue, 3 Sep 2013 04:09:36 +0200 Subject: [PATCH 04/30] Added pacman (archlinux PACkage MANager) cheatsheet --- cheatsheets/pacman | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 cheatsheets/pacman diff --git a/cheatsheets/pacman b/cheatsheets/pacman new file mode 100644 index 0000000..bffe1f5 --- /dev/null +++ b/cheatsheets/pacman @@ -0,0 +1,32 @@ +# All the following command work as well with multiple package names + +# To search for a package +pacman -Ss + +# To update the local package base and upgrade all out of date packages +pacman -Suy + +# To install a package +pacman -S + +# To uninstall a package +pacman -R + +# To uninstall a package and his depedencies, removing all new orphans +pacman -Rcs + +# To get informations about a package +pacman -Si + +# To install a package from builded package file (.tar.xz) +pacman -U + +# To list the commands provided by an installed package +pacman -Ql nvidia-utils | sed -n -e 's/.*\/bin\///p' | tail -n +2 + +# To list explicitly installed packages +pacman -Qe + +# To list orphan packages (installed as dependencies and not required anymore) +pacman -Qdt + From 837042f71802e8df97dba8115eafca1d9c5d2b38 Mon Sep 17 00:00:00 2001 From: Manu Date: Tue, 3 Sep 2013 05:39:24 +0200 Subject: [PATCH 05/30] Added yaourt (Yet AnOther User Repository Tool) cheatsheet --- cheatsheets/pacman | 11 +++++++++++ cheatsheets/yaourt | 23 +++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 cheatsheets/yaourt diff --git a/cheatsheets/pacman b/cheatsheets/pacman index bffe1f5..e348ea2 100644 --- a/cheatsheets/pacman +++ b/cheatsheets/pacman @@ -30,3 +30,14 @@ pacman -Qe # To list orphan packages (installed as dependencies and not required anymore) pacman -Qdt + +# You can't directly install packages from the Arch User Database (AUR) with pacman. +# You need yaourt to perform that. But considering yaourt itself is in the AUR, here is how to +build a package from its tarball. +# First, get the .tar.gz archive and unpack it +wget +tar -xzf +cd +# Then build the package and install it +makepkg -s +pacman -U diff --git a/cheatsheets/yaourt b/cheatsheets/yaourt new file mode 100644 index 0000000..f3a6ec1 --- /dev/null +++ b/cheatsheets/yaourt @@ -0,0 +1,23 @@ +# All pacman commands are working the same way with yaourt. +# Just check the pacman cheatsheet. +# For instance, to install a package : +pacman -S +yaourt -S +# The difference is that yaourt will also query the Arch User Repository, +# and if appropriate, donwload the source and build the package requested. + +# Here are the commands yaourt provides while pacman doesn't : + +# To search for a package and install it +yaourt + +# To update the local package base and upgrade all out of date package, including the ones from +AUR and the packages based on development repos (git, svn, hg...) +yaourt -Suya --devel + +# For all of the above commands, if you want yaourt to stop asking constantly for confirmations, +use the option --noconfirm + +# To build a package from source +yaourt -Sb + From 1599c81e8f9f80a5dde4d494a505f0a455774d75 Mon Sep 17 00:00:00 2001 From: Benny Date: Tue, 3 Sep 2013 11:08:25 +0200 Subject: [PATCH 06/30] Create tmux cheatfile --- cheatsheets/tmux | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 cheatsheets/tmux diff --git a/cheatsheets/tmux b/cheatsheets/tmux new file mode 100644 index 0000000..fe369c2 --- /dev/null +++ b/cheatsheets/tmux @@ -0,0 +1,41 @@ +# Start tmux +tmux + +# Detach from tmux +Ctrl-B D + +# Restore tmux session +tmux attach + +# Display session +tmux ls + +# Start a shared session +tmux -S /tmp/your_shared_session +chmod 777 /tmp/your_shared_session + +# Help screen (Q to quit) +Ctrl-B ? + +# Scroll in window +Ctrl-B PageUp/Down + +# Window management +# ================= + +# Create window +Ctrl-B C + +# Destroy window +Ctrl-B X + +# Switch between windows +Ctrl-B [0-9] +or +Ctrl-B Arrows + +# Split windows horizontally +Ctrl-B % + +# Split windows vertically +Ctrl-B " From 00549c1d8e06962962d4ef47a8d2474f69600ad4 Mon Sep 17 00:00:00 2001 From: Benny Date: Tue, 3 Sep 2013 11:10:20 +0200 Subject: [PATCH 07/30] Use lowercase letters --- cheatsheets/tmux | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/cheatsheets/tmux b/cheatsheets/tmux index fe369c2..e9b76ce 100644 --- a/cheatsheets/tmux +++ b/cheatsheets/tmux @@ -1,41 +1,41 @@ -# Start tmux +# Start tmux: tmux -# Detach from tmux -Ctrl-B D +# Detach from tmux: +Ctrl-b d -# Restore tmux session +# Restore tmux session: tmux attach -# Display session +# Display session: tmux ls -# Start a shared session +# Start a shared session: tmux -S /tmp/your_shared_session chmod 777 /tmp/your_shared_session -# Help screen (Q to quit) -Ctrl-B ? +# Help screen (Q to quit): +Ctrl-b ? -# Scroll in window -Ctrl-B PageUp/Down +# Scroll in window: +Ctrl-b PageUp/PageDown # Window management # ================= -# Create window -Ctrl-B C +# Create window: +Ctrl-b c -# Destroy window -Ctrl-B X +# Destroy window: +Ctrl-b x -# Switch between windows -Ctrl-B [0-9] +# Switch between windows: +Ctrl-b [0-9] or -Ctrl-B Arrows +Ctrl-b Arrows -# Split windows horizontally -Ctrl-B % +# Split windows horizontally: +Ctrl-b % -# Split windows vertically -Ctrl-B " +# Split windows vertically: +Ctrl-b " From a45568ec5f3b079613e9656f4a70e915b1c92c65 Mon Sep 17 00:00:00 2001 From: LIETART Frederic Date: Tue, 3 Sep 2013 13:25:16 +0200 Subject: [PATCH 08/30] Add set editor to git Add set editor to git --- cheatsheets/git | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cheatsheets/git b/cheatsheets/git index d0e7c80..fb5a1c7 100644 --- a/cheatsheets/git +++ b/cheatsheets/git @@ -2,6 +2,9 @@ git config --global user.name "John Doe" git config --global user.email johndoe@example.com +# To set your editor: +git config --global core.editor emacs + # To enable color: git config --global color.ui true From 253eae29354bc094802766d72f8b04bdaf3ca5f9 Mon Sep 17 00:00:00 2001 From: Chimyx Date: Tue, 3 Sep 2013 16:01:09 +0200 Subject: [PATCH 09/30] Correction in pacman file --- cheatsheets/pacman | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cheatsheets/pacman b/cheatsheets/pacman index e348ea2..353f6c5 100644 --- a/cheatsheets/pacman +++ b/cheatsheets/pacman @@ -22,7 +22,7 @@ pacman -Si pacman -U # To list the commands provided by an installed package -pacman -Ql nvidia-utils | sed -n -e 's/.*\/bin\///p' | tail -n +2 +pacman -Ql | sed -n -e 's/.*\/bin\///p' | tail -n +2 # To list explicitly installed packages pacman -Qe From 139ff6c32ea61f1a9f2ebccce2cd6a087ab33f00 Mon Sep 17 00:00:00 2001 From: John Shanahan Date: Tue, 3 Sep 2013 23:53:58 -0400 Subject: [PATCH 10/30] Merge --- cheat | 4 ++-- setup.py | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/cheat b/cheat index 9aa85e0..a8d3af7 100755 --- a/cheat +++ b/cheat @@ -141,8 +141,8 @@ def main(): # create/edit option option = sys.argv[1].lower() if option in ['-e', '--edit', '-c', '--create']: - # make sure EDITOR environment variable is set and that at least 3 arguments - # are given + # make sure EDITOR env variable is set and that at least + # 3 arguments are given if 'EDITOR' not in os.environ: print('In order to use "create" or "edit" you must set your ' 'EDITOR environment variable to your favorite editor\'s path') diff --git a/setup.py b/setup.py index c115c4c..38cf968 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,8 @@ from distutils.core import setup import os -setup(name='cheat', +setup( + name='cheat', version='1.0', summary='Create and view interactive cheatsheets on the command-line', homepage='', From ebdca118eaa69c48a8ca2a03b9ba2102f716039b Mon Sep 17 00:00:00 2001 From: a-sk Date: Wed, 4 Sep 2013 09:52:54 +0400 Subject: [PATCH 11/30] -d now separates output using a newline --- cheat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cheat b/cheat index 6d1bddc..09f1228 100755 --- a/cheat +++ b/cheat @@ -143,7 +143,7 @@ def main(): # list cheat directories and exit if option in ['-d', '--cheat_directories']: - print(' '.join(cheat_directories())) + print('\n'.join(cheat_directories())) exit() # print the cheatsheet if it exists From 4fe31ec47957cbe9bbdfe949604d18889979b7ad Mon Sep 17 00:00:00 2001 From: John Shanahan Date: Thu, 5 Sep 2013 22:50:55 -0400 Subject: [PATCH 12/30] Added 'import argparse' to 'cheat' --- cheat | 1 + setup.py | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cheat b/cheat index a8d3af7..8d27c2d 100755 --- a/cheat +++ b/cheat @@ -19,6 +19,7 @@ cheat.py -- Quick, abridged man pages with examples (main routines) import os import sys +import argparse import subprocess DEFAULT_CHEAT_DIR = os.environ.get('DEFAULT_CHEAT_DIR') or \ diff --git a/setup.py b/setup.py index 38cf968..c115c4c 100644 --- a/setup.py +++ b/setup.py @@ -3,8 +3,7 @@ from distutils.core import setup import os -setup( - name='cheat', +setup(name='cheat', version='1.0', summary='Create and view interactive cheatsheets on the command-line', homepage='', From 948d407b655c7d3b302ef79ada8fc8f8eb49d76d Mon Sep 17 00:00:00 2001 From: Matthieu Keller Date: Fri, 6 Sep 2013 16:51:31 +0200 Subject: [PATCH 13/30] Update aptitude --- cheatsheets/aptitude | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/cheatsheets/aptitude b/cheatsheets/aptitude index 26d0af7..a837979 100644 --- a/cheatsheets/aptitude +++ b/cheatsheets/aptitude @@ -3,3 +3,13 @@ aptitude search "whatever" # To display package records for the named package(s): aptitude show pkg(s) + +# To install a package: +aptitude install package + +# To remove a package: +aptitude remove package + +# To remove unnecessary package: +aptitude autoclean + From dc4846b6359827fb7e48762449a7c810d508022f Mon Sep 17 00:00:00 2001 From: Matthieu Keller Date: Fri, 6 Sep 2013 16:53:36 +0200 Subject: [PATCH 14/30] Update grep --- cheatsheets/grep | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cheatsheets/grep b/cheatsheets/grep index 70fa3de..cd79eb5 100644 --- a/cheatsheets/grep +++ b/cheatsheets/grep @@ -1,5 +1,11 @@ # Basic: grep pattern file +# case nonsensitive research: +grep -i pattern file + # Recursively grep for string in folder: grep -R pattern folder + +# Getting pattern from file (one by line): +grep -f pattern_file file From bbabedb3cebaaddb0644b7fac145a950ade8bdf4 Mon Sep 17 00:00:00 2001 From: Ritchie Lincoln Date: Fri, 6 Sep 2013 20:55:22 -0600 Subject: [PATCH 15/30] added chmod to cheats --- cheatsheets/chmod | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 cheatsheets/chmod diff --git a/cheatsheets/chmod b/cheatsheets/chmod new file mode 100644 index 0000000..31c5eb7 --- /dev/null +++ b/cheatsheets/chmod @@ -0,0 +1,36 @@ +# Add execute for all (myscript.sh) +chmod a+x myscript.sh + +# Set user to read/write/execute, group/global to read only (myscript.sh), symbolic mode +chmod u=rwx, go=r myscript.sh + +# Remove write from user/group/global (myscript.sh), symbolic mode +chmod a-w myscript.sh + +# Remove read/write/execute from user/group/global (myscript.sh), symbolic mode +chmod = myscript.sh + +# Set user to read/write and group/global read (myscript.sh), octal notation +chmod 644 myscript.sh + +# Set user to read/write/execute and group/global read/execute (myscript.sh), octal notation +chmod 755 myscript.sh + +# Set user/group/global to read/write (myscript.sh), octal notation +chmod 666 myscript.sh + +# Roles +u - user (owner of the file) +g - group (members of file's group) +o - global (all users who are not owner and not part of group) +a - all (all 3 roles above) + +# Numeric representations +7 - full (rwx) +6 - read and write (rw-) +5 - read and execute (r-x) +4 - read only (r--) +3 - write and execute (-wx) +2 - write only (-w-) +1 - execute only (--x) +0 - none (---) From 93bda9dc2053f1661c699c3308fc031cb6efb209 Mon Sep 17 00:00:00 2001 From: adelviscio Date: Sat, 7 Sep 2013 00:29:49 -0400 Subject: [PATCH 16/30] Removed cat Piping cat to sed is an extra step. Sed can handle file arguments. --- cheatsheets/sed | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cheatsheets/sed b/cheatsheets/sed index 5d97e4a..f60b269 100644 --- a/cheatsheets/sed +++ b/cheatsheets/sed @@ -10,5 +10,5 @@ echo 'It is daytime' | sed 's/day/night/g' # To remove leading spaces sed -i -r 's/^\s+//g' file.txt -# To remove empty lines -cat file.txt | sed '/^$/d' +# Remove empty lines and print results to stdout: +sed '/^$/d' file.txt From 11b680f49b333c7352e3418cdee7ce4b01c4d8f8 Mon Sep 17 00:00:00 2001 From: Chris Lane Date: Sat, 7 Sep 2013 13:28:10 -0400 Subject: [PATCH 17/30] Merging. --- cheat | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/cheat b/cheat index 8d27c2d..64391ef 100755 --- a/cheat +++ b/cheat @@ -1,7 +1,11 @@ #!/usr/bin/env python """ -cheat.py -- Quick, abridged man pages with examples (main routines) - Copyright (C) 2013, Chris Lane +cheat.py -- cheat allows you to create and view interactive cheatsheets on the + command-line. It was designed to help remind *nix system + administrators of options for commands that they use frequently, + but not frequently enough to remember. + + Copyright (C) 2013, Chris Lane This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by From 213c7a31e1b4ce668f98c7efeed804eb927e646f Mon Sep 17 00:00:00 2001 From: Chris Lane Date: Sat, 7 Sep 2013 14:38:13 -0400 Subject: [PATCH 18/30] Updated the README to describe the -d flag and zsh coordination. --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index 6cbfeb9..1457dd4 100644 --- a/README.md +++ b/README.md @@ -63,6 +63,7 @@ Clone this repository and `cd` into it, then run mkdir ~/.cheat cp cheatsheets/* ~/.cheat + Modifying Cheatsheets ===================== The value of `cheat` is that it allows you to create your own cheatsheets - the @@ -111,6 +112,8 @@ You may, of course, append multiple directories to your `CHEATPATH`: export CHEATPATH=$CHEATPATH:/path/to/more/cheats ``` +You may view which directories are on your `CHEATPATH` with `cheat -d`. + Enabling Syntax Highlighting ---------------------------- `cheat` can apply syntax highlighting to your cheatsheets if so desired. To @@ -140,12 +143,18 @@ Likewise, an existing cheatsheet may be edited via: cheat -e foo ``` +Command Autocompletion in zsh +----------------------------- +`zsh` users may use `cheat -d` in coordination with the provided `\_cheat` file +to implement autocompletion [as described here][4]. + Contributing ============ If you would like to contribute cheetsheets or program functionality, please fork this repository, make your chanages, and send me a pull request. + Related Projects ================ @@ -166,3 +175,4 @@ Related Projects [1]: https://github.com/lucaswerkmeister/cheats [2]: https://github.com/jahendrie/cheat [3]: http://errtheblog.com/posts/21-cheat +[4]: https://github.com/chrisallenlane/cheat/pull/77 From ffcafa4480ee6f132d993bb0210ddcd86c23c41d Mon Sep 17 00:00:00 2001 From: Ritchie Lincoln Date: Sat, 7 Sep 2013 12:41:51 -0600 Subject: [PATCH 19/30] give user the option to edit cheatsheet when trying to create an existing cheatsheet --- cheat | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/cheat b/cheat index 6d1bddc..faf8861 100755 --- a/cheat +++ b/cheat @@ -64,8 +64,12 @@ def edit_cheatsheet(cheat, cheatsheets): def create_cheatsheet(cheat, cheatsheets): "Create a new cheatsheet." if cheat in cheatsheets: - print ('Cheatsheet "%s" already exists' % cheat) - exit() + print ('Cheatsheet "%s" already exists...' % cheat) + ans = raw_input('Would you like to edit cheatsheet for "%s" (Y/N)? ' % cheat) + if ans.lower() in ['y', 'yes']: + edit_cheatsheet(cheat, cheatsheets) + else: + exit() import cheatsheets as cs From acb1a827eccf4a0bc1a42a6c705840759d4eb8ae Mon Sep 17 00:00:00 2001 From: Matthieu Keller Date: Sun, 8 Sep 2013 15:23:00 +0200 Subject: [PATCH 20/30] Create sort --- cheatsheets/sort | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 cheatsheets/sort diff --git a/cheatsheets/sort b/cheatsheets/sort new file mode 100644 index 0000000..a7ace90 --- /dev/null +++ b/cheatsheets/sort @@ -0,0 +1,11 @@ +# To sort a file: +sort file + +# To sort a file by keppeing only unique: +sort -u file + +# To sort a file and reverse the result: +sort -r file + +# To sort a fiule randomly: +sort -R file From d4a40a9b203efbc7dc1746471d406d37e2205556 Mon Sep 17 00:00:00 2001 From: Matthieu Keller Date: Sun, 8 Sep 2013 15:43:25 +0200 Subject: [PATCH 21/30] Update sort --- cheatsheets/sort | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cheatsheets/sort b/cheatsheets/sort index a7ace90..4c243ba 100644 --- a/cheatsheets/sort +++ b/cheatsheets/sort @@ -1,11 +1,11 @@ # To sort a file: sort file -# To sort a file by keppeing only unique: +# To sort a file by keeping only unique: sort -u file # To sort a file and reverse the result: sort -r file -# To sort a fiule randomly: +# To sort a file randomly: sort -R file From eb00ab5d0bf53e51099695a795b68bbcc4667670 Mon Sep 17 00:00:00 2001 From: b_b Date: Tue, 10 Sep 2013 17:04:40 +0200 Subject: [PATCH 22/30] add minimal screen cheatsheet --- cheatsheets/screen | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 cheatsheets/screen diff --git a/cheatsheets/screen b/cheatsheets/screen new file mode 100644 index 0000000..cc2d3e4 --- /dev/null +++ b/cheatsheets/screen @@ -0,0 +1,11 @@ +# Start a new named screen session: +screen -S session_name + +# Detach from the current session: +Press Ctrl+A then press d + +# Re-attach a detached session: +screen -r session_name + +# List all screen sessions: +screen -ls From ba904a2bd63606578e97aa95ad0d2482be94988d Mon Sep 17 00:00:00 2001 From: ABorgna Date: Tue, 10 Sep 2013 23:19:48 -0300 Subject: [PATCH 23/30] Update vim Using same format as 7z and emacs --- cheatsheets/vim | 67 +++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 54 insertions(+), 13 deletions(-) diff --git a/cheatsheets/vim b/cheatsheets/vim index 22b8bf5..fca5bbd 100644 --- a/cheatsheets/vim +++ b/cheatsheets/vim @@ -1,14 +1,55 @@ -# Insertion -a - enters insertion mode, append after the cursor. -A - enters insertion mode, at the end of the line. -i - enters insertion mode, insert before the cursor. -I - enters insertion mode, at the beginning of the line. -o - enters insertion mode, creating a new line under the cursor. -O - enters insertion mode, creating a mew line above the cursor. -C - enters insertion mode, cut the end of the line. - # File management -:w - writes (saves) file -:x - writes (saves) file ans exit -:q - quits -:q! - quits without saving changes + +:e reload file +:q quit +:q! quit without saving changes +:w write file +:w {file} write new file +:x write file and exit + +# Movement + + k + h l basic motion + j + +w next start of word +w next start of whitespace-delimited word +e next end of word +E next end of whitespace-delimited word +b previous start of word +B previous start of whitespace-delimited word +0 start of line +$ end of line + +# Insertion +# To exit from insert mode use Esc or Ctrl-C +# Enter insertion mode and: + +a append after the cursor +A append at the end of the line +i insert before the cursor +I insert at the beginning of the line +o create a new line under the cursor +O create a new line above the cursor +R enter insert mode but replace instead of inserting chars +:r {file} insert from file + +# Editing + +u undo +yy yank (copy) a line +y{motion} yank text that {motion} moves over +p paste after cursor +P paste before cursor + or x delete a character +dd delete a line +d{motion} delete text that {motion} moves over + + +# Preceding a motion or edition with a number repeats it n times +# Examples: + + 50k moves 50 lines up + 2dw deletes 2 words + 5yy copies 5 lines From a44c824f59b1f6c90c2cb9239acb4553640b4f45 Mon Sep 17 00:00:00 2001 From: ABorgna Date: Wed, 11 Sep 2013 00:21:44 -0300 Subject: [PATCH 24/30] Added at cheatsheet --- cheatsheets/at | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 cheatsheets/at diff --git a/cheatsheets/at b/cheatsheets/at new file mode 100644 index 0000000..2827a45 --- /dev/null +++ b/cheatsheets/at @@ -0,0 +1,17 @@ +# To schedule a one time task +at {time} +{command 0} +{command 1} +Ctrl-d + +# {time} can be either +now | midnight | noon | teatime (4pm) +HH:MM +now + N {minutes | hours | days | weeks} +MM/DD/YY + +# To list pending jobs +atq + +# To remove a job (use id from atq) +atrm {id} From 60e2e66014d0272b5fe90d2707deb732aa59ef71 Mon Sep 17 00:00:00 2001 From: ABorgna Date: Wed, 11 Sep 2013 00:33:55 -0300 Subject: [PATCH 25/30] Added chown cheatsheet --- cheatsheets/chown | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 cheatsheets/chown diff --git a/cheatsheets/chown b/cheatsheets/chown new file mode 100644 index 0000000..811a864 --- /dev/null +++ b/cheatsheets/chown @@ -0,0 +1,8 @@ +# Change file owner +chown user file + +# Change file owner and group +chown user:group file + +# Change owner recursively +chown -R user directory From acbd8632778cd70d9a3b68692d3b9a6efd1e60bb Mon Sep 17 00:00:00 2001 From: ABorgna Date: Wed, 11 Sep 2013 01:00:59 -0300 Subject: [PATCH 26/30] Added ifconfig cheatsheet --- cheatsheets/ifconfig | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 cheatsheets/ifconfig diff --git a/cheatsheets/ifconfig b/cheatsheets/ifconfig new file mode 100644 index 0000000..ca0b9d1 --- /dev/null +++ b/cheatsheets/ifconfig @@ -0,0 +1,13 @@ +# Display network settings of the first ethernet adapter +ifconfig wlan0 + +# Display all interfaces, even if down +ifconfig -a + +# Take down / up the wireless adapter +ifconfig {up|down} wlan0 + +# Set a static IP and netmask +ifconfig eth0 192.168.1.100 netmask 255.255.255.0 +# You may also need to add a gateway IP +route add -net 192.168.1.0 netmask 255.255.255.0 gw 192.168.1.1 From 50fd4c66388ffcb33c070d921ada0db4b0a36f08 Mon Sep 17 00:00:00 2001 From: Amit Saha Date: Thu, 12 Sep 2013 09:59:20 +1000 Subject: [PATCH 27/30] cheatsheets/netstat: Which process is listening on a port --- cheatsheets/netstat | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cheatsheets/netstat b/cheatsheets/netstat index caba5be..72fbc07 100644 --- a/cheatsheets/netstat +++ b/cheatsheets/netstat @@ -3,3 +3,9 @@ sudo netstat -lnptu # To view routing table (use -n flag to disable DNS lookups): netstat -r + +# Which process is listening to port +netstat -pln | grep | awk '{print $NF}' + +Example output: 1507/python + From 3deb00bb0a91d724a1ffe0e4e19002f494fba8bf Mon Sep 17 00:00:00 2001 From: ImmortalPC Date: Fri, 13 Sep 2013 00:21:50 +0200 Subject: [PATCH 28/30] Add apparmor --- cheatsheets/apparmor | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 cheatsheets/apparmor diff --git a/cheatsheets/apparmor b/cheatsheets/apparmor new file mode 100644 index 0000000..d4a623d --- /dev/null +++ b/cheatsheets/apparmor @@ -0,0 +1,16 @@ +# To activate a profile: +sudo aa-enforce usr.bin.firefox +# OR +export _PROFILE_='usr.bin.firefox' sudo $(rm /etc/apparmor.d/disable/$_PROFILE_ ; cat /etc/apparmor.d/$_PROFILE_ | apparmor_parser -a ) + +# TO disable a profile: +sudo aa-disable usr.bin.firefox +# OR +export _PROFILE_='usr.bin.firefox' sudo $(ln -s /etc/apparmor.d/$_PROFILE_ /etc/apparmor.d/disable/ && apparmor_parser -R /etc/apparmor.d/$_PROFILE_) + +# To list profiles loaded: +sudo aa-status +# OR +sudo apparmor_status + +# List of profiles aviables: /etc/apparmor.d/ From 2c86db1aac845a846c68a052c10c2bc2705da2a3 Mon Sep 17 00:00:00 2001 From: ImmortalPC Date: Fri, 13 Sep 2013 00:26:42 +0200 Subject: [PATCH 29/30] Add a description --- cheatsheets/apparmor | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cheatsheets/apparmor b/cheatsheets/apparmor index d4a623d..3e6d337 100644 --- a/cheatsheets/apparmor +++ b/cheatsheets/apparmor @@ -1,3 +1,5 @@ +# Desc: Apparmor will protect the system by confining programs to a limited set of resources. + # To activate a profile: sudo aa-enforce usr.bin.firefox # OR From 385ac4d4847d6aaf1efa6ea01b358cc11195decd Mon Sep 17 00:00:00 2001 From: ImmortalPC Date: Fri, 13 Sep 2013 00:34:09 +0200 Subject: [PATCH 30/30] Add apt-get --- cheatsheets/apt-get | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 cheatsheets/apt-get diff --git a/cheatsheets/apt-get b/cheatsheets/apt-get new file mode 100644 index 0000000..0f4bcd6 --- /dev/null +++ b/cheatsheets/apt-get @@ -0,0 +1,13 @@ +# Desc: Allows to update the operating system + +# To fetch package list +apt-get update + +# To download and install updates without installing new package. +apt-get update + +# To download and install the updates AND install new necessary packages +apt-get dist-upgrade + +# Full command: +apt-get update && apt-get dist-upgrade