mirror of
https://github.com/cheat/cheat.git
synced 2025-09-01 01:28:30 +02:00
Compare commits
51 Commits
Author | SHA1 | Date | |
---|---|---|---|
417f47f037 | |||
f39fad1324 | |||
4cf03c5363 | |||
afcd74c8bf | |||
e27ce3f1f9 | |||
e9b8f04c24 | |||
d14c759a48 | |||
c70dc002fa | |||
ff8ba4e717 | |||
718ec4f685 | |||
3d8343a878 | |||
a5352ad9e5 | |||
f5ee3d5e29 | |||
e64babc972 | |||
cd465ef84f | |||
96e26a38d4 | |||
998ed00424 | |||
1fd03d3305 | |||
77cba58599 | |||
c5a738a8b1 | |||
250a265b25 | |||
c232721119 | |||
55492c50ac | |||
d9df28e3f2 | |||
710c7bcf70 | |||
efba736aee | |||
95774db7c5 | |||
da63c5d27f | |||
2e1cda114a | |||
353fe48d60 | |||
a96bd229a6 | |||
be2cb6e632 | |||
426b0aaa0d | |||
9041c57d21 | |||
1dd9d85509 | |||
9506167af8 | |||
27482cbabd | |||
03bb651bf0 | |||
c4a5ca3900 | |||
03b587f538 | |||
e4d7722476 | |||
3807aa5433 | |||
956ce7fadd | |||
57876ed0e7 | |||
58abb16ca1 | |||
54e30022f0 | |||
c412cd0534 | |||
2d67038188 | |||
603bc360c0 | |||
61458933eb | |||
6f579f9234 |
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,2 +1,5 @@
|
||||
*.pyc
|
||||
MANIFEST
|
||||
build
|
||||
cheat.egg-info
|
||||
dist
|
||||
|
@ -38,7 +38,7 @@ from docopt import docopt
|
||||
|
||||
if __name__ == '__main__':
|
||||
# parse the command-line options
|
||||
options = docopt(__doc__, version='cheat 2.1.0')
|
||||
options = docopt(__doc__, version='cheat 2.1.8')
|
||||
|
||||
# list directories
|
||||
if options['--directories']:
|
||||
|
26
cheat/cheatsheets/bower
Normal file
26
cheat/cheatsheets/bower
Normal file
@ -0,0 +1,26 @@
|
||||
# Install a package locally
|
||||
bower install <package-name>
|
||||
|
||||
# Install a package locally directly from github
|
||||
bower install <user>/<repo>
|
||||
|
||||
# Install a specific package locally
|
||||
bower install <package-name>#<version>
|
||||
|
||||
# Install a package locally and save installed package into bower.json
|
||||
bower install <package-name> --save
|
||||
|
||||
# Retrieve info of a particular package
|
||||
bower info <package-name>
|
||||
|
||||
# List local packages
|
||||
bower list
|
||||
|
||||
# Search for a package by name
|
||||
bower search <package-name>
|
||||
|
||||
# Update a package to their newest version
|
||||
bower update <package-name>
|
||||
|
||||
# Remove a local package
|
||||
bower uninstall <package-name>
|
16
cheat/cheatsheets/dnf
Normal file
16
cheat/cheatsheets/dnf
Normal file
@ -0,0 +1,16 @@
|
||||
# To install the latest version of a package:
|
||||
dnf install <package name>
|
||||
|
||||
# To search package details for the given string
|
||||
dnf search <string>
|
||||
|
||||
# To find which package provides a binary
|
||||
dnf provides <path to binary>
|
||||
|
||||
# The following are available after installing "dnf-plugins-core"
|
||||
|
||||
# Download a package
|
||||
dnf download <package name>
|
||||
|
||||
# install the build dependencies for a SRPM or from a .spec file
|
||||
dnf builddep <srpm/.spec file>
|
@ -4,6 +4,9 @@ docker -d
|
||||
# start a container with an interactive shell
|
||||
docker run -ti <image_name> /bin/bash
|
||||
|
||||
# "shell" into a running container (docker-1.3+)
|
||||
docker exec -ti <container_name> bash
|
||||
|
||||
# inspect a running container
|
||||
docker inspect <container_name> (or <container_id>)
|
||||
|
||||
|
11
cheat/cheatsheets/dpkg
Normal file
11
cheat/cheatsheets/dpkg
Normal file
@ -0,0 +1,11 @@
|
||||
# Install the package or upgrade it
|
||||
dpkg -i test.deb
|
||||
|
||||
# Remove a package including configuration files
|
||||
dpkg -P test.deb
|
||||
|
||||
# List all installed packages with versions and details
|
||||
dpkg -I
|
||||
|
||||
# Find out if a Debian package is installed or not
|
||||
dpkg -s test.deb | grep Status
|
17
cheat/cheatsheets/gzip
Normal file
17
cheat/cheatsheets/gzip
Normal file
@ -0,0 +1,17 @@
|
||||
# To create a *.gz compressed file
|
||||
gzip test.txt
|
||||
|
||||
# To create a *.gz compressed file to a specific location using -c option (standard out)
|
||||
gzip -c test.txt > test_custom.txt.gz
|
||||
|
||||
# To uncompress a *.gz file
|
||||
gzip -d test.txt.gz
|
||||
|
||||
# Display compression ratio of the compressed file using gzip -l
|
||||
gzip -l *.gz
|
||||
|
||||
# Recursively compress all the files under a specified directory
|
||||
gzip -r documents_directory
|
||||
|
||||
# To create a *.gz compressed file and keep the original
|
||||
gzip < test.txt > test.txt.gz
|
@ -19,8 +19,8 @@ ip route
|
||||
# Display all routes for IPv6
|
||||
ip -6 route
|
||||
|
||||
# Add route via gateway IP
|
||||
ip route add 192.168.0.0/24 via 192.168.1.1
|
||||
# Add default route via gateway IP
|
||||
ip route add default via 192.168.1.1
|
||||
|
||||
# Add route via interface
|
||||
ip route add 192.168.0.0/24 dev eth0
|
||||
|
@ -19,3 +19,14 @@ journalctl /usr/bin/dbus-daemon
|
||||
# Filter by PID
|
||||
journalctl _PID=123
|
||||
|
||||
# Filter by Command, e.g., sshd
|
||||
journalctl _COMM=sshd
|
||||
|
||||
# Filter by Command and time period
|
||||
journalctl _COMM=crond --since '10:00' --until '11:00'
|
||||
|
||||
# List all available boots
|
||||
journalctl --list-boots
|
||||
|
||||
# Filter by specific User ID e.g., user id 1000
|
||||
journalctl _UID=1000
|
||||
|
5
cheat/cheatsheets/p4
Normal file
5
cheat/cheatsheets/p4
Normal file
@ -0,0 +1,5 @@
|
||||
# Print details related to Client and server configuration
|
||||
p4 info
|
||||
|
||||
# Open a file and add it to depot
|
||||
p4 add <filename>
|
15
cheat/cheatsheets/paste
Normal file
15
cheat/cheatsheets/paste
Normal file
@ -0,0 +1,15 @@
|
||||
# Concat columns from files
|
||||
paste file1 file2 ...
|
||||
|
||||
# List the files in the current directory in three columns:
|
||||
ls | paste - - -
|
||||
|
||||
# Combine pairs of lines from a file into single lines:
|
||||
paste -s -d '\t\n' myfile
|
||||
|
||||
# Number the lines in a file, similar to nl(1):
|
||||
sed = myfile | paste -s -d '\t\n' - -
|
||||
|
||||
# Create a colon-separated list of directories named bin,
|
||||
# suitable for use in the PATH environment variable:
|
||||
find / -name bin -type d | paste -s -d : -
|
2
cheat/cheatsheets/ping6
Normal file
2
cheat/cheatsheets/ping6
Normal file
@ -0,0 +1,2 @@
|
||||
# get all ipv6 neighbors via broadcast ping
|
||||
ping6 -I eth0 ff02::1
|
5
cheat/cheatsheets/smbclient
Normal file
5
cheat/cheatsheets/smbclient
Normal file
@ -0,0 +1,5 @@
|
||||
# To display public shares on the server:
|
||||
smbclient -L <hostname> -U%
|
||||
|
||||
# To connect to a share:
|
||||
smbclient //<hostname>/<share> -U<username>%<password>
|
18
cheat/cheatsheets/ss
Normal file
18
cheat/cheatsheets/ss
Normal file
@ -0,0 +1,18 @@
|
||||
ss
|
||||
Utility to investigate sockets
|
||||
|
||||
Args
|
||||
-4/-6 list ipv4/ipv6 sockets
|
||||
-n numeric addresses instead of hostnames
|
||||
-l list listing sockets
|
||||
-u/-t/-x list udp/tcp/unix sockets
|
||||
-p Show process(es) that using socket
|
||||
|
||||
# show all listing tcp sockets including the corresponding process
|
||||
ss -tlp
|
||||
|
||||
# show all sockets connecting to 192.168.2.1 on port 80
|
||||
ss -t dst 192.168.2.1:80
|
||||
|
||||
# show all ssh related connection
|
||||
ss -t state established '( dport = :ssh or sport = :ssh )'
|
@ -4,12 +4,19 @@ ssh -i /path/to/file.pem user@example.com
|
||||
# To connect on an non-standard port:
|
||||
ssh -p 2222 user@example.com
|
||||
|
||||
# To connect and forward the authentication agent
|
||||
ssh -A user@example.com
|
||||
|
||||
# To execute a command on a remote server:
|
||||
ssh -t user@example.com 'the-remote-command'
|
||||
|
||||
# To tunnel an x session over SSH:
|
||||
ssh -X user@example.com
|
||||
|
||||
# Redirect traffic with a tunnel between local host (port 8080) and a remote
|
||||
# host (remote.example.com:5000) through a proxy (personal.server.com):
|
||||
ssh -f -L 8080:remote.example.com:5000 user@personal.server.com -N
|
||||
|
||||
# To launch a specific x application over SSH:
|
||||
ssh -X -t user@example.com 'chromium-browser'
|
||||
|
||||
|
11
cheat/cheatsheets/udisksctl
Normal file
11
cheat/cheatsheets/udisksctl
Normal file
@ -0,0 +1,11 @@
|
||||
# Get info about block device
|
||||
udisksctl info -b <block_device>
|
||||
|
||||
# Mounting device
|
||||
udisksctl mount --block-device <block_device>
|
||||
|
||||
# Unmounting device
|
||||
udisksctl unmount --block-device <block_device>
|
||||
|
||||
# Get help
|
||||
udisksctl help
|
18
cheat/cheatsheets/uniq
Normal file
18
cheat/cheatsheets/uniq
Normal file
@ -0,0 +1,18 @@
|
||||
# show all lines without duplication
|
||||
# `sort -u` and `uniq` is the same effect.
|
||||
sort file | uniq
|
||||
|
||||
# show not duplicated lines
|
||||
sort file | uniq -u
|
||||
|
||||
# show duplicated lines only
|
||||
sort file | uniq -d
|
||||
|
||||
# count all lines
|
||||
sort file | uniq -c
|
||||
|
||||
# count not duplicated lines
|
||||
sort file | uniq -uc
|
||||
|
||||
# count only duplicated lines
|
||||
sort file | uniq -dc
|
@ -22,6 +22,9 @@ yum info <package name>
|
||||
# List currently enabled repositories:
|
||||
yum repolist
|
||||
|
||||
# List packages containing a certain keyword:
|
||||
yum list <package_name_or_word_to_search>
|
||||
|
||||
# To download the source RPM for a package:
|
||||
yumdownloader --source <package name>
|
||||
|
||||
|
21
cheat/cheatsheets/zoneadm
Normal file
21
cheat/cheatsheets/zoneadm
Normal file
@ -0,0 +1,21 @@
|
||||
# Halt zone
|
||||
zoneadm -z <zone_name> halt
|
||||
|
||||
# Delete Zone
|
||||
zoneadm -z <zone_name> halt
|
||||
zoneadm -z <zone_name> uninstall
|
||||
|
||||
# Verify Zone
|
||||
zoneadm -z <zone_name> verify
|
||||
|
||||
# Installing Zone
|
||||
zoneadm -z <zone_name> install
|
||||
|
||||
# Boot Zone
|
||||
zoneadm -z <zone_name> boot
|
||||
|
||||
# Reboot Zone
|
||||
zoneadm -z <zone_name> reboot
|
||||
|
||||
# List Zones
|
||||
zoneadm list -cv
|
@ -25,28 +25,16 @@ def create_or_edit(sheet):
|
||||
# if the cheatsheet does not exist
|
||||
if not exists(sheet):
|
||||
create(sheet)
|
||||
|
||||
# if the cheatsheet exists and is writeable...
|
||||
elif exists(sheet) and is_writable(sheet):
|
||||
|
||||
# if the cheatsheet exists but not in the default_path, copy it to the
|
||||
# default path before editing
|
||||
elif exists(sheet) and not exists_in_default_path(sheet):
|
||||
copy(path(sheet), os.path.join(sheets.default_path(), sheet))
|
||||
edit(sheet)
|
||||
|
||||
# if the cheatsheet exists but is not writable...
|
||||
elif exists(sheet) and not is_writable(sheet):
|
||||
# ... ask the user if we should copy the cheatsheet to her home directory for editing
|
||||
yes = prompt_yes_or_no(
|
||||
'The ' + sheet + ' sheet is not editable. Do you want to copy it to '
|
||||
'your user cheatsheets directory before editing? Keep in mind that '
|
||||
'your sheet will always be used before system-wide one.'
|
||||
)
|
||||
|
||||
# if yes, copy the cheatsheet to the home directory before editing
|
||||
if yes:
|
||||
copy(path(sheet), os.path.join(sheets.default_path(), sheet))
|
||||
edit(sheet)
|
||||
|
||||
# if no, just abort
|
||||
else:
|
||||
die('Aborting.')
|
||||
# if it exists and is in the default path, then just open it
|
||||
else:
|
||||
edit(sheet)
|
||||
|
||||
|
||||
def create(sheet):
|
||||
@ -75,6 +63,12 @@ def exists(sheet):
|
||||
return sheet in sheets.get() and os.access(path(sheet), os.R_OK)
|
||||
|
||||
|
||||
def exists_in_default_path(sheet):
|
||||
""" Predicate that returns true if the sheet exists in default_path"""
|
||||
default_path_sheet = os.path.join(sheets.default_path(), sheet)
|
||||
return sheet in sheets.get() and os.access(default_path_sheet, os.R_OK)
|
||||
|
||||
|
||||
def is_writable(sheet):
|
||||
""" Predicate that returns true if the sheet is writeable """
|
||||
return sheet in sheets.get() and os.access(path(sheet), os.W_OK)
|
||||
|
@ -2,13 +2,6 @@ from cheat import cheatsheets
|
||||
from cheat.utils import *
|
||||
import os
|
||||
|
||||
# @kludge: it breaks the functional paradigm to a degree, but declaring this
|
||||
# var here (versus within get()) gives us a "poor man's" memoization on the
|
||||
# call to get(). This, in turn, spares us from having to call out to the
|
||||
# filesystem more than once.
|
||||
cheats = {}
|
||||
|
||||
|
||||
def default_path():
|
||||
""" Returns the default cheatsheet path """
|
||||
|
||||
@ -37,11 +30,7 @@ def default_path():
|
||||
|
||||
def get():
|
||||
""" Assembles a dictionary of cheatsheets as name => file-path """
|
||||
|
||||
# if we've already reached out to the filesystem, just return the result
|
||||
# from memory
|
||||
if cheats:
|
||||
return cheats
|
||||
cheats = {}
|
||||
|
||||
# otherwise, scan the filesystem
|
||||
for cheat_dir in reversed(paths()):
|
||||
|
Reference in New Issue
Block a user