Linux Professional Institute LPIC-1 - PowerPoint PPT Presentation

1 / 109
About This Presentation
Title:

Linux Professional Institute LPIC-1

Description:

Linux Professional Institute LPIC-1 _____ RayanFarmad Information Technology Topic 107: Administrative Tasks /etc/timezone ... – PowerPoint PPT presentation

Number of Views:444
Avg rating:3.0/5.0
Slides: 110
Provided by: Raz67
Category:

less

Transcript and Presenter's Notes

Title: Linux Professional Institute LPIC-1


1
?? ??? ???
Linux Professional Institute LPIC-1 ______________
____________________RayanFarmad Information
Technology
2
????? ?????
  1. ?????? ?? ?????? ??? ???????? ????
  2. ????? ????? ???????????? ???? (FSF)
  3. ??? ??? ???????? ??? ??? ?????? ??????
  4. ?????? ???? ???? ?? ??? ???
  5. ??? ??? ? ?????? ??????? ?? ??
  6. ????? ??? ??? ? ?????? ??????? ???? ?? ??? ???
    ???
  7. ????? ??? ??? ? ?????? ?? ???? ???
  8. ?????? ?????
  9. ??????? ?????? ??????
  10. ???? ?????? ??????
  11. ????? ????? ??? ?????? ?????? ???? ??
  12. ??? ???? ?? ???? ????? ??????

3
?????? ?? ?????? ??? ???????? ????Free Open
Source Softwares
  • ???? ??? ??? (OpenSource) ?? ???? ??? ?????? ???
    ?? ??? ? ???? (source) ?? ???? ????? ???? ???????
    ??????? ? ????? ????.
  • ?? ?????? ????? ?? ????? ???????? ?? ?? ?????
    ????? ?? ??? ???? ????? ??????? ?? ??? ?? ????
    ??? ? ??????? ?????? ???? ???.
  • ??????? ?? ????? ??? ????? ???? ?????? ?? ?????
    ?? ????? ???? ????? ????? ?? ?? ?? ??????? ?????
    ????? ?? ??? ?? ?? ???? ??????? ? ?? ????? ????
    ?? ??? ????? ??? ???? ???? ?? ?? ?? ???? ?????
    ??? ??? ?? ????? ?? ??? ???? ?? ?????? ??????
    ???? ??? ? ?? ????? ??? ???? ???????? ?? ??? ??
    ????? ??? ???? ?? ?????.

4
????? ???????????? ????
????? ??? ???????? ???? ?? ?????? ?????????? ???
?? ?? ????? ??? ???? ???? ?????? ??????? ????? ??
?? ?? ???? ???????????? ???? ? ????? ????? GNU
????? ???.?? ???? ????? ??? ????? ?? ????? ???
???? ?????????? ?? ????? ?? ??? ??? ???????
?????????????? ???? ????? ???????????? ???? ???
???.
5
??? ??? ???????? ??? ??? ?????? ??????Free ??
????? ????? ??? !
???? free ?? ???????????? ??? ??? ?? ????? ?????
?? ???????(?? ?? ?????)? ????? ?/?? ????? ????
????????? ???. ?? ?????? ?? ?? ????? ?????
?????? ?????? ??????? ????? ?? ????? ????? ?????
????? ??? ?? ???? ?? ?? ????????? ???? ?????
?????? "Free Software" ???
6
?????? ???? ???? ?? ??? ???
GNU GPL ?????????? ????? ?????? ???
CopyLeft
7
??? ??? ? ?????? ??????? ?? ??
  1. ?? ?????? ????? ?? ???? ??? ????? ? ?? ?????
    ????.
  2. ?? ?????? ??????? ? ??????? ????? ??? ??? ??
    ????.
  3. ???? ?????? ???? ???? ??? ?????.
  4. ????? ????? ???.
  5. ??????? ? ???????.
  6. ?????? ?? ?????? ????? ?????.

8
????? ??? ??? ? ?????? ??????? ???? ?? ??? ??? ???
  • ??? ????
  • ??????? ???? ?? ??????? ???? ????? ?? ??? ??? .
  • Yahoo!?IBM ?Google ?Mozilla
  • ????? ?? ??????? ?? ?????? ?? ?????.
  • ?????? ??????? ??? ????? ?? ??????.
  • ????? ??????? ??????????? ?? ????? ???? ???
    ???????? ????
  • ?????- ?????? ?????? ?????? ? ?????? ???? ???? ??
    ??????
  • ??????? ?????? ?????? ?????? ?? ????? ???
    ???????

9
????? ??? ??? ? ?????? ?? ???? ???
  • ???? ??????
  • ??????? ?????? ?????? 80 ?????? ?? ??????.
  • ??????? ????? ????.
  • ???? ??????? ?????? ?????
  • ????? ???? iran.ir
  • ???? ??????? ????? ?????
  • ????? ??????? ???? ?? ? ?????? ???????.
  • ?????? ????? ???????.
  • ?????? ??? ????? ????.

10
?????? ?????
  1. ?????? ?? ???? ???? ?? ???? ( Kernel) ???.
  2. ???? ??? ???? ????? ???? ?? ????? ?? ??? ?? ???
    ????? ???? ??? ?????? ????? ? ??? ????? ? ?????
    ????? ???? ????? ???? ???.
  3. ?????? ?? ??????? ?? ????????? ?? ????? ??? ?????
    ???? ????? ?? ?? ????? ???? ??? ???.


11
??????? ?????? ??????
?Andrew Tanenbaum
Richard Stallman
Linus Torvalds
12
?????? ? ???? ?? ??????
????? ????? ????? ??? ????? ??????
13
???? ?????? ??????
  1. ?????
  2. ?????? ???? ????? ?????.
  3. ????? ? ?????? ????(Free Freedom)
  4. ????? ??? ????
  5. ?????? ????? ?? defrag ???? ??????? ?? ?????
  6. ?????? ????? ?? ?????? ??? ??? ?????
  7. ?????? ?????? ?? ???? ????? ?? ?? ???????? ??
    ???.
  8. 80 ??????? ???? ?? ??? ?????? ?? ????.
  9. ????? ? ??????? ?????? ????? ???? ???.
  10. ....

