Presentation is loading. Please wait.

Presentation is loading. Please wait.

40 Years and Still Rocking the Terminal!

Similar presentations


Presentation on theme: "40 Years and Still Rocking the Terminal!"— Presentation transcript:

1 40 Years and Still Rocking the Terminal!
UNIX 40 Years and Still Rocking the Terminal!

2 A Little History Developed by AT&T @ Bell Labs in 1969
Many different variants BSD, Solaris, HP-UX, AIX Version 7 or System V Linux is not UNIX but a “Unix-like” system

3 The C Programming Language
Unix is “Open” Built using The C Programming Language Unix is a portable, multi-tasking and multi-user operating system consisting of many small, powerful programs

4 What Makes Unix AWESOME!?
Commands, Commands, and more Commands

5 These three tools alone can do incredible things
Interpreters The Bourne-Again Shell (BASH) AWK SED These three tools alone can do incredible things

6 What is BASH BASH is an improved replacement shell
It’s also a powerful scripting language It supports full logical expressions and looping mechanics But its true power is it’s ability to chain together commands with pipes and redirects Drop down a terminal and show how to make a variable, how to read a variable How to make an if/else and if/elif/else, a for in using a `ls type`

7 Some Power Features Pipes: cat someFile | awk ‘{ print $1 }’ - reads someFile to stdout, then redirects it as the stdin to awk Redirection: diff file1 file2 > theDifferences - redirects all output to a file named theDifferences tidy -i an_HTML_file 2> /dev/null - redirects any errors for /dev/null (a.k.a. “the default log file”)

8 What is AWK? “AWK is a programming language that is designed for processing text-based data, either in files or data streams” Powerful enough to write full programs Incredible enough to use from the terminal kill -9 `ps aux | awk -V user=$(whoami) '{ if ($1 ~ user ) print $2}'`

9 What is SED SED is a stream editor
Using regular expressions, you can edit an input stream Most powerful when used in conjunction within a BASH script sed ‘s/p(ython|erl)/ruby/g’ - searches for the word python or perl and replace it with ruby

10 Basic Terminal Commands
cd - Change directories ls - Directory listing rm - Remove a file mkdir - Make a new directory pwd - Print the Present Working Directory cp - Copy a file mv - Move or Rename a file wc - Word or Line or Character count cat - Concatenate multiple files head - Output the first line of an input file tail - Output the last line of an input file grep - Search a file and print matching lines vi - Complicated Text Editor (Alt is nano or pico)

11 Using the Commands... To change a directory - cd theDirName - cd ~/levelOne/levelTwo/levelThree - cd ../ To list the contents in a directory - ls - ls -l - ls --color=”always”

12 Using the Commands... To make a directory - mkdir theDirName - mkdir -p levelOne/levelTwo/levelThree To search a file for a pattern - grep -E “p(ython|perl)” fileName - grep “plain text” ./ Delete a directory structure - rm -Rf ~/temp # will recursively delete everything in temp

13 Customize Your Commands
BASH allows you to customize built-in commands with the alias command alias ls=’ls -G’ alias ll=’ls -l’ alias la=’ls -a’

14 Type the following into a Terminal
A Quick Script Type the following into a Terminal cat << EOF > /usr/local/bin/hunt #!/bin/bash find $(pwd) -name “$1” -print EOF chmod 755 /usr/local/bin/hunt

15 A Better Shell Prompt BASH uses a lot of environment variable
These variables are used by built-in commands and to customize BASH PS1 is the variable BASH uses to style your first prompt (Prompt Style 1)

16 \d the date in "Weekday Month Date" format
\e an ASCII escape character (033) \h the hostname up to the first `.' \H the hostname \j the number of jobs currently managed by the shell \l the basename of the shell's terminal device name \n newline \r carriage return \s the name of the shell, the basename of $0 (the portion following the final slash) \t the current time in 24-hour HH:MM:SS format \T the current time in 12-hour HH:MM:SS format the current time in 12-hour am/pm format \u the username of the current user \v the version of bash (e.g., 2.00) \V the release of bash, version + patchlevel (e.g., ) \w the current working directory \W the basename of the current working direcory \! the history number of this command \# the command number of this command \$ if the effective UID is 0, a #, otherwise a $ \nnn the character corresponding to the octal number nnn \\ a backslash \[ begin a sequence of non-printing characters \] end a sequence of non-printing characters

17 BASH Colors Black 0;30 Dark Gray 1;30 Blue 0;34 Light Blue 1;34
Green ; Light Green 1;32 Cyan ; Light Cyan 1;36 Red ; Light Red 1;31 Purple ; Light Purple 1;35 Brown ; Yellow ;33 Light Gray 0; White ;37

18 A Custom PS1 \e[0;31m\]\h\[\e[1;30m\]] \[\e[1;30m\]\w \n$\[\e[0m\] Produces the following prompt


Download ppt "40 Years and Still Rocking the Terminal!"

Similar presentations


Ads by Google