800 likes | 1.18k Views
Introduction to Unix. Produced by Jon Johansson Presented by Waldemar Lysz AICT University of Alberta May 4, 2009. Topics. What is Unix? Your Unix environment The file system directory structure SSH connections Unix commands Compilers.
E N D
Introduction to Unix Produced by Jon Johansson Presented by Waldemar Lysz AICT University of Alberta May 4, 2009
Topics • 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
Unix History: The People who brought us Unix Ken Thompson Dennis Ritchie Douglas McIlroy
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
Linux Unix-like OS Linus Torvalds
Unix-like 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
Unix You Can Try • 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 cluster.srv.ualberta.ca
Unix Components You do not need to know anything about the kernel in order to use a UNIX system!
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. You do not need to know anything about the kernel in order to use a UNIX system!
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!
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
Browse directories Edit files CommandLine
Unix Interface • high performance Unix machines are generally accessed remotely • connect through a command line
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) ls –al /home/wdl
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
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;
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
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.
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
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.
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
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
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
Environment • Your working environment is defined whenever you login or start another shell. • 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
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.
Exercise 1: Logging in and getting some basic information about the system.
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
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.
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
The Unix File System • the file system resembles an inverted tree • the tree is anchored in the root directory • designated with a ‘/’
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
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)
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
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
File System Commands ls list directory contents cd change the current working directory pwd print the name of the current/working directory
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
Exercise 2: Understanding the structure of the file system and obtaining information about it.
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
SSH- Connecting To Unix Host • 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.
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
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
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.
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
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>
SSH – scp Unix Data Mover • Secure Copy, scp, is used in copying files over the network securely • It uses ssh for data transfer, and uses the same authentication and provides the same security as ssh • How to run scp: scp <source> <destination> • where the source and destination can be paths in the local file system or have the form user@host:/dir/for/file
SSH – scp to use scp to copy a file to a remote system: scp localdir/to/filelocation user@host:/dir/for/file to use scp to copy a remote file to the local system: scp user@host:/dir/for/file localdir/to/filelocation to keep the file attributes of the source file from the source host, use -p: scp -p user@host:/dir/for/file localdir/to/filelocation scp test jon@um01.cs.ualberta.ca:/home/dsk05/cshome/jon scp jonj@cortex.westgrid.ca:/scratch_large/jonj/ibm/test .
SSH – More Info • Tutorials • http://csociety.ecn.purdue.edu/~sigos/projects/ssh • http://kimmo.suominen.com/docs/ssh/ • FAQ: • http://www.employees.org/~satch/ssh/faq
Exercise 3: Connect to remote sites Moving data between machines use one of other lab machines or: cluster.srv.ualberta.ca nexus.westgrid.ca cortex.westgrid.ca