14
????? ????? ??? ?????? ?????? ???? ??
?????? ? ?????? ????? ????? IBM? Novel? SGI?
Linux Journal? Linux Magazine ? Turbo Linux? ..
?? ?????? ??? ????? ????? ?? ???? ? ????? ???
????? ?? ????? ???? ????? ? ??????? ???.
15
????? ????? ??? ?????? ?????? ???? ??
Junior Level Linux Professional
Advanced Level Linux Professional
Senior Level Linux Professional
16
LPIC-1 Chapters
Topic 101 System Architecture Topic 102 Linux
Installation and Package Management Topic 103
GNU and Unix Commands Topic 104 Devices, Linux
File systems, FHS Topic 105 Shells, Scripting
and Data Management Topic 106 User Interfaces
and Desktops Topic 107 Administrative Tasks
Topic 108 Essential System Services Topic 109
Networking Fundamentals Topic 110 Security
17
LPIC-1 Exam 101 Chapters
Topic 101 System Architecture 101.1 Determine
and configure hardware settings 101.2 Boot the
system 101.3 Change runlevels and shutdown or
reboot system Topic 102 Linux Installation and
Package Management 102.1 Design hard disk
layout 102.2 Install a boot manager 102.3
Manage shared libraries 102.4 Use Debian
package management 102.5 Use RPM and YUM
package management
18
LPIC-1 Chapters
  • Topic 103 GNU and Unix Commands
  • 103.1 Work on the command line
  • 103.2 Process text streams using filters
  • 103.3 Perform basic file management
  • 103.4 Use streams, pipes and redirects
  • 103.5 Create, monitor and kill processes
  • 103.6 Modify process execution priorities
  • 103.7 Search text files using regular expressions
  • 103.8 Perform basic file editing operations using
    vi
  • Topic 104 Devices, Linux File systems, FHS
  • 104.1 Create partitions and filesystems
  • 104.2 Maintain the integrity of filesystems
  • 104.3 Control mounting and unmounting of
    filesystems
  • 104.4 Manage disk quotas
  • 104.5 Manage file permissions and ownership
  • 104.6 Create and change hard and symbolic links
  • 104.7 Find system files and place files in the
    correct location

19
LPIC-1 Exam 102 Chapters
  • Topic 105 Shells, Scripting and Data Management
  • 105.1 Customize and use the shell environment
  • 105.2 Customize or write simple scripts
  • 105.3 SQL data management
  • Topic 106 User Interfaces and Desktops
  • 106.1 Install and configure X11
  • 106.2 Setup a display manager
  • 106.3 Accessibility
  • Topic 107 Administrative Tasks
  • 107.1 Manage user and group accounts and related
    system files
  • 107.2 Automate system administration tasks by
    scheduling jobs
  • 107.3 Localisation and internationalisation

20
LPIC-1 Exam 102 Chapters
  • Topic 108 Essential System Services
  • 108.1 Maintain system time
  • 108.2 System logging
  • 108.3 Mail Tranfer Agent (MTA) basics
  • 108.4 Manage printers and printing
  • Topic 109 Networking Fundamentals
  • 109.1 Fundamentals of internet protocols
  • 109.2 Basic network configuration
  • 109.3 Basic network troubleshooting
  • 109.4 Configure client side DNS
  • Topic 110 Security
  • 110.1 Perform security administration tasks
  • 110.2 Setup host security
  • 110.3 Securing data with encryption

21
Method Of Installing Linux !
1- Using Virtual Machines (Vmware,Virtual
Box,Xen,VMware ESX Server) 2- Installing
Beside Windows
22
What are Virtual Machines ?
23
What are Virtual Machines ?
Applications of Virtual Machines 1- Client
Virtual Machines (VMware , Virtual Box) 2-
Virtual Servers (VMware ESX Server, Xen Server)
24
Sample of Virtual Machines
25
Open Source XenVirtual Server
26
What are Virtual Machines ? ESX Server
27
WorkShop Lets Install your Own Linux
28
Topic 101 System Architecture 101.1 Determine
and configure hardware settings 101.2 Boot the
system 101.3 Change runlevels and shutdown or
reboot system
29
Linux File System Hierarchy Standard
30
Linux File System Hierarchy Standard?????????
????? ???? ????? ??????
  • / Root
  • /boot
  • This contains the Kernel, Firmware and system
    related files.
  • /sbin
  • /bin
  • /lib
  • /dev
  • /etc (et cetera )
  • /home
  • /tmp (temporary files)
  • /var
  • /usr/local
  • /sys
  • /proc (process)

31
Linux File System Hierarchy Standard
/media A generic mount point for removable media
like CD-ROM, USB, Floppies etc /mnt A generic
mount point for temporary file systems. This
comes handy particulary when troubleshooting from
CDROM etc wherein you might have to mount the
Root file system and edit configurations. /opt A
rarely used directory in Linux for Optional
Software Packages. This is extensively used in
UNIX OS like Sun Solaris where the software
packages are installed /usr A sub hierarchy to
the root file system which is a User data
directory. Contains user specific utilities and
applications. /usr/sbin Contains Non-essential
Non-critical system binaries and network utilities
32
Linux File System Hierarchy Standard
/usr/local A sub hierarchy under the /usr
directory which has Local System specific data
including user and system binaries and their
libraries /var Variable data, such as logs,
databases, websites, and temporary spool
(e-mail..) files .The /var directory is mostly
mounted as a separate filesystem under the root
where in all the variable content like logs,
spool files for printers, crontab,at jobs, mail,
running process. /tmp A temporary file system
which hold temporary files which are cleared at
system reboot. There is also a /var/tmp directory
which holds temporary files too. the only
difference between the two is that /var/tmp
directory holds files that are protected at
system reboot. In other words, /var/tmp files are
not flushed upon a reboot
33
/proc (process filesystem)
/proc Virtual filesystem documenting kernel
and process status, mostly text files (e.g.,
uptime, network) /proc/PID/cmdline, which
contains the command which originally started the
process. /proc/PID/cwd, a symlink to the current
working directory of the process. /proc/PID/envir
on, a file containing the names and contents of
the environment variables that affect the
process. /proc/PID/exe, a symlink to the
original executable file, if it still exists (a
process may continue running after its original
executable has been deleted or replaced). /proc/P
ID/root, a symlink to the root path as seen by
the process /proc/PID/status, a file containing
basic information about a process including its
run state and memory usage.
34
Tools and utilities to list various hardware
information
  • modprobe
  • program to add and remove modules from the Linux
    Kernel
  • lsmod
  • list loaded modules.
  • lspci
  • lspci is a utility for displaying information
    about all PCI buses in the system and all devices
    connected to them.
  • lsusb
  • lsusb is a utility for displaying information
    about USB buses in the system and the devices
    connected to them.
  • hald(hal deamonis a computer program that runs
    in the background)
  • hald is a daemon that maintains a database of
    the devices connected to the system in real-time

