Вы находитесь на странице: 1из 27

Copyright © 2007. Cybage Software Pvt. Ltd. All Rights Reserved. Cybage Confidential.

Linux Presentation

Authored by: Jyoti Kumar & Santosh Kamble


Presented by: Jyoti Kumar
Date: 11-12-2007

Copyright © 2007. Cybage Software Pvt. Ltd. All Rights Reserved. Cybage Confidential.
Agenda

 Unix/Linux Overview and


getting help in Linux
 Browsing Linux Filesystem
 The Bash Shell

Copyright © 2007. Cybage Software Pvt. Ltd. All Rights Reserved. Cybage Confidential.
Unix History & Its principles

 Unix History
 First version of Unix was created in Bell Labs in 1969
 Thereafter many Unix flavors emerged with its new name
 E.g. IBM – AIX, HP – UX, SUN – Solaris etc..
 These all flavors operate in similar manner

 Unix Principles
 Everything is a file including hardware
 Can create small, single purpose programs
 Chain the programs together to perform complex tasks

Copyright © 2007. Cybage Software Pvt. Ltd. All Rights Reserved. Cybage Confidential.
Linux origins and Why Linux
 Linus Torvald, a Finnish college student in 1991 created Linux
kernel
 And when Linux kernel combined with GNU applications, Complete
free UNIX-like OS possible
 It is open source development model – Free software!
 It supports wide variety of hardware
 It supports many networking protocols and configurations
 Now it is fully supported (RedHat, SuSE)

Copyright © 2007. Cybage Software Pvt. Ltd. All Rights Reserved. Cybage Confidential.
Logins / Virtual Consoles / Command syntax
 Login Modes:Text & Graphical Login Mode
 Virtual consoles provide multiple non-GUI logins
 There are by default 6 available virtual consoles
 It is available through CTRL – ALT - F [ 1 - 6 ]
 And X will be available at CTRL – ALT – F7, incase if it is running
 Linux Commands have the following syntax:
 commands [options] [arguments]
 Each item is separated by a space
 Command options modify the command behavior
 Arguments are filenames or other information needed by the
command
 Command can be separated with semicolon (;)

Copyright © 2007. Cybage Software Pvt. Ltd. All Rights Reserved. Cybage Confidential.
Getting Help In Linux

 Don’t try to memorize everything!


 Many levels of help is there in Linux
 whatis <command>
 <command> --help
 man and info
 /usr/share/doc
 Man is called as Linux manual
 Navigating Man pages
 Searching the manual with man –k <keyword> | This will list all
matching pages
 Alternative command apropos <keyword>

Copyright © 2007. Cybage Software Pvt. Ltd. All Rights Reserved. Cybage Confidential.
Browsing the Filesystem

 Understand Linux File Hierarchy Concepts


 All Linux files and directories are organized into a single-rooted
inverted tree structure
 Filesystem begins at the “root” directory (Top level Directory),
represented by “/” (forward slash) character
 The home directories
 /root (superuser home directory), /home/<username>
 The bin directories
 /bin, /usr/bin, /usr/local/bin
 /sbin, /usr/sbin, /usr/local/sbin
 Foreign filesystem mountpoints
 /media and /mnt

Copyright © 2007. Cybage Software Pvt. Ltd. All Rights Reserved. Cybage Confidential.
Other Important Directories

 /etc – Consists of system config files


 /tmp – Consists of temporary files
 /boot - Kernel and bootloader (Grub)
 /var and /srv - Server data
 /proc and /sys - System information
 /lib, /usr/lib, - The lib directories
 /usr/local/lib - The lib directories
 pwd - Current Working Directory & it
displays the absolute path to the
current directory

Copyright © 2007. Cybage Software Pvt. Ltd. All Rights Reserved. Cybage Confidential.
Absolute Pathnames & Relative Pathnames
 Absolute pathnames begin with a slash (/)
 It signifies complete "road map" to file location
 It can be used anytime you wish to specify a file name

 Relative pathnames do not begin with /


 It specifies location relative to your present working directory
 It can be used as a shorter way to specify a file name

