Archives

Tag: Cheat Sheets

  • DNS Terms Cheatsheet


    There are a lot more domain record terms than this, but these are the ones I most frequently encounter. I’ll add more as I run into them.

    Records

    Record Description Use
    A Address Record Point a domain to a specific IP address
    CNAME Canonical Name Record This is an alias of one name to another. Example: A CNAME of www.cagrimmett.com to cagrimmett.com tells the server to look for the WWW version wherever the non-WWW version’s A record resides. CNAME records must always point to another domain name, never directly to an IP address.
    MX Mail Exchange Record Direct’s a domain’s email to the server hosting the accounts. I most frequently use this for setting up Google Apps.
    NS Name Server Record Determines which servers will communicate DNS info for a domain. You usually have a primary and secondary. This site uses Cloudflare’s name servers.
    DNSKEY DNS Key Record The key record used in DNSSEC.

    Terms

    Term Full Name Description
    DNS Domain Name System Basically a phone book for the web. When you try to go to a domain (e.g. google.com) in your browser, the domain name system tells your browser where to find that domain, usually an IP address.
    TTL Time To Live How long it will take any change you make now to go into effect
    @ Self-referential character You don’t use the actual domain name in your DNS settings. Instead, you use the @ symbol to indicate the domain name.
    DNSSEC Domain Name System Security Extensions A set of protocols that add a layer of security to the DNS lookup and exchange processes.
  • Linux Webserver Cheat Sheet


    There is obviously a lot more than this, so I’ll add more as I encounter and use them.

    Last updated on: July 6, 2016.

    Connecting

    • Connecting: ssh username@serveraddress
    • Switching to root once you get in, if needed: su root

    Where to find things

    • Logs: /var/log/apache2
    • Site roots: /var/www/ if a single site, /var/www/vhosts if multiple sites on virtual host infrastructure
    • Config files: /etc/apache2/sitesavailable and /etc/apache2/sitesenabled

    Changing directories, creating files and directories, viewing text files

    • Changing directory: cd ~/path/to/folder
    • Going up one directory: cd ..
    • Creating files: touch filename.jpg
    • Creating directories: mkdir directory_name
    • Viewing text files: less filename.txt or cat filename.txt
    • Closing out of less: q

    wget

    Wget retrieves content from web servers.

    Syntax:

    $ wget [option] URL

    Options:

    • -O – Which output file the file you are downloading should get written to.
    • -q – Quiet mode. Doesn’t show the download status and other output.

    Example – Getting a file from the web:

    $ wget -O /path/to/filename.json http://example.com/URL/to/filename.json

    Reading the manual for commands

    $ man <command>

    Examples:

    • man cron
    • man date

    Crontab

    Cron is a time-based job scheduler in Linux and Unix. Here is my full TIL on cron.

    Load your personal crontab (cron table) file:

    $ crontab -e

    View your personal crontab:

    $ crontab -l

    Syntax:

    min hour day of month month day of week command
    * * * * * command
    0 – 59 0 – 23 1 – 31 1 – 12 0 – 6 (0 to 6 are Sunday to Saturday) shell command you want to run at that time

    Examble: Download a JSON file from Quandl and overwrite GOLD.json with it Monday through Friday at 5pm server time

    0 17 * * 1-5 wget -O "/path/to/quandl_data/GOLD.json" "https://www.quandl.com/api/v3/datasets/LBMA/GOLD.json"

    Date

    Display a date and time:

    • $ date spits out the date and time on the server
    • $ TZ=US/Pacific date spits out the server’s date and time adjusted to the Pacific timezone
    • TZ=US/Eastern date -d 'Tue Jul 5 10:43:07 PDT 2016' converts the timestamp in the -d option to the Eastern timezone.
    • date -d @1467740657 converts UNIX timestamps to something you can actually read

    Eric Davis has a Simple CLI date calculator writeup on his site.