35
Logs in Linux
  • What are logs?
  • Introduce With rsyslog and syslog
  • Common Linux log files name and usage
  • /var/log/message General message and system
    related stuff
  • /var/log/auth.log Authenication logs
  • /var/log/kern.log Kernel logs
  • /var/log/cron.log Crond logs (cron job)
  • /var/log/maillog Mail server logs
  • /var/log/qmail/ Qmail log directory (more
    files inside this directory)
  • /var/log/httpd/ Apache access and error logs
    directory
  • Introduce with some useful command
  • tail f /var/log/messages
  • head /var/log/messagesbootloader
  • cat /var/log/messages
  • dmesg (The program helps users to print out
    their bootup messages)

36
Linux bootloaders
  • What are bootloaders?
  • MBR
  • Types of bootloaders
  • Grub
  • Configuration file
  • /boot/grub/menu.lst
  • /boot/grub/grub.cfg
  • lilo(Linux Loader)
  • Configuration file
  • /etc/lilo.conf

37
Linux Runlevels
  • Debian Linux runlevels ID Description
  • 0 Halt
  • 1 Single-User mode
  • 2-5 Full Multi-User with console logins and
    display manager if installed
  • 6 Reboot
  • Red Hat Linux/Fedora runlevels ID Description
  • 0 Halt
  • 1 Single-User mode
  • 2 Not used/User-definable
  • 3 Multi-User mode, console logins only
  • 4 Not used/User-definable
  • 5 Multi-User mode, with display manager as well
    as console logins
  • 6 Reboot

38
Linux Start up and Run Levels
  • /etc/inittab
  • The Init Program
  • the kernel will start a program called init, if
    it finds it. The init process reads the file
    "/etc/inittab" and uses this file to determine
    how to create processes
  • /etc/init.d/
  • init PID?
  • Some Useful Commands
  • reboot
  • shutdown
  • telinit (same as example init 2)
  • runlevel

39
Best Sites of the Week
  • nixCraft
  • http//www.cyberciti.biz/
  • Linux Commands - A practical reference
  • http//www.pixelbeat.org/cmdline.html
  • Linux Command Line Cheat Sheets
  • http//www.scottklarr.com/topic/115/linux-unix-ch
    eat-sheets---the-ultimate-collection/
  • Linux Online Manual
  • http//linux.die.net
  • http//cb.vu/unixtoolbox.xhtml
  • http//linuxcommand.org/lts0040.php

40
Best of Networking open source software
2009 (BOSS 2009)
Cacti Cacti provides a complete graphing
framework for data of nearly every sort. It
includes templates to monitor a wide variety of
devices, from Linux and Windows servers to Cisco
routers and switches, and collections of
contributed templates cover an even greater
variety of hardware and software. There really is
no comparison to this tool in either the open
source or commercial world
41
Topic 102 Linux Installation and Package
Management
Ways of Installing Software on Linux Systems? 1-
Using Package Managers (apt ,yum) 2- Using
Source packages (example.tar.gz)
42
Topic 102 Linux Installation and Package
Management
  • Package Manager
  • APT (Advanced Packaging Tool)
  • YUM (Yellow Dog Updater Modified)
  • Debian Base Redhat Base Packages
  • .deb (example apache_1.3.31-6_i386.deb )
  • .rpm
  • Related Commands
  • /etc/apt/sources.list
  • apt-get install
  • apt-cache search
  • aptitude
  • Synaptic package manager (GUI front end for APT)
  • dpkg
  • dpkg-reconfigure
  • dselect
  • tasksel

43
Debian Linux apt package management cheat sheet
  • apt APT is acronym for Advanced Package Tool.
  • APT related config files
  • /etc/apt/sources.list Locations to fetch
    packages from.
  • /etc/apt/sources.list.d/ Additional source
    list fragments.
  • /etc/apt/apt.conf APT configuration file.
  • Related Commands
  • apt-get add a new package
  • apt-get install samba
  • apt-get remove remove the package called samba
    but keep the configuration files
  • apt-get remove samba
  • apt-get --purge remove (erase) package and
    configuration file
  • apt-get --purge remove samba
  • apt-get cache search remove (erase) package and
    configuration file
  • apt-cache search mc
  • apt-get update
  • apt-get upgrade

44
Debian Linux dpkg package management cheat sheet
  • dpkg Debian packaging tool
  • Related options
  • dpkg-reconfigure debFileName
  • dpkg i debFileName
  • dpkg --purge debFileName
  • dpkg l List packages matching given pattern.
  • -s Report status of specified
    package.
  • -L List files installed to your system
    from package-name.
  • -S Search for a filename from
    installed packages.
  • See man dpkg(8) for further details

45
Topic 103 GNU and Unix Commands
  • What is Linux SHELL ?
  • A shell is a piece of software that provides an
    interface for users to an operating system shell
    which provides access to the services of a
    kernel.
  • Shell is not part of system kernel, but uses the
    system kernel to execute programs, create files
    etc.
  • Shell is an command language interpreter that
    executes commands read from the standard input
    device
  • Operating system shells
  • command-line interface (CLI)
  • graphical user interface (GUI)

