RH033
E N D
Presentation Transcript
RH033 Redhat Enterprise Linux Essentials
Unit 1 • Redhat Linux Essentials • Overview
Redhat Enterprise Linux • Certified with Leading OEM and ISV Products • ISV Independent Software Vendor • OEM Original Equipment Manufacturer • ABI/API Compatibility • Application Binary Interface • Application Programming Interface • ELF Executable and Linking Format • LSB Linux Standards Base • BEA BEA System Inc, San Jose, California. “Think Liquid” • HPC High Performance Computing
Unix Flavors • UNIX from AT&T, at Bell Labs, in 1969. • AIX from IBM • HP/UX from Hewlett-Packard • SunOS (Later Solaris) from Sun • IRIX from SGI (Silicon Graphics)
Unix Principles • Everything is a file. • Including hardware • Configuration data stored in text • Small, single-purpose programs • Avoid Captive User Interfaces • Ability to chain programs together to perform complex tasks.
GNU Project / FSF • GNU Project started in 1984 • Goal : Create “Free” UNIX clone • By, 1990, Nearly all required userspace application created. • gcc, emacs etc. • Free Software Foundation • Non-profit Organization that manages the GNU Project • Four Freedoms • http://www.gnu.org/philosophy/free-sw.html
GPL – GNU General Public License • Primary license for Open Source Software • Encourages free software • All enhancements and changes to GPL-software must also be GPL • Often called “CopyLeft” • “All rights Reversed” • http://www.gnu.org/copyleft/gpl.html • X Window System, has it’s own T&C. • BSD code need to be abide the terms of Berkeley Software Distribution. Visit http://www.bsd.com
Linux Origins • Linux Torvalds • Finish College Student in 1991 • Created Linux Kernel • When Linux Kernel Combined with GNU Applications, complete free UNIX-like OS possible.
Why Linux? • Fresh Implementation of UNIX APIs. • Open Source Development model. • Supports wide variety of hardware. • Supports many networking protocols and configurations. • Fully supported. • Linux is a UNIX-like OS. • Multi-user and Multi-tasking. • Wide hardware support. Checklist. • Fully Supported.
Redhat Enterprise Linux • A distribution of Linux • Custom version of a recent Linux Kernel. • Utilities and applications. • Installation and configuration software • Support available. • RHEL includes installation and configuration software, a patched and rigorously tested recent version of the Linux Kernel, and thousands of utilities and applications. • gdm is the default display manager for RHEL.
Recommended Hardware Specifications for RHEL • Pentium Pro or better with 256 MB RAM • Or • 64-bit Intel/AMD with 512 MB RAM • 2-6 GB Disk Space • Bootable CD • Other processor architectures supported • Itanium 2, IBM Power, IBM Mainframe.
Virtual Consoles • Virtual Consoles are available through CTRL – ALT – F[1-6] • If X is running, it is available as CTRL – ALT – F7 • The virtual consoles enable a user to have multiple logins even when not using an X Window system. • You can scroll at the virtual consoles by using SHIFT-PAGEUP and SHIFT-PAGEDOWN. The scroll buffer is stored in video memory, so if you are running a graphical program such as X, the scroll buffer is lost.
The Xorg GUI Framework • The goal of X.Org include a faster and more open development model than Xfree86, support for a wide variety of video cards and input devices and the development of a highly modular and flexible graphical framework for Unix and Linux. • http://xorg.freedesktop.org • Or • http://www.x.org/wiki • X Client activity that spawns an X server event informing the web browser to send an HTTP request to the link’s target ( or anchor). You do not really see the X server, but X clients. • X provides the data I/O infrastructure for X clients, like a human nervous system, it sends messages when touched by client activity. • An X Client running on one system can display on any X server running on any operating system, if sufficient access is granted. • For each managed display, this socket is /tmp/.X11-unix/X# where # is 0 to the greatest number of permitted connections.
Xorg Graphical Environments • Collections of applications that provide a graphical working environment with a consistent look and feel. • GNOME (GNU Network Object Model Environment) The default desktop environment. • KDE ( K before L) Environment based on the Qt toolkit.
Starting Xorg • Nothing needed if system boots to a graphical login. Just authenticate. • If system boots to a virtual console login, Xorg must be started manually. • Run startx to manually start Xorg. • Changing Password. • At least 6 but no more that 255 characters. • Other criteria depends on particular OS.
Unit 2 • Running Commands and Getting Help
Getting Help • --help • whatis -- with makewhatis • man • info • /usr/share/doc/html/en/ • Software source code • Documentations
Running Commands • Commands have the following syntax: • Command [ options] [arguments] • Each item is separated by a space. • Options modify the command’s behavior • Word options usually preceded by “--” • Single-letter options usually preceded by “-” • Can be passed as “-a –b –c “ or “-abc” • Arguments are filenames or other date needed by the commands.
The –help option • Anything in straight braces ([]) is optional. • Anything followed by “…” represents an arbitrary-length list of that thing. • If you see multiple options separated by pipes (|), it means you can use any one of them. • Text in straight brackets(<>) represents variable date. So <filename> means “insert the filename you wish to use here”. • Sometimes, such variables are simply written in all CAPS.
The man Command • The collection of all man pages on a system is called the Linux Manual. The Linux is divided into sections, each of which covers a particular topic, and every man page is associated with exactly one of these sections. • The sections are: • Manual Sections. • 1 User Commands • 2 System Calls • 3 Library Calls • 4 Special Files • 5 File Formats • 6 Games • 7 Miscellaneous • 8 Administrative Commands • man and man –k commands
The info command • info pages are structured like a website. • Each page is divided into “nodes”. • Links to nodes are preceded by “*”. • info [<command>] • If you run info with no arguments you will be presented with a list links to the top nodes of every available info page.
Navigating info Pages • While viewing an info page • Navigate with arrows, pgUp, pgDown • Tab Move to next link • Enter Follow link the cursor is on • n/p/u View next/previous/up-one node • s[<text>] Search for text (default: last search) • q Quit Viewing page • If you prefer the navigation keys used by man, such as using “/”, “n” and “N” to search, you can start info with the –vi-keys arguments.
Extended docs • /usr/share/doc • http://www.redhat.com/docs
Miscellaneous • ‘man –f foo’ is the same as ‘whatis foo’. • If your system has just been installed, neither man –f nor whatis will work until an administrator runs makewhatis. • ls –lh
Unit 3 Browsing the File system
Linux File Hierarchy Concepts • Files and directories are organized into a single-rooted inverted tree structure. • Filesystem begins at the “root” directory, represented by a lone “/” (Forward slash) character. • Names are case-sensitive. • Paths are delimited by “/”. • A user’s path is a list of directories that are searched for commands typed at the command line.
Some Important Directories • The essential binaries necessary to boot and maintain the system reside in /bin for regular binaries and /sbin for system binaries. • Non-essential binaries, such as graphical environments, web browsers, office tools and so forth, are installed in /usr/bin and /usr/sbin. • On a newly installed system, there will also be /usr/local/bin and /usr/local/sbin directories, but they will be empty. • CD-ROM is mounted under /media/cdrom folder. • Filesystems that are on non-removable media but are not part of the RHEL, hierarchy are usually mounted under /mnt. • Visit http://www.pathname.com/fhs
Other Important Directories • /etc -System Configuration Files • /tmp -Temporary files • /boot -Kernel and boot loader • /var and /svr -Server data • /proc and /sys -system Information • The lib directories • /lib, /usr/lib, /usr/local/lib
On Folders • Once a day the system automatically deletes any files over seven days old in /tmp and it’s subdirectories. • The /var directory contains regularly-changing system files such as logs, print spools and email spools. • In the future, server data may be moved to the /srv directory so that /var only contains logs, spools and so forth. • Each shell and system process has a current working directory (cwd).
File and Directory Names • Names may be up to 255 characters. • All characters are valid, except the “/”. • It may be unwise to use certain special characters in file or directory names. • Some characters should be protected with quotes when referencing them. • Names are case sensitive. • Example: MAIL, Mail, mail and mAiL • Again, possible but may not be wise. • To access a file with name contains special characters, enclose the filename in quotes.
Absolute Pathnames • Absolute pathnames begin with a slash (/) • Complete “road map” to file location. • Can be used anytime you wish to specify a file name. • To change to your previous working directory • $ cd – • A dash (-) represents your previous working directory. It’s a handy shortcut to use to switch back and forth between two directories.
Copying Files and Directories • cp – copy files and directories • Usage: • cp [options] file destination • More than one file may be copied at a time if the destination is a directory. • cp [options] file1 file2 dest • If final argument is an existing directory, a copy of the source files are placed in that directory with the same name as the source. • Otherwise, the destination is interpreted as a file name, and a copy of the source file is created with that.
On Copying • When copying a single file to a destination, cp first checks to see if a directory exists with the destination name. • If it does, a copy of the source file is placed there with it’s original name. • If not, the destination is assumed to be a new file name, and a copy of the source file is made with the destination name.
Moving and Renaming Files and Directories • mv – move and/or rename files and directories. • Usage: • mv [options] file destination • More than one file may be moved at a time if the destination is a directory. • mv [options] file1 file2 dest • If the destination directory does not exit, the slash will cause the command to fail with an error message. • If the destination directory does not exist (but the destination pathname is valid), the source directory will be moved to the destination directory with the new name.
Creating and Removing Files • rm – remove files • Usage: • rm [options] filenames… • -i – interactive • -r – recursive • -f – force • touch – create empty files or update file timestamps • The –r option tells rm to remove files recursively and thus it will delete directories and their contents. • There is no way to undo the effects of rm, except to restore from a backup. • rmdir will only remove empty directories. To remove a directory and it’s contents, use rm –r.
Using Nautilus • Gnome graphical Filesystem browser • Can run in “Spatial” or “Browser” mode • Accessed via … • Desktop icons • Home: Your home directory • Computer: Root Filesystem, network resources and removable media. • “File Browser” option on Application menu. • Typing CTRL-SHIFT-w closes all parent windows. • “Spatial” or “Browser Mode” can be edited.
Moving and Copying in Nautilus • Drag and Drop • Left-button: Move on same filesystem, copy on different system. • Ctrl-Left-button : Always Copy • Ctrl-Left-button: Ask whether to copy, move or create symbolic link (alias) • Context Menu • Right-click or rename, cut, copy or paste.
Determining File Content • Files can contain many types of data. • Check file type with file before opening to determine appropriate command or application to use. • Syntax • file [options] filename(s) • fileprints its best guess of the type of data contained in a file whose name is given as an argument. It bases it’s guess on a comparison of the contents of the file and the patterns and offsets in it’s reference file, /usr/share/magic.
Viewing an Entire Text File • Syntax: • cat [options] [files..] • Contents of the files are displayed sequentially with no break. • Files display “concatenated”. • -A Show all characters, including control characters and non-printing characters. • -s “Squeeze” multiple adjacent blank lines into a single blank line. • -b Number each (non-blank) line of output.
Viewing Text Page by Page • Syntax: • less [options] [filename] • Scroll with arrows/pgUp/pgDown • Useful commands while viewing: • /text --search for text • n --next match • v -- open file in text editor. • less is the pager used by man
On less • Less navigation commands: • <space> move ahead one full screen • <return> move ahead one line • <Ctrl-d> move ahead (down) half a screen • g move to the top of the file. • /text search forward for text • n repeat last search • q quit • b move back one full screen • k move back one line • <Ctrl-u> move back (up) half a screen • G move to the bottom of the file • ?text search backward for text • N repeat last search, but in opposite direction. • v open file in a text editor (vi by default)
less options • -c Clear before displaying. Screen is redrawn instead of scrolled between screens. • -r Display raw control characters. (May cause display problems) • -s “squeeze” multiple blank lines into a single blank line • -e Exit the second time it reaches the end of the line. • -m Verbose prompt, like more (by default it uses a colon).
Unit 4 • The bash Shell
bash introduction • “Bourne Again Shell” • Successor to sh, the original Unix shell • Developed for the GNU Project • The de factor standard Linux Shell • Backward-compatible with Bourne shell (sh)- the original (Standard) UNIX shell
bash Heritage and Features • Bourne Again Shell (bash) • Implements many of the best features from earlier shells: sh, csh, ksh , tcsh • Command line completion • Command line editing • Command line history • Sophisticated prompt control
Command Line Shortcuts:File Globbing • Globbing is wildcard expansion: • * - matches zero or more characters • ? – matches any single character • [a-z] – matches a range of characters • [^a-z] – matches all except the range. • The use of wildcards, or metacharacters, allows one pattern to expand to multiple filenames by a process called globbing. • RHEL uses UTF-8 encoding of characters, which means that each capital letter comes directly after the corresponding lower-case letter. • Use echo ?o* to find the effect of wild characters.
Some topics: Tab, history, ~ • The TAB Key • history • !! – to repeat last command • !c – to repeat last command that started with c • !n – to repeat a command by its number in history output • !?abc – to repeat last command that contains (as opposed to “started with”) abc • !-n – to repeat a command entered n commands back. • User ^old^new to repeat the last command with old changed to new. • Tilde(~) • May refer to your home directory ( ~/.bash_profile) • May refer to another user’s home directory. (~gmustafa/.bashrc)
Command Line Expansion:Variable and String • Parameter/Variable: ($) • Substitute the value of a variable in a command line. • $ cd $HOME/public/html • To see a list of variables and their values, run the set command. • Curly braces: { } • A string is created for every pattern inside the braces regardless if any file exists. • $ rm hello.{c,o} • Curly braces are useful for generating patterned strings.
Command Line Expansion:Command and Math • Command Output – ‘’ or $ () • Substitute output from a command in a command line. • $ echo “Hostname: `hostname`” • $ echo “Hostname: $(hostname)” • Arithmetic - $[] • Substitute result of arithmetic expression in a command line. • $echo Area : $[$X * $Y] • $echo Area : `expr $X\*$Y`
Protecting form Expansion:Backslash • Backslash (\) is the escape character and makes the next character literal. • $echo Your Cost :\$5.00 • Used as last character on line to “Continue command on next line” • $find / -name foo* • $find / -name foo\*