mirror of
https://github.com/cheat/cheat.git
synced 2025-12-10 17:24:01 +01:00
Compare commits
34 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6a2eda80d4 | ||
|
|
20d52376f9 | ||
|
|
3b2848668a | ||
|
|
a8f91d4224 | ||
|
|
e0adbbc5b9 | ||
|
|
905f12a279 | ||
|
|
0c24bbbaaf | ||
|
|
baa782b8ce | ||
|
|
740358e4c0 | ||
|
|
2ebc8c9fac | ||
|
|
f3ecf76239 | ||
|
|
84df17a0f6 | ||
|
|
91c28712e6 | ||
|
|
8eda2266bc | ||
|
|
47fd7c90f4 | ||
|
|
cafa2fb2fd | ||
|
|
9c31ba5102 | ||
|
|
da65ea32d8 | ||
|
|
e1aec49ed6 | ||
|
|
ab86ac970d | ||
|
|
90f66ccaf3 | ||
|
|
f63406bc3e | ||
|
|
b3a93bc128 | ||
|
|
8f0d2e9fc3 | ||
|
|
4c2d0d2d8e | ||
|
|
ac445388d9 | ||
|
|
705601f0b1 | ||
|
|
2d7fdb5425 | ||
|
|
4512a61086 | ||
|
|
4d57f529c9 | ||
|
|
5caa8fed38 | ||
|
|
69f91e0cf4 | ||
|
|
fdbc8909cc | ||
|
|
76a91ce358 |
@@ -38,7 +38,7 @@ from docopt import docopt
|
|||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
# parse the command-line options
|
# parse the command-line options
|
||||||
options = docopt(__doc__, version='cheat 2.1.13')
|
options = docopt(__doc__, version='cheat 2.1.18')
|
||||||
|
|
||||||
# list directories
|
# list directories
|
||||||
if options['--directories']:
|
if options['--directories']:
|
||||||
|
|||||||
@@ -23,3 +23,6 @@ apt-get -o Dir::Cache="/path/to/destination/dir/" -o Dir::Cache::archives="./" i
|
|||||||
|
|
||||||
# Show apt-get installed packages.
|
# Show apt-get installed packages.
|
||||||
grep 'install ' /var/log/dpkg.log
|
grep 'install ' /var/log/dpkg.log
|
||||||
|
|
||||||
|
# Silently keep old configuration during batch updates
|
||||||
|
apt-get update -o DPkg::Options::='--force-confold' ...
|
||||||
|
|||||||
@@ -6,3 +6,6 @@ printf '1:2:3' | awk -F ":" '{print $1+$2+$3}'
|
|||||||
|
|
||||||
# print a multiplication table
|
# print a multiplication table
|
||||||
seq 9 | sed 'H;g' | awk -v RS='' '{for(i=1;i<=NF;i++)printf("%dx%d=%d%s", i, NR, i*NR, i==NR?"\n":"\t")}'
|
seq 9 | sed 'H;g' | awk -v RS='' '{for(i=1;i<=NF;i++)printf("%dx%d=%d%s", i, NR, i*NR, i==NR?"\n":"\t")}'
|
||||||
|
|
||||||
|
# Specify output separator character
|
||||||
|
printf '1 2 3' | awk 'BEGIN {OFS=":"}; {print $1,$2,$3}'
|
||||||
|
|||||||
@@ -18,3 +18,10 @@ set -x
|
|||||||
|
|
||||||
# Turn off debugging:
|
# Turn off debugging:
|
||||||
set +x
|
set +x
|
||||||
|
|
||||||
|
# Retrieve N-th piped command exit status
|
||||||
|
printf 'foo' | fgrep 'foo' | sed 's/foo/bar/'
|
||||||
|
echo ${PIPESTATUS[0]} # replace 0 with N
|
||||||
|
|
||||||
|
# Lock file:
|
||||||
|
( set -o noclobber; echo > my.lock ) || echo 'Failed to create lock file'
|
||||||
|
|||||||
22
cheat/cheatsheets/cups
Normal file
22
cheat/cheatsheets/cups
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
# Manage printers through CUPS:
|
||||||
|
http://localhost:631 (in web browser)
|
||||||
|
|
||||||
|
# Print file from command line
|
||||||
|
lp myfile.txt
|
||||||
|
|
||||||
|
# Display print queue
|
||||||
|
lpq
|
||||||
|
|
||||||
|
# Remove print job from queue
|
||||||
|
lprm 545
|
||||||
|
or
|
||||||
|
lprm -
|
||||||
|
|
||||||
|
# Print log location
|
||||||
|
/var/log/cups
|
||||||
|
|
||||||
|
# Reject new jobs
|
||||||
|
cupsreject printername
|
||||||
|
|
||||||
|
# Accept new jobs
|
||||||
|
cupsaccept printername
|
||||||
32
cheat/cheatsheets/hardware-info
Normal file
32
cheat/cheatsheets/hardware-info
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
# Display all hardware details
|
||||||
|
sudo lshw
|
||||||
|
|
||||||
|
# List currently loaded kernel modules
|
||||||
|
lsmod
|
||||||
|
|
||||||
|
# List all modules available to the system
|
||||||
|
find /lib/modules/$(uname -r) -type f -iname "*.ko"
|
||||||
|
|
||||||
|
# Load a module into kernel
|
||||||
|
modprobe modulename
|
||||||
|
|
||||||
|
# Remove a module from kernel
|
||||||
|
modprobe -r modulename
|
||||||
|
|
||||||
|
# List devices connected via pci bus
|
||||||
|
lspci
|
||||||
|
|
||||||
|
# Debug output for pci devices (hex)
|
||||||
|
lspci -vvxxx
|
||||||
|
|
||||||
|
# Display cpu hardware stats
|
||||||
|
cat /proc/cpuinfo
|
||||||
|
|
||||||
|
# Display memory hardware stats
|
||||||
|
cat /proc/meminfo
|
||||||
|
|
||||||
|
# Output the kernel ring buffer
|
||||||
|
dmesg
|
||||||
|
|
||||||
|
# Ouput kernel messages
|
||||||
|
dmesg --kernel
|
||||||
23
cheat/cheatsheets/lib
Normal file
23
cheat/cheatsheets/lib
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
# Display available libraries
|
||||||
|
ldconfig -p
|
||||||
|
|
||||||
|
# Update library resources
|
||||||
|
ldconfig
|
||||||
|
|
||||||
|
# Display libraries and file location
|
||||||
|
ldd
|
||||||
|
|
||||||
|
# Libraries available to apps in real-time
|
||||||
|
"Dynamic Libraries" (.so.)
|
||||||
|
|
||||||
|
# Libraries only available to apps when installed (imported)
|
||||||
|
"Static Libraries" (.a.)
|
||||||
|
|
||||||
|
# Standard (usual) library file location
|
||||||
|
/lib
|
||||||
|
|
||||||
|
# Sofware-accessible source for library info
|
||||||
|
/etc/ld.so.cache # (binary)
|
||||||
|
|
||||||
|
# Human-readable source for library info
|
||||||
|
/etc/ld.so.conf # (points to /etc/ld.so.conf.d)
|
||||||
@@ -9,3 +9,9 @@ ls -lh
|
|||||||
|
|
||||||
# Display files, sorted by size
|
# Display files, sorted by size
|
||||||
ls -S
|
ls -S
|
||||||
|
|
||||||
|
# Display directories only
|
||||||
|
ls -d */
|
||||||
|
|
||||||
|
# Display directories only, include hidden
|
||||||
|
ls -d .*/ */
|
||||||
|
|||||||
@@ -12,3 +12,8 @@ CREATE DATABASE owa CHARACTER SET utf8 COLLATE utf8_general_ci;
|
|||||||
|
|
||||||
# To add a user and give rights on the given database
|
# To add a user and give rights on the given database
|
||||||
GRANT ALL PRIVILEGES ON database.* TO 'user'@'localhost'IDENTIFIED BY 'password' WITH GRANT OPTION;
|
GRANT ALL PRIVILEGES ON database.* TO 'user'@'localhost'IDENTIFIED BY 'password' WITH GRANT OPTION;
|
||||||
|
|
||||||
|
# To list the privileges granted to the account that you are using to connect to the server. Any of the 3 statements will work.
|
||||||
|
SHOW GRANTS FOR CURRENT_USER();
|
||||||
|
SHOW GRANTS;
|
||||||
|
SHOW GRANTS FOR CURRENT_USER;
|
||||||
|
|||||||
33
cheat/cheatsheets/ntp
Normal file
33
cheat/cheatsheets/ntp
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
# Verify ntpd running:
|
||||||
|
service ntp status
|
||||||
|
|
||||||
|
# Start ntpd if not running:
|
||||||
|
service ntp start
|
||||||
|
|
||||||
|
# Display current hardware clock value:
|
||||||
|
sudo hwclock -r
|
||||||
|
|
||||||
|
# Apply system time to hardware time:
|
||||||
|
sudo hwclock --systohc
|
||||||
|
|
||||||
|
# Apply hardware time to system time:
|
||||||
|
sudo hwclock --hctosys
|
||||||
|
|
||||||
|
# Set hwclock to local time:
|
||||||
|
sudo hwclock --localtime
|
||||||
|
|
||||||
|
# Set hwclock to UTC:
|
||||||
|
sudo hwclock --utc
|
||||||
|
|
||||||
|
# Set hwclock manually:
|
||||||
|
sudo hwclock --set --date="8/10/15 13:10:05"
|
||||||
|
|
||||||
|
# Query surrounding stratum time servers
|
||||||
|
ntpq -pn
|
||||||
|
|
||||||
|
# Config file:
|
||||||
|
/etc/ntp.conf
|
||||||
|
|
||||||
|
# Driftfile:
|
||||||
|
location of "drift" of your system clock compared to ntp servers
|
||||||
|
/var/lib/ntp/ntp.drift
|
||||||
@@ -19,3 +19,6 @@ openssl x509 -text -noout -in server.crt
|
|||||||
echo | openssl s_client -connect <hostname>:443 2> /dev/null | \
|
echo | openssl s_client -connect <hostname>:443 2> /dev/null | \
|
||||||
awk '/-----BEGIN/,/END CERTIFICATE-----/' | \
|
awk '/-----BEGIN/,/END CERTIFICATE-----/' | \
|
||||||
openssl x509 -noout -enddate
|
openssl x509 -noout -enddate
|
||||||
|
|
||||||
|
# Generate Diffie-Hellman parameters:
|
||||||
|
openssl dhparam -outform PEM -out dhparams.pem 2048
|
||||||
|
|||||||
5
cheat/cheatsheets/ping
Normal file
5
cheat/cheatsheets/ping
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
# ping a host with a total count of 15 packets overall.
|
||||||
|
ping -c 15 www.example.com
|
||||||
|
|
||||||
|
# ping a host with a total count of 15 packets overall, one every .5 seconds (faster ping).
|
||||||
|
ping -c 15 -i .5 www.example.com
|
||||||
@@ -4,6 +4,9 @@ rpm -ivh <rpm>
|
|||||||
# To remove a package:
|
# To remove a package:
|
||||||
rpm -e <package>
|
rpm -e <package>
|
||||||
|
|
||||||
|
# To remove a package, but not its dependencies
|
||||||
|
rpm -e --nodeps <package>
|
||||||
|
|
||||||
# To find what package installs a file:
|
# To find what package installs a file:
|
||||||
rpm -qf </path/to/file>
|
rpm -qf </path/to/file>
|
||||||
|
|
||||||
@@ -17,3 +20,12 @@ rpm -q --whatrequires <file>
|
|||||||
|
|
||||||
# To list all installed packages:
|
# To list all installed packages:
|
||||||
rpm -qa
|
rpm -qa
|
||||||
|
|
||||||
|
# To find a pkg's dependencies
|
||||||
|
rpm -i --test <package>
|
||||||
|
|
||||||
|
# Display checksum against source
|
||||||
|
rpm -K <package>
|
||||||
|
|
||||||
|
# Verify a package
|
||||||
|
rpm -V <package>
|
||||||
|
|||||||
21
cheat/cheatsheets/rss2email
Normal file
21
cheat/cheatsheets/rss2email
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
'rss2email -- converts rss feeds and emails them to your inbox'
|
||||||
|
|
||||||
|
# List all feeds
|
||||||
|
r2e list
|
||||||
|
|
||||||
|
# Convert RSS entries to email
|
||||||
|
r2e run
|
||||||
|
|
||||||
|
# Add a new feed
|
||||||
|
r2e add <feed address>
|
||||||
|
|
||||||
|
# Add a new feed with new email address
|
||||||
|
r2e add <feed address> [newemail address]
|
||||||
|
|
||||||
|
# Delete a feed
|
||||||
|
r2e delete <# of feed in list/>
|
||||||
|
|
||||||
|
# Help
|
||||||
|
r2e -h
|
||||||
|
|
||||||
|
|
||||||
18
cheat/cheatsheets/systemd
Normal file
18
cheat/cheatsheets/systemd
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
# Display process startup time
|
||||||
|
systemd-analyze
|
||||||
|
|
||||||
|
# Display process startup time at service level
|
||||||
|
systemd-analyze blame
|
||||||
|
|
||||||
|
# List running units
|
||||||
|
systemctl list-units
|
||||||
|
|
||||||
|
# Load a unit at startup
|
||||||
|
systemctl enable foo.service
|
||||||
|
|
||||||
|
# Start or Stop a unit
|
||||||
|
systemctl <start | stop> foo.service
|
||||||
|
|
||||||
|
# Unit file locations
|
||||||
|
/etc/systemd/system
|
||||||
|
/usr/lib/systemd/system
|
||||||
@@ -24,3 +24,8 @@ tar -jtvf /path/to/foo.tgz
|
|||||||
|
|
||||||
# To create a .gz archive and exclude all jpg,gif,... from the tgz
|
# To create a .gz archive and exclude all jpg,gif,... from the tgz
|
||||||
tar czvf /path/to/foo.tgz --exclude=\*.{jpg,gif,png,wmv,flv,tar.gz,zip} /path/to/foo/
|
tar czvf /path/to/foo.tgz --exclude=\*.{jpg,gif,png,wmv,flv,tar.gz,zip} /path/to/foo/
|
||||||
|
|
||||||
|
# To use parallel (multi-threaded) implementation of compression algorithms:
|
||||||
|
tar -z ... -> tar -Ipigz ...
|
||||||
|
tar -j ... -> tar -Ipbzip2 ...
|
||||||
|
tar -J ... -> tar -Ipixz ...
|
||||||
|
|||||||
22
cheat/cheatsheets/tr
Normal file
22
cheat/cheatsheets/tr
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
#replace : with new line
|
||||||
|
echo $PATH|tr ":" "\n" #equivalent with:
|
||||||
|
echo $PATH|tr -t ":" \n
|
||||||
|
|
||||||
|
#remove all occurance of "ab"
|
||||||
|
echo aabbcc |tr -d "ab"
|
||||||
|
#ouput: cc
|
||||||
|
|
||||||
|
#complement "aa"
|
||||||
|
echo aabbccd |tr -c "aa" 1
|
||||||
|
#output: aa11111 without new line
|
||||||
|
#tip: Complement meaning keep aa,all others are replaced with 1
|
||||||
|
|
||||||
|
#complement "ab\n"
|
||||||
|
echo aabbccd |tr -c "ab\n" 1
|
||||||
|
#output: aabb111 with new line
|
||||||
|
|
||||||
|
#Preserve all alpha(-c). ":-[:digit:] etc" will be translated to "\n". sequeeze mode.
|
||||||
|
echo $PATH|tr -cs "[:alpha:]" "\n"
|
||||||
|
|
||||||
|
#ordered list to unordered list
|
||||||
|
echo "1. /usr/bin\n2. /bin" |tr -cs " /[:alpha:]\n" "+"
|
||||||
33
cheat/cheatsheets/vagrant
Normal file
33
cheat/cheatsheets/vagrant
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
# Initate Vagrant
|
||||||
|
mkdir vag-vm; cd vag-vm
|
||||||
|
vagrant init
|
||||||
|
|
||||||
|
# Add a box to vagrant repo
|
||||||
|
vagrant box add hashicorp/precise32
|
||||||
|
|
||||||
|
# Add a box Vagrant file
|
||||||
|
config.vm.box = "hashicorp/precise32"
|
||||||
|
|
||||||
|
# Add vm to public network as host
|
||||||
|
config.vm.network "public_network"
|
||||||
|
|
||||||
|
# Add provision script to vagrant file
|
||||||
|
config.vm.provision :shell, path: "provision.sh"
|
||||||
|
|
||||||
|
# Start vm
|
||||||
|
vagrant up
|
||||||
|
|
||||||
|
# Connect to started instance
|
||||||
|
vagrant ssh
|
||||||
|
|
||||||
|
# Shutdown vm
|
||||||
|
vagrant halt
|
||||||
|
|
||||||
|
# Hibernate vm
|
||||||
|
vagrant suspend
|
||||||
|
|
||||||
|
# Set vm to initial state by cleaning all data
|
||||||
|
vagrant destroy
|
||||||
|
|
||||||
|
# Restart vm with new provision script
|
||||||
|
vagran reload --provision
|
||||||
2
setup.py
2
setup.py
@@ -3,7 +3,7 @@ import os
|
|||||||
|
|
||||||
setup(
|
setup(
|
||||||
name = 'cheat',
|
name = 'cheat',
|
||||||
version = '2.1.13',
|
version = '2.1.18',
|
||||||
author = 'Chris Lane',
|
author = 'Chris Lane',
|
||||||
author_email = 'chris@chris-allen-lane.com',
|
author_email = 'chris@chris-allen-lane.com',
|
||||||
license = 'GPL3',
|
license = 'GPL3',
|
||||||
|
|||||||
Reference in New Issue
Block a user