46
Topic 103 GNU and Unix Commands
  1. Bourne shell (sh)
  2. Almquist shell (ash)
  3. o Debian Almquist shell (dash)
  4. Bourne-Again shell (bash)
  5. Korn shell (ksh)
  6. Z shell (zsh)
  7. C shell (csh)
  8. eshell EMACS shell es Es shell
  9. esh (Unix) Easy Shell
  10. fish friendly interactive shell
  11. rc shell (rc) shell for Plan 9 from Bell Labs
    and Unix
  12. scsh (Scheme Shell)
  13. Stand-alone Shell (sash)

47
Topic 103 GNU and Unix Commands
  • Standard streams
  • stdin Standard input is data (often text) going
    into a program.
  • The program requests data transfers by use of the
    read operation.
  • stdoutStandard output is the stream where a
    program writes its output data
  • The program requests data transfer with the write
    operation
  • stderrStandard error is another output stream
    typically used by programs to output error
    messages or diagnostics

48
Topic 103 GNU and Unix Commands
  • echo display a line of text
  • pwd the pwd command (print working directory)
  • uname (short for unix name)
  • prints the name, version and other details about
    the current machine and the operating system
    running on it
  • uname -m ????? ?????? ?????
  • uname -r ????? ???? ? ???? ? ??????? ??? ??
    ?????
  • cat
  • cat /proc/cpuinfo
  • cat /proc/version
  • history Shows the command history
  • man

