Presentation is loading. Please wait.

Presentation is loading. Please wait.

CSC 382: Computer SecuritySlide #1 CSC 382: Computer Security Introduction to UNIX Programming.

Similar presentations


Presentation on theme: "CSC 382: Computer SecuritySlide #1 CSC 382: Computer Security Introduction to UNIX Programming."— Presentation transcript:

1 CSC 382: Computer SecuritySlide #1 CSC 382: Computer Security Introduction to UNIX Programming

2 CSC 382: Computer SecuritySlide #2 Topics 1.What is UNIX? 2.Logging on. 3.Basic Commands. 4.The UNIX Shell 5.Compiling on UNIX

3 CSC 382: Computer SecuritySlide #3 What is UNIX? UNIX:: /yoo'niks/ [In the authors' words, "A weak pun on Multics"] n. (also `Unix') An interactive time-sharing system originally invented in 1969 by Ken Thompson after Bell Labs left the Multics project, originally so he could play games on his scavenged PDP-7. Dennis Ritchie, the inventor of C, is considered a co-author of the system.

4 CSC 382: Computer SecuritySlide #4 Logging on to UNIX General Categories –Console –Network For the first assignment, we will log on to zappa.nku.edu

5 CSC 382: Computer SecuritySlide #5 1. Console login: your_username password: your_password Last login: Sun Aug 28 19:35:32 2005 from foo.com. You have new mail. Terminal type? [vt100] Sun Microsystems Inc. SunOS 5.9 Generic May 2002 NOTICE: April 19, 2005 – The upgrade to Java JDK 1.5.2 has been completed. $

6 CSC 382: Computer SecuritySlide #6 2. Network Login using Putty on MS Windows client

7 CSC 382: Computer SecuritySlide #7

8 CSC 382: Computer SecuritySlide #8 3. Insecure Network Login via Telnet f/ Win client

9 CSC 382: Computer SecuritySlide #9

10 CSC 382: Computer SecuritySlide #10 Structure of a UNIX command #command [[ - ] option(s)] [option argument(s)] [command argument(s)] Examples: $ ls $ ls -la $ ls -la m* $ lpr -Pspr -n 3 proposal.ps

11 CSC 382: Computer SecuritySlide #11 File Maintenance Commands Creating, Deleting and Managing Files –cp, mv, rm, ls # cp myfile myfile2 # mv myfile2 renamed_file # mv “latest revisions october.txt” laterevs.txt # rm renamed_file # ls Desktop Mail myfile myfile2 # ls –al

12 CSC 382: Computer SecuritySlide #12 File Maintenance Commands Viewing the Contents of Files –cat, more, less # cat > myfile This is an example of how to use the cat command to add plain text to a file # more myfile This is an example of how to use the cat command to add plain text to a file

13 CSC 382: Computer SecuritySlide #13 File Maintenance Commands Creating, Deleting and Managing Directories –mkdir, cd, pwd, rmdir # mkdir first # cd first # pwd /home7/smithj/first # cd # pwd /home7/smithj # cp myfile myfile2 # ls my* myfile myfile2 # rmdir first rmdir: first: Directory not empty

14 CSC 382: Computer SecuritySlide #14 Obtaining Help with man

15 CSC 382: Computer SecuritySlide #15 Obtaining Help with man man [options][-s section] command-list # man ls User Commands ls(1) NAME ls - list contents of directory SYNOPSIS /usr/bin/ls [-aAbcCdfFghilLmnopqrRstux1@] [file...] /usr/xpg4/bin/ls [-aAbcCdfFghilLmnopqrRstux1@] [file...] DESCRIPTION For each file that is a directory, ls lists the contents of the directory. For each file that is an ordinary file, ls repeats its name and any other information requested. The output is sorted alphabetically by default. When no argument is given, the current directory is listed. …

16 CSC 382: Computer SecuritySlide #16 whatis # whatis login setenv login login (1) - sign on to the system setenv set (1) - shell built-in functions to determine the characteristics for environmental variables of the current shell and its descendents apropos # apropos web neon neon (3) - HTTP and WebDAV client lib installer installer (1m) - Solaris Web Start installer smcwebserver smcwebserver (1m) - start the Sun console wbem wbem (5) - Web-Based Enterprise Mgmt Other Forms of Help

17 CSC 382: Computer SecuritySlide #17 What is a shell? A command interpreter. –Runs external commands like cp and rm. –Built-in commands change shell environment: cd – change directory VAR=value –I/O redirection. cat /etc/shells >shells –Ease of use Command line editing, tab completion, history. –Programming Conditionals, loops, etc.

18 CSC 382: Computer SecuritySlide #18 Environment Variables

19 CSC 382: Computer SecuritySlide #19 Shell Initialization Files Configure shell settings at login. –Create aliases. –Set environment variables. bash initialization files –/etc/profileSystem-wide for sh and bash. –/etc/bashrcSystem-wide for bash. –~/.bashrcUser startup file.

20 CSC 382: Computer SecuritySlide #20 Globbing ? Matches any one character. * Matches zero or more characters. [] Matches list of characters inside brackets.

21 CSC 382: Computer SecuritySlide #21 Globbing > ls *html announce.html guidelines.html readings.html sites.html assignments.html index.html schedule.html > cd assignments > ls a[2-3]?html a2.html a3.html

22 CSC 382: Computer SecuritySlide #22 Command History Up-arrowPrevious command Down-arrowNext command historyList old commands !! Previous command !# Command # !$ Last arg of previous command

23 CSC 382: Computer SecuritySlide #23 Command line editing Ctrl-aBeginning of line Ctrl-eEnd of line Left-arrow Move back one character Right-arrow Move forward one character Ctrl-u Erase line

24 CSC 382: Computer SecuritySlide #24 Filename completion TABCompletes filename TAB-TABShow list of possible completions.

25 CSC 382: Computer SecuritySlide #25 UNIX C Programming $ cat >hello.c #include int main(int argc, char *argv[]) { printf("Hello, world!\n"); return 0; }

26 CSC 382: Computer SecuritySlide #26 UNIX C Programming $ gcc –o hello hello.c $./hello Hello, world!

27 CSC 382: Computer SecuritySlide #27 gcc Flags -ansiUse ANSI C 99 standard. -pedanticDisallow C extensions. -WallPrint all warnings. -o fileName output file. -gInclude debugging info. -ggdbAdd extra GDB debug info.

28 CSC 382: Computer SecuritySlide #28 Command Line Arguments argc – integer number of arguments argv – array of character string arguments

29 CSC 382: Computer SecuritySlide #29 printargs.c $ cat >printargs.c #include int main(int argc, char *argv[]) { int i; for(i=0; i<argc; i++) printf("arg[%d] = %s\n", i, argv[i]); return 0; }

30 CSC 382: Computer SecuritySlide #30 printargs $ gcc –ansi –pedantic –Wall –o printargs printargs.c $./printargs a b c 1 2 3 arg[0] =./printargs arg[1] = a arg[2] = b arg[3] = c arg[4] = 1 arg[5] = 2 arg[6] = 3


Download ppt "CSC 382: Computer SecuritySlide #1 CSC 382: Computer Security Introduction to UNIX Programming."

Similar presentations


Ads by Google