mirror of
https://github.com/cheat/cheat.git
synced 2025-12-08 08:24:01 +01:00
Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cafa2fb2fd | ||
|
|
9c31ba5102 | ||
|
|
da65ea32d8 | ||
|
|
e1aec49ed6 | ||
|
|
ab86ac970d | ||
|
|
90f66ccaf3 | ||
|
|
f63406bc3e | ||
|
|
b3a93bc128 | ||
|
|
8f0d2e9fc3 | ||
|
|
4c2d0d2d8e | ||
|
|
ac445388d9 | ||
|
|
705601f0b1 | ||
|
|
2d7fdb5425 | ||
|
|
4512a61086 |
@@ -38,7 +38,7 @@ from docopt import docopt
|
||||
|
||||
if __name__ == '__main__':
|
||||
# parse the command-line options
|
||||
options = docopt(__doc__, version='cheat 2.1.13')
|
||||
options = docopt(__doc__, version='cheat 2.1.15')
|
||||
|
||||
# list 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.
|
||||
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
|
||||
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:
|
||||
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)
|
||||
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 | \
|
||||
awk '/-----BEGIN/,/END CERTIFICATE-----/' | \
|
||||
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:
|
||||
rpm -e <package>
|
||||
|
||||
# To remove a package, but not its dependencies
|
||||
rpm -e --nodeps <package>
|
||||
|
||||
# To find what package installs a file:
|
||||
rpm -qf </path/to/file>
|
||||
|
||||
@@ -17,3 +20,12 @@ rpm -q --whatrequires <file>
|
||||
|
||||
# To list all installed packages:
|
||||
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
|
||||
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 ...
|
||||
|
||||
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
|
||||
Reference in New Issue
Block a user