49
Manual Pages in Linux
Layout All man pages follow a common layout that
is optimized for presentation on a simple ASCII
text display. NAME The name of the command
or function, followed by a one-line description
of what it does. SYNOPSIS In the case of a
command, you get a formal description of how to
run it and what command line options it takes.
For program functions, a list of the parameters
the function takes and which header file contains
its definition. For experienced users, this may
be all the documentation they need. DESCRIPTION
A textual description of the functioning of the
command or function. EXAMPLES Some examples
of common usage. SEE ALSO A list of related
commands or functions.
50
Manual Pages in Linux
Usage man ltcommand_namegt Section Description 1
General commands 2 System calls 3 C library
functions 4 Special files (usually devices,
those found in /dev) and drivers 5 File formats
and conventions 6 Games and screensavers 7
Miscellanea 8 System administration commands
and daemons
51
Topic 103 GNU and Unix Commands
history An event designator is a reference to a
command line entry in the history list. ! Start a
history substitution, except when followed by a
blank, newline, or (. !n Refer to command line
n. !-n Refer to the current command line minus
n. !! Refer to the previous command. This is a
synonym for '!-1'. ! The entire command line
typed so far.
52
Topic 103 GNU and Unix Commands
  • cp
  • cp dir/ . ??? ???? ???? ???? ??? ????? ??
    ????????? ???? ??? ?? ???? ???? ?? ?? ?? ?????
  • cp -a /tmp/dir1 . ??? ???? ????????? ???? ???
    ?? ???? ???? ?? ?? ?? ?????
  • cp -a dir1 dir2??? ????????? ???? ( dir1 ) ??
    ????????? ???? ( dir2 ). ?? ??? dir1 ? dir2 ????
    ???? ????????? ??? ???? ? ???? ?? ???? ????
  • cp file file1????? ??? ? ????? ?? ???? ?? ?????
    ?????? ??. ?? ??? file1 ???? ???? ???? ??? ??
    ???? ????
  • find
  • find . -name 'my'
  • This searches in the current directory and below
    it, for files and directories with names starting
    with my
  • find . -name "my" -type f
  • This limits the results of the above search to
    only regular files, therefore excluding
    directories, special files, pipes, symbolic
    links, etc. my
  • find . -size 100k -a -size -500k
  • searching files with size between 100 kilobytes
    and 500 kilobytes.

53
Topic 103 GNU and Unix Commands
  • mkdir
  • mv (rename)
  • ls (list , options l ,-a , -R )
  • -l long format, displaying Unix file types,
    permissions, number of hard links, owner, group,
    size, date, and filename
  • -a lists all files in the given directory,
  • -R recursively lists subdirectories.
  • -d shows information about a symbolic link or
    directory
  • -t sort the list of files by modification time.
  • -h print sizes in human readable format. (e.g.,
    1K, 234M, 2G, etc.)
  • ls 0-9

54
Topic 103 GNU and Unix Commands
  • Linux Permissions
  • - --- --- ---
  • R read - 4
  • W write - 2
  • X execute - 1

55
Best of open source software
  1. Munin
  2. iptraf - Real-time Network Statistics
  3. tcpdump - Detailed Network Traffic Analysis
  4. Gnome System Monitor - Real-time Systems
    Reporting and Graphing
  5. Alien is a program that converts between the rpm,
    dpkg
  6. htop

56
Topic 103 GNU and Unix Commands
  • Linux Permissions
  • umask
  • mkdir
  • mkdir dir1
  • mkdir dir1 dir2
  • mkdir -p /tmp/dir1/dir2
  • df (Disk Free)
  • du (Disk Usage), -h ,-s
  • chmod
  • fdisk
  • chown
  • chown R webadminwebadmin /home/webadmin/test
  • bg
  • fg
  • jobs
  • kill

57
Topic 103 GNU and Unix Commands
  • ps
  • pstree
  • top
  • free
  • uptime
  • killall
  • wc (word Count)
  • nl (Number of Lines)
  • cut
  • paste
  • nohup

58
Topic 103 GNU and Unix Commands
  • nice
  • Runs a command at a lower or higher priority .
  • The nice value can range from 0 to 39, with 39
    being the lowest priority. For example, if a
    command normally runs at a priority of 20,
    specifying an increment of 5 runs the command at
    a lower priority, 25, and the command runs
    slower. The nice command does not return an error
    message if you attempt to increase a command's
    priority without the appropriate authority.
    Instead, the command's priority is not changed,
    and the system starts the command as it normally
    would.
  • nice n command
  • ps
  • renice
  • top

59
Topic 103 GNU and Unix Commands
  • grep,fgrep,egrep - print lines matching a pattern
  • grep command searches the given file for lines
    containing a match to the given strings or words.
    By default, grep prints the matching lines. Use
    grep to search for lines of text that match one
    or many regular expressions, and outputs only the
    matching lines
  • grep command syntax
  • grep 'word' filename
  • grep 'string1 string2' filename
  • cat otherfile grep 'something'
  • command grep 'something
  • Use grep to search file
  • grep boo /etc/passwd
  • grep --color vivek /etc/passwd
  • egrep same as grep E
  • fgrep same as grep -F

60
Topic 103 GNU and Unix Commands
  • Examples of using the grep command
  • To search a file for a simple text string
  • grep copying help
  • This searches the file help for the string
    copying and displays each line on your terminal.
  • To search a file using regular expression
  • grep -n 'dDon\'t' tasks
  • This uses a regular expression to find and
    display each line in the file tasks that contains
    the pattern don't or Don't. The line number for
    each line is also displayed.
  • The expression is quoted to prevent the shell
    expanding the metacharacters , and '. Double
    quotes are used to quote the single quote in
    dDon't.

61
Topic 103 GNU and Unix Commands
  • To use the output of another command as input to
    the grep command
  • ls -l grep 'd........x'
  • This lists all the directories in the current
    directory for which other users have execute
    permission.
  • The expression is quoted to prevent the shell
    interpreting the metacharacter.
  • To redirect the results of a search to a file
  • grep Smith /etc/passwd gt smurffs
  • This searches the passwd file for each occurrence
    of the name Smith and places the results of this
    search in the file smurffs. There being a lot of
    Smiths everywhere this is quite a large file

More infohttp//www.cyberciti.biz/faq/howto-use-
grep-command-in-linux-unix/
62
Topic 103 GNU and Unix Commands
  • nohup
  • Most of the time you login into remote server
    via ssh. If you start a shell script or command
    and you exit (abort remote connection), the
    process/command will get killed. Sometime job or
    command takes a long time. If you are not sure
    when the job will finish, then it is better to
    leave job running in background. However, if you
    logout the system, the job will be stopped. What
    do you do?
  • nohup Syntax
  • nohup command-name
  • example
  • nohup find / -type f name tes gt out.txt

63
Topic 103 GNU and Unix Commands
  • sed
  • sed (stream editor) is a Unix utility that (a)
    parses text files and (b) implements a
    programming language which can apply textual
    transformations to such files. It reads input
    files line by line (sequentially), applying the
    operation which has been specified via the
    command line (or a sed script), and then outputs
    the line.
  • sed -e 's/foo/bar/' myfile.txt
  • cat /etc/passwd sed -e '1,15d
  • The d command tells sed to delete lines 115 of
    the input stream,
  • cut
  • cut is a Unix command line utility which is used
    to extract sections from each line of input
    usually from a file.
  • cut -d -f 5- /etc/passwd

64
Topic 103 GNU and Unix Commands
  • Compression in linux
  • tar
  • gzip
  • gunzip
  • bzip2
  • zip
  • Types of archives
  • .tar.gz
  • .tar
  • .tar.bz2
  • .tgz
  • Example
  • gzip myfile
  • Compresses the file myfile, making it
    myfile.gz. Note. When doing this the original
    file will no longer exist on the drive
  • gunzip -f myfile.gz
  • Uncompress the file myfile.gz and if the
    uncompressed file(s) already exist force an
    overwrite. When doing this the file myfile.gz
    will no longer be on the drive.

65
Topic 103 GNU and Unix Commands
tar In computing, tar (derived from tape archive
and commonly referred to as "tarball") is both a
file format and the name of a program used to
handle such files .tgz is equivalent to
.tar.gz .tbz and .tb2 is equivalent to
.tar.bz2 .taz is equivalent to .tar.Z .tlz is
equivalent to .tar.lzma .txz is equivalent to
.tar.xz (Xz compression is not yet widely
supported by common tar distributions January
2010)
Moreinfo http//en.wikipedia.org/wiki/List_of_arc
hive_formats http//en.wikipedia.org/wiki/Comparis
on_of_file_archivers
66
Topic 103 GNU and Unix Commands
tar command options -c Create new archive, or
overwrite an existing archive, adding the
specified files to it. -r Append the
named new files to existing archive. Note that
this will only work on media on
which an end-of-file mark can be over-
written. -t List contents of archive. If
any files are named on the command
line, only those files will be listed. -x
Extract files from archive. If any files are
named on the com- mand line, only
those files will be extracted from the archive.
The file arguments may be specified as
glob patterns (see glob(3) for more
information), in which case tar will extract all
archive members that match each
pattern. -j Compress archive using bzip2. The
bzip2 utility must be in- stalled
separately. -z Compress archive using
gzip(1). -w Interactively rename files. This
option causes tar to prompt the user
for the filename to use when storing or
extracting files in an archive.
67
Topic 103 GNU and Unix Commands
Linux Compression Comparison (GZIP vs BZIP2 vs
LZMA vs ZIP vs Compress)
68
Topic 103 GNU and Unix Commands
  • Introduce with some Editors in Linux
  • mcedit Full featured terminal text editor for
    Unix-like systems.
  • Mined Powerful text editor with extensive
    Unicode and CJK support, with mouse
    control and menus.
  • Nano An open source clone of Pico.
  • ne - a minimal, modern replacement for vi.
  • gedit a simple GNOME text editor, fairly
    equivalent to KEdit
  • KWrite default editor on KDE, more
    sophisticated than KEdit
  • Notepad a tabbed text editor
  • vi
  • vim
  • pico

More info http//en.wikipedia.org/wiki/List_of_te
xt_editors
69
Topic 103 GNU and Unix Commands
  • Vi editors
  • The name vi is derived from the shortest
    unambiguous abbreviation for the command visual
    in ex the command in question switches the line
    editor ex to visual mode. The name vi is
    pronounced /'vi?'a?, but never "six" as in the
    Roman numeral VI.
  • Vi has two modes insertion mode and command mode
  • Quitting
  • x Exit, saving changes
  • q Exit as long as there have been no changes
  • ZZ Exit and save changes if any have been made
  • q! Exit and ignore any changes
  • Motion
  • h Move left
  • j Move down
  • k Move up
  • l Move right

Moreinfo http//www.lagmonster.org/docs/vi.html
70
Topic 103 GNU and Unix Commands
Moreinfo http//en.wikipedia.org/wiki/List_of_tex
t_editors
71
Topic 103 GNU and Unix Commands
  • Usage of Vi plugin in editors MSWord

72
Best of open source software List of Linux
Security Audit
  1. Network Vulnerability Audits
  2. Nessus (YoLinux tutorial) - Remote security
    scanner - This is my favorite security audit
    tool!! Checks service exploits and
    vulnerabilities.
  3. ISIC - IP Stack Integrity Checker
  4. Argus - IP network transaction auditing tool.
    This daemon promiscuously reads network datagrams
    from a specified interface, and generates network
    traffic status records
  5. SAINT - Finds computers on the network, port
    scans and does a vulnerability check and outputs
    a report. - Commercial product.
  6. InterSect Alliance - Intrusion analysis.
    Identifies malicious or unauthorized access
    attempts.
  7. Linuxforce AdminForce CGI Auto Audit - CGI
    script analyzer to find security deficiencies.

More info http//www.yolinux.com/TUTORIALS/LinuxS
ecurityTools.html http//www.securityfocus.com/inf
ocus/1423
73
Topic 104 Devices, Linux Filesystems,
Filesystem Hierarchy Standard
  • ext2
  • second extended filesystem is a file system for
    the Linux kernel
  • ext3
  • The ext3 or third extended filesystem is a
    journaled file system that is commonly used by
    the Linux kernel
  • Ext4
  • The ext4 or fourth extended filesystem is a
    journaling file system developed as the successor
    to ext3.
  • xfs
  • XFS is a high-performance journaling file system
    created by Silicon Graphics, originally for their
    IRIX operating system and later ported to Linux
    kernel. XFS is particularly proficient at
    handling large files and at offering smooth data
    transfers.
  • reiserfs v3
  • vfat
  • hpfs
  • nfs

More info Program to mount linux Partitions in
Windows http//www.fs-driver.org/screenshots.html
74
Topic 104 Devices, Linux Filesystems,
Filesystem Hierarchy Standard
  • fdisk (for fixed disk), Partition table
    manipulator for Linux
  • cfdisk
  • parted
  • mkfs
  • mkfs ("make a filesystem") is the standard Unix
    command for formatting a disk partition with a
    specific filesystem. The basic syntax is
  • mkfs -t type device
  • mkswap
  • mkswap - set up a Linux swap area
  • After creating the swap area, you need the swapon
    command to start using it.

75
Topic 104 Devices, Linux Filesystems,
Filesystem Hierarchy Standard
  • du (Disk Usage h s )
  • df (Disk free)
  • fsck
  • The system utility fsck (for "file system
    check") is a tool for checking the consistency of
    a file system in Unix and Unix-like operating
    systems such as Linux.
  • Example fsck /dev/sdb1
  • In Windows CHKDSK and SCANDISK
  • e2fsck
  • check a Linux ext2/ext3 file system
  • e2fsck is used to check a Linux second extended
    file system (ext2fs).
  • mke2fs
  • create an ext2/ext3 filesystem
  • debugfs
  • ext2/ext3 file system debugger

76
Topic 104 Devices, Linux Filesystems,
Filesystem Hierarchy Standard
  • dumpe2fs
  • dump ext2/ext3 filesystem information
  • -b print the bad blocks of the filesystem.
  • -h Display only the superblock information.
  • dumpe2fs -h /dev/fd0
  • tune2fs
  • To tune an extended filesystem, use tune2fs.
  • tune2fs options device
  • tune2fs -l /dev/fd0

77
Topic 104 Devices, Linux Filesystems,
Filesystem Hierarchy Standard
  • /etc/fstab (file systems table)
  • The fstab file typically lists all used disks and
    disk partitions, and indicates how they are to be
    used or otherwise integrated into the overall
    system's file system.
  • 2.The mount point, where the data is to be
    attached to the filesystem.
  • 3.The filesystem type, or the algorithm used to
    interpret the filesystem.
  • 4.Options, including if the filesystem should be
    mounted at boot
  • 5.dump-freq adjusts the archiving schedule for
    the partition (used by dump).
  • 6.pass-num Controls the order in which fsck
    checks the device/partition for errors at boot
    time. The root device should be 1. Other
    partitions should be 2, or 0 to disable checking.

78
Topic 104 Devices, Linux Filesystems,
Filesystem Hierarchy Standard
  • /media
  • mount
  • mount options -t vfstype -o options device
    dir
  • mount /dev/sdb1 /mnt/flash
  • umount
  • Detach a filesystem

79
Topic 104 Devices, Linux Filesystems,
Filesystem Hierarchy Standard
  • Quotas
  • On a system, root can manage the usage of disk
    space per user and per filesystems.
  • The two limits that can be setup are
  • The soft limit (soft ) specifies the maximum
    amount of disk usage a quota user is allowed to
    have.
  • The hard limit (hard ) specifies the absolute
    limit on the disk usage a quota user can't go
    beyond it. There is also the possibility to setup
    a grace period that will enforce the soft limit
    only after an amount of time specified.

80
Topic 104 Devices, Linux Filesystems,
Filesystem Hierarchy Standard
  • Setting up quotas for users
  • 1) The keyword usrquota or/and grpquota must be
    added in file /etc/fstab for the partition
    interested.
  • 2) Add in each root filesystems the file
    user.quota or/and group.quota.
  • Only root can do the quota administration and
    once the empty files have been created some disk
    quota can be set such as
  • Soft limitation on number of files and inodes.
  • Hard limitation on number of files and inodes if
    the grace time is set.
  • More info on how to enable quotas
  • http//en.wikibooks.org/wiki/LPI_Linux_Certificati
    on/Managing_Disk_Quota

