1.09k likes | 1.11k Views
Discover the history, structure, and key concepts of UNIX and Linux operating systems. Learn about shells, commands, user accounts, and file systems. Connect to UNIX remotely, choose shells, and execute commands efficiently. Explore the hierarchical file structure and basic Unix commands. View files, change passwords, and understand the role of system administrators. Get insights into UNIX file systems and the tree structure.
E N D
Part One The Essence of UNIX
Overview • Unix history • Origins, versions, distributions • Using Unix • Log in/out • Unix shells • Basic commands • Editor(s) • Compile a C/C++ program
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 History • Bell Labs … • UC Berkeley … • Commercial versions: • Solaris, Irix, HP/UX, Ultrix, SCO Unix, AIX, … • Open source versions: • FreeBSD • Linux
Linux and UNIX • Linux is UNIX-like • Created by Linus Torvalds • Not written from traditional UNIX code • Linux is original code • follows POSIX standards
Linux Distributions • Many companies have createdLinux distributions • distributions contain • source code for the Linux kernel and utilities • installation tools • professional documentation • technical support, • specialized software • They can charge as much as they choose for their Linux distributions
UNIX Concepts • Shell • The interface between user and OS • Hierarchical Structure • Directory and subdirectory organization • Layered components • Layers of software cover hardware
Choosing Your Shell • Shells interpret commands and act as first-class programming language • A default shell is associated with your account when created • A list of some UNIX shells: • Bourne • C shell • Korn • Bash, tcsh
Choosing User Names and Passwords • To use UNIX, a user must log in by providing a unique user name and password • UNIX system administrators create accounts by adding user names and passwords
Connecting to a UNIX System • Directly via attached terminal • Via terminal window in windowing system • Remotely through telnet, rsh or ssh
Connecting to UNIXUsing Telnet • telnet is terminal emulation software • Deemed insecure • Better: ssh • connects to Unix server • Once connected to a UNIX host, work with UNIX may begin • Uses IP addresses or domain names to access remote systems
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 (shell dependent) • Certain keystrokes perform command-line editing • Use up and down arrow keys to scroll through command history • Multiple command entry • Separate commands with semicolon(;) • The clear command • Clears the current screen
Getting Help The man program displays the UNIX online reference manual, called the man pages, for help purposes
Viewing Files • Use cat, more, and less to view an entire 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
Viewing Files • 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
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 command • C shell – logout command
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
Understanding the Role of the UNIX System Administrator • User “root” manages the UNIX system • Adds users and deletes old accounts • Also called the superuser • Unlimited permission to alter system
Understanding the UNIXFile 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
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
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
Understanding Pathsand 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
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
Listing Directory Contents The ls (list) command displays a directory’s contents, including files and subdirectories
Listing Directory Contents • ls options: • a include files with “.” • l long format • R recursively list subdirectories
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 Permissionsfor Security • 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 the execute (x) to grant access
Using Input and Error Redirection • You can use redirection operators to retrieve input from something other than the standard input device and send output to something other than the standard output device • Examples of redirection: • Redirect the ls command output to a file, instead of to the monitor (or screen) • Redirect a program that receives input from the keyboard to receive input from a file instead • Redirect error messages to files, instead of to the screen by default
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 (>>)
Creating new files • using cat output redirection • concatenate text via output redirection • touch command on new file • invoke editor for new file
Manipulating Files • Delete files when you no longer needed • rm command • permanently removes a file or an empty directory • -r option removes a directory and everything it contains • Copy files as a means of back-up or as a means to assist with new file creation • cp command • copies the file(s) specified by the source path to the location specified by the destination path
Manipulating Files • Moving a file • mv command • removes file from one directory and places it in another • Finding a file helps you locate it in the directory structure • find command • searches for the file that has the name you specify
Manipulating Files • Combining files using output redirection • cat command • concatenate text of two different files via output redirection • paste command • joins text of different files in side by side fashion • Extracting fields of a file using output redirection • cut command • removes specific columns or fields from a file