Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Unix: A Gentle Introduction

zkanda
January 30, 2014

Unix: A Gentle Introduction

Unix: A Gentle Introduction

zkanda

January 30, 2014
Tweet

More Decks by zkanda

Other Decks in Technology

Transcript

  1. • Unix is an operating system • Developed by AT&T

    employees at Bell Labs(1969-1971) • Rewritten in C (1972) - C was developed for the Unix OS - C allowed Unix to be portable • Unix spread outside AT&T (1975) - Government agencies, universities, corporation - Free licenses and source code • Branches and improvements (1977-present) - Open source: BSD, Linux - Closed source: Solaris, AIX, HP/UX - Mixed source: Mac OS X (Apple) • “Unix” now means a “Unix-like system”
  2. WHY USE UNIX DIRECTLY? • Why use Unix directly instead

    of a graphical user interface (GUI)? - Difference in power and control • Similar to car transmissions - Automatic: give up control for convenience - Manual: give up convenience for control
  3. How to interact with unix? • Terminal Application • -

    Provides command line access to unix • (Xterm, gnome-terminal, guake, etc.)
  4. TERMINAL AND UNIX SHORTCUTS • Up/Down arrows: Review previous commands

    • Control + a: Move cursor to start a line • Control + e: Move cursor to the end of line • Tab: Try to complete the command or filename • Tab + Tab: When tabs doesn't complete, show list of possible matches.
  5. COMMAND STRUCTURE command options arguments Example: • echo 'Hello World'

    • echo -n 'Hello World' • ls -l -a -h Desktop • ls -lah Desktop • cat -n file1.txt file2.txt
  6. KERNEL AND SHELLS • Kernel - Core of the OS

    - Allocates time and memory to programs • Shell - Outer layer of the OS - Interacts with user - Sends requests to kernel - Most unix use bash shell, but includes other choices
  7. POPULAR SHELLS • sh: Thompson Shell(1971) • sh: Bourne Shell(1977)

    • csh: C Shell(1979) • tcsh: Tabbed C Shell(1979) • ksh: Korn Shell(1982) • bash: Bourne-Again Shell(1987) • zsh: Z Shell(1990) echo $SHELL /bin/bash
  8. UNIX MANUAL PAGES Most important aspect of this talk •

    “man” command • man man • man echo • man --help Searching for command: • man -k command
  9. Filesystem Basics • pwd – print working directory • ls

    – list directory contents • cd – change directory example: • ls -la • cd ~
  10. Filesystem Organization Directory/Folder Contens / Root /bin Unix binaries, programs

    /sbin System binaries, system programs /dev Devices: hard drives, keyboard, mouse, etc. /home User home directories /lib Libraries of code /tmp Temporary files /var Various, mostly files the system use /usr /usr/bin /usr/etc /usr/lib /usr/local User programs, tools and libraries (not files)
  11. Unix Text Editors • ed (EditText) - Earliest Unix editor,

    not user-friendly • vi (visual editing mode), vim (vi improved) - Modal, fingers rarely leave keyboard home row • GNU Emacs (editor macros) - Macros to automate work, swiss army knife • pico (pine composer), nano (1000x larger than pico) - Basic features, easy to use
  12. Reading Files • cat - Concatenate • more - Paginated

    output • less - Backward scrolling - Better memory use - less > more
  13. Reading Portions of files • head - Display lines from

    beginning of a file • tail - Display lines from end of a file • tail -f - “Follow” the tail of a file
  14. Directories • mkdir <directory name> - make directory • Rmdir

    <directory name> - remove directory(if empty) • rm -r <directory name> - remove directory(all)
  15. Moving and Renaming Files and Directories • mv - move

    file • rename - rename file - very unreliable - please use “mv” for renaming Option Description -n No overwriting -f Force overwriting -i Interactive overwriting, “ask me” -v verbose
  16. Deleting Files and Directories WARNING: Deleted files cannot be recovered!

    • rm - remove a file • rmdir - remove a directory(only if empty) • rm -r - remove recursively, usefull with directories