Slide 1

Slide 1 text

Kickin’ It Old School by Rachel Baker with the Command Line

Slide 2

Slide 2 text

Goals 1. Help beginners become more comfortable with using the command line tools.
 2. Expand the knowledge of intermediate command line users.
 3. Engage everyone in an educational (hopefully) workshop exercise of adding a user to a remote server, connecting to the remote server with your SSH key, and pairing with screen.
 4. Guilting other senior engineers into helping anyone stuck during the workshop portion.

Slide 3

Slide 3 text

Essentials

Slide 4

Slide 4 text

Little Help pwd Display current directory path.
 pwd : print working directory man : format and display manual pages man cd Display manual for cd command.
 man man Display manual for the man command.

Slide 5

Slide 5 text

Moving Around cd : change working directory cd .. Move up one directory.
 cd ~ Move to the home directory.
 cd - Move to your last directory location.
 cd /usr/bin Move into the /usr/bin directory.
 cd / Move into the root directory. ! !

Slide 6

Slide 6 text

Create folders mkdir wp Create a directory named “wp” within my current working directory.
 mkdir ~/wp Create a directory named “wp” within my home directory. mkdir : make a directory

Slide 7

Slide 7 text

touch : create a file touch hiphop.txt Creates the empty file (0 bytes) hiphop.txt in the current working directory, if the file doesn’t already exist. touch hip.sh hop.sh Creates empty files hip.sh and hop.sh in the current working directory, if the file doesn’t already exist. touch -m 01021200 hip.sh Changes access and modification time for the file hip.sh to January 2nd at 12:00pm of the current year. Create Files

Slide 8

Slide 8 text

List Contents ls : list contents of a directory ls List contents of the current directory.
 ls -a List all contents of the current directory.
 ls ~ -h List contents of your home directory with human- readable file sizes.
 
 ls ~ -ahl List all contents of your home directory with permissions and human-readable file sizes.

Slide 9

Slide 9 text

Copy Contents cp : copy files and directories cp file.txt ~ Copy file.txt in current working directory to home directory. cp -R files/ /wp Copy everything in files directory from current working directory into /wp directory. The files directory itself is not included. cp -R files /wp Same as above, but the files directory itself is included. cp foo.txt bar.txt Copy all contents of foo.txt file to bar.txt file.

Slide 10

Slide 10 text

Move Contents mv : move files and directories mv foo.txt bar.txt Renames foo.txt in current working directory to bar.txt.
 mv ~/wp / Move the wp directory and its contents from home into root.
 mv ~/wp/* / Move the contents of the wp directory from home into root. ! !

Slide 11

Slide 11 text

Searching

Slide 12

Slide 12 text

Locate Files find : walk a hierarchy find /wp -type f -name "*.php" Find all php files in the “wp” directory.
 find / -mmin -60 
 Find all files that were modified within the past hour. find / -size +50M Find all files that are larger than 50MB. find / -type d -name "wp-*"
 Find all directories that begin with “wp-“. find . -type f -exec chmod 644 {} ‘;’ Find all files within the current working directory and change their permissions to 644.

Slide 13

Slide 13 text

Search Within grep : prints lines that are a pattern match grep define /srv/wp/wp-config.php Find all lines that contain the string “define” in the wp- config.php file.
 grep -n define /srv/wp/wp-config.php
 Find all lines that contain the string “define” in the wp- config.php file, and display the line number. grep -inr Error /var/log Recursively find anything in in the /var/log that contains the string “Error” (case insensitive) and display the line number.

Slide 14

Slide 14 text

Streams

Slide 15

Slide 15 text

ls -ahl /wp > root-files.txt Creates a file (root-files.txt) that contains the output of the ls command. If the file already exists it is overwritten. Streaming Output > : redirect stdout to a file >> : redirect and append stdout to a file ls -ahl /wp >> root-files.txt Creates a file (root-files.txt) that contains the output of the ls command. If the file already exists the output is appended.

Slide 16

Slide 16 text

cp ~/wp /wp > cp-output.txt 2>&1 Creates a file (cp-output.txt) that contains the output or the error of the cp command. If the file already exists it is overwritten. Streaming Errors 2>&1 : send stderr to same location as stdout 2>> : redirect and append stderr to a file cp ~/wp /wp > /dev/null 2>> cp-errors.txt Ignore stdout from cp command, but create or append stderr to a file (cp-errors.txt).

Slide 17

Slide 17 text

find . -type d | sed 's:[^-][^/]*/:--:g; s:^-: |:' Find directories within current working directory and modify the output stream to display a graphical tree of subdirectories. ! history | awk '{print $2}' | awk 'BEGIN {FS="|"} {print $1}’| sort | uniq - c | sort -rn | head -10 Get command history, sort output by second column (command), count the uniques, sort and display 10 most common results. Piping Output | : process and command chaining tool

Slide 18

Slide 18 text

Workshop http://rachelbaker.me/tenup.html