SlideShare une entreprise Scribd logo
1  sur  45
Télécharger pour lire hors ligne
UNIX Basics

  Ian Darwin
TCP Informatics
 January, 2005


   Presented from a Mac using Apple’s Keynote presentation software

                                                                      1
What is this about?
       Brief Introduction to UNIX
 •
             ideas
         -
             basic commands
         -
             some examples
         -
       For those who know MS-Windows but
 •
       next-to-nothing about UNIX/Linux




Watch for advanced tips here        And watch for silly little notes here

                                                                            2
Outline


        Background
    •
        File System
    •
        Shell and Basic Commands
    •
        Shell Scripting
    •
        Everything Else
    •




                       All this and more, in one hour. Whew!

                                                               3
What is UNIX?
• An operating system in use for 35 years
  – Invented as a timesharing system, hence
    usable both on server machines and on
    desktops
  – Originally command-line based, like DOS (but
    smarter :-))
    – Early users logged in over very slow terminals
  – Now has several GUIs, like MS-Windows
    – Most based on “X Windows”, MIT’s networked
      window system
    – Most MICe people use one called GNOME

                                  X Windows predates Microsoft Windows

                                                                         4
Terminal Window




    What do I do now?
•
        The subject of this talk!
    -


                                    5
GUI Our look: GNOME Blue




 The first icon (here a red hat) gives you a Start Menu


                                                          6
“Traditional” GUI: WindowMaker




No toolbar or start menu - right click on desktop for “Root Menu”


                                                                    7
The Many Faces of UNIX
• Variants: Sun Solaris (MRI console), SGI
  (miceviz), FreeBSD/NetBSD/OpenBSD
• Linux is a re-implementation of a UNIX-
  like system, from the ground up
• Mac OS is built on top of BSD UNIX
• quot;Many variantsquot; is good for choice, but
  bad for consistency
  • quot;Userquot; commands pretty similar, quot;adminquot;
    commands vary more


                                              8
Where is UNIX?
• Everywhere: the Internet is run on UNIX
  – Including Microsoft Hotmail, until last year!
• Things invented on UNIX:
  – TCP/IP, Sendmail, DNS, SSH
  – Apache Web Server
  – Mosaic browser (basis of Netscape and IE)
  – C/C++, Perl, Python and Java programming
    languages
  – Tcl/TK, VTk, OpenGL

                                     They lied about Hotmail. For years.

                                                                           9
UNIX Filesystem




                  10
UNIX File System 101

    UNIX organizes files into directories
.
        “Just like MS-Windows does”
    .
        BUT: UNIX uses the forward slash (”/”)
    .
        between pathname components
    Have as many directories as you need
.
        by topic, by project, etc.
    .
    There are some “well-known”
.
    directories on most UNIX systems...

                            Did I mention that UNIX had this directory tree 15 years before MS-DOS?


                                                                                                  11
