104
Linux Arti Srivastava

Linux training

Embed Size (px)

DESCRIPTION

Introduction of Linux – History, Distributions Exploring Command line tools – shells, redirection, pipes Software Management – RPM, dpkg Hardware configuration– modprobe, lspci, lsmod, insmod, rmmod Managing Files – mkdir, cp, rm, grep, find Administering the system – useradd, usermod, shutdown, crontab, chown Networking – ifconfig, route, nslookup, ping, samba, ftp, http, mail, ssh, scp

Citation preview

Page 1: Linux training

Linux

Arti Srivastava

Page 2: Linux training

2

Agenda

1. Introduction of Linux – History, Distributions

2. Exploring Command line tools – shells, redirection, pipes

3. Software Management – RPM, dpkg

4. Hardware configuration– modprobe, lspci, lsmod, insmod, rmmod

5. Managing Files – mkdir, cp, rm, grep, find

6. Administering the system – useradd, usermod, shutdown, crontab, chown

7. Networking – ifconfig, route, nslookup, ping, samba, ftp, http, mail, ssh, scp

Page 3: Linux training

3

1. Introduction of Linux – History, Distributions

Page 4: Linux training

History

4

In 80’s, Microsoft’s DOS was the dominated OS for PC

Apple MAC was better, but expensive

UNIX was much better, but much, much more expensive. Only for minicomputer for commercial applications

People were looking for a UNIX based system, which is cheaper and can run on PC

Both DOS, MAC and UNIX were proprietary, i.e., the source code of their kernel is protected

No modification is possible without paying high license fees

Page 5: Linux training

GNU

5

Established in 1984 by Richard Stallman, who believes that software should be free from restrictions against copying or modification in order to make better and efficient computer programs

GNU is a recursive acronym for “GNU's Not Unix” Aim at developing a complete Unix-like operating system which is free for copying and modificationCompanies make their money by maintaining and distributing the software, e.g. optimally packaging the software with different tools (Redhat, Slackware, Mandrake, SuSE, etc)Stallman built the first free GNU C Compiler in 1991. But still, an OS was yet to be developed

Page 6: Linux training

Begin Linux

6

Andrew Tanenbaum developed Minix, a simplified version of UNIX that runs on PC

In Sept 1991, Linus Torvalds, a second year student of Computer Science at the University of Helsinki, developed the preliminary kernel of Linux, known as Linux version 0.0.1

Soon more than a hundred people joined the Linux camp. Then thousands. Then hundreds of thousands

It was licensed under GNU General Public License, thus ensuring that the source codes will be free for all to copy, study and to change.

Page 7: Linux training

7

At 25/11/2012 08:31pm, there are 118,240 users and 95,204 machines registered.My guess at the number of Linux users: 63,195,939

World population: 7,096,950,557Internet users: 2,478,272,151

– Taken from linuxcounter.net

Page 8: Linux training

Major Software from GNU Project

8

Gcc : c compilerG++: C++ compilerGdb: source code debuggerGNU make: a version of makeBison: a parser generatorBash: command shellGNU emacs: a text editor

Page 9: Linux training

Linux directory structure

9

/ - root directory/bin – essential programs/boot – boot information for linux/dev – includes all devices/mnt – storage devices are mounted/proc – fluid data and status of kernel/sbin – sys admin software /etc – admin related config files and folders/home/lib/tmp/usr/var

Page 10: Linux training

Linux Variant

10

SuseRedhatDebianMandrakeUbuntuCentosScientificOS

Page 11: Linux training

Desktop Applications

11

Word processing (OpenOffice, Koffice)Programming (C, C++, Perl, Python, Java, PHP)Graphics (GIMP)Web browsers (Mozilla, Konquerer)Email (Evolution, Mozilla, KMail)Audio (amarok)Video (mplayer)Games (MAME)

Page 12: Linux training

Linux continue to grow…

12

Mobile OS: Android is Linux based Major Virtualization flavour: Base kernel is Linux

Citrix Xen Vmware

Cloud solution - Openstack

Page 13: Linux training

13

Page 14: Linux training

14

2. Exploring Command line tools – shells, redirection, pipes

Page 15: Linux training

Shell

15

Bash – Baurne Again Shell (Default Shell)

Csh

Tcsh

Zsh

In GUI – xterm, kconsole

Page 16: Linux training

Shell Configuration Files

16

Login config files: ~/.bashrc

~/.profile

~/.bash_login

~/.bash_logout

Global configuration file /etc/profile

