Download
introduction to unix n.
Skip this Video
Loading SlideShow in 5 Seconds..
Introduction to Unix PowerPoint Presentation
Download Presentation
Introduction to Unix

Introduction to Unix

217 Views Download Presentation
Download Presentation

Introduction to Unix

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

  1. Introduction to Unix Jon Johansson AICT University of Alberta April 25, 2008

  2. Agenda • What is Unix? • Your Unix environment • The file system directory structure • SSH connections • Unix commands • Compilers UNIX is a registered trademark of The Open Group in the United States and other countries LINUX is a trademark or a registered trademark of Linus Torvalds

  3. Unix • UNIX is a computer operating system. • An operating system is the program that controls all the other parts of a computer system, both the hardware and the software. • It allocates the computer's resources and schedules tasks • It allows you to make use of the facilities provided by the system • Every computer requires an operating system • The UNIX operating system has three important features; a kernel, the shell and a file system.

  4. Unix • UNIX is a multi-user, multi-tasking operating system • multiple users may have multiple tasks running simultaneously • on a PC a single user is logged in and interacting with the computer at any time

  5. Unix • UNIX is a machine independent OS • not specific to just one type of computer hardware • designed from the beginning to be independent of the computer hardware • UNIX is a software development environment • was born in and designed to function within this type of environment

  6. Unix History: The People who brought us Unix Ken Thompson Dennis Ritchie Douglas McIlroy

  7. Unix History • 1969: Unix first written by AT&T employees • Ken Thompson • Dennis Ritchie • Douglas McIlroy • ~1985: development of the AT&T Unix splits into two main streams • BSD (Berkley Source Dist.) • System V • 1983: GNU project starts • 1991: Linux kernel development begins ATT Unix BSD System V Linux http://en.wikipedia.org/wiki/Image:Unix_history-simple.png

  8. Unix History • There are two major variants of Unix • System V • AT&T distributes System V for their computers. • System V is also the basis for several commercial implementations including: Hewlett-Packard HP-UX, Apple AUX, Amdahl UTS, Cray UNICOS, IBM AIX, SGI IRIX • BSD • from the University of California Berkeley • BSD is available directly from UCB and in a number of commercial versions including: Sun, Apollo, DEC Ultrix, Gould UTX/32

  9. Unix History • System V and BSD contain a large set of commands in common • Some of these commands, support different options and have different default behaviors and output formats. For example: Other examples: ls, stty, mail, grep • Each version also has its own unique utilities • Some very common tasks, such as browsing a file, are performed by totally different utilities: System V uses "pg" whereas BSD uses "more". • ps –ef (System V) • ps –aux(BSD)

  10. Unix • IRIX is the System V-based Unix Operating System with BSD extensions developed by Silicon Graphics (SGI) nexus.westgrid.ca • AIX (Advanced Interactive eXecutive)is an operating system developed by IBM based on UNIX System V cortex.westgrid.ca • Linux is a clone of the Unix operating system • Linux kernel has been written from scratch by Linus Torvalds and others • GNU tools developed through the GNU Project

  11. Linux • Linux is a Unix-like operating system kernel • created by Linus Torvalds • started working on Linux in 1991 • source code for Linux is freely available to everyone under the GNU General Public license Linus Torvalds

  12. GNU Project • Started by Richard Stallman in 1983 • Develop a complete Unix-like operating system composed entirely of free software • Need lots of components: • a kernel → Linux • compilers • editors • text formatters • mail software • many other things … Richard Stallman GNU Logo

  13. Unix Components • the kernel • controls the hardware • the shell • an interpreter between the user and the computer • tools and applications • hundreds of tools available to UNIX users which make the computer useful

  14. Unix Components – Kernel • The Kernel is the core of the UNIX system. • Loaded at system start up (boot) • memory-resident control program • Manages the entire resources of the system, presenting them to you and every other user as a coherent system. • Provides services to user applications such as device management, process scheduling, etc.

  15. Unix Components – Kernel Example functions performed by the kernel are: • managing the machine's memory and allocating it to each process • scheduling the work done by the CPU so that the work of each user is carried out as efficiently as is possible • accomplishing the transfer of data from one part of the machine to another • interpreting and executing instructions from the shell • enforcing file access permissions You do not need to know anything about the kernel in order to use a UNIX system!

  16. Windows Shell A graphical user interface (GUI) • allows a user to interact with the computer using a pointing device such as a mouse • select words from drop down menus • select images such as icons on the display screen • icons represent commands for movement, activation or some other action aka the WIMP interface • Windows • Icons • Menus • Pointing Device

  17. Browse directories Edit files CommandLine

  18. Windows Shell • Note that all the things that you can do through the GUI you can do from the command line: • browse directories • GUI: Windows Explorer browsing • command line: use cd and dir commands • read contents of files • GUI: double click on the file to open it with the default application • command line: type <filename> • edit files • GUI: double click on the file to open it with the default application • command line: notepad <filename>

  19. Unix Interface • high performance unix machines are generally accessed remotely • connect through a command line • WIMP interface and the desktop paradigm is no longer very useful • need to learn a bunch of commands to do work • CLI – Command Line Interface – not for WIMPS

  20. Unix Commands: Syntax • Usual command-line syntax is: command • an executable to be run, you instruct what a system should do • the first word on the command line option • this specifies how the command is run. Options are prefixed with a dash ” - " character. argument • what is to be affected, it could be a file, directory, stdin, stdout, user, process, etc. • Example format: command option(s)argument(s)

  21. Unix Commands: man pages • get help with commands through the man pages, (man commands), for example: • you might like to read: • In Unix case matters! • For Example: LSis not equal tols $ man ps $ man ls $ man intro

  22. Unix Commands: man pages While viewing a man page you have few commands: Spacebar move one screen further Enter move one line further b moves one screen back /pattern searches forward for "pattern" ?pattern searches backward for "pattern" n the next occurrence of the "pattern" q quits the man(1) command h prints a help screen;

  23. Unix Commands • Example of command options and output (most commands have many options, see the man pages for details). • Thelscommand with options to list all files in long format: $ ls -la • file names starting in dot are normally hidden • permissions are: Read, Write, eXecute • columns are owner, group, and all

  24. Unix Components – Shell • Whenever you login to a Unix system you are placed in a shell program. • the shell's prompt is usually visible at the cursor's position on your screen. • to get your work done, you enter commands at this prompt. • The shell is a command interpreter. • it takes each command and passes it to the operating system kernel to be acted upon. • it then displays the results of this operation on your screen. • Several shells are usually available on any UNIX system, each with its own strengths and weaknesses.

  25. Unix Components – Shell • Different users may use different shells. • the system is set up with a default shell, which can be overridden or changed • The most commonly available shells are: • Bourne shell (sh) • C shell (csh) • Korn shell (ksh) • TC Shell (tcsh) • Bourne Again Shell (bash) • Each shell also includes its own programming language • command files, called "shell scripts" are used to accomplish a series of tasks

  26. Bourne Shell (sh) • This is the original Unix shell written by Steve Bourne of Bell Labs. • /bin/sh, /sbin/sh • It is available on all UNIX systems. • This shell does not have the interactive facilities provided by modern shells such as the C shell and Korn shell. • The Bourne shell provides an easy to use language with which you can write shell scripts.

  27. Bourne Again SHell (bash) • a public domain shell written by the Free Software Foundation under their GNU initiative. • fairly standard default shell on Linux distributions • bash provides all the interactive features of the C shell (csh) and the Korn shell (ksh) • bash’s programming language is compatible with the Bourne shell (sh) • bash is one of the more popular shell choices

  28. Agenda • What is Unix? • Your Unix environment • The file system directory structure • SSH connections • Unix commands • Compilers UNIX is a registered trademark of The Open Group in the United States and other countries LINUX is a trademark or a registered trademark of Linus Torvalds

  29. Environment • Your working environment is defined whenever you login or start another shell. • This environment is set using the values that the shell finds in the initialization files (which it always reads as it starts up). • You can change your working environment by editing these initialization files and setting new values for the various variables. • Each shell handles its initialization files in a different way

  30. Environment • To see the list of environment variables being used: printenv • You can print the value of a particular environment variable with the “echo” command: echo $SHELL • You set an environment variable like this: $ jon@um01:~>MY_NAME="Jon" $ jon@um01:~>echo $MY_NAME $ Jon

  31. Unix Components – Utilities • UNIX provides several hundred utility programs, often referred to as commands. • You can accomplish universal functions, such as: • editing • file maintenance • printing • sorting • programming support • online info • etc. • And they are modular, i.e., single functions can be grouped to perform more complex tasks.

  32. Exercise 1: Logging in and getting some basic information about the system.

  33. Agenda • What is Unix? • Your Unix environment • The file system directory structure • SSH connections • Unix commands • Compilers UNIX is a registered trademark of The Open Group in the United States and other countries LINUX is a trademark or a registered trademark of Linus Torvalds

  34. The Unix File System • A file system is a logical method for organizing and storing large amounts of information in a way which makes it easy to manage. • The file is the smallest unit in which information is stored.

  35. The Unix File System / Root directory of the file system. /bin User utilities fundamental to both single-user and multi- user environments. /sbin System programs and administration utilities fundamental to both single-user and multi-user environments. /boot Programs and configuration files used during operating system startup /dev Device nodes; see intro(4). /etc System configuration files and scripts. /tmp Temporary files. The contents of /tmp are usually NOT preserved across a system reboot. /usr The majority of user utilities and applications. /var Multi-purpose log, temporary, transient, and spool files. /home User home directories on many Linux systems /root Home directory for the root account

  36. The Unix File System • the file system resembles an inverted tree • the tree is anchored in the root directory • designated with a ‘/’

  37. The Unix File System • every item in the unix file system tree is either a directory or a file • a directory is like a file folder • a directory can contain files, and other directories • a directory contained within another is called the child of the other

  38. The Unix File System • different unix distributions put user home directories in different places • you are placed in your home directory when you log in • the directory that you are in now is called the “current working directory” • check the path with ‘pwd’ (print working directory)

  39. The Unix File System • the location of an object in the file system is described by a “path” • the “absolute path” includes all the directories starting from “/” • the “relative path” includes only subdirectories of the current working directory

  40. The Unix File System Slash / means the root directory Tilde ~ means your home directory Dot . means right here, current directory Dot Dot ..means up one level

  41. File System Commands ls list directory contents cd change the current working directory pwd print the name of the current/working directory

  42. Unix Commands grepget regular expression Finds word in a stream of text |pipe text from one command to the next. This symbol is normally a shifted “\” key

  43. Exercise 2: Understanding the structure of the file system and obtaining information about it.

  44. Agenda • What is Unix? • Your Unix environment • The file system directory structure • SSH • Unix commands • Compilers UNIX is a registered trademark of The Open Group in the United States and other countries LINUX is a trademark or a registered trademark of Linus Torvalds

  45. SSH • Secure Shell (ssh) is a set of programs to: • log into another computer over a network, • to execute commands in a remote machine, • and to move files from one machine to another. • It provides strong authentication and secure communications over un-secure channels. • It is intended as a replacement for telnet, rlogin, rsh, and rcp. • For SSH2, there is a replacement for FTP: sftp.

  46. SSH • Secure Shell also provides secure X connections and secure forwarding of arbitrary TCP connections. • ssh connects and logs into the specified hostname • the user must prove his/her identity to the remote machine using one of several methods • see the man page for details • we only use the password

  47. SSH - How it Works • ssh works by the exchange and verification of information, using public and private keys, to identify hosts and users • we will only be concerned with a password exchange • after you've authenticated (successfully logged in) communications are encrypted

  48. SSH daemon • sshd is the daemon that listens for connections from clients • it forks a new daemon for each incoming connection • the forked daemons handle key exchange, encryption, authentication, command execution, and data exchange.

  49. SSH In order to connect to a remote machine you must: • run the ssh client on your desktop machine • the client connects to the sshd server running on the remote machine • the client and server establish a connection and run through a protocol which attempts to establish that you have the right to make a connection • enter your password

  50. How to run SSH • To login to a remote host: ssh <hostname> • To login to a remote host with a different username: ssh -l <username> <hostname> • To login to a remote host and send a command: ssh <hostname> <command> • To login to a remote host and forward X11: ssh -X <hostname>