81
Topic 104 Devices, Linux Filesystems,
Filesystem Hierarchy Standard
  • grace period
  • Soft limits, on the other hand, can be exceeded
    for a limited amount of time. This period of time
    is known as the grace period, which is one week
    by default. If a user stays over his or her soft
    limit longer than the grace period, the soft
    limit will turn into a hard limit and no further
    allocations will be allowed. When the user drops
    back below the soft limit, the grace period will
    be reset.
  • edquota
  • Customize the disk quota limits
  • repquota
  • To display a quota report, use repquota
  • quotaon
  • Enable quota on the disk

82
Topic 104 Devices, Linux Filesystems,
Filesystem Hierarchy Standard
  • chmod
  • umask
  • chown
  • chgrp (change group)
  • change the file group ownership 
  • chgrp group target1 target2 ..
  • 1- The group parameter indicates the new group
    with which the targets should be associated. It
    may either be a symbolic name or an identifier.
  • 2-The target1 parameter indicates the files or
    directories for which the change should be made.
  • 3-The target2 parameter indicates optional
    additional files or directories for which the
    change should be made.

83
Topic 104 Devices, Linux Filesystems,
Filesystem Hierarchy Standard
  • ln (creates links between files.)
  • To make a soft (symbolic) link "hello" to the
    file /home/razavi/world"
  • ln -s /home/razavi/world hello
  • find
  • find / \( -name '.txt' -o -name '.doc' -o
    -size 5M \)
  • locate
  • locate reads one or more databases prepared by
    updatedb(8) and writes file names matching at
    least one of the PATTERNs to standard output, one
    per line
  • updatedb
  • whereis
  • whereis searches the normal executable and man
    page locations for a specified file.