/etc/bash.bashrc

Shell variable Using Environment variables: env

PATH

alias

set

unset

Page 17: Linux training

Commands

17

Change the working directory – cd, cd~, cd /, cd /var/log

Display the working directory – pwd

Display a line of text – echo Hello

Execute a program – exec myprog

Time an operation – time lsof Total execution time, user cpu time, system cpu time

Set options – environment variables

Terminate the shell Exit

logout

Page 18: Linux training

MAN Page

18

1 Executable programs and shell commands

2 System calls provided by the kernel

3 Library calls provided by program libraries

4 Device files (usually stored in /dev)

5 File formats

6 Games

7 Miscellaneous (macro packages, conventions, and so on)

8 System administration commands (programs run mostly or exclusively

by root)

9 Kernel routines

Page 19: Linux training

Redirection

19

> : Creates a new file containing standard output. If the specified file exists, it’s

overwritten.

>> : Appends standard output to the existing file. If the specified file doesn’t exist, it’s created.

2> : Creates a new file containing standard error. If the specified file exists, it’s

overwritten.

2>> : Appends standard error to the existing file. If the specified file doesn’t exist,

it’s created.

&> : Creates a new file containing both standard output and standard error. If the

specified file exists, it’s overwritten.

< : Sends the contents of the specified file to be used as standard input.

<< : Accepts text on the following lines as standard input.

Page 20: Linux training

Redirection continued…

20

<> : Causes the specified file to be used for both standard input and standard

output.

tee command

View the command and send the output to another file

lsmod | tee lsmod.txt

Page 21: Linux training

Pipes

21

ps aux | grep apache

xargs

find ./ -name “*~” | xargs rm

Page 22: Linux training

Less is more

22

more

less

Page 23: Linux training

23

3. Software Management – RPM, dpkg, yum, processes

Page 24: Linux training

Package Concepts

24

Packages: collection of files

Installed file database

Dependencies

Checksums

Upgrades and uninstallation

Package naming: samba-4.0.12-24.i386.rpm– Package name

– Version no

– Build no

– arhitecture

Page 25: Linux training

RPM Operations

25

-i : Installs a package;

-U : Installs a new package or upgrades an existing one

-F or --freshen : Upgrades a package only if an earlier version already exists

-q : Queries a package—finds if a package is installed, what files it contains, and so on

-V or --verify : Verifies a package—checks that its files are present and unchanged

since installation

-e : Uninstalls a package

Page 26: Linux training

rpm examples

26

rpm -qa -> lists all the installed packages

rpm -qc {pname} -> list configuartion file names for given package

rpm -qi {pnane} -> Give details of package

rpm -ql {pname} -> lists the files in a package

rpm -qR {pname} -> Lists package dependencies

rpm -qf filename -> List the package name of given file

rpm -qpl {pname} -> lists all the files in a package

rpm -qp {pname} -> list the package with given pname(*/?)

rpm -Va -> Verify all the installed packages

rpm -V {pname} -> Verify specify package

rpm -V -f {filename} {packagename} -> Verify a specified file in a package

Page 27: Linux training

rpm continued…

27

extracting data from rpms – rpm2cpio

$ rpm2cpio XXXsrc.rpm > xxx.cpio

$cpio –i –make-directories < xxx.cpio

$rpm2cpio xxxsrc.rpm | cpio –i –make-directories

Page 28: Linux training

dpkg dpkg –i xxx.deb

dpkg –r xxx.deb

apt-get install xxx

Page 29: Linux training

dpkg

dselect utility – menu driven

aptitude install/update/remove

/etc/dpkg/dpkg.cfg and ~/.dpkg.cfg,

/etc/apt/apt.conf(controls dselect and apt)

Page 30: Linux training

Yum

/etc/yum.repos.d

/etc/yum.conf

Yum client Redhat 5: yum

Sles10 : zypper

Sles11 : rug

Yum installation Setting the yum repo

install, upgrade, uninstall

Try this: http://linux.dell.com/repo/hardware/

Page 31: Linux training

alien

Covert packages from one format to another

Formats are:

Linux standard base

RPM

deb

stampede(.slp)

Solaris(.pkg)

Slackware(.tgz)

# alien --to-rpm --scripts ./mypkg.deb

Page 32: Linux training

Library management

/etc/ld.so.conf

