760 likes | 862 Views
Review of: Chapters One - Four. History of Unix OS. The Unix OS was developed (based on Multics & CTSS operating systems) by Ken Thompson at the AT&T Bell Laboratories in 1969. He wanted to create an multi-user operating system to run “space wars” game.
E N D
History of Unix OS • The Unix OS was developed (based on Multics & CTSS operating systems) by Ken Thompson at the AT&T Bell Laboratories in 1969. He wanted to create an multi-user operating system to run “space wars” game. • Ken’s philosophy was to create an operating system with commands or “utilities” that would do one thing well very well (i.e. UNIX).
History of Unix OS • The first versions of UNIX were written in “machine-dependent” program (such as PDP-7). • Ken Thompson approached Dennis Ritchie developer of C program), and in 1973 they compiled UNIX in C programming language to make operating system “portable” to other computers systems.
History of Unix OS • The Unix OS is a multi-user OS allowing more that more person to directly communicate with the computer. • Although the OS can only work on one task at a time, a small piece of time (time slice) is dedicated to each task or user - this is referred to as “time-sharing”. • Time sharing gives the illusion that the CPU is giving all the users its full attention
History of Linux • Linux operating system developed by Finnish programming student named Linus Torvalds • Linus wanted to develop Unix-like OS just to experiment with the new 386 MHz personal computer
Introducing the UNIXOperating System • UNIX can be used on systems functioning as: • Dedicated servers or client workstations in a server-based network • Client/server workstations connected to a peer-to-peer network • Stand-alone workstations not connected to a network
Introducing the UNIXOperating System • UNIX is a multi-user system • Allows many users access and share the resources of a server computer • UNIX is a multitasking system • Allows user to execute more than one program at a time • UNIX is a portable operating system • Used in many computing environments
UNIX Concepts • Shell • The interface between user and OS • Hierarchical Structure • Directory and subdirectory organization • Layered components • Layers of software surround the computer’s inner core
Linux and UNIX • Linux is UNIX-like • Not written from traditional UNIX code • Linux is original code • Includes POSIX standards • Other Linux information • Created by Linus Torvalds • Offers all the complexity of UNIX • Linux can coexist with other OSs
Connecting to a UNIX System • Remotely through Telnet/Secure Shell • Through network client software • As peer on peer-to-peer network • On a stand-alone PC • Through a dumb terminal
Connecting to UNIX • Telnet • terminal emulation software • Easy and unsecure • Secure Shell • Terminal emulation software • Session encrypted end-to-end • Bundled with secure ftp and copy • X-Windows
Logging in to UNIX • Log in by entering username and password when UNIX system booted or connected to • Enter at prompt (command-line mode) or into login box (GUI mode) • You’re at the Shell prompt -- Now commands can be issued at the command prompt
Your Shell • Shells interpret commands and act as first-class programming languages • A default shell is associated with your account when created – Bash is the default shell in Linux (cat /etc/shells) • A short list of some UNIX shells: • Bourne (original Unix shell) • Cshell (similar to C programming language) • Korn (backwards-compatible upgd to bourne) • Bash (combo of Bourne, C and Korn shells)
Entering Commands • To interact with UNIX, a command is entered at the command prompt • UNIX is case-sensitive and most commands are typed in lower case • Two categories of commands • User-level: perform tasks • System administration: system management
Entering Commands • The date command • Displays the system date, which the system administrator maintains • The cal command • Shows the system calendar • The who command • Shows who is using the system and their current location
Entering Commands • Command-line editing • Certain keystrokes perform command-line editing (shell dependent) • Multiple command entry • More than one command on one line by separating with a semicolon(;) • The clear command • Clears the current screen
Entering Commands • Command-line history • Use up and down arrow keys to scroll through command history • The whatis command • Displays a brief description of a command for help purposes • Note the numbers in ()’s – that is the man section
Logging Out of UNIX • Logging out ends your current process and indicates to UNIX that you are finished • Logging out is shell dependent • Bourne, Korn, Bash – exit or Ctrl-D • C shell – logout command
Understanding the Role of the UNIX System Administrator • System administrator manages the UNIX system • Adds users and deletes old accounts • Called root (also called the superuser) • Unlimited permission to alter system (in other words very dangerous) • Prompt ends with # (pound) symbol • Normal user prompt $(dollar) %(percent) symbol
Changing Passwords • For security purposes, changing passwords is necessary • Use the passwd command • UNIX allows new password if: • The new password differs by at least three characters • It has six or more characters, including at least two letters and one number • It is different from the user name • passwd To change current user’s password • passwd<username> To change specified user
Viewing Files with cat, more, less, head, and tail Commands • Use cat, more, lessandtail to view file contents: • cat displays a whole file at one time • more displays a file one screen at a time, allowing scroll down • less displays a file one screen at a time, allowing scroll down and up • tail displays the end of a file • head displays the beginning of a file
Viewing Files with cat, more, less, head, and tail Commands • Use head and tail to view the first few or last few lines of a file • head displays the first few lines • tail displays the last few lines
Redirecting Output • The greater than sign (>) is called a redirection symbol • Create a new file or overwrite an existing file by attaching (>) to a command that produces output • To append to an existing file, use two redirection symbols (>>)
Understanding the UNIX File System • A file is the basic component for data storage • UNIX considers everything it interacts with a file • A file system is UNIX’s way of organizing files on mass storage (disk) devices • A physical file system is a section of the hard disk that has been formatted to hold files • The file system is organized in a hierarchical structure similar to an inverted tree
Understanding the Standard Tree Structure • The structure starts at the root level • Root is the name of the file at this basic level and it is denoted by the slash character (/) • A directory is a file that can contain other files and directories • A subdirectory is a directory within a directory • The subdirectory is considered the child of the parent directory
Using UNIX Partitions • The section of the disk that holds a file system is called a partition • When installing UNIX, one of the first tasks is deciding how to partition a storage device, or hard disk • Hard disks may have many partitions • UNIX partitions are given names
Using UNIX Partitions • Storage devices are called peripheral devices • Peripheral devices connect to the computer through electronic interfaces • IDE - Integrated Drive Electronics • SCSI - Small Computer System Interface (sda1)
Exploring the Root File System • UNIX must mount a file system before any programs can access files on it • To mount a file system is to connect it to the directory tree structure • The root file system is mounted by the kernel when the system starts
Exploring the Root File System • The root directory contains sub-directories that contain files: • /bin contains binaries, or executables needed to start the system and perform system tasks • /boot contains files needed by the bootstrap loader as well as kernel images • /dev contains system device reference files (Next slide is wrong. Should /dev)
Exploring the Root File System • Root subdirectories continued: • /etc contains configuration files that the system uses when the computer starts • /lib contains kernel modules, security information, and the shared library images • /mnt contains mount points for temporary mounts by the system administrator • /proc is a virtual file system allocated in memory only
Exploring the Root File System • Root subdirectories continued: • /root is the home directory of the root user, or the system administrator • /sbin contains essential network programs used only by the system administrator • /tmp is a temporary place to store data during processing cycles • /var contains subdirectories which have sizes that often change, such as error logs
Using the Mount Command • Users can access mounted file systems which they have permission (covered later) to access • Additional file systems can be mounted at any time using the mount command • To ensure system security, only the root user uses the mount command
Paths and Pathnames • To specify a file or directory, use its pathname, which follows the branches of the file system to the desired file • A forward slash ( / ) separates each directory name • The UNIX command prompt may indicate your location within the file system • Use the UNIX pwd command to display the current path name
Bash Prompt Syntax • To see your PS1 variable type and enter: echo $PS1 • To read more look at the man page for bash man bash
Navigating the File System • To navigate the UNIX directory structure, use the cd (change directory) command • UNIX refers to a path as either: • Absolute - begins at the root level and lists all subdirectories to the destination file • Relative - begins at your current working directory and proceeds from there
Managing Directories and Files • mkdir (make directory) command • Create a new directory • rmdir (make directory) command • Delete an empty directory • cp (copy) command • Copy files from one director to another • rm (remove) command • Delete files
Setting File Permissions • chmod command • To set file permissions • Settings are read (r), write (w), execute (x) • The three types of users are owners, groups, and others • Setting permissions to directories • Use execute (x) to grant access
vi editor Pronounced: `vee eye‘’
What is vi ? • The visual editor on the Unix. • Before this the primary editor used on Unix was line editor • User was able to see/edit only one line of the text at a time • The vi editor is not a text formater • you cannot set margins • center headings • Etc…
Characteristics of vi • The vi editor is a very powerful but at the same time it is cryptic • It is hard to learn, specially for windows users • The best way to learn vi commands is to use them
Vim equals Vi • The current iteration of vi for Linux is called vim • Vi Improved • http://www.vim.org
Starting vi • Type vi filename at the shell prompt • After pressing enter the command prompt disappears and you see tilde(~) characters on all the lines • These tilde characters indicate that the line is blank
Vi modes • There are two modes in vi • Command mode • Input mode • When you start vi by default it is in command mode • How can you go to command mode from input mode? • By pressing the Esc key
How to exit from vi • First go to command mode • press Esc There is no harm in pressing Esc even if you are in command mode. Your terminal may just beep or flash if you press Esc in command mode • There are different ways to exit when you are in the command mode
How to exit from vi • :q <enter> is to exit, if you have not made any changes to the file • :q! <enter> is the forced quit, it will discard the changes and quit • :wq <enter> is for save and Exit • :x <enter> is same as above command • ZZ is for save and Exit (Note this command is uppercase)
Moving Around • You can move around only when you are in the command mode • Arrow keys usually works(but may not) • The standard keys for moving cursor are: • h - for left • l - for right • j - for down • k - for up