84
Topic 104 Devices, Linux Filesystems,
Filesystem Hierarchy Standard
  • which
  • which searches the locations in your PATH
    variable for a specified file.
  • type
  • type is a Unix command that displays how a name
    would be interpreted if used as a command.
  • /etc/updatedb.conf

85
Topic 105 Shells, Scripting and Data Management
  • /etc/profile
  • /etc/profile contains the system default
    settings for users who login using the Bourne
    shell, "/bin/sh". When these users login, the
    Bourne shell runs the commands in this file
    before giving the shell prompt to the user. Most
    of these commands are variable assignments which
    configure the behavior of the shell.
  • /.bash_profile
  • /.bash_login
  • The /.bash_login file defines default file
    protection by setting the umask
  • /.profile
  • /.bashrc
  • The /.bashrc file is used to define a bunch of
    user-specific aliases and functions and personal
    environment variables. It first reads
    /etc/bashrc, which describes the default prompt
    (PS1) and the default umask value. After that,
    you can add your own settings. If no /.bashrc
    exists, /etc/bashrc is read by default.
  • /.bash_logout

86
Topic 105 Shells, Scripting and Data Management
  • /.profile
  • In the absence of /.bash_profile and
    /.bash_login, /.profile is read.
  • /.bashrc
  • The /.bashrc file is used to define a bunch of
    user-specific aliases and functions and personal
    environment variables. It first reads
    /etc/bashrc, which describes the default prompt
    (PS1) and the default umask value. After that,
    you can add your own settings. If no /.bashrc
    exists, /etc/bashrc is read by default.
  • /.bash_logout
  • Upon logout, the commands in /.bash_logout are
    executed, which can for instance clear the
    terminal, so that you have a clean window upon
    logging out of a remote session, or upon leaving
    the system console

87
Topic 105 Shells, Scripting and Data Management
  • /etc/profile
  • env (display environment, set environment for
    process )
  • export
  • set
  • unset
  • /.bash_profile
  • /.bash_login
  • /.profile
  • /.bashrc
  • /.bash_logout
  • alias
  • lists

88
Topic 105 Shells, Scripting and Data Management
  • SQL data management
  • mySQL
  • PostgreSQL
  • MSSQL Server
  • MS Access
  • FoxPro
  • Oracle

89
Topic 105 Shells, Scripting and Data Management
  • Structured Query Language
  • insert
  • update
  • select
  • select from tablename
  • delete
  • from
  • where
  • group by
  • order by
  • join

90
Topic 107 Administrative Tasks
  • Understanding fields in /etc/passwd
  • 1.Username It is used when user logs in. It
    should be between 1 and 32 characters in length.
  • 2.Password An x character indicates that
    encrypted password is stored in /etc/shadow file.
  • 3.User ID (UID) Each user must be assigned a
    user ID (UID). UID 0 (zero) is reserved for root
    and UIDs 1-99 are reserved for other predefined
    accounts. Further UID 100-999 are reserved by
    system for administrative and system
    accounts/groups.
  • 4.Group ID (GID) The primary group ID (stored in
    /etc/group file)
  • 5.User ID Info,6.Home directory
  • 7.Command/shell The absolute path of a command
    or shell (/bin/bash). Typically, this is a shell.

91
Topic 107 Administrative Tasks
  • Understanding /etc/shadow file
  • 1.User name It is your login name
  • 2.Password It your encrypted password.
  • 3.Last password change (lastchanged) Days since
    Jan 1, 1970 that password was last changed
  • 4.Minimum The minimum number of days required
    between password changes i.e. the number of days
    left before the user is allowed to change his/her
    password
  • 5.Maximum The maximum number of days the
    password is valid (after that user is forced to
    change his/her password)
  • 6.Warn The number of days before password is to
    expire that user is warned that his/her password
    must be changed
  • 7.Inactive The number of days after password
    expires that account is disabled
  • 8.Expire days since Jan 1, 1970 that account is
    disabled i.e. an absolute date specifying when
    the login may no longer be used

