Sunday 31 August 2014

DNS and DHCP


DNS Zones
Storage unit of Domain names + IPs
Mostly forward but also reverse
Stored in File or AD
 File (C:\windows\system32\Domain.Dns)
  -Primary + 1 or more secondary
  -Only Primary is R/W
  -Secondary updated by Primary or other secondary
 AD-Integrated
  -Stored in AD
  -Replicated with other AD data incrementally
  -Secure dynamic Updates

Forwarders+Stubs
Forwarders
Root hints:Internet top-level servers
Conditional:Commonly accessed domain DNS server

Stub Zones
 -Contains Authoritative DNS server resource records
  *SOA, *NS, *A(Glue)
 -Receives updates

Cache Management+Resource Records
DNS Server cache
 -Prevents redundant lookups
 -Usually valid for 1 day
 -Clear

Common RR
 -A (host record for IPv4), AAAA(host record for IPv6)
 -PTR (pointer record for reverse lookup)
 -CNAME (alias)
 -MX
To display DNS cache on client machine - ipconfig /displaydns


Namespace  This is the name of a domain, not specifi cally an Active Directory domain though. It’s a logical set of hosts signifi ed by a name controlled by a set of name servers. This is
equivalent to a computer’s last name; they’re all part of the same family. For example, Bigfirm.com is the namespace for hosts in the Bigfi rm.com domain.

Recursion  This is a server-directed process to resolve an FQDN. If the server cannot resolve the FQDN with its own information, it will send the query to other name servers. The recursion process comprises root servers and domain name servers. Root servers are the top of the hierarchical naming structure. The root servers list the name servers that control the top-level domain names such as .com, .gov, and .edu. The top-level domain servers control the registry of subdomains beneath the top-level domain.

Delegation  This means allowing another name server to control a subdomain of a given namespace. For example, the Bigfirm.com name servers can delegate control of the Ecoast.Bigfi rm.com namespace to another server.

Forwarding  This is an alternative to the recursion process. Forwarding is a lateral request to another name server within the network. The forwarding server obtains a response and relays it to the originating name server.

Iteration  This is a client-directed process to resolve an FQDN. If the client receives a negative request from a name server, it will query another name server.
NetBIOS Naming System  This legacy naming system was used primarily within old Microsoft NT 4.0 networks. Its processes are still part of modern-day Windows operating systems, however, particularly when using non-domain (workgroup)–based computers.

Service Records  Service records (SRVs) are records within a DNS namespace to resolve a service to a hostname. This is an essential part of DNS supporting Active Directory.

Dynamic DNS Update  Dynamic DNS (DDNS) update is a process that allows DNS clients to register their hostnames in an assigned namespace such as DHCP. This reduces the need of admins to manually enter records in the name server databases. This is another essential part of DNS supporting Active Directory.

----------------------------------------------------------------

DHCP Process (DORA) - Discovery,Offer,Request,Acknowledge

DHCP Database
 -Backup
 -Restore
 -Reconcile

DHCP Failover
 -Load sharing
 -Hot standby



Sunday 17 August 2014

Japanese Basic

konit chi wa - (Hello) late in the morning & afternoon
ohio - good morning
ohio gozaiemas - with respect
sang - mr, mrs, miss (family name)

ha ji mi(n) mash delt - how do u do (used when people meet for the first time)
doezo yoro shaku - nice to meet u (pls be nice to me)
----
su mee ma sant - excuse me, sorry
air go - english language
waka remas - understand
ka - ? question (end of the sentence)

air go ga  waka remas ka? - do u understand english
high - yes
ei yelt - no
waka remas sant - don't understand
high, waka yemas

nihong - japanese
su mee ma sant, nihong go ga waka yemas ka?
-----

america jin(t) - America person - american
watashi - I
des - is, am , are
watashi wa amercian jint(t) des.

american jint(t) des ka?
Green sang wa american jint(t) des ka? -- Ms. green, r u an american?
high, watashi wa amercian jint(t) des.

soe des - that's right
high, soe des.

chi ga emas - incorrect
ei yelt, chi ga yemas.
-------

Saturday 16 August 2014

PHP & MySQL basic

CREATE DATABASE ijdb;
DROP DATABASE ijdb;

CREATE TABLE joke (
id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
    jokeText TEXT,
    jokeDate DATE NOT NULL
) DEFAULT CHARACTER SET utf8;

SHOW TABLES;
DESCRIBE joke;
DROP TABLE joke;


INSERT INTO joke SET
joketext = "Why did the chicken cross the road? To get to the other side!",
jokedate = "2011-04-01";

INSERT INTO joke
(joketext, jokedate)
VALUES (
"Why did the chicken cross the road? To get to the other side!",
"2011-04-01"
);


SELECT * FROM joke;
SELECT id, jokedate from joke;
SELECT id, LEFT(joketext, 20), jokedate FROM joke; - LEFT , lets us tell MySQL to display a column’s contents up to a specified maximum number of characters.
SELECT COUNT(*) FROM joke; - COUNT , which lets us count the number of results returned.
SELECT COUNT(*) FROM joke WHERE jokedate >= "2011-01-01";
SELECT joketext FROM joke WHERE joketext LIKE "%chicken%";

SELECT joketext FROM joke WHERE
joketext LIKE "%knock%" AND
jokedate >= "2011-04-01" AND
jokedate < "2011-05-01";


UPDATE joke SET jokedate = "2011-04-01"
WHERE joketext LIKE "%chicken%";

DELETE FROM tableName WHERE conditions;
DELETE FROM tableName WHERE conditions;