/etc/ld.so.conf.d/*.conf

Temporarily changing the library path LD_LIBRARY_PATH

$ export LD_LIBRARY_PATH=/usr/local/testlib:/opt/newlib

ldd Displaying shared library dependencies : ldd /bin/cat

Page 33: Linux training

Understanding the kernel

uname –n -> hostname

uname –s -> kernel name

uname –v -> kernel version

uname –r -> kernel release

uname –m -> machine option

uname –p -> Processor

uname –o -> Operating system

uname –i -> Hardware platform

uname –a -> all information

Page 34: Linux training

Process – ps output meaning(columns)

Username

Process ID

Parent Process ID

TTY – identifying terminal

Cpu time

Cpu priority

memory use

Command

Page 35: Linux training

Other Process related commands

Dynamic variant of process – top

nice : Run a program with modified scheduling priority. Priority ranges from

-20(most favorable) to +19(least favorable)

renice : alter priority of running processes

kill

nohup

killall

Page 36: Linux training

36 Confidential

4. Hardware configuration– modprobe, lspci, lsmod, insmod, rmmod

Page 37: Linux training

Hardware

BIOS – resides on the motherboard in ROM – EEPROM/Flash memory

When computer is turned on- BIOS performs POST and initializes hardware and then load boot loader

IRQ - An interrupt request (IRQ), or interrupt, is a signal sent to the CPU instructing it to suspend its current activity and to handle some external event such as keyboard input. /proc/interrupts

I/O addresses (also referred to as I/O ports) are unique locations in memory that are reserved for communications between the CPU and specific physical hardware devices. Like IRQs, These are commonly associated with specific devices and should not ordinarily be shared.

DMA Addresses - Direct memory addressing (DMA) is an alternative method of communication to I/O ports. Rather than have the CPU mediate the transfer of data between a device and memory, DMA permits the device to transfer data directly, without the CPU’s attention. The result can be lower CPU requirements for I/O activity, which can improve overall system performance.

/proc/dma

Page 38: Linux training

Common Linux Devices• Linux Device Windows Name Typical IRQ I/O Address

• /dev/ttyS0 COM1 4 0x03f8

• /dev/ttyS1 COM2 3 0x02f8

• /dev/ttyS2 COM3 4 0x03e8

• /dev/ttyS3 COM4 3 0x02e8

• /dev/lp0 LPT1 7 0x0378-0x037f

• /dev/lp1 LPT2 5 0x0278-0x027f

• /dev/fd0 A: 6 0x03f0-0x03f7

• /dev/fd1 B: 6 0x0370-0x0377

Page 39: Linux training

Coldplug and Hotplug devices

Colplug devices – Components internal to the computer such as memory, CPU, pci cards etc. resides on the motherboard in ROM – EEPROM/Flash memory

Hotplug devices – Devices which can be added/removed when the system is in running state.

Page 40: Linux training

Configuring expansion cards

lspci

setpci

• /usr/share/misc/pci.ids

Page 41: Linux training

Learning about kernel modules

lsmod

insmod

modprobe

rmmod

modinfo

Page 42: Linux training

Configuring USB devices

USB basics USB 1.0 and USB 1.1 : 12Mbps

USB 2.0 : 48Mbps

USB 3.0 : 3.2 Gbps

USB devices: Scanner, printer, mice, digital camera, keyboard, speakers etc.

lsusb

/proc/bus/usb

usbmgr

/etc/usbmgr/usbmgr.conf

Page 43: Linux training

Systems Run Levels

0: Halt

1: single User mode

2: Multi user mode without NFS

3: Full multi user mode

4: unused

5: X11

6: reboot

Page 44: Linux training

Filesystems

fdisk

mkfs –t ext3 /dev/sda2

mkswap /dev/hda2

swapon /dev/hda2

fsck

/etc/fstab

df

du

Page 45: Linux training

45 Confidential

5. Managing Files – mkdir, cp, rm, grep, find

Page 46: Linux training

File types

Regular file

Directory file

Special file Character

Block

Links Soft link Hard link

Sockets

Named pipes

Page 47: Linux training

Managing Links

ln [options] source link

Hard link: ln mainfile hlinkfile

Soft link: ln –s mainfile slinkfile

Page 48: Linux training

Inode table

Owner of the file

Group of the file

File type

File access permission

Date and time of last access

Date and time of last modification

Number of links to the file

Size of the file

Addresses of blocks where the file is physically present

Page 49: Linux training

Surrogate super block and Inode table

Super block – state of the file system Size

No of files it can accommodate

How many mores can be created

sync

Page 50: Linux training

How to check file inode no

ls –i filename

Page 51: Linux training

File Commands

ls

cp

mv

rm

touch : Last file modification time/inode change time/access time

ln

chmod

chown

mkdir

rmdir

umask

Page 52: Linux training

File Commands contd… cut

paste

join

split

expand

unexpand

uniq

sort

head

tail

wc

tr

nl

Page 53: Linux training

File Archiving Commands

tar

cpio

gzip

Gunzip

bzip2

Page 54: Linux training

Managing file ownership

Changing file ownership: chown

Chown [options] [newowner][:newgroup] filename

Changing file group ownership

chgrp [options] [newgroup] filename

Page 55: Linux training

File Access

Changing file permission: chmod

$ ls -l test

-rwxr-xr-x 1 rodsmith users 111 Apr 13 13:48 test– “-” -> file

– d -> firectory

– l -> symbolic link

– p -> Named pipe

– s -> Socket

– b -> Block device

– c -> Character device

SUID

SGID

Sticky bit

Page 56: Linux training

Setting the default mode and group

Default permissions are configurable and defined by user mask.(umask)

• Umask Created Files Created Directories

• 000 666 (rw-rw-rw-) 777 (rwxrwxrwx)

• 002 664 (rw-rw-r--) 775 (rwxrwxr-x)

• 022 644 (rw-r--r--) 755 (rwxr-xr-x)

• 027 640 (rw-r-----) 750 (rwxr-x---)

• 077 600 (rw-------) 700 (rwx------)

• 277 400 (r--------) 500 (r-x------)

Page 57: Linux training

Managing Disk Quotas

Enabling Quota Support Kernel 2.4.x – quota v1 support

Kernel 2.6.x – quota v2 support

/etc/fstab

/dev/hdc5 /home ext3 usrquota,grpquota 1 1

chkconfig quota on

Setting quota for users, edquota raghu

Page 58: Linux training

Locating Files

whereis

which

locate

find

type

Updatedb

/etc/updatedb.conf

Page 59: Linux training

Regular Expressions

59

Bracket Expressions: d[aeiou]g => dag, deg, dig, dog, dug

Range Expression : a[1-5] => a1, a2, a3, a4, a5

Any single character except new line: .

Start and end of line: ^ and $

Repetition operators: * -> 0 and more), + -> 1 and more, ? -> 0 and 1

Any single character except new line: .

Multiple possible strings: Linux | Windows

Escaping: backslash \

Page 60: Linux training

grep

60

grep [options] regexp [files]

grep openmanage /var/log/messages

grep –i openmanage /var/log/messages

grep –r –i openmanage /var/log

grep –r –i error /var/log

Page 61: Linux training

Sed(stream editor)

61

Modifies the contents of files

• sed [options] -f script-file [input-file]

• sed [options] script-text [input-file]

$ sed ‘s/2009/2010/’ cal-2009.txt > cal-2010.txt

Page 62: Linux training

awk

62

Print list of all processes of all the users ps -ef | awk '{print $1"=>" $8}‘

Print all the child process of PPID 1. ps -ef | grep -w 1 | grep -v /1 | awk '{print $2"=>"$3"=>"$8}‘

Display and create all the loaded module details in a file lsmod | awk '{print $1}'| xargs modinfo | tee mod.txt

Page 63: Linux training

File Systems

63

Ext2/3: Native file system

Reiserfs : Suitable for small files – less than 1K

Vfat : 32bit file system compatible with win

XFS : Journaling file systems –handle large files

JFS : Handles power down and crashes

Swap: virtual memory

Iso9660 : cdfs, dvd

Page 64: Linux training

64

Page 65: Linux training

65 Confidential

6. Administering the system – useradd, usermod, shutdown, crontab, chown

Page 66: Linux training

66 Confidential

Booting Linux and editing files

Page 67: Linux training

Boot Loaders BIOS->MBR->Boot loader->OS kernel

LILO

GRUB

Boot messages: /var/log/messages

Command dmesg

Page 68: Linux training

LILO – Linux Loader

Configuration file: /etc/lilo.conf

Boot loader location: boot=/dev/hda

Default: default os to boot

Boot Prompt

Boot Timeout

Linux root partition, root=/dev/hda4

Boot in read-only mode

Linux boot image: image=/kernelimage

RAM disk: initrd=oskernel imahe

Extra kernel option: mem=2048

Lilo –c – testing purpose

Lilo –v – output in verpose

Page 69: Linux training

LILO prompt

Boot: linux 1 -> To boot in single user mode 1/S/s/single can be typed

If suppose init program is corrupted Boot: linux init=/bin/sh can be used

Page 70: Linux training

GRUB

Configuration file: /boot/grub/menu.lst (some read/fedora used grub.conf)

Page 71: Linux training

Confidential71

LILO and GRUB

LILO GRUB

/dev/hda (hd0)

/dev/hda1 (hd0,0)

/dev/hdb (hd1)

/etc/lilo.conf /boot/grub/menu.lst

lilo /etc/lilo.conf grub-install /dev/hda

Page 72: Linux training

Linux Boot Process

• System Power on-> CPU executes BIOS code->BIOS(Post, check and configure hardware)->Boot loader kicks off->OS kernel is loaded(initialize devices, mount boot partition, init program starts->init selects run level from /etc/inittab and default level run level loads

Inittab entry

• id:runlevels:action:process

# Default runlevel. The runlevels used by RHS are:

# 0 - halt (Do NOT set initdefault to this)

# 1 - Single user mode

# 2 - Multiuser, without NFS (The same as 3, if you do not have networking)

# 3 - Full multiuser mode

# 4 - unused

# 5 - X11

# 6 - reboot (Do NOT set initdefault to this)

Page 73: Linux training

Linux Boot Process contd..

inittab file

id:3:initdefault:

5:2345:respawn:/sbin/mingetty tty5

chkconfig : updates and queries run level information for system services.

runlevel : Find the current and previous run level

init : parent of all the processes

telinit: tell init to switch to specified runlevel

shutdown

Page 74: Linux training

Life cycle of a process

fork and exec init – process id 1

getty

login

sh

Who or grep or any command running on shell

kill

Page 75: Linux training

Linux installation and designing hard disk layout

/ : default root partition

/var : logs related entries

/home: User home directory

/opt: Optional packages

Swap space: typically double of RAM

Page 76: Linux training

Managing Users

useradd

usermod

userdel

groupadd

groupmod

gpasswd

Chage: change user password expiry information

Page 77: Linux training

usermod

Usermod –l [newlogin] [login]

Usermod –c [comment login]

Usermod –f [no of days] [login] => no of days password to expire

Usermod –L [login] -> lock the password and suspend the user

Usermod –U [login] -> unlock the password

Usermod –e [yyyy-mm-dd] [login] -> change the expiration date

Page 78: Linux training

Tuning User and System Environments

Global Configuration file /etc/profile

/etc/bash.bashrc

User Configuration file ~/.profile

~/.bashrc

Configuartion file for added user’s fefault environment setting /etc/skel

Kernel Parameter /etc/sysctl.conf

sysctl

Page 79: Linux training

Automate system administration tasks by scheduling jobs

Manage cron and at jobs

Configure user access to cron and at services

The following is a partial list of the used files, terms, and utilities:

/etc/cron.{d,daily,hourly,monthly,weekly}

/etc/crontab

crontab –e

Page 80: Linux training

Cronjob Definition

80

* * * * * Command

Minute(0-59)

Hour(0-23)

Day of month(0-31)

Month(1-12)

Day of week(1-7)

Page 81: Linux training

System logging

Syslog configuration files: /etc/syslog.conf

/etc/sysconfig/syslog

/var/log

/var/log/messages

dmesg

last

Binary names: syslogd

klogd

Page 82: Linux training

Systems Monitoring

Process ps

top

Disk space df

du

Bandwidth tcpdump

netstat

Memory pmap

ps

free

other commands lsof

Page 83: Linux training

Systems Monitoring contd…

uptime: Load average is average no of processes waiting to run in 1min, 5min, and 15 mins. Ideally it should be <1.

tload is graphical presentation of uptime.

vmstat-Virtual memory usage

pmap -x pid: mapping of processes with memory resources

scsiinfo

hdparam

Page 84: Linux training

Perform security administration tasks

Audit system to find files with the suid/sgid bit set.

Set or change user passwords and password aging information.

Discovering open ports on a system: nmap, netstat

Setting up limits on user logins, processes and memory usage ulimit

Basic sudo configuration and usage /etc/sudoers

Page 85: Linux training

Linux Kernel

Module components in source tree: /usr/src/linux

Module components at runtime: /lib/modules/<kernelversion>/kernel.

Download latest stable kernel from www.kernel.org

Unpack the kernel

Compiling a kernel: make config/menuconifg/xconfig

make dep

make bzImage

make modules

make modules_install

make install

Installing the kernel image using boot loader: /boot/grub/grub.conf

Reboot the system and new kernel should be up

Page 86: Linux training

Shell Scripting

Variables – strings, numbers, environment and paramter Conditions: shell booleans Control Structures: if, elif, for, while, until, case Lists Functions Commands built into shell Getting the result of a command Here documents

Page 87: Linux training

Quoting

Declaration svar = “Hello world”

$svar “$svar” ‘$svar’ \$svar

Page 88: Linux training

Environment Variables

$HOME $PATH $PS1 $PS2 $0 $# $$ $1, $2, $3…

$*

$@

Page 89: Linux training

Control Structures

Ifif condition

then

Statements

else

Statements

fi

elifif condition

then

Statements

elif

then

statements

else

Statements

fi

Page 90: Linux training

Control Structures contd..

forfor variable in values

do

statements

done

whilewhile condition do

statements

done

untiluntil condition

do

statements

done

Page 91: Linux training

Control Structures contd..

CaseCase variable in

pattern1 statements;;

pattern2 statements;;

pattern3 statements;;

esac

Page 92: Linux training

Debugging scripts

sh –n <script> sh –v <script> sh –x <script>

Page 93: Linux training

GUI Based Monitoring tools

Nagios Cacti Zabbix MRTG Nfsen

Page 94: Linux training

94 Confidential

7. Networking

Page 95: Linux training

Basic Network Configuration

Manually and automatically configure network interfaces

Basic TCP/IP host configuration

The following is a partial list of the used files, terms, and utilities:

/etc/hostname

/etc/hosts

/etc/resolv.conf

/etc/nsswitch.conf

ifconfig

Page 96: Linux training

Configuring Network

/etc/sysconfig/network-scripts/ifcfg-eth0

A Sample Network Configuration File DEVICE=eth0 BOOTPROTO=static IPADDR=192.168.29.39 NETMASK=255.255.255.0 NETWORK=192.168.29.0 BROADCAST=192.168.29.255 GATEWAY=192.168.29.1 ONBOOT=yes

# ifconfig eth0 up 192.168.29.39 netmask 255.255.255.0

# route add default gw 192.168.29.1

ifconfig eth0

DNS Entry: /etc/resolv.conf

Page 97: Linux training

Configuring routing

# route add -net 172.20.0.0 netmask 255.255.0.0 gw 172.21.1.1

ifup eth0

ifdown eth0

ethtool

Page 98: Linux training

Network Port numbers

• Port Number TCP or UDP Purpose Example Linux Servers

20 TCP File Transfer Protocol ProFTPd, vsftpd

21 TCP FTP ProFTPd, vsftpd

22 TCP Secure Shell (SSH) OpenSSH, Dropbear

23 TCP Telnet in.telnetd

25 TCP Simple Mail Transfer Protocol (SMTP)Sendmail, Postfix,

53 TCP and UDP Domain Name System (DNS) BIND;

Page 99: Linux training

Diagnosing Network connections

ping

traceroute

netstat

nslookup

dig

Examining raw network traffic– tcpdump

– wireshark

Page 100: Linux training

Various tools

telnet

ftp

ssh

scp

ping

Page 101: Linux training

Linux Server

Web Server – Apache

Database Server – mysql, oracle

ftp server – proftp, vsftp

File server - samba

Mail server – sendmail, postfix

Page 102: Linux training

Linux Firewall

#iptables -t filter -A INPUT -p tcp --dport 22 -j DROP#iptables -t filter -A INPUT -p udp --dport 22 -j DROP#iptables -t filter -A INPUT -p tcp --dport 23 -j DROP #iptables -t filter -A INPUT -p udp --dport 23 -j DROP#iptables -t filter -P OUPUT DROP#iptables -t filter -A OUTPUT -p tcp --dport 80 -j ACCEPT#iptables -t filter -A OUTPUT -p udp --dport 80 -j ACCEPT #iptables -t filter -A OUTPUT -p tcp --dport 53 -j ACCEPT#iptables -t filter -A OUTPUT -p udp --dport 53 -j ACCEPT  # service iptables save#service iptables restart

Page 103: Linux training

Exercise

How long the server is running and no of users who are using the system.

Create a user with your name, create a group name training, validity period, home directory, assign training group

Search for files with specific pattern

Display line no 10 to line no 20 , from a file having 30 lines.

print file in reverse

Page 104: Linux training

References

www.tldp.org

www.kernel.org

www.linux.org