92
Topic 107 Administrative Tasks
  • Understanding /etc/group File
  • It stores group information or defines the user
    groups i.e. it defines the groups to which users
    belong. There is one entry per line, and each
    line has the format (all fields are separated by
    a colon ()
  • 1.group_name It is the name of group. If you
    run ls -l command, you will see this name printed
    in the group field.
  • 2.Password Generally password is not used,
    hence it is empty/blank. It can store encrypted
    password. This is useful to implement privileged
    groups.
  • 3.Group ID (GID) Each user must be assigned a
    group ID. You can see this number in your
    /etc/passwd file.
  • 4.Group List It is a list of user names of
    users who are members of the group. The user
    names, must be separated by commas.

93
Topic 107 Administrative Tasks
  • More about a user groups
  • Users on Linux systems are assigned to one or
    more groups for following reasons
  • To share files or other resource with a small
    number of users
  • Ease of user management
  • Ease of user monitoring
  • Group membership is perfect solution for large
    Linux (UNIX) installation.
  • Group membership gives you or your user special
    access to files and directories or devices which
    are permitted to that group

94
Topic 107 Administrative Tasks
  • The /etc/skel Directory
  • The /etc/skel directory contains files and
    directories that are automatically copied over to
    a new user's home directory when such user is
    created by the useradd program.
  • Several user configuration files are placed in
    /etc/skel by default when the operating system is
    installed. Typically they might include
    .bash_profile, .bashrc, .bash_logout, dircolors,
    .inputrc and .vimrc.
  • SKEL/etc/skel.

95
Topic 107 Administrative Tasks
  • /etc/crontab
  • is system crontabs file. Usually only used by
    root user or daemons to configure system wide
    jobs. All individual user must must use crontab
    command to install and edit their jobs as
    described above. /var/spool/cron/ or
    /var/cron/tabs/ is directory for personal user
    crontab files. It must be backup with users home
    directory.
  • Directory Description
  • /etc/cron.d/ Put all scripts here and call them
    from /etc/crontab file.
  • /etc/cron.daily/ Run all scripts once a day
  • /etc/cron.hourly/ Run all scripts once an hour
  • /etc/cron.monthly/ Run all scripts once a month
  • /etc/cron.weekly/ Run all scripts once a week

96
Topic 107 Administrative Tasks
  • /etc/cron.d,daily,hourly,monthly,weekly
  • /etc/at.deny
  • /etc/at.allow
  • /etc/crontab
  • /etc/cron.allow
  • /etc/cron.deny
  • /var/spool/cron/
  • Any files in /var/spool/cron or
    /var/spool/cron/crontabs. Those are individual
    files created by any user using the cron
    facility. Each file is given the name of the
    user. You will almost always find a root file in
    /var spool/cron/root. If the user account named
    jinx is using cron, you will also find a jinx
    file as /var/spool/cron/jinx.
  • crontab

97
Topic 107 Administrative Tasks
  • at
  • at - execute commands at a later time
  • Run jobs at specific times
  • atrm
  • Remove Jobs
  • atrm job...
  • at r job
  • atq

98
Topic 107 Administrative Tasks
  • /etc/timezone
  • /etc/localtime
  • /usr/share/zoneinfo
  • Environment variables
  • LC_
  • LC_ALL

99
Topic 107 Administrative Tasks
  • /usr/bin/locale
  • locale - Description of multi-language support
  • tzselect
  • tzconfig
  • date
  • e.g date Y/m/d
  • iconv

100
Topic 108 Essential System Services
  • /usr/share/zoneinfo
  • /etc/ntp.conf
  • hwclock(hardware Clock)
  • ntpd
  • ntpdate,ntp (package Command name)
  • pool.ntp.org

101
Topic 108 Essential System Services Mail Tranfer
Agent (MTA) basics
  • Common Open Source Mail Servers

102
Topic 108 Essential System Services Manage
printers and printing
  • CUPS configuration files, tools and utilities
  • /etc/cups
  • lpd legacy interface (lpr, lprm, lpq)
  • Installing CUPS on Debain Based Distros
  • apt-get install cupsys
  • CUPS Port http//localhost631

103
Topic 109 Networking Fundamentals Fundamentals
of internet protocols
  • /etc/services
  • the configuration file /etc/services maps port
    numbers to named services
  • ftp
  • telnet
  • host (The static table lookup for host names)
  • ping
  • dig (DNS Lookup utility)
  • traceroute
  • traceroute is a computer network tool used to
    show the route taken by packets across an IP
    network
  • tracepath

104
Topic 109 Networking Fundamentals Fundamentals
of internet protocols
  • /etc/hostname
  • /etc/hosts
  • /etc/resolv.conf
  • ifconfig (shows network adapters)
  • ifup
  • ifdown
  • route
  • /etc/nsswitch.conf (name service switch)

105
  • exec
  • find . -name "rc.conf" -print
  • This command will search in the current
    directory and all sub directories for a file
    named rc.conf.
  • Note The -print option will print out the path
    of any file that is found with that name. In
    general -print wil print out the path of any file
    that meets the find criteria.
  • find . -name "rc.conf" -exec chmod or '' \
  • The \ argument indicates the exec command line
    has ended.
  • find . -exec grep "www.rayanfarmad.ir" '' \
    -print
  • This command will search in the current
    directory and all sub directories. All files that
    contain the string will have their path printed
    to standard output.

106
  • The inetd - /etc/inetd.conf file
  • inetd, called also the super server, will load a
    network program based upon a request from the
    network. The inetd.conf file tells inetd which
    ports to listen to and what server to start for
    each port.
  • The first thing to look at as soon as you put
    your Linux system on ANY network is what services
    you need to offer. Services that you do not need
    to offer should be disabled and uninstalled so
    that you have one less thing to worry about, and
    attackers have one less place to look for a hole.
    Look at your /etc/inetd.conf file to see what
    services are being offered by your inetd program.
    Disable what you do not need by commenting them
    out by adding a at the beginning of the line,
    and then sending your inetd process a SIGHUP
    command to update it to the current inetd.conf
    file.
  • Restart inetd
  • killall -HUP inetd

107
  • SSH
  • /etc/ssh_config
  • /etc/sshd_config
  • /etc/ssh_known_hosts
  • RSA
  • In cryptography, RSA (which stands for Rivest,
    Shamir and Adleman who first publicly described
    it) is an algorithm for public-key cryptography.
    It is the first algorithm known to be suitable
    for signing as well as encryption, and was one of
    the first great advances in public key
    cryptography. RSA is widely used in electronic
    commerce protocols, and is believed to be secure
    given sufficiently long keys and the use of
    up-to-date implementations.

108
In a world without any fences or walls, Who
needs gates or windows ?
109
(No Transcript)
Write a Comment
User Comments (0)
About PowerShow.com