LPI-1 Revision

LPI-1 Revision

This article is not a complete guide, it contains random notes from my revision for LPIC-1.

 Networking

IP Addressing

Remember, in IP addresses, the most significant bit is first:  

Bit10100101
x76543210
2^x1286432168421
Total=128+32+4+1=165

Image from wikipedia

IP address binary conversion from wikipedia.

NETWORK MASK CONVERSIONS

  • /32 = 255.255.255.255   11111111 IPs = 2^(32-32) = 1
  • /31 = 255.255.255.254   11111110 IPs = 2^(32-31) = 2
  • /30 = 255.255.255.252   11111100 IPs = 2^(32-30) = 4
  • /29 = 255.255.255.248   11111000 IPs = 2^(32-29) = 8
  • /28 = 255.255.255.240   11110000 IPs = 2^(32-28)= 16
  • /27 = 255.255.255.224   11100000 IPs = 2^(32-27)= 32
  • /26 = 255.255.255.192   11000000 IPs = 2^(32-26)= 64
  • /25 = 255.255.255.128   10000000 IPs = 2^(32-25)= 128
  • /24 = 255.255.255.0       00000000 IPs = 2^(32-24)= 256

BROADCAST AND NETWORK ADDRESSES

  • Broadcast Address: host portion of address set to 1
  • Network Address: host portion of address set to 0.

Example network and broadcast calculation with octet boundary mask:

  • Address: 192.168.1.1/24
  • Netmask: 255.255.255.0
  • Broadcast: 192.168.1.255
  • Network: 192.168.1.0

Example broadcast and network address calculation with non octet-boundary mask:

  • Address: 172.28.4.7/12
  • Address (Binary):
    • 172=128+32+8+4 = 10101100
    • 28=16+8+4 =00011100
    • 4=4 = 00000100
    • 7=4+2+1 = 00000111
    • Combined: 10101100.0001 1100.00000100.00000111
  • Netmask (Binary) : 11111111.1111 0000.00000000.00000000
  • 2nd Octet (Decimal): 2^7+2^6+2^5+2^4 = 128+64+32+16 = 240
  • Netmask (Decimal): 255.240.0.0
  • Network (Binary): 10101100.0001 0000.00000000.00000000
  • Network (Decimal): 172.16.0.0/12
  • Broadcast (Binary):  10101100.0001 1111.11111111.11111111
  • Broadcast (Decimal): 172.31.255.255

Ranges for Old-School network classes:

  • A: 0-127
  • B: 127-191
  • C: 192-223
  • D: 224/8

RFC 1918 Reserved Ranges:

  • 10/8
  • 172.16/12 (16-31)
  • 192.168/16

Netstat flags

  • -n No DNS resolution
  • -t tcp
  • -u udp
  • -l listening

Users and Groups, Permissions

ETC PASSWD Fields:

  1. username
  2. x (for shadow passwords)
  3. UID
  4. GID
  5. GECOS / comment
  6. home directory
  7. shell (optional)

ETC Group fields:

  1. name
  2. x ( for shadow passwords)
  3. GID
  4. comma separated list of members

Octal Permissions: Normal

  • 4 Read
  • 2 Write
  • 1 Execute

Octal Permissions: Special

  • 4 Setuid
  • 2 Setguid
  • 1 Sticky

Kernel

  • modinfo, shows path, version magic and filename for a kernel module.
    [email protected]:~# modinfo loop
    filename: /lib/modules/2.6.32-5-xen-amd64/kernel/drivers/block/loop.ko
    alias: block-major-7-*
    license: GPL
    depends: 
    vermagic: 2.6.32-5-xen-amd64 SMP mod_unload modversions 
    parm: max_loop:Maximum number of loop devices (int)
    parm: max_part:Maximum number of partitions per loop device (int)
  • Update modules.dep: depmod -a
  • modprobe reads optional config file /etc/modprobe.conf

 Misc

Partition Types

  • 82 Swap
  • 83 Linux
  • 8E LVM

Shutdown flags

  • -r reboot
  • -h halt
  • -P turn off power
  • -f skip fsck
  • -F force fsck
  • -c cancel a running shutdown

lsusb flags

  •  -s bus:device, show a specific device

Bash options

  • noclobber:  prevents files being overwritten with a redirect. Set with set -o noclobber, unset with set +o noclobber.
    [email protected]:~# date >/tmp/clobbertest
    [email protected]:~# date >/tmp/clobbertest
    [email protected]:~# shopt -o noclobber
    noclobber off
    [email protected]:~# set -o noclobber
    [email protected]:~# shopt -o noclobber
    noclobber on
    [email protected]:~# date >/tmp/clobbertest 
    -su: /tmp/clobbertest: cannot overwrite existing file
    [email protected]:~# set +o noclobber
    [email protected]:~# date >/tmp/clobbertest 
    [email protected]:~#