Copyright © 2007. Cybage Software Pvt. Ltd. All Rights Reserved. Cybage Confidential.
Changing Directories & Listing Directory Contents
 cd - Changing directories
 Change directories to an absolute or relative path
 $ cd /home/jkumar/project
 $ cd project/documents
 Move to a directory one level up
 $ cd ..
 Move to your home directory
 $ cd
 Move to your previous working directory:
 $ cd –
 Lists the contents of the current directory or as specified
 ls [options] [files_or_dirs]

Copyright © 2007. Cybage Software Pvt. Ltd. All Rights Reserved. Cybage Confidential.
Copying, Moving and Renaming Files and Directories

 cp - Copying files and directories


 cp [options] file destination
 More than one file may be copied at a time if the destination is a
directory
 cp [options] file1 file2 destination
 mv - Moving and/or rename files and directories
 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

Copyright © 2007. Cybage Software Pvt. Ltd. All Rights Reserved. Cybage Confidential.
Creating and Removing Files & Directories

 rm - remove files
 Usage: rm [options] filenames
 -i - interactive
 -r - recursive
 -f - force
 touch – create empty files or update file timestamps
 mkdir - make a directory
 rmdir - remove an empty directory
 rm –r - recursively remove a directory and all of its contents

Copyright © 2007. Cybage Software Pvt. Ltd. All Rights Reserved. Cybage Confidential.
Determining File Content & Viewing Text File

 Files can contain many types of data


 Check file type with file before opening to determine
appropriate command or application to use
 file [options] filename(s)
 Viewing Text File
 cat [options] [file...]
 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

Copyright © 2007. Cybage Software Pvt. Ltd. All Rights Reserved. Cybage Confidential.
Partitions, File System And File Types
 Disk drives are divided into partitions
 Partitions are formatted with file system allowing user to store
data
 Default file system: ext3, The Third Extended Linux File System
 Other common file systems: ext2 and msdos (Typically used for
the floppies) & iso 9660 (Typically used for the CDs)
 There are seven fundamental file types..
 Regular File (-)
 Directory (d)
 Symbolic Link (l)
 Block Special File (b)
 Character Special File (c)
 Named Pipe (p)
 Socket (s)

Copyright © 2007. Cybage Software Pvt. Ltd. All Rights Reserved. Cybage Confidential.
Inode – Index Node

 An inode table contains a list of all files in an ext2 or ext3


filesystem
 An inode (index node) is an entry in the table, containing
information about a file (the metadata) which includes
 file type, permissions, link count, UID, GID
 the file's size and various time stamps
 pointers to the file's data blocks on disk
 other data about the file
 The computer's reference for a file is the inode number
 The human way to reference a file is by file name
 A directory is a mapping between the human name for the file
and the computer's inode number

Copyright © 2007. Cybage Software Pvt. Ltd. All Rights Reserved. Cybage Confidential.
Symbolic and Hard Links
 A symbolic link points to another file
 ls –l displays the link name and the referenced file
 The content of the symbolic link is the name of the file that that
its references
 ln –s <file name> <link name>

 Hard Link: One physical file on the file system


 Each link references the file’s inode
 File is present in the file system as long as one link remains
 ln <file name> <link name>
 It cannot span drive or partitions

Copyright © 2007. Cybage Software Pvt. Ltd. All Rights Reserved. Cybage Confidential.
Checking Free Space

 df - Reports disk space usage


 Reports total kilobytes, kilobytes used, kilobytes free per file
system
 -h displays sizes in easier to read units
 df –h /home
 du - Reports disk space usage
 Reports kilobytes used per directory
 Includes subtotals for each subdirectory
 du –sh /home

Copyright © 2007. Cybage Software Pvt. Ltd. All Rights Reserved. Cybage Confidential.
Removable Media

 “Mounting” means making a foreign filesystem look like part of


