1 / 96

CIS 90 - Lesson 2

CIS 90 - Lesson 2. Lesson Module Status Slides - draft Flash cards – 13 No-stress quiz – Web Calendar summary – done Web book pages - done Commands – done Lab – Jim's. CIS 90 - Lesson 2. Quiz.

Télécharger la présentation

CIS 90 - Lesson 2

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CIS 90 - Lesson 2 • Lesson Module Status • Slides - draft • Flash cards – 13 • No-stress quiz – • Web Calendar summary – done • Web book pages - done • Commands – done • Lab – Jim's

  2. CIS 90 - Lesson 2 Quiz • Please close your books, turn off your monitor, take out a blank sheet of paper and answer these questions: • What command shows the other users logged in to the computer? • What is the lowest level, inner-most component of a UNIX/Linux Operating System called? • What part of UNIX/Linux is both a user interface and a programming language?

  3. CIS 90 - Lesson 2 Commands  = hands on exercise for topic

  4. CIS 90 - Lesson 2 Last weeks Assignment • Student surveys due today • Question on previous material? • Lab 1 due (before midnight) • Questions/feedback on lab?

  5. CIS 90 - Lesson 2 Introducing some new commands for this lesson cat filename cd path echo string file filename ls path type filename Print file contents Change directory Print string (on screen) Show file information List files in directory Show the directory that has contains this command

  6. CIS 90 - Lesson 2 Logging in

  7. CIS 90 - Lesson 2 Logging in always requires: username + password + terminal type

  8. CIS 90 - Lesson 2 Login and Passwords • init starts up the mingetty process on each terminal which • prompts for login username, gets it, then starts login. [root@nosmo ~]# ps t tty1 PID TTY STAT TIME COMMAND 3545 tty1 Ss+ 0:00 /sbin/mingetty tty1 2) login collects the password and checks it with /etc/passwdand /etc/shadow [root@nosmo ~]# ps t tty1 PID TTY STAT TIME COMMAND 3545 tty1 Ss+ 0:00 /bin/login – 3) login then starts up the shell specified in the /etc/passwdfile [root@nosmo ~]# ps t tty1 PID TTY STAT TIME COMMAND 4917 tty1 Ss+ 0:00 –bash

  9. CIS 90 - Lesson 2 /etc/passwd Fields f1:f2:f3:f4:f5:f6:f7 f1=User name f2=Password f3=User id (uid) f4=Group id (gid) f5=Comment f6=Home directory f7=Command/shell

  10. CIS 90 - Lesson 2 /etc/shadow • Fields f1:f2:f3:f4:f5:f6 • f1=User name • f2=Password • $1$... (MD5 encrypted) • * (locked) • !! (no password set) • f3=Last password changed • f4=Minimum • f5=Maximum • f6=Inactive • f7=Expire

  11. CIS 90 - Lesson 2 Passwords and cracking

  12. CIS 90 - Lesson 2 passwd change password /home/cis90/simmsben $ passwd Changing password for user simmsben. Changing password for simmsben (current) UNIX password: New UNIX password: Retype new UNIX password: passwd: all authentication tokens updated successfully. /home/cis90/simmsben $

  13. CIS 90 - Lesson 2 Class Exercise Login to Opus and change passwords Login to Opus: Use new student accounts. Change passwords with passwd command. username: lllllfff password: lllllfff1 1st 5 letters of last name, 1st 3 letters of first name

  14. CIS 90 - Lesson 2 John the Ripper

  15. CIS 90 - Lesson 2 How to make a strong password • The longer the better (8 or more) • Use upper case, lowercase, punctuation, digits • Something you can remember • Keep it secret • Change when compromised • Wh0le#! (Whole sh’bang) • KuKu4(co)2 (Cuckoo for Cocoa Puffs) • #0p&s@ve (shop and save) • Idl02$da (I do laundry on Tuesday)

  16. CIS 90 - Lesson 2 Class Exercise Strong Passwords Change password now to a strong password if its not already.

  17. CIS 90 - Lesson 2 Housekeeping

  18. CIS 90 - Lesson 2 • Call roll • Fix TBA signup sheet • Must add by 9/13 • Parking cards

  19. CIS 90 - Lesson 2 Programs

  20. CIS 90 - Lesson 2 UNIX/Linux Architecture System Commands • 100’s of system commands and utilities . • Commands like ls (list directories), cat (print a file), rm (remove a file), … etc. • Utilities like vi (text editor), sort (sorts file contents), find (searches), … etc. • Larger utilities like sendmail (email), tar (backup), tcpdump (sniffer), … etc. • Administrative utilities like useradd, groupadd, passwd (change password), … etc. Shell System Commands Applications Kernel

  21. CIS 90 - Lesson 2 Programs Executable binary code or scripts The overly simple explanation: “they are the green and bright red ones .. you can run them”

  22. CIS 90 - Lesson 2 Programs Executable binary code or scripts cal apropos [rsimms@nosmo src]$ apropos uname oldolduname [obsolete] (2) - obsolete system calls olduname [obsolete] (2) - obsolete system calls uname (1p) - return system name uname (1) - print system information uname (2) - get name and information about current kernel uname (3p) - get the name of the current system uuname (1) - List the names of the known remote UUCP sites [rsimms@nosmo src]$ cal July 2008 Su Mo Tu We Th Fr Sa 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 Two examples: apropos and cal Use apropos to look up any references in the whatis database. Use cal to print a calendar

  23. CIS 90 - Lesson 2 Programs Executable binary code or scripts apropos cal ls command shows both files are executables (green and x bits set)

  24. CIS 90 - Lesson 2 Programs Executable binary code or scripts apropos cal file command shows apropos is a bash script and cal is binary code (has been compiled)

  25. CIS 90 - Lesson 2 Programs Executable binary code or scripts apropos (script) cal (binary code) cat command chokes on the binary (unprintable) program file. cat command shows readable ASCII script file

  26. CIS 90 - Lesson 2 Programs Executable binary code or scripts From: gcal-3.01.tar.gz cal Note: The cal binary code resulted from compiling the original gcal.c source code.

  27. CIS 90 - Lesson 2 Programs Executable binary code or scripts FYI: There are lots and LOTS of commands in the “bin” (binary) directories /bin /usr/bin /sbin /usr/sbin

  28. Class Exercise Programs 2 1 3 4 C C C C C C C C C C C C-HC 5 6 7 C C C Instructor station

  29. Class Exercise Programs • Team introductions: • high school attended • longest job held • Choose a scribe and a pilot • Issue the commands on the next pages • Answer the questions at the end • Scribe writes the programs you selected, whether they ran or not and if they did what happened on the white board. • We will then go around the room. Each team will stand and introduce themselves to the rest of the class, the pilot will go to the from and explain what their team discovered.

  30. CIS 90 - Lesson 2 Class Exercise Programs /home/cis90/guest $ apropos uname oldolduname [obsolete] (2) - obsolete system calls olduname [obsolete] (2) - obsolete system calls uname (1) - print system information uname (1p) - return system name uname (2) - get name and information about current kernel uname (3p) - get the name of the current system /home/cis90/guest $ cal July 2008 Su Mo Tu We Th Fr Sa 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 /home/cis90/guest $ type uname cal uname is /bin/uname cal is hashed (/usr/bin/cal)

  31. CIS 90 - Lesson 2 Class Exercise Programs /home/cis90/guest $ cd /usr/bin /usr/bin $ ls apropos cal apropos cal /usr/bin $ file apropos cal apropos: Bourne shell script text executable cal: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.6.9, dynamically linked (uses shared libs), for GNU/Linux 2.6.9, stripped /usr/bin $ cat apropos #!/bin/sh # # apropos -- search the whatis database for keywords. < snipped > done exit /usr/bin $ cat cal

  32. CIS 90 - Lesson 2 Class Exercise Programs /usr/bin $ cat cal ELF4tD4(444444Ø9Ø9Ø9ØØ4Ø%ì9ììÐÐHHH PåtdÈ6ÈÈQåtd/lib/ld-linux.so.2GNU libncurses.so.5__gmon_start___Jv_RegisterClassestgetent_fini_inittputstgetstrlibc.so.6_IO_stdin_usedstrcpy__printf_chkexit_IO_putcsetlocaleoptindstrrchr__swprintf_chk__IK'ÿ¯^o"HU"  dpßC2öFÏñ´F½29öNôÿ°ñÿìñÿ¹ ð`$¤ÔpïΧCREÚ¢¹Ë8BÄI4<¥¼w<ø2ÖFmsetge o) åìñÿB@ã|(CEÕì¼Pv¼îʬKãÀ8òØqX¹utc__wcscpy_chkfputsmemcpy__strtol_internalnl_q nginfogetenv__ctype_b_locstderr__snprintf_chklocaltime__vfprintf_chkwcstombsÀO printf_chkbindtextdomain__libc_start_main_edata__bss_start_endGLIBC_2.3GLIBàR .3.4GLIBC_2.4GLIBC_2.0libdl.so.2/lib/ld-linux.so.2qFXHÊ¿¹VSFXH QLû.SFXHRB]f`T XH\Ê£¹ì£¡Üÿÿÿ¡ ¡üÿÿÿ°¡Èÿÿÿ¸¡ÐÿÿÿÔ¡ ¡$48¡Øÿÿÿ<¡ÔÿÿÿL¡h¡¡ôÿÿÿ¬¡Äÿÿÿ´¡øÿÿÿÔ¡Ìÿÿÿ < snipped > /usr/bin $ reset /usr/bin $

  33. CIS 90 - Lesson 2 Class Exercise Programs Team 1: Find 3 programs in /bin, can you run them, what happened? Team 2: Find 3 programs in /sbin, can you run them, what happened? Team 3: Find 3 programs in /usr/bin, can you run them, what happened? Team 4: Find 3 programs in /usr/sbin, can you run them, what happened? Team 5: Find 2 bash shell scripts, can your run them, what happened? Team 6: Find 2 binary programs, can your run them, what happened?

  34. CIS 90 - Lesson 2 Program to Process

  35. CIS 90 - Lesson 2 Program to Process From hard drive to RAM Program (a file on drive) console screen (default) stdout Loads into RAM Options: NA Args: NA console keyboard (default) read write 0 1 system info file info, data, date & time info, process info, etc. (read from or written to kernel) console screen (default) 2 stdin stderr

  36. CIS 90 - Lesson 2 Example program to process: ls command /dev/pts/1 /home/cis90/simmsben/Poems $ tty /dev/pts/1 /home/cis90/simmsben/Poems $ ls ant Blake nursery Shakespeare twister Yeats /home/cis90/simmsben/Poems $ stdout Options: NA Args: NA ant Blake nursery Shakespeare twister Yeats ls read /dev/pts/1 /dev/pts/1 0 directory contents ant Blake nursery Shakespeare twister Yeats (This file information comes from the kernel) 1 stdin 2 stderr

  37. CIS 90 - Lesson 2 Example program to process: bc command [rsimms@nosmo ~]$ tty /dev/pts/1 [rsimms@nosmo ~]$ bc 2> errors <snipped> 2+2 4 4/0 quit [rsimms@nosmo ~]$ cat errors Runtime error (func=(main), adr=5): Divide by zero /dev/pts/1 stdout Options: NA Args: NA 4 bc /home/rsimms/errors /dev/pts/1 0 1 2 stdin 2+2 4/0 stderr Runtime error (func=(main), adr=5): Divide by zero Note: BC is an interactive command and requires user input via stdin

  38. CIS 90 - Lesson 2 Class Exercise Running Programs • What console device are you on? (use tty) • List the files in your current directory (use ls command). Where did the ls process get this file information? Where did it output it to? • Run the calculator program (the bc command). • Add 2 + 2 • Multiply 5 * 7 • Divide 5 / 0 • Q • Where does the bc program get its input from? Where does it write its output to? • Repeat using: bc 2> yourlastname(where did the errors go?) • How can you print the print the errors from the previous step.

  39. CIS 90 - Lesson 2 Command Syntax

  40. CIS 90 - Lesson 2 Command Syntax Command Options Arguments Redirection Command – is the name of an executable program file. Options – various options which control how the program will operate. Arguments – the objects the command is directed to work upon. Redirection – The default input stream (stdin) is from the console keyboard, the default output (stdout) and error (stderr) streams go to the console screen. Redirection can modify these streams to other files or devices.

  41. CIS 90 - Lesson 2 Command Syntax Command Options Arguments Redirection clear hostname hostname -i hostname -s ps ps -e ps -F ps -e -F ps -eF ls ls -l ls /Blake ls -l /Blake ls -l /Blake > blakepoems

  42. CIS 90 - Lesson 2 Command Syntax Command Options Arguments Redirection [root@opus ~]# hostname opus.cabrillo.edu [root@opus ~]# hostname -i 127.0.0.1 [root@opus ~]# hostname -s opus

  43. CIS 90 - Lesson 2 Command Syntax Command Options Arguments Redirection [root@opus ~]#ps PID TTY TIME CMD 14801 pts/0 00:00:00 bash 15728 pts/0 00:00:00 ps [rsimms@opus ~]$ ps -F UID PID PPID C SZ RSS PSR STIME TTY TIME CMD rsimms 14801 14800 0 1165 1452 0 06:50 pts/0 00:00:00 -bash rsimms 15729 14801 0 1061 928 1 13:47 pts/0 00:00:00 ps -F [rsimms@opus ~]$ ps -e PID TTY TIME CMD 1 ? 00:00:05 init 2 ? 00:00:00 migration/0 3 ? 00:00:00 ksoftirqd/0 4 ? 00:00:00 watchdog/0 5 ? 00:00:00 migration/1 6 ? 00:00:00 ksoftirqd/1 7 ? 00:00:00 watchdog/1 8 ? 00:00:00 events/0 < snipped >

  44. CIS 90 - Lesson 2 Command Syntax Command Options Arguments Redirection [root@opus ps -e -F UID PID PPID C SZ RSS PSR STIME TTY TIME CMD root 1 0 0 515 628 1 Jun18 ? 00:00:05 init [3] root 2 1 0 0 0 0 Jun18 ? 00:00:00 [migration/0] root 3 1 0 0 0 0 Jun18 ? 00:00:00 [ksoftirqd/0] root 4 1 0 0 0 0 Jun18 ? 00:00:00 [watchdog/0] root 5 1 0 0 0 1 Jun18 ? 00:00:00 [migration/1] root 6 1 0 0 0 1 Jun18 ? 00:00:00 [ksoftirqd/1] < snipped > [rsimms@opus ~]$ ps -e -F UID PID PPID C SZ RSS PSR STIME TTY TIME CMD root 1 0 0 515 628 1 Jun18 ? 00:00:05 init [3] root 2 1 0 0 0 0 Jun18 ? 00:00:00 [migration/0] root 3 1 0 0 0 0 Jun18 ? 00:00:00 [ksoftirqd/0] root 4 1 0 0 0 0 Jun18 ? 00:00:00 [watchdog/0] root 5 1 0 0 0 1 Jun18 ? 00:00:00 [migration/1] root 6 1 0 0 0 1 Jun18 ? 00:00:00 [ksoftirqd/1] < snipped >

  45. CIS 90 - Lesson 2 Command Syntax Command Options Arguments Redirection [root@opus /home/cis90/simmsben/Poems $ ls ant Blake nursery Shakespeare twister Yeats /home/cis90/simmsben/Poems $ ls -l total 48 -rw-r--r-- 1 simmsben cis90 237 Aug 26 2003 ant drwxr-xr-x 2 simmsben cis90 4096 Jul 20 2001 Blake -rw-r--r-- 1 simmsben cis90 779 Oct 12 2003 nursery drwxr-xr-x 2 simmsben cis90 4096 Oct 31 2004 Shakespeare -rw-r--r-- 1 simmsben cis90 151 Jul 20 2001 twister drwxr-xr-x 2 simmsben cis90 4096 Jul 20 2001 Yeats /home/cis90/simmsben/Poems $ ls Blake/ jerusalem tiger /home/cis90/simmsben/Poems $ ls -l Blake/ total 16 -rw-r--r-- 1 simmsben cis90 582 Jul 20 2001 jerusalem -rw-r--r-- 1 simmsben cis90 115 Jul 20 2001 tiger /home/cis90/simmsben/Poems $ ls -l Blake/ > blakepoems /home/cis90/simmsben/Poems $ cat blakepoems total 16 -rw-r--r-- 1 simmsben cis90 582 Jul 20 2001 jerusalem -rw-r--r-- 1 simmsben cis90 115 Jul 20 2001 tiger

  46. CIS 90 - Lesson 2 Class Exercise Command Line clear hostname hostname -i hostname -s ps ps -e ps -F ps -e -F ps -eF ls ls -l ls /bin ls -l /bin ls -lS /bin ls –ls /bin > yourlastname cat yourlastname Try these commands out on your computer

  47. CIS 90 - Lesson 2 Environment Variables

  48. CIS 90 - Lesson 2 Variables A little bit of programming now $ echo $HOSTNAME opus.cabrillo.edu $ echo $HOME /home/cis90/simmsben $ echo $LOGNAME simmsben $ echo $SHELL /bin/bash

  49. CIS 90 - Lesson 2 Shell (Environment) Variables common environment variables

  50. CIS 90 - Lesson 2 Shell (Environment) Variables env command – show all environment variables /home/cis90/simmsben/Poems $env HOSTNAME=opus.cabrillo.edu SHELL=/bin/bash TERM=xterm HISTSIZE=1000 USER=simmsben LS_COLORS=no=00:fi=00:di=00;34:ln=00;36:pi=40;33:so=00;35:bd=40;33;01:cd=40;33;01:or=01;05;37;41:mi=01;05;37;41:ex=00;32:*.cmd=00;32:*.exe=00;32:*.com=00;32:*.btm=00;32:*.bat=00;32:*.sh=00;32:*.csh=00;32:*.tar=00;31:*.tgz=00;31:*.arj=00;31:*.taz=00;31:*.lzh=00;31:*.zip=00;31:*.z=00;31:*.Z=00;31:*.gz=00;31:*.bz2=00;31:*.bz=00;31:*.tz=00;31:*.rpm=00;31:*.cpio=00;31:*.jpg=00;35:*.gif=00;35:*.bmp=00;35:*.xbm=00;35:*.xpm=00;35:*.png=00;35:*.tif=00;35: USERNAME= MAIL=/var/spool/mail/simmsben PATH=/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/home/cis90/simmsben/../bin:/home/cis90/simmsben/bin:. INPUTRC=/etc/inputrc PWD=/home/cis90/simmsben/Poems LANG=en_US.UTF-8 SSH_ASKPASS=/usr/libexec/openssh/gnome-ssh-askpass SHLVL=1 HOME=/home/cis90/simmsben BASH_ENV=/home/cis90/simmsben/.bashrc LOGNAME=simmsben CVS_RSH=ssh LESSOPEN=|/usr/bin/lesspipe.sh %s G_BROKEN_FILENAMES=1 _=/bin/env OLDPWD=/home/cis90/simmsben /home/cis90/simmsben/Poems $

More Related