Cheat Sheets

Debian/Ubuntu cheat sheet

Tags: •  • 

Find packages that contain a file

apt-file search "somefile"

List all installed packages

% apt-cache pkgnames
% dpkg -l

List files owned by package

% dpkg -L <i>pkg</i>

What package owns a file

% dpkg -S <i>/path/to/file</i>

Display package information

% dpkg -p <i>pkg</i>

Fedora cheat sheet

Tags:

Disable SELinux

/usr/sbin/setenforce 0

VIM cheat sheet

Tags:
Command Effect
:opt Options window, display current vim configuration

Microsoft Windows cheat sheet

Tags:

Installation

Selecting different HAL during installation

A different HAL (e.g. Standard HAL instead of ACPI HAL) can be chosen on installation by hitting F5 during the Press F6 if you need to install a third party SCSI or RAID driver message.

Commands

Recursive directory removal

rmdir /s /q [directory]

Removing desktop.ini files from a directory structure

FOR /f %G in ('dir /b') do attrib %G\desktop.ini -h -s
FOR /f %G in ('dir /b') do del %G\desktop.ini

IPv4 CIDR notation cheat sheet

Tags:

IPv4 network addressing cheat sheet, with CIDR notation, number of addresses, and masks.


MySQL cheat sheet

Tags:

Backup and restore

Backing up tables:

mysqldump -p -c -Q databasename tablename1 tablename2 ... > whatever.sql

Restoring tables:

mysql -p databasename < whatever.sql

Creating a user and their own database

CREATE DATABASE dbname;
GRANT USAGE ON dbname.* TO username@'%';
GRANT ALL ON dbname.* TO username@'%';
SET PASSWORD FOR username@'%' = PASSWORD('blah');
FLUSH PRIVILEGES;

Changing passwords

SET PASSWORD = PASSWORD('blah');

Changing administrator password

mysql -u root
mysql> SET PASSWORD FOR root@localhost = PASSWORD('new_password');

Disabling network access

In my.cnf, add the keyword ==skip-networking== and the line ==bind-address=127.0.0.1== (for any applications that still require TCP networking) to the ==![mysqld]== section.

Flushing Initial Database and Users

drop database test;
use mysql;
delete from db;
delete from user where not (host="localhost" and user="root");
flush privileges;

Deleting users

REVOKE ALL PRIVILEGES ON . FROM username@'%'; REVOKE GRANT OPTION ON . FROM username@'%';


OpenSSL cheat sheet

Tags:

End-user Functions

Create Certificate Request/Unsigned Key

openssl req -nodes -new -keyout blah.key.pem -out blah.req.pem
  • blah.key.pem will act as an SSLCertificateKeyFile for Apache

Fingerprint for Unsigned Certificate

openssl x509 -subject -dates -fingerprint -in blah.key.pem

Generate Key

openssl genrsa -out blah.key.pem

Display Certificate Information

openssl x509 -in blah.crt.pem -noout -text

Creating a PEM File for Servers

cat blah.key.pem blah.crt.pem blah.dhp.pem > blah.pem

Creating PKCS12-format File

openssl pkcs12 -export -in blah.crt.pem -inkey blah.key.pem -out blah.p12 -name "Bill Gates"

Signing E-mails

openssl smine -sign -in msg.txt -text -out msg.encrypted -signer blah.crt.pem -inkey blah.key.pem

Certificate Authority Functions

When setting up a new CA on a system, make sure index.txt and serial exist (empty and set to 01, respectively), and create directories private and newcert. Edit openssl.cnf - change defaultdays, certificate and privatekey, possibly key size (1024, 1280, 1536, 2048) to whatever is desired.

Create CA Certificate

openssl req -new -x509 -keyout private/something-CA.key.pem -out ./something-CA.crt.pem -days 3650

Export CA Certificate in DER Format

openssl x509 -in something-CA.crt.pem -outform der -out something-CA.crt
  • Used by web browsers

Revoke Certificate

openssl ca -revoke blah.crt.pem

Generate Certificate Revokation List

openssl ca -gencrl -out crl/hotnudiegirls.com-CA.crl

Sign Certificate Request

openssl ca -out blah.crt.pem -in blah.req.pem
  • blah.crt.pem acts as !SSLCertificateFile for Apaache

Create Diffie-Hoffman Parameters for Current CA

openssl dhparam -out hotnudiegirls.com-CA.dhp.pem 1536

Creating Self-Signed Certificate from Generated Key

openssl req -new -x509 -key blah.key.pem -out blah.crt.pem

  • Use only when you’ve no CA and will only be generating one key/certificate (useless for anything that requires signed certificates on both ends)

Command-line Tricks

Simple file encryption

openssl enc -bf -A -in file_to_encrypt.txt

(password will be prompted)

Simple file decryption

openssl enc -bf -d -A -in file_to_encrypt.txt

Syndicate content