the main tree.
 Before accessing, media must be mounted
 Before removing, media must be unmounted
 By default, non-root users may only mount certain devices (cd,
dvd, floppy, usb, etc)
 Mountpoints are usually under /mnt
 mount /mnt/cdrom
 umount /mnt/cdrom
 mount /mnt/floppy
 umount /mnt/floppy

Copyright © 2007. Cybage Software Pvt. Ltd. All Rights Reserved. Cybage Confidential.
Archive Files & Compression Utilities

 Archiving places many files into one target file


 Easier to back up, store, and transfer
 tar - Archiving command
 Creating Archives
 tar cvf archive_name files...
 Inspecting Archives
 tar tvf archive_name.tar
 Extracting Archives
 tar xvf archive_name.tar
 gzip, gunzip - Standard Linux compression utility
 bzip2, bunzip2 - Newer Linux compression utility
 Often tar archives are compressed

Copyright © 2007. Cybage Software Pvt. Ltd. All Rights Reserved. Cybage Confidential.
The bash Shell

 "Bourne Again Shell"


 Backward-compatible with Bourne shell (sh) - the original
(standard) UNIX shell.
 Bourne Shell (sh) - Original UNIX shell written by Steven Bourne
at AT&T
 Bash shell Implements many of the extra features found in csh,
ksh, and tcsh
 Command line completion
 Command line editing
 Command line history

Copyright © 2007. Cybage Software Pvt. Ltd. All Rights Reserved. Cybage Confidential.
Command Line Shortcuts

 File Globing, 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 Tab Key, <TAB> to complete command lines:
 For the command name, it will complete a command name
 For an argument, it will complete a file name
 History, $history
 bash stores a history of commands you've entered, which can
be used to repeat commands
 Use history command to see list of "remembered" commands

Copyright © 2007. Cybage Software Pvt. Ltd. All Rights Reserved. Cybage Confidential.
Command Line Expansion
 Tilde ( ~ ) : It may refer to your home directory
 cat ~/.bashrc
 It may also refer to another user's home directory
 $ ls ~jkumar/projects.doc
 Variable and String
 Parameter/Variable: ( $ )
 Substitute the value of a variable in a command line
 $ cd $HOME/projects.doc
 Curly braces: { } - A string is created for every pattern inside the
braces regardless if any file exists
 $ rm hello.{c,o}
 Command Output - ``
 Substitute output from a command in a command line
 $ echo “Current Working Directory is: `pwd`"

Copyright © 2007. Cybage Software Pvt. Ltd. All Rights Reserved. Cybage Confidential.
Protecting From Expansion

 Backslash ( \ ) is the escape character and makes the next


character literal
 $ echo Your cost: \$5.00
 Quote prevents expansion
 Single quotes (') inhibit all expansion
 Double quotes (") inhibit all expansion, except:
 $ (dollar sign) including $() and $[], variable expansion
 ` (backquotes), command substitution
 \ (backslash), single character inhibition
 ! (exclamation point), history substitution

Copyright © 2007. Cybage Software Pvt. Ltd. All Rights Reserved. Cybage Confidential.
History Tricks
 Use the up and down arrow keys to scroll through previous
commands
 Type <CTRL-R> to search for a command in command history.
 (reverse-i-search)`':
 To recall last argument from previous command:
 <ESC>. (the escape key followed by a period)
 <ALT-.> (hold down the alt key while pressing the period)

Copyright © 2007. Cybage Software Pvt. Ltd. All Rights Reserved. Cybage Confidential.
Variables & Aliases
 A variable is a label that has a value
 Variables are used to configure the shell or other programs
 Variables are resident in memory
 There are two types of variables: local and environment
 Local variables are used only by the shell
 Environment variables are passed onto other commands
 set to display all variables
 env to display environment variables

 Aliases let you create shortcuts to commands


 alias dir='ls -laF'
 Use alias by itself to see all set aliases
 Use alias followed by an alias name to see alias value

Copyright © 2007. Cybage Software Pvt. Ltd. All Rights Reserved. Cybage Confidential.
Thank You !

Copyright © 2007. Cybage Software Pvt. Ltd. All Rights Reserved. Cybage Confidential.

Вам также может понравиться