A Typical? Unix/Linux Layout
                                                            / (root)




      /bin                                                                                   /opt




             /etc                                                                     /var

                        /home                                                  /tmp
                                         /mnt                /usr      sbin




                         bin               lib               local     sbin   share




  A more typical UNIX hierarchy
  Drawn by Ian Darwin (http://www.darwinsys.com)
  using Graffle 3 (www.omnigroup.com) on UNIX (Mac OS X).




                                                                                                    12
Networking - NFS & SaMBa
  This same “seamless” hierarchy is
•
  preserved for network filesystems (NFS)
• Most Linux boxes here have /projects/
  mice as a shared filesystem via NFS
        No special syntax or ”drive letters” to access
    -
    Our file server also makes these files
•
    available via SMB (SAMBA) for mounting
    on MS-Windows desktops



                                                         13
Shells and Shell Windows
  Every UNIX user has a “shell” or
•
  “command interpreter” (analogous to
  command.com or cmd.exe)
• UNIX has many different shells
        At this level does not matter which you use
    -
    Reads commands, interprets special
•
    characters and built-ins, runs programs
        Things like *, | and > are pretty much the same
    -
        as on DOS and on most shells


                              How many special characters are special on UNIX? All of them.

                                                                                              14
Command Format
    Most commands have this format:
•
        command options filenames
    -
        That is, options (alterations) before filenames
    -
    Options are a dash (not slash) plus a letter
•
        ls -l gives long form listing
    -
    Some options require another argument
•
        sort -o newdata data
    -
    Some commands take non-standard
•
    argument formats


                                                          15
The Terminal Window
    Each UNIX desktop comes with a
•
    “terminal window” program, for commands
    Right-click on the Desktop, New->Terminal
•
    Choose Terminal from the Utilities menu
•
    Click on the Terminal Icon in the toolbar
•
    Each of these lets you type UNIX
•
    commands...




                                                16
Starting a Terminal




                  See? They’ve made it look almost “just like MS-Windows”

                                                                        17
Remote Terminal: SSH
    SSH is a network protocol to login to a
•
    computer over the network
        replaces rsh and telnet which are insecure
    -
        You appear to be logged in “over there”
    -
        SSH is both a command-line tool and (on MS-
    -
        Windows) also a windowed application
    Usage: ssh user@hostname [command]
•
        With no command, logs you in “over there
    -
        With a command, just runs it “over there”
    -
        If user names same on both computers, omit it
    -



                                                        18
ssh to miceviz just for one command
  ssh miceviz date
•
• ssh miceviz ls -l | more
• ssh miceviz who




                                      19
ssh to miceviz and process images
  ssh miceviz
•
• cd /projects/mice/YOUR_DIRECTORY
• Use any of the MINC tools on your image
  files, which appear in the directory




                                            20
The help desk: quot;manquot; pages
  Nobody can remember all the options to
•
  all the commands
• UNIX provides the man command
      prints online manual pages
     -
     man + name-of-command = details
     man -k + keyword = list of possible pages
    Some UNIXes have additional tools
     Linux has info   Solaris has answerbook
     More detailed


                                                 21
Top 10 Commands
• Every UNIX user needs these quot;top 10quot;
  commands
• cat cd date grep ls more mv ps rm who
• And one of these editors:
  – vi or emacs




                          UNIX people like giving stupid names to clever things

                                                                             22
Basics: cat & more
    cat displays a file with no page breaks
•
        like DOS type command
    -
        other advanced uses
    -
    more displays a file a screen at a time
•
        lots of flexibility: q for quit, h for help, multiple
    -
        files, etc.




                                                                23
Basics: cd & pwd
    cd changes to a directory
•
        similar to DOS
    -
        with no argument, to your home directory
    -
        with a directory name, cd’s to that directory
    -
        directory name can be full path (starting with /)
    -
        or relative
        paths can include . or ..
    -
    pwd = Print Working Directory
•




                                                            24
Basics: ls

  ls lists the contents of directories, that is, the
•
  details about files
• ls - short listing (like dir/w)
• ls -l - long listing (dir, explorer list view)
    -rw-r--r-- 1 ian                        wheel 9218 21 Aug 14:49 support.dat
    drwxr-xr-x 4 ian                        admin 136 17 Jan 16:31 talk-others
    lrwxr-xr-x 1 ian                        admin   16 6 Jan 19:31 w -> /shared/w

        Three kinds of things you’ll see: files (”-”),
-
        directories (”d”) and “symlinks” (”l”, like
        Aliases or Shortcuts)
    ls -h shows the sizes in “human readable”, good for large image files

                                                                                    25
ls and Permissions
  UNIX has a more powerful (but complex)
•
  set of permissions than MS-Windows
• Each file or directory has user (owner),
  group, and “other” permissions
        Each of which can be r, w or x in any combo
    -
        ls -l shows all this
    -
  The chmod command lets a file’s owner
•
  change its permissions
• If UNIX won’t let you at a file and ls says
  it’s there, contact the files’ owner

                                                      26
Basics: cp, mv, rm
  cp is the copy command
•
• mv is the move/rename command
• These will normally overwrite a file without
  warning (on “standard” UNIX)
        Our systems have more safety: should ask for
    -
        confirmation if you try to overwrite
    rm deletes files
•
        Most UNIXes do not have an undelete, so it
    -
        asks first



                                                       27
Basics Bonus: mkdir & rmdir


    mkdir & rmdir create and remove
•
    directories
        for mkdir, must not already exist
    -
        for rmdir, directory must be empty
    -




                                             28
Basics: grep
  grep finds files that contain a specified
•
  pattern
• grep Mark *.txt
• grep -i mark *.txt # -i = ignore case
• Patterns can be more complex
        a good hour-long discussion
    -
        google “unix regular expressions” for detail
    -




                                                       29
Basics: ps & top & kill
  System information commands, like
•
  CTRL/Alt/Delete->Process Manager
• ps lists “your” processes
        options let you see other users’ processes
    -
  top shows all processes, “cpu hogs” at top
•
• kill can terminate a program




                                                     30
Example: find and kill a process
    $ ps -ax | grep someBadProgram
    1868 tport             0:00 someBadProg
    1971 pts02             0:00 someBadProg
    1973 ?                 0:09 someBadProg

     Assuming that you are logged in on pts02
•
     (who shows that)
         kill 1971
     -
     If that isn’t strong enough,
•
         kill -KILL 1971
     -



                                                31
Basic Misc: date, who
      date command prints date & time
•
•     $ date
      Tue Jan 25 10:56:54 EST 2005
      UNIX was originally for timesharing
•
          Might have many (thousands) of users on a
      -
          single server (dumb terminals)
          who lists users logged in
      -
    $ who
    root       ttyd1   Jan 24 12:13
    baghdadi   ttyq0   Jan 24 12:29   (mouse18.phenogenomics.ca)
    idarwin    ttyq1   Jan 24 19:17   (mouse12.phenogenomics.ca)
    $




                                                 How did they get here? Answer soon

                                                                                      32
Basics Bonus: find & locate
  The find command goes through
•
  directories to find files by name, by age
  (what did I call that file I made last
  Thursday??), and so on
• It is probably too complex to learn today
        Remember: man find
    -
  The locate command tells you about files
•
  by name only
• $ locate Project42



                                              33
DOS to UNIX Command Help

    DOS     UNIX
    attr    chmod
    cd      cd, pwd
    date    date
    del     rm
    dir     ls
    dir/s   ls -R, find (locate?)
    find    grep
    more    more (cat?)
    ren     mv


                                    34
Text Editing
  Many UNIX programs are controlled by
•
  editing their “ini” files (called “dot files” on
  UNIX: names begin with a “.”)
• Can start by using a notepad-style editor
  that is included with the system
        Start Menu->Accessories->Text Editor
    -
    Should eventually learn to use a UNIX text
•
    editor, either vi or emacs
        online tutorials
    -




                                                     35
Shell Scripting


Saving Time and Typing




                         36
Shell Scripting
    Anything you type more than once could
•
    become a shell script
        put the commands into a text file
    -
        in a directory on your PATH
    -
        mark it “executable” with chmod +x
    -
        Then run it like any other UNIX command
    -




                                                  37
More on scripting
  Whole books are written on UNIX shell
•
  scripting
• Good idea to use only ksh features - most
  portable to other UNIX-like systems
• See the O’Reilly books Learning the Korn
  shell or Learning the Bash shell




                                              38
Other kinds of scripting
  UNIX was written by programmers for
•
  programmers; a great development
  environment
• Because of this many other scripting
  languages have been written:
        awk - older, simpler
    -
        perl - powerful, strange syntax
    -
        python - same power, better syntax
    -
        Python more used at MICe; Perl more used in
    -
        BioInformatics


                                                      39
Everything Else


More good stuff for UNIX




                           40
Neat Stuff for UNIX
• Infinite supply of quot;free softwarequot;
• quot;Open Officequot;: complete MS-Office-like
  suite
  – Writer, Presents, Calc, Draw, etc.
  – free! (http://www.openoffice.org/)
  – Reads/writes all MS-Office formats,
    increasingly compatible




                                           41
Neat Stuff II (all free!)
• Web clients
  – Mozilla Firefox web browser
– Email clients
  – Mozilla Thunderbird email (like Netscape)
  – Evolution email (looks like MS-Outlook)
• Graphical programs
  – gimp - nice bitmap manipulation program
  – sodipodi - very nice drawing program



                                                42
VNC - Virtual Network Computing
    Lets you access a machines’ X Desktop
•
    remotely
        similar to MS-Windows Terminal Server or
    -
        Remote Help Access
        Used on the MRI Scanner console
    -




                                                   43
UNIX is a big subject: Where to get help?

    Ask a friend who knows
•
    The man command
•
    google
•
    books
•
    Sysadmin magazine
•




                                            44
Q&A
 1. Did I really use Unix for this talk? Yes.
        2. Do I hate Microsoft? No.
   3. Do I ever use MS-Windows? Yes.
 4. Do I have MS-Windows on any of my
            own computers? No.
5. You get to ask the rest of the questions.



                                                45

Contenu connexe

Tendances

Part 4 of 'Introduction to Linux for bioinformatics': Managing data
Part 4 of 'Introduction to Linux for bioinformatics': Managing data Part 4 of 'Introduction to Linux for bioinformatics': Managing data
Part 4 of 'Introduction to Linux for bioinformatics': Managing data Joachim Jacob
 
Introduction to Linux for bioinformatics
Introduction to Linux for bioinformaticsIntroduction to Linux for bioinformatics
Introduction to Linux for bioinformaticsBITS
 
A beginners introduction to unix
A beginners introduction to unixA beginners introduction to unix
A beginners introduction to unixzafarali1981
 
Module 1 introduction to Linux
Module 1 introduction to LinuxModule 1 introduction to Linux
Module 1 introduction to LinuxTushar B Kute
 
Introduction to Linux
Introduction to Linux Introduction to Linux
Introduction to Linux Harish R
 
Unix OS & Commands
Unix OS & CommandsUnix OS & Commands
Unix OS & CommandsMohit Belwal
 
Part 2 of 'Introduction to Linux for bioinformatics': Installing software
Part 2 of 'Introduction to Linux for bioinformatics': Installing softwarePart 2 of 'Introduction to Linux for bioinformatics': Installing software
Part 2 of 'Introduction to Linux for bioinformatics': Installing softwareJoachim Jacob
 
Introduction to Linux_by_Amit & Jiban
Introduction to Linux_by_Amit & Jiban Introduction to Linux_by_Amit & Jiban
Introduction to Linux_by_Amit & Jiban Amit Nath
 
Linux Introduction (Commands)
Linux Introduction (Commands)Linux Introduction (Commands)
Linux Introduction (Commands)anandvaidya
 
LINUX Admin Quick Reference
LINUX Admin Quick ReferenceLINUX Admin Quick Reference
LINUX Admin Quick Referencewensheng wei
 
Linux.ppt
Linux.ppt Linux.ppt
Linux.ppt onu9
 
Linux Command Suumary
Linux Command SuumaryLinux Command Suumary
Linux Command Suumarymentorsnet
 
Linux Command Line Basics
Linux Command Line BasicsLinux Command Line Basics
Linux Command Line BasicsWe Ihaveapc
 
BITS: Introduction to linux, distributions and installation
BITS: Introduction to linux, distributions and installationBITS: Introduction to linux, distributions and installation
BITS: Introduction to linux, distributions and installationBITS
 

Tendances (20)

Part 4 of 'Introduction to Linux for bioinformatics': Managing data
Part 4 of 'Introduction to Linux for bioinformatics': Managing data Part 4 of 'Introduction to Linux for bioinformatics': Managing data
Part 4 of 'Introduction to Linux for bioinformatics': Managing data
 
Linux Commands
Linux CommandsLinux Commands
Linux Commands
 
Introduction to Linux for bioinformatics
Introduction to Linux for bioinformaticsIntroduction to Linux for bioinformatics
Introduction to Linux for bioinformatics
 
A beginners introduction to unix
A beginners introduction to unixA beginners introduction to unix
A beginners introduction to unix
 
Module 1 introduction to Linux
Module 1 introduction to LinuxModule 1 introduction to Linux
Module 1 introduction to Linux
 
Linux
LinuxLinux
Linux
 
Introduction to Linux
Introduction to Linux Introduction to Linux
Introduction to Linux
 
Linux
Linux Linux
Linux
 
Unix OS & Commands
Unix OS & CommandsUnix OS & Commands
Unix OS & Commands
 
Part 2 of 'Introduction to Linux for bioinformatics': Installing software
Part 2 of 'Introduction to Linux for bioinformatics': Installing softwarePart 2 of 'Introduction to Linux for bioinformatics': Installing software
Part 2 of 'Introduction to Linux for bioinformatics': Installing software
 
Linux basic commands tutorial
Linux basic commands tutorialLinux basic commands tutorial
Linux basic commands tutorial
 
Introduction to Linux_by_Amit & Jiban
Introduction to Linux_by_Amit & Jiban Introduction to Linux_by_Amit & Jiban
Introduction to Linux_by_Amit & Jiban
 
Linux Introduction (Commands)
Linux Introduction (Commands)Linux Introduction (Commands)
Linux Introduction (Commands)
 
LINUX Admin Quick Reference
LINUX Admin Quick ReferenceLINUX Admin Quick Reference
LINUX Admin Quick Reference
 
Linux.ppt
Linux.ppt Linux.ppt
Linux.ppt
 
Linux commands
Linux commandsLinux commands
Linux commands
 
Linux Command Suumary
Linux Command SuumaryLinux Command Suumary
Linux Command Suumary
 
Linux Command Line Basics
Linux Command Line BasicsLinux Command Line Basics
Linux Command Line Basics
 
BITS: Introduction to linux, distributions and installation
BITS: Introduction to linux, distributions and installationBITS: Introduction to linux, distributions and installation
BITS: Introduction to linux, distributions and installation
 
Linux Presentation
Linux PresentationLinux Presentation
Linux Presentation
 

En vedette

Academic Librarian Portfolios
Academic Librarian PortfoliosAcademic Librarian Portfolios
Academic Librarian PortfoliosDanielle Mihram
 
Academic portfolio template
Academic portfolio templateAcademic portfolio template
Academic portfolio templateWSSU CETL
 
WE1.L10 - GRACE Applications to Regional Hydrology and Water Resources
WE1.L10 - GRACE Applications to Regional Hydrology and Water ResourcesWE1.L10 - GRACE Applications to Regional Hydrology and Water Resources
WE1.L10 - GRACE Applications to Regional Hydrology and Water Resourcesgrssieee
 
final emoji-board EMAIL ME NOWSWAG11
final emoji-board EMAIL ME NOWSWAG11final emoji-board EMAIL ME NOWSWAG11
final emoji-board EMAIL ME NOWSWAG11Joe Humphreys
 
Chapter 1Into the Internet
Chapter 1Into the InternetChapter 1Into the Internet
Chapter 1Into the InternetPatty Ramsey
 
Chapter 7 Multimedia
Chapter 7 MultimediaChapter 7 Multimedia
Chapter 7 MultimediaPatty Ramsey
 
Chapter 4 Form Factors & Power Supplies
Chapter 4 Form Factors & Power SuppliesChapter 4 Form Factors & Power Supplies
Chapter 4 Form Factors & Power SuppliesPatty Ramsey
 
Introduction to PHP - SDPHP
Introduction to PHP - SDPHPIntroduction to PHP - SDPHP
Introduction to PHP - SDPHPEric Johnson
 
Appendex d
Appendex dAppendex d
Appendex dswavicky
 
Groundwater Research and Technology, Stefan Schuster
Groundwater Research and Technology, Stefan SchusterGroundwater Research and Technology, Stefan Schuster
Groundwater Research and Technology, Stefan SchusterTXGroundwaterSummit
 
Chapter 4 Form Factors Power Supplies
Chapter 4 Form Factors Power SuppliesChapter 4 Form Factors Power Supplies
Chapter 4 Form Factors Power SuppliesPatty Ramsey
 
Offshore pipelines
Offshore pipelinesOffshore pipelines
Offshore pipelineshaiifa25
 
Ch5(ms access with php)
Ch5(ms access with php)Ch5(ms access with php)
Ch5(ms access with php)Chhom Karath
 
eMail 101 (4) Class for Self help Virtual Senior Center
eMail 101 (4) Class for Self help Virtual Senior Center eMail 101 (4) Class for Self help Virtual Senior Center
eMail 101 (4) Class for Self help Virtual Senior Center SnowSugar Video
 
Introduction to PHP
Introduction to PHPIntroduction to PHP
Introduction to PHPprabhatjon
 
Setting up a gmail account
Setting up a gmail accountSetting up a gmail account
Setting up a gmail accountkeelyswitzer
 

En vedette (20)

Library Service and Teaching Portfolios
Library Service and Teaching PortfoliosLibrary Service and Teaching Portfolios
Library Service and Teaching Portfolios
 
Academic Librarian Portfolios
Academic Librarian PortfoliosAcademic Librarian Portfolios
Academic Librarian Portfolios
 
Academic portfolio template
Academic portfolio templateAcademic portfolio template
Academic portfolio template
 
WE1.L10 - GRACE Applications to Regional Hydrology and Water Resources
WE1.L10 - GRACE Applications to Regional Hydrology and Water ResourcesWE1.L10 - GRACE Applications to Regional Hydrology and Water Resources
WE1.L10 - GRACE Applications to Regional Hydrology and Water Resources
 
final emoji-board EMAIL ME NOWSWAG11
final emoji-board EMAIL ME NOWSWAG11final emoji-board EMAIL ME NOWSWAG11
final emoji-board EMAIL ME NOWSWAG11
 
Chapter 1Into the Internet
Chapter 1Into the InternetChapter 1Into the Internet
Chapter 1Into the Internet
 
Chapter 7 Multimedia
Chapter 7 MultimediaChapter 7 Multimedia
Chapter 7 Multimedia
 
Chapter 4 Form Factors & Power Supplies
Chapter 4 Form Factors & Power SuppliesChapter 4 Form Factors & Power Supplies
Chapter 4 Form Factors & Power Supplies
 
Introduction to PHP - SDPHP
Introduction to PHP - SDPHPIntroduction to PHP - SDPHP
Introduction to PHP - SDPHP
 
Appendex d
Appendex dAppendex d
Appendex d
 
Groundwater Research and Technology, Stefan Schuster
Groundwater Research and Technology, Stefan SchusterGroundwater Research and Technology, Stefan Schuster
Groundwater Research and Technology, Stefan Schuster
 
Chapter 4 Form Factors Power Supplies
Chapter 4 Form Factors Power SuppliesChapter 4 Form Factors Power Supplies
Chapter 4 Form Factors Power Supplies
 
Ch07
Ch07Ch07
Ch07
 
Php i-slides
Php i-slidesPhp i-slides
Php i-slides
 
Offshore pipelines
Offshore pipelinesOffshore pipelines
Offshore pipelines
 
Ch5(ms access with php)
Ch5(ms access with php)Ch5(ms access with php)
Ch5(ms access with php)
 
eMail 101 (4) Class for Self help Virtual Senior Center
eMail 101 (4) Class for Self help Virtual Senior Center eMail 101 (4) Class for Self help Virtual Senior Center
eMail 101 (4) Class for Self help Virtual Senior Center
 
Introduction to PHP
Introduction to PHPIntroduction to PHP
Introduction to PHP
 
Setting up a gmail account
Setting up a gmail accountSetting up a gmail account
Setting up a gmail account
 
Introduction to PHP
Introduction to PHPIntroduction to PHP
Introduction to PHP
 

Similaire à UNIX Basics Guide

Similaire à UNIX Basics Guide (20)

Introduction about linux
Introduction about linuxIntroduction about linux
Introduction about linux
 
Linux introduction (eng)
Linux introduction (eng)Linux introduction (eng)
Linux introduction (eng)
 
Linux forensics
Linux forensicsLinux forensics
Linux forensics
 
Terminal basic-commands(Unix) -partI
Terminal basic-commands(Unix) -partITerminal basic-commands(Unix) -partI
Terminal basic-commands(Unix) -partI
 
Linux basics
Linux basicsLinux basics
Linux basics
 
operating system
operating systemoperating system
operating system
 
linux.pdf
linux.pdflinux.pdf
linux.pdf
 
Linux_CASESTUDY.ppt
Linux_CASESTUDY.pptLinux_CASESTUDY.ppt
Linux_CASESTUDY.ppt
 
Programming and problem solving 3
Programming and problem solving 3Programming and problem solving 3
Programming and problem solving 3
 
Intro to linux
Intro to linuxIntro to linux
Intro to linux
 
Online Training in Unix Linux Shell Scripting in Hyderabad
Online Training in Unix Linux Shell Scripting in HyderabadOnline Training in Unix Linux Shell Scripting in Hyderabad
Online Training in Unix Linux Shell Scripting in Hyderabad
 
IntroToUnix.ppt
IntroToUnix.pptIntroToUnix.ppt
IntroToUnix.ppt
 
IntroToUnix.ppt.intro.to.linuxlinuxintroduction
IntroToUnix.ppt.intro.to.linuxlinuxintroductionIntroToUnix.ppt.intro.to.linuxlinuxintroduction
IntroToUnix.ppt.intro.to.linuxlinuxintroduction
 
Linux for beginners
Linux for beginnersLinux for beginners
Linux for beginners
 
Linux
LinuxLinux
Linux
 
Introduction to linux
Introduction to linuxIntroduction to linux
Introduction to linux
 
Lamp ppt
Lamp pptLamp ppt
Lamp ppt
 
Intro tounix
Intro tounixIntro tounix
Intro tounix
 
Cross platform php
Cross platform phpCross platform php
Cross platform php
 
Unix Basics
Unix BasicsUnix Basics
Unix Basics
 

Dernier

Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGSujit Pal
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 

Dernier (20)

Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAG
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 

UNIX Basics Guide

  • 1. UNIX Basics Ian Darwin TCP Informatics January, 2005 Presented from a Mac using Apple’s Keynote presentation software 1
  • 2. What is this about? Brief Introduction to UNIX • ideas - basic commands - some examples - For those who know MS-Windows but • next-to-nothing about UNIX/Linux Watch for advanced tips here And watch for silly little notes here 2
  • 3. Outline Background • File System • Shell and Basic Commands • Shell Scripting • Everything Else • All this and more, in one hour. Whew! 3
  • 4. What is UNIX? • An operating system in use for 35 years – Invented as a timesharing system, hence usable both on server machines and on desktops – Originally command-line based, like DOS (but smarter :-)) – Early users logged in over very slow terminals – Now has several GUIs, like MS-Windows – Most based on “X Windows”, MIT’s networked window system – Most MICe people use one called GNOME X Windows predates Microsoft Windows 4
  • 5. Terminal Window What do I do now? • The subject of this talk! - 5
  • 6. GUI Our look: GNOME Blue The first icon (here a red hat) gives you a Start Menu 6
  • 7. “Traditional” GUI: WindowMaker No toolbar or start menu - right click on desktop for “Root Menu” 7
  • 8. The Many Faces of UNIX • Variants: Sun Solaris (MRI console), SGI (miceviz), FreeBSD/NetBSD/OpenBSD • Linux is a re-implementation of a UNIX- like system, from the ground up • Mac OS is built on top of BSD UNIX • quot;Many variantsquot; is good for choice, but bad for consistency • quot;Userquot; commands pretty similar, quot;adminquot; commands vary more 8
  • 9. Where is UNIX? • Everywhere: the Internet is run on UNIX – Including Microsoft Hotmail, until last year! • Things invented on UNIX: – TCP/IP, Sendmail, DNS, SSH – Apache Web Server – Mosaic browser (basis of Netscape and IE) – C/C++, Perl, Python and Java programming languages – Tcl/TK, VTk, OpenGL They lied about Hotmail. For years. 9
  • 11. UNIX File System 101 UNIX organizes files into directories . “Just like MS-Windows does” . BUT: UNIX uses the forward slash (”/”) . between pathname components Have as many directories as you need . by topic, by project, etc. . There are some “well-known” . directories on most UNIX systems... Did I mention that UNIX had this directory tree 15 years before MS-DOS? 11
  • 12. A Typical? Unix/Linux Layout / (root) /bin /opt /etc /var /home /tmp /mnt /usr sbin bin lib local sbin share A more typical UNIX hierarchy Drawn by Ian Darwin (http://www.darwinsys.com) using Graffle 3 (www.omnigroup.com) on UNIX (Mac OS X). 12
  • 13. Networking - NFS & SaMBa This same “seamless” hierarchy is • preserved for network filesystems (NFS) • Most Linux boxes here have /projects/ mice as a shared filesystem via NFS No special syntax or ”drive letters” to access - Our file server also makes these files • available via SMB (SAMBA) for mounting on MS-Windows desktops 13
  • 14. Shells and Shell Windows Every UNIX user has a “shell” or • “command interpreter” (analogous to command.com or cmd.exe) • UNIX has many different shells At this level does not matter which you use - Reads commands, interprets special • characters and built-ins, runs programs Things like *, | and > are pretty much the same - as on DOS and on most shells How many special characters are special on UNIX? All of them. 14
  • 15. Command Format Most commands have this format: • command options filenames - That is, options (alterations) before filenames - Options are a dash (not slash) plus a letter • ls -l gives long form listing - Some options require another argument • sort -o newdata data - Some commands take non-standard • argument formats 15
  • 16. The Terminal Window Each UNIX desktop comes with a • “terminal window” program, for commands Right-click on the Desktop, New->Terminal • Choose Terminal from the Utilities menu • Click on the Terminal Icon in the toolbar • Each of these lets you type UNIX • commands... 16
  • 17. Starting a Terminal See? They’ve made it look almost “just like MS-Windows” 17
  • 18. Remote Terminal: SSH SSH is a network protocol to login to a • computer over the network replaces rsh and telnet which are insecure - You appear to be logged in “over there” - SSH is both a command-line tool and (on MS- - Windows) also a windowed application Usage: ssh user@hostname [command] • With no command, logs you in “over there - With a command, just runs it “over there” - If user names same on both computers, omit it - 18
  • 19. ssh to miceviz just for one command ssh miceviz date • • ssh miceviz ls -l | more • ssh miceviz who 19
  • 20. ssh to miceviz and process images ssh miceviz • • cd /projects/mice/YOUR_DIRECTORY • Use any of the MINC tools on your image files, which appear in the directory 20
  • 21. The help desk: quot;manquot; pages Nobody can remember all the options to • all the commands • UNIX provides the man command prints online manual pages - man + name-of-command = details man -k + keyword = list of possible pages Some UNIXes have additional tools Linux has info Solaris has answerbook More detailed 21
  • 22. Top 10 Commands • Every UNIX user needs these quot;top 10quot; commands • cat cd date grep ls more mv ps rm who • And one of these editors: – vi or emacs UNIX people like giving stupid names to clever things 22
  • 23. Basics: cat & more cat displays a file with no page breaks • like DOS type command - other advanced uses - more displays a file a screen at a time • lots of flexibility: q for quit, h for help, multiple - files, etc. 23
  • 24. Basics: cd & pwd cd changes to a directory • similar to DOS - with no argument, to your home directory - with a directory name, cd’s to that directory - directory name can be full path (starting with /) - or relative paths can include . or .. - pwd = Print Working Directory • 24
  • 25. Basics: ls ls lists the contents of directories, that is, the • details about files • ls - short listing (like dir/w) • ls -l - long listing (dir, explorer list view) -rw-r--r-- 1 ian wheel 9218 21 Aug 14:49 support.dat drwxr-xr-x 4 ian admin 136 17 Jan 16:31 talk-others lrwxr-xr-x 1 ian admin 16 6 Jan 19:31 w -> /shared/w Three kinds of things you’ll see: files (”-”), - directories (”d”) and “symlinks” (”l”, like Aliases or Shortcuts) ls -h shows the sizes in “human readable”, good for large image files 25
  • 26. ls and Permissions UNIX has a more powerful (but complex) • set of permissions than MS-Windows • Each file or directory has user (owner), group, and “other” permissions Each of which can be r, w or x in any combo - ls -l shows all this - The chmod command lets a file’s owner • change its permissions • If UNIX won’t let you at a file and ls says it’s there, contact the files’ owner 26
  • 27. Basics: cp, mv, rm cp is the copy command • • mv is the move/rename command • These will normally overwrite a file without warning (on “standard” UNIX) Our systems have more safety: should ask for - confirmation if you try to overwrite rm deletes files • Most UNIXes do not have an undelete, so it - asks first 27
  • 28. Basics Bonus: mkdir & rmdir mkdir & rmdir create and remove • directories for mkdir, must not already exist - for rmdir, directory must be empty - 28
  • 29. Basics: grep grep finds files that contain a specified • pattern • grep Mark *.txt • grep -i mark *.txt # -i = ignore case • Patterns can be more complex a good hour-long discussion - google “unix regular expressions” for detail - 29
  • 30. Basics: ps & top & kill System information commands, like • CTRL/Alt/Delete->Process Manager • ps lists “your” processes options let you see other users’ processes - top shows all processes, “cpu hogs” at top • • kill can terminate a program 30
  • 31. Example: find and kill a process $ ps -ax | grep someBadProgram 1868 tport 0:00 someBadProg 1971 pts02 0:00 someBadProg 1973 ? 0:09 someBadProg Assuming that you are logged in on pts02 • (who shows that) kill 1971 - If that isn’t strong enough, • kill -KILL 1971 - 31
  • 32. Basic Misc: date, who date command prints date & time • • $ date Tue Jan 25 10:56:54 EST 2005 UNIX was originally for timesharing • Might have many (thousands) of users on a - single server (dumb terminals) who lists users logged in - $ who root ttyd1 Jan 24 12:13 baghdadi ttyq0 Jan 24 12:29 (mouse18.phenogenomics.ca) idarwin ttyq1 Jan 24 19:17 (mouse12.phenogenomics.ca) $ How did they get here? Answer soon 32
  • 33. Basics Bonus: find & locate The find command goes through • directories to find files by name, by age (what did I call that file I made last Thursday??), and so on • It is probably too complex to learn today Remember: man find - The locate command tells you about files • by name only • $ locate Project42 33
  • 34. DOS to UNIX Command Help DOS UNIX attr chmod cd cd, pwd date date del rm dir ls dir/s ls -R, find (locate?) find grep more more (cat?) ren mv 34
  • 35. Text Editing Many UNIX programs are controlled by • editing their “ini” files (called “dot files” on UNIX: names begin with a “.”) • Can start by using a notepad-style editor that is included with the system Start Menu->Accessories->Text Editor - Should eventually learn to use a UNIX text • editor, either vi or emacs online tutorials - 35
  • 37. Shell Scripting Anything you type more than once could • become a shell script put the commands into a text file - in a directory on your PATH - mark it “executable” with chmod +x - Then run it like any other UNIX command - 37
  • 38. More on scripting Whole books are written on UNIX shell • scripting • Good idea to use only ksh features - most portable to other UNIX-like systems • See the O’Reilly books Learning the Korn shell or Learning the Bash shell 38
  • 39. Other kinds of scripting UNIX was written by programmers for • programmers; a great development environment • Because of this many other scripting languages have been written: awk - older, simpler - perl - powerful, strange syntax - python - same power, better syntax - Python more used at MICe; Perl more used in - BioInformatics 39
  • 40. Everything Else More good stuff for UNIX 40
  • 41. Neat Stuff for UNIX • Infinite supply of quot;free softwarequot; • quot;Open Officequot;: complete MS-Office-like suite – Writer, Presents, Calc, Draw, etc. – free! (http://www.openoffice.org/) – Reads/writes all MS-Office formats, increasingly compatible 41
  • 42. Neat Stuff II (all free!) • Web clients – Mozilla Firefox web browser – Email clients – Mozilla Thunderbird email (like Netscape) – Evolution email (looks like MS-Outlook) • Graphical programs – gimp - nice bitmap manipulation program – sodipodi - very nice drawing program 42
  • 43. VNC - Virtual Network Computing Lets you access a machines’ X Desktop • remotely similar to MS-Windows Terminal Server or - Remote Help Access Used on the MRI Scanner console - 43
  • 44. UNIX is a big subject: Where to get help? Ask a friend who knows • The man command • google • books • Sysadmin magazine • 44
  • 45. Q&A 1. Did I really use Unix for this talk? Yes. 2. Do I hate Microsoft? No. 3. Do I ever use MS-Windows? Yes. 4. Do I have MS-Windows on any of my own computers? No. 5. You get to ask the rest of the questions. 45