mirror of https://github.com/cheat/cheat.git
Explicitly mark comment lines in builtin sheets.
This commit is contained in:
parent
f89d887c21
commit
8245d3f4ec
|
@ -1,2 +1,2 @@
|
||||||
To search for apt packages:
|
# To search for apt packages:
|
||||||
apt-cache search "whatever"
|
apt-cache search "whatever"
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
To connect to a running Asterisk session:
|
# To connect to a running Asterisk session:
|
||||||
asterisk -rvvv
|
asterisk -rvvv
|
||||||
|
|
||||||
To issue a command to Asterisk from the shell:
|
# To issue a command to Asterisk from the shell:
|
||||||
asterisk -rx "<command>"
|
asterisk -rx "<command>"
|
||||||
|
|
||||||
To originate an echo call from a SIP trunk on an Asterisk server, to a specified number:
|
# To originate an echo call from a SIP trunk on an Asterisk server, to a specified number:
|
||||||
asterisk -rx "channel originate SIP/<trunk>/<number> application echo"
|
asterisk -rx "channel originate SIP/<trunk>/<number> application echo"
|
||||||
|
|
||||||
To print out the details of SIP accounts:
|
# To print out the details of SIP accounts:
|
||||||
asterisk -rx "sip show peers"
|
asterisk -rx "sip show peers"
|
||||||
|
|
||||||
To print out the passwords of SIP accounts:
|
# To print out the passwords of SIP accounts:
|
||||||
asterisk -rx "sip show users"
|
asterisk -rx "sip show users"
|
||||||
|
|
||||||
To print out the current active channels:
|
# To print out the current active channels:
|
||||||
asterisk -rx "core show channels"
|
asterisk -rx "core show channels"
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
To implement a for loop:
|
# To implement a for loop:
|
||||||
for file in `ls .`;
|
for file in `ls .`;
|
||||||
do echo 'file';
|
do echo 'file';
|
||||||
echo 'found';
|
echo 'found';
|
||||||
done
|
done
|
||||||
|
|
||||||
To implement a case command:
|
# To implement a case command:
|
||||||
case "$1"
|
case "$1"
|
||||||
in
|
in
|
||||||
0) echo "zero found";;
|
0) echo "zero found";;
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
To resize an image to a fixed width and proportional height:
|
# To resize an image to a fixed width and proportional height:
|
||||||
convert original-image.jpg -resize 100x converted-image.jpg
|
convert original-image.jpg -resize 100x converted-image.jpg
|
||||||
|
|
||||||
To resize an image to a fixed height and proportional width:
|
# To resize an image to a fixed height and proportional width:
|
||||||
convert original-image.jpg -resize x100 converted-image.jpg
|
convert original-image.jpg -resize x100 converted-image.jpg
|
||||||
|
|
||||||
To resize an image to a fixed width and height:
|
# To resize an image to a fixed width and height:
|
||||||
convert original-image.jpg -resize 100x100 converted-image.jpg
|
convert original-image.jpg -resize 100x100 converted-image.jpg
|
||||||
|
|
||||||
To resize an image and simultaneously change its file type:
|
# To resize an image and simultaneously change its file type:
|
||||||
convert original-image.jpg -resize 100x converted-image.png
|
convert original-image.jpg -resize 100x converted-image.png
|
||||||
|
|
||||||
To resize all of the images within a directory:
|
# To resize all of the images within a directory:
|
||||||
To implement a for loop:
|
# To implement a for loop:
|
||||||
for file in `ls original/image/path/`;
|
for file in `ls original/image/path/`;
|
||||||
do new_path=${file%.*};
|
do new_path=${file%.*};
|
||||||
new_file=`basename $new_path`;
|
new_file=`basename $new_path`;
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
To cut out the third field of text or stdoutput that is delimited by a #:
|
# To cut out the third field of text or stdoutput that is delimited by a #:
|
||||||
cut -d# -f3
|
cut -d# -f3
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
To release the current IP address:
|
# To release the current IP address:
|
||||||
sudo dhclient -r
|
sudo dhclient -r
|
||||||
|
|
||||||
To obtain a new IP address:
|
# To obtain a new IP address:
|
||||||
sudo dhclient
|
sudo dhclient
|
||||||
|
|
||||||
Running the above in sequence is a common way of refreshing an IP.
|
# Running the above in sequence is a common way of refreshing an IP.
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
To find files by extension (ex: .jpg):
|
# To find files by extension (ex: .jpg):
|
||||||
find . -iname "*.jpg"
|
find . -iname "*.jpg"
|
||||||
|
|
||||||
To find directories:
|
# To find directories:
|
||||||
find . -type d
|
find . -type d
|
||||||
|
|
||||||
To find files:
|
# To find files:
|
||||||
find . -type f
|
find . -type f
|
||||||
|
|
||||||
To find files by octal permission:
|
# To find files by octal permission:
|
||||||
find . -type f -perm 777
|
find . -type f -perm 777
|
||||||
|
|
||||||
To find files with setuid bit set:
|
# To find files with setuid bit set:
|
||||||
find . -xdev \( -perm -4000 \) -type f -print0 | xargs -0 ls -l
|
find . -xdev \( -perm -4000 \) -type f -print0 | xargs -0 ls -l
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
To set your identify:
|
# To set your identify:
|
||||||
git config --global user.name "John Doe"
|
git config --global user.name "John Doe"
|
||||||
git config --global user.email johndoe@example.com
|
git config --global user.email johndoe@example.com
|
||||||
|
|
||||||
To enable color:
|
# To enable color:
|
||||||
git config --global color.ui true
|
git config --global color.ui true
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
To create a symlink:
|
# To create a symlink:
|
||||||
ln -s path/to/the/target/directory name-of-symlink
|
ln -s path/to/the/target/directory name-of-symlink
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
To dump a database to a file:
|
# To dump a database to a file:
|
||||||
mysqldump -uusername -ppassword the-database > db.sql
|
mysqldump -uusername -ppassword the-database > db.sql
|
||||||
|
|
||||||
To dump a database to a .tgz file:
|
# To dump a database to a .tgz file:
|
||||||
mysqldump -uusername -ppassword the-database | gzip -9 > db.sql
|
mysqldump -uusername -ppassword the-database | gzip -9 > db.sql
|
||||||
|
|
||||||
To dump all databases to a file:
|
# To dump all databases to a file:
|
||||||
mysqldump -uusername -ppassword --all-databases > all-databases.sql
|
mysqldump -uusername -ppassword --all-databases > all-databases.sql
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
To view which users/processes are listening to which ports:
|
# To view which users/processes are listening to which ports:
|
||||||
sudo netstat -lnptu
|
sudo netstat -lnptu
|
||||||
|
|
|
@ -1,33 +1,33 @@
|
||||||
Single target scan:
|
# Single target scan:
|
||||||
nmap [target]
|
nmap [target]
|
||||||
|
|
||||||
Scan from a list of targets:
|
# Scan from a list of targets:
|
||||||
nmap -iL [list.txt]
|
nmap -iL [list.txt]
|
||||||
|
|
||||||
iPv6:
|
# iPv6:
|
||||||
nmap -6 [target]
|
nmap -6 [target]
|
||||||
|
|
||||||
OS detection:
|
# OS detection:
|
||||||
nmap -O [target]
|
nmap -O [target]
|
||||||
|
|
||||||
Save output to text file:
|
# Save output to text file:
|
||||||
nmap -oN [output.txt] [target]
|
nmap -oN [output.txt] [target]
|
||||||
|
|
||||||
Save output to xml file:
|
# Save output to xml file:
|
||||||
nmap -oX [output.xml] [target]
|
nmap -oX [output.xml] [target]
|
||||||
|
|
||||||
Scan a specific port:
|
# Scan a specific port:
|
||||||
nmap -source-port [port] [target]
|
nmap -source-port [port] [target]
|
||||||
|
|
||||||
Do an aggressive scan:
|
# Do an aggressive scan:
|
||||||
nmap -A [target]
|
nmap -A [target]
|
||||||
|
|
||||||
Traceroute:
|
# Traceroute:
|
||||||
nmap -traceroute [target]
|
nmap -traceroute [target]
|
||||||
|
|
||||||
Ping scan only: -sP
|
# Ping scan only: -sP
|
||||||
Don't ping: -PN
|
# Don't ping: -PN
|
||||||
TCP SYN ping: -PS
|
# TCP SYN ping: -PS
|
||||||
TCP ACK ping: -PA
|
# TCP ACK ping: -PA
|
||||||
UDP ping: -PU
|
# UDP ping: -PU
|
||||||
ARP ping: -PR
|
# ARP ping: -PR
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
To send a desktop notification via dbus:
|
# To send a desktop notification via dbus:
|
||||||
notify-send -i 'icon-file/name' -a 'application_name' 'summary' 'body of message'
|
notify-send -i 'icon-file/name' -a 'application_name' 'summary' 'body of message'
|
||||||
|
|
||||||
The -i and -a flags can be omitted if unneeded.
|
# The -i and -a flags can be omitted if unneeded.
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
To create a 2048-bit private key:
|
# To create a 2048-bit private key:
|
||||||
openssl genrsa -out server.key 2048
|
openssl genrsa -out server.key 2048
|
||||||
|
|
||||||
To create the Certificate Signing Request (CSR):
|
# To create the Certificate Signing Request (CSR):
|
||||||
openssl req -new -key server.key -out server.csr
|
openssl req -new -key server.key -out server.csr
|
||||||
|
|
||||||
To sign a certificate using a private key and CSR:
|
# To sign a certificate using a private key and CSR:
|
||||||
openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
|
openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
|
||||||
|
|
||||||
(The above commands may be run in sequence to generate a self-signed SSL certificate.)
|
# (The above commands may be run in sequence to generate a self-signed SSL certificate.)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
To copy a file from your local machine to a remote server:
|
# To copy a file from your local machine to a remote server:
|
||||||
scp foo.txt user@example.com:remote/dir
|
scp foo.txt user@example.com:remote/dir
|
||||||
|
|
||||||
To copy a file from a remote server to your local machine:
|
# To copy a file from a remote server to your local machine:
|
||||||
scp user@example.com:remote/dir/foo.txt local/dir
|
scp user@example.com:remote/dir/foo.txt local/dir
|
|
@ -1,8 +1,8 @@
|
||||||
To replace all occurrences of "day" with "night" and write to stdout:
|
# To replace all occurrences of "day" with "night" and write to stdout:
|
||||||
sed s/day/night file.txt
|
sed s/day/night file.txt
|
||||||
|
|
||||||
To replace all occurrences of "day" with "night" within file.txt:
|
# To replace all occurrences of "day" with "night" within file.txt:
|
||||||
sed s/day/night file.txt > file.txt
|
sed s/day/night file.txt > file.txt
|
||||||
|
|
||||||
To replace all occurrences of "day" with "night" on stdin:
|
# To replace all occurrences of "day" with "night" on stdin:
|
||||||
echo 'It is daytime' | sed s/day/night/
|
echo 'It is daytime' | sed s/day/night/
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
To shred a file (5 passes) and verbose output:
|
# To shred a file (5 passes) and verbose output:
|
||||||
shred -n 5 -v file.txt
|
shred -n 5 -v file.txt
|
||||||
|
|
||||||
To shred a file (5 passes) and a final overwrite of zeroes:
|
# To shred a file (5 passes) and a final overwrite of zeroes:
|
||||||
shred -n 5 -vz file.txt
|
shred -n 5 -vz file.txt
|
||||||
|
|
||||||
To do the above, and then truncate and rm the file:
|
# To do the above, and then truncate and rm the file:
|
||||||
shred -n 5 -vzu file.txt
|
shred -n 5 -vzu file.txt
|
||||||
|
|
||||||
To shred a partition:
|
# To shred a partition:
|
||||||
shred -n 5 -vz /dev/sda
|
shred -n 5 -vz /dev/sda
|
||||||
|
|
||||||
Remember that shred may not behave as expected on journaled file systems if file data is being journaled.
|
# Remember that shred may not behave as expected on journaled file systems if file data is being journaled.
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
To view which users/processes are listening to which ports:
|
# To view which users/processes are listening to which ports:
|
||||||
sudo sockstat -l
|
sudo sockstat -l
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
To split a large text file into smaller files of 1000 lines each:
|
# To split a large text file into smaller files of 1000 lines each:
|
||||||
split file.txt -l 1000
|
split file.txt -l 1000
|
||||||
|
|
||||||
To split a large binary file into smaller files of 10M each:
|
# To split a large binary file into smaller files of 10M each:
|
||||||
split file.txt -b 10M
|
split file.txt -b 10M
|
||||||
|
|
||||||
To consolidate split files into a single file:
|
# To consolidate split files into a single file:
|
||||||
cat x* > file.txt
|
cat x* > file.txt
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
To execute a command on a remote server:
|
# To execute a command on a remote server:
|
||||||
ssh -t user@example.com 'the-remote-command'
|
ssh -t user@example.com 'the-remote-command'
|
||||||
|
|
||||||
To tunnel an x session over SSH:
|
# To tunnel an x session over SSH:
|
||||||
ssh -X user@example.com
|
ssh -X user@example.com
|
||||||
|
|
||||||
To launch a specific x application over SSH:
|
# To launch a specific x application over SSH:
|
||||||
ssh -X -t user@example.com 'chromium-browser'
|
ssh -X -t user@example.com 'chromium-browser'
|
||||||
|
|
||||||
For more information, see:
|
# For more information, see:
|
||||||
http://unix.stackexchange.com/q/12755/44856
|
# http://unix.stackexchange.com/q/12755/44856
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
To copy a key to a remote host:
|
# To copy a key to a remote host:
|
||||||
ssh-copy-id username@host
|
ssh-copy-id username@host
|
||||||
|
|
||||||
To copy a key to a remote host on a non-standard port:
|
# To copy a key to a remote host on a non-standard port:
|
||||||
ssh-copy-id username@host -p 2222
|
ssh-copy-id username@host -p 2222
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
To generate an SSH key:
|
# To generate an SSH key:
|
||||||
ssh-keygen -t rsa
|
ssh-keygen -t rsa
|
||||||
|
|
||||||
To generate a 4096-bit SSH key:
|
# To generate a 4096-bit SSH key:
|
||||||
ssh-keygen -t rsa -b 4096
|
ssh-keygen -t rsa -b 4096
|
||||||
|
|
||||||
To copy a key to a remote host:
|
# To copy a key to a remote host:
|
||||||
ssh-copy-id username@host
|
ssh-copy-id username@host
|
||||||
|
|
||||||
To copy a key to a remote host on a non-standard port:
|
# To copy a key to a remote host on a non-standard port:
|
||||||
ssh-copy-id username@host -p 2222
|
ssh-copy-id username@host -p 2222
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
To redirect stderr to stdout:
|
# To redirect stderr to stdout:
|
||||||
some-command 2>&1
|
some-command 2>&1
|
||||||
|
|
||||||
To redirect stderr to a file
|
# To redirect stderr to a file
|
||||||
some-command 2> errors.txt
|
some-command 2> errors.txt
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
To extract an uncompressed archive:
|
# To extract an uncompressed archive:
|
||||||
tar -xvf /path/to/foo.tar
|
tar -xvf /path/to/foo.tar
|
||||||
|
|
||||||
To create an uncompressed archive:
|
# To create an uncompressed archive:
|
||||||
tar -cvf /path/to/foo.tar /path/to/foo/
|
tar -cvf /path/to/foo.tar /path/to/foo/
|
||||||
|
|
||||||
To extract a .gz archive:
|
# To extract a .gz archive:
|
||||||
tar -xzvf /path/to/foo.tgz
|
tar -xzvf /path/to/foo.tgz
|
||||||
|
|
||||||
To create a .gz archive:
|
# To create a .gz archive:
|
||||||
tar -czvf /path/to/foo.tgz /path/to/foo/
|
tar -czvf /path/to/foo.tgz /path/to/foo/
|
||||||
|
|
||||||
To extract a .bz2 archive:
|
# To extract a .bz2 archive:
|
||||||
tar -xjvf /path/to/foo.tgz
|
tar -xjvf /path/to/foo.tgz
|
||||||
|
|
||||||
To create a .bz2 archive:
|
# To create a .bz2 archive:
|
||||||
tar -cjvf /path/to/foo.tgz /path/to/foo/
|
tar -cjvf /path/to/foo.tgz /path/to/foo/
|
||||||
|
|
Loading…
Reference in New Issue