PHP
-----------
$var1 = 'PHP';
echo "$var1 rules!";    // Outputs 'PHP rules!'
echo '$var1 rules!';    // Outputs '$var1 rules!'
ou can include the name of a variable right inside a text string, and have the value inserted in its place if you surround the string with double quotes instead of single quotes. This process of converting variable names to their values is known as variable interpolation. However, as the last line demonstrates, a string surrounded with single quotes will not interpolate the variable names it contains.



$myarray = array('one', 2, '3');
echo $myarray[0];       // Outputs 'one'
echo $myarray[1];       // Outputs '2'
echo $myarray[2];       // Outputs '3'

$myarray[1] = 'two';    // Assign a new value
$myarray[3] = 'four';   // Create a new element

$myarray[] = 'the fifth element';
echo $myarray[4];       // Outputs 'the fifth element'


$birthdays['Kevin'] = '1978-04-12';
$birthdays['Stephanie'] = '1980-05-16';
$birthdays['David'] = '1983-09-09';



htmlspecialchars($firstname, ENT_QUOTES, 'utf-8')

----------------------------------
For documentation - php.net/date (for eg); dev.mysql.com (click on Developer zone);

-----------------------------------

Connecting to MySQL database from PHP
------------
Need a user account for php. Go to phpMyAdmin, select a database, click on Priviledge. Add user.

<?php

$link = mysqli_connect('localhost', 'ijdbuser', 'mypassword');
if (!$link)
{
$output = "Unable to connect to the database server";
include 'output.html.php';
exit();
}

if (!mysqli_set_charset($link, 'utf8'))
{
$output = "Unable to set  database connection encoding";
include 'output.html.php';
exit();
}

if (!mysqli_select_db($link, 'ijdb'))
{
$output = 'Unable to locate joke database';
include 'output.html.php';
exit();
}

$output = 'Database connection established';
include 'output.html.php';

?>

SQL Join
Select * From joke INNER JOIN author on authorid = author.id

File List

PHP-L3S4-Variables,Operators.pdf
PHP-L3S5-Arrays.pdf
PHP-L3S6-PassingVariablesInLinks.pdf
PHP-L3S8-PassingVariablesInForms.pdf
PHP-L4S3-ConditionalStatements.pdf
PHP-L4S4-Loops.pdf
PHP-L4S7-ControllerAndTemplates.pdf
PHP-L6S5-SendingSqlQueries with PHP.pdf
PHP-L6S6-Handling SELECT Resultset.pdf
PHP-L7S3-Inserting Data Into Database.pdf
PHP-L7S4-Deleting Data from Database.pdf
PHP-L11S4-Types Of Includes.pdf
PHP-L11S6-Variable Scope&Global Access.pdf

sample codes.zip


Monday 11 August 2014

Linux Baisc Commands

Linux commands are case sensitive.

cat <filename> (print/display the text in file)

$PATH is a variable that tells shell where to look for specific command
echo $PATH

which (show where this command path is)

To run 2 commands together
echo $a;$b
ls;ls 

history (command history that typed in)

ls --help (To get help about a command)

man <command> (display manual)
man -k <command> (search for that command as keyword in other commands)

info (same/more info than man)

whatis <command> (displays brief description of the command)
whereis <command> (displays location of the command)

less (read text files page by page, even it's zipped)

Working with directories

pwd (present working directory)
cd -absolute path or -relative path
cd ~ (bring back to current user's home directory)
cd . and cd ..

ls -l (optional folder name) (displays file list with rights); line starts with - is a file while starting with d is a directory)
ls -R (recursive, list all files within current directory and within sub-directories)
ls -a (list all files including hidden files (those files start with .)
ls -al


mv <source> <destination>
cp <source file> <destination file>
cp -R <source folder> <destination folder>
rm <file name>
rmdir <folder name> (the contents of the folder must be empty first rm *)
rm -rf <name> (force remove recursively)


/etc     - system wide config files
/lib      - linked library files used by binaries in /bin and /usr/bin
/usr/lib -linked library files used by binaries in /bin and /usr/bin
/var/log - log files

syslog   - program that manages storage of logs for daemons on the system
Klog     - logs Kernel specific messages
dmesg   - used to view kernel messages

Checking CPU and Memory
free -tom
top

IP, DNS, etc
/etc/resolv.conf (where current DNS server info is stored)
ifconfig
route
dig

Users and Groups
standard, root, system users

id - info about a user
w - what users logged in are doing
who - who is logged in
sudo - do command with root privledges

/etc/passwd
/etc/group
System accounts usually/generally have low user ID numbers.

useradd - add uer
groupadd - add group
last - show recent logsin
passwd - change passwords
usermod - change aspects of existing user
userdel - delete user
groupdel - delete group
eg. sudo usermod -a -G pineGroup patrick
     sudo usermod -a -G sudo patrick

/etc/passwd  - user info
/etc/shadow  - user passwords
/etc/group  - group info

File Permission and Ownership
user group other (ugo)
chmod ugo -w file (remove write permission from everyone)
chmod go -w file (remove write permission from group, other)
chmod o +x file (add execute permission to other)
chmod 555 file (change the permission using number instead of letters)
sudo chown spowers:pirate gold.txt (change ownership to spowers (user), pirate (group))

If a person has a write access to a folder, he can also delete anything in that folder.
To prevent people from erasing each other's files in public folder like /tmp,
chmod o+t folder (sets sticky bit,only user can delete the file)
chmod 1777 folder (sets sticky bit,only user can delete the file)

Special Directories and Files
ln -s source-file sybolic-file  - Symbolic link 


/tmp  - short term storage, get erased on boot
/var/tmp  -  same, but doesn't get deleted
/var/  - files that change often (mail, logs, etc)