Table of Contents

Notes to be organized to Wiki Pages later


Common Commands, nagivating the file system


Important Places


ls long output


Files preceeded by a . are hidden/config files and won't show unless -a flag is used in ls cmd.

ls readout: perms, ?, user, group, file, last touched, name.

first perm bit 'd' means it's a dir.

Regular Expressions


Any Single Character

A dot will match any single char except newlines: a.z will match abz aQz a9Z and etc.

Repetition Operators

A regex may be followed by a special symbol to denote how many times a matching item must exist.

Multiple Possible Strings:

Vertical Bar (|) separates two possible matches:

Parentheses

Surrounds subexpressions (no example in chapter 1)

Escaping

If you want to match special chars like a dot (.) you must escape it with a backslask: \. (Not unlike bash and python)

grep


Searches for patterns: grep [options] regexp [files]

flags:

sed


sed 's/2012/2013/' file.txt > new.txt # Change first occurrence of 2012 to 2013 and redirect output to new.txt

File Permissions


ls


Can change default permissions with umask.

chmod


numeric or symbolic modes.

Set user to group

chown


: or . works as seperator

Cron


Scheduled task system. Stateless, doesn't remember previous jobs.

Sample Syntax:

SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root

# For details see man 4 crontabs

# Example of job definition:
# .---------------- minute (0 - 59)
# |  .------------- hour (0 - 23)
# |  |  .---------- day of month (1 - 31)
# |  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ...
# |  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# |  |  |  |  |
# *  *  *  *  * user-name  command to be executed
*/2 1 1,15 * * root echo "Hello world!" > /tmp/hello.txt # 1st and 15th day of month

# /2 = every 2
# 1,15 = 1st and 15th
# 1-5 = 1st through 5th

Otherwise, symlinking scripts/programs to cron.daily,monthly, weekly, hourly, etc folders will work.

user cron

crontab -e to edit user cron, independent from system cron.

Package Management


CENTOS

rpm

yum

UBUNTU


uses apt-get / dpkg

apt

Config file located in /etc/apt. sources.list important. sources.list.d folder contains official repos.

top


top stuff.

Managing Shared Libraries


Code/functions compiled into files called libraries that other programs/code can call on, reducing code and disk space by not having 50 variations of code that do the same thing.

Managing Processes


Managing Hardware


BIOS


Enumerates hardware before OS is loaded. Drivers will determine how hardware acts in Linux OS. May need to drownload drivers from manufacturers for optimal performance.

Drivers


drivers loaded in /sys/bus/pci/drivers.

probs


If problems present, check bios. Check drivers! Check lsmod, lspci, lsusb. use modprobe to load modules. Check with the vendor.

REDIRECT VIDEO TO SERIAL! - Real World examples


Not on exam, but steps demo underlying system that are on exam.

serial --unit 1 --speed=9600
terminal --timeout 300 console serial

LVM - Logical Volume Manager


Logicall manages volumes/partitions, create and resize across multiple disks.

Configure LVM

Filesystem Health


/etc/fstab

Mounts devs on boot.

device      mount     FS     Options -   Dump   - Pass(fschk)
/dev/sda1    /        ext4    defaults    0|1     0|1|2

device = device
mount = mount location
FS = filesystem to expect
Options = boot options (defaults is a combo of options). Like, rw, ro, sync, async, etc.
Dump = old unix backup system. If dump not installed or used, it means nothing. 0 no bkup, 1 = bkup.
Pass = FSCHK, 0 no check, 1 check (high pri), 2 check (2ndary pri)

add label to device/part

File Management Commands 1 & 2


System D


An alternative init system – (usual is upstart, sysV) Breaks up config files.

Is a program, running all the time. SysV = script, one line/procedural at a time. hangup on one line can cause delays. SystemD, one hung up module won't block all others.

SystemD on boot looks for UNITS and TARGETS.

Xorg Configuration


Find and Locate

Both used to search for files. locate uses a database of information to search and is updated via a syscron or manual updatedb. find will search the disk in specified locations for files and objects.