0% found this document useful (0 votes)
39 views

System Admin Basic

Linux is a free and open-source operating system that was created in 1991 by Linus Torvalds. It was developed as an alternative to proprietary operating systems like DOS, Mac OS, and UNIX. The document discusses the history and development of Linux, including its origins from the GNU project and UNIX. It defines key terms like operating systems, system software, and application software. It also outlines some major advantages of Linux like low cost, stability, security, and flexibility.

Uploaded by

Syed F Badar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views

System Admin Basic

Linux is a free and open-source operating system that was created in 1991 by Linus Torvalds. It was developed as an alternative to proprietary operating systems like DOS, Mac OS, and UNIX. The document discusses the history and development of Linux, including its origins from the GNU project and UNIX. It defines key terms like operating systems, system software, and application software. It also outlines some major advantages of Linux like low cost, stability, security, and flexibility.

Uploaded by

Syed F Badar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 141

Introduction to Linux OS (Lecture one)

• Introductions of software.

• Types of software.

• How OS works.

• Famous OS.

• What is Linux OS.

• History of Linux

• License Rights.

• Advantages and Disadvantage.

• Flavors of Linux OS.

What is Software

Software is any set of machine-readable instructions, most often in the


form of a computer program, that directs a computer's processor to perform
specific operations.

Types Of Software

• System Software.

• Application Software.

• Embedded Software.

System Software

System software (or systems software) is an operating system


designed to operate and control the computer hardware and to provide a
platform for running application software.

The program directly related to the computer hardware and perform tasks
associated with controlling and utilizing computer hardware.
Application software

Application software consists of Programs that direct computers to perform


specific information processing activities for end users.

Application software are programs that help a user perform a specific job.

Eg.

Office, web-browser, Media Players etc

Embedded software

Embedded software resides as firmware within embedded systems,


devices dedicated to a single use. In that context there is no clear distinction
between the system and application software.

It is computer software, written to control machines or devices that are not


typically thought of as computers. It is typically specialized for the particular
hardware.

Eg. Remote control, mp3 player, modems, BIOS.

What is an Operating System

An operating system (OS) is a collection of software that, after being


initially loaded into the computer by a boot program, manages computer
hardware resources and provides common services for computer programs.

The operating system is a vital component of the system software in a


computer system.

Application programs usually require an operating system to function. OS is


the interface between hardware and user .

OSes are used to run applications and control hardware components.

How Operating System works


Some Famous Operating Systems

• Microsoft Widows.

• Unix.

• Mac.

• Linux.

• Minix.

Linux Operating System

Linux is a Unix-like computer operating system assembled under the model


of free and open source software development and distribution.

Linux is a very powerful operating system and it is gradually becoming


popular throughout the world.
The defining component of Linux is the Linux kernel, an operating system
kernel first released 5 October 1991 by Linus Torvalds.

Since the C compiler that builds Linux and the main supporting user space
system tools and libraries originated in the GNU Project, initiated in 1983
by Richard Stallman, the Free Software Foundation prefers the name
GNU/Linux.

Before Linux

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

Apple MAC is better, but expensive.

UNIX is much better, but its also expensive. Only for minicomputer for
commercial applications.

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

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

History Of Linux Operating System

The Unix operating system was conceived and implemented by Ken


Thompson and Dennis Ritchie at (AT&T Bell Laboratories) in 1969 and
first released in 1970.

Its availability and portability caused it to be widely adopted, copied and


modified by academic institutions and businesses. Its design became
influential to authors of other systems.

In 1983, Richard Stallman started the GNU project with the goal of
creating a free UNIX-like operating system. As part of this work, he wrote the
GNU General Public License (GPL).

By the early 1990s there was almost enough available software to create a
full operating system. However, the GNU kernel, called Hurd, failed to
attract enough attention from developers leaving GNU incomplete.
MINIX, a Unix-like system intended for academic use, was released by
Andrew S. Tanenbaum in 1987. While source code for the system was
available, modification and redistribution were restricted.

Minix was for class teaching only. No intention for commercial use.

In 1991, Linus Torvalds, a 21-year-old student of Computer Science at the


University of Helsinki, Finland started working on some simple ideas for an
operating system. He developed the preliminary kernel of Linux, known as
Linux version 0.01

It was put to the Internet and received enormous response from worldwide
software developers

By September 1991, Linux version 0.01 was released on the FTP server
(ftp.funet.fi) of the Finnish University and Research Network (FUNET). It had
10,239 lines of code.

In October 1991, Linux version 0.02 was released.

In February 1992 version 0.12 was released,

Torvalds adopted the GNU General Public License (GPL) over his previous
self-drafted license, which had not permitted commercial redistribution.

In March 1992, Linux version 0.95 was the first to be capable of running X
Windows.

GNU Project

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”

GNU software guarantees these freedom-rights legally (via its license), and is
therefore free software; the use of the word "free" always being taken to
refer to freedom.

In order to ensure that the entire software of a computer grants its users all
freedom rights (use, share, study, modify), even the most fundamental and
important part, the operating system (including all its numerous utility
programs), needed to be written.
Stallman decided to call this operating system GNU (a recursive acronym
"GNU's not Unix"), basing its design on that of Unix; however, in contrast to
Unix which was proprietary software, GNU was to be freedom-respecting
software (free software) that users can use, share, study and modify.

Development was initiated in January, 1984. The goal of making a


completely free software operating system was achieved in 1992.

GNU

The GNU General Public License (GNU GPL or GPL) is the most widely used
free software license, which guarantees end users (individuals, organizations,
companies) the freedoms to use, study, share (copy), and modify the
software.

Software that ensures that these rights are retained is called free software.

The license was originally written by Richard Stallman founder of the Free
Software Foundation (FSF) for the GNU project.

Mascot of Linux
Linus Torvalds announced in 1996 that there would be a mascot for Linux, a
penguin.

This was due to the fact when they were about to select the mascot,
Torvalds did mention he was bitten by a Little Penguin on a visit to the
National Zoo & Aquarium, Canberra, Australia.

Tux is a penguin character and the official mascot of the Linux kernel.
Originally created as an entry to a Linux logo competition, Tux is the most
commonly used icon for Linux, although different Linux distributions depict
Tux in various styles.

The first person to call the penguin "Tux" was James Hughes, who said that
it stood for "(T)orvalds (U)ni(X)"
Advantages of Linux over Windows

It's almost free to relatively inexpensive. Source code is included.

Bugs are fixed quickly and help is readily available through the vast support
in Internet.

Linux is more stable than Windows. Linux is truly multi-user and multi-
tasking.

Multiuser: OS that can simultaneously serve a number of users.

Multitasking: OS that can simultaneously execute a number of programs.

Low cost:
There is no need to spend time and huge amount money to obtain licenses
since Linux and much of it’s software come with the GNU General Public
License. There is no need to worry about any software that you use in Linux.

Stability:
Linux has high stability compared with other operating systems. There is no
need to reboot the Linux system to maintain performance levels.

Rarely it freeze up or slow down. It has a continuous up-times of hundreds of


days or more

Performance:

Linux provides persistent high performance on workstations and on


networks. It can handle unusually large numbers of users simultaneously,
and can make old computers sufficiently responsive to be useful again.
Flexibility:
Linux is very flexible. Linux can be used for high performance server
applications, desktop applications, and embedded systems.

Compatibility:
It runs all common Unix software packages and can process all common file
formats.

Wider Choice:

The large number of Linux distributions gives you a choice. Each distribution
is developed and supported by a different organization. You can pick the one
you like best; the core functionalities are the same; most software runs on
most distributions.
Fast and Easy Installation:
Linux distributions come with user-friendly installation and setup programs.

Multitasking & Multiuser:


Linux is a multitasking operating system. Several programs can run at the
same time. It is Also a true multiuser operating system. Several users can
logon to the same machine at the same time. There is no need to have
separate user licenses.

Security:
Linux is one of the most secure operating systems. File ownership and
permissions make Linux more secure.

Open source:
Linux is an open source operating systems. You can easily get the source
code for Linux and edit it to develop your personal operating system.

Crash proof:

Linux has memory protection between processes, so that one program can't
bring the whole system down.

Today, Linux is widely used for both basic home and office uses. It is the
main operating system used for high performance business and in web
servers.

Linux has made a high impact in this world. Today, Linux systems are used in
every domain, from embedded systems to supercomputers.

No threat of viruses.

Linux systems are extremely stable.

Linux is Free.

Linux comes with most of the required software pre-installed.

Linux never gets slow.

Linux does not need defragmentation.

Linux can even run on oldest hardware

Adding more software is a matter of a few clicks


Disadvantages compared with Windows

Linux isn't as popular as Windows

Less commercial company is responsible for Linux.

Linux is relatively hard to learn and use as compared to Windows

Linux Distributions

Today there are hundreds of different distributions available. Some popular


Linux distributions of them include
Linux Distribution.

Ubuntu Redhat Trix Box Fedora Gentoo Debian

OpenSUSE PCLinuxOS LinuxMint Mandriva ArchLinux Kubuntu

Slackware BackTrack ‘Rocks Cluster Distribution’ Scientific Linux


Installation of CentOs 6.3 (Lecture #02)
CENTOS

Community Enterprise Operating System

CentOS (Community ENTerprise Operating System) are a Linux distribution


which attempts to provide a free enterprise class computing platform.

OS family Unix-like (based on RHEL)

Working state Current

Source model Free and open source software

Initial release 03:32:38, May 14, 2004 (UTC)

Latest stable release 6.4, (March 9, 2013)

Marketing target Free computing (desktops, mainframes, servers,


workstations)

Available language(s) Multilingual

Update method Yum (PackageKit)

Package manager RPM Package Manager

Supported platforms i386, x86-64 (as of CentOS5)

Kernel type Monolithic (Linux)

Default user interface GNOME and KDE (user-selectable)

License GNU GPL & various others.

Official website CentOS.org

In July 2010, CentOS overtook Debian to become the most


popular Linux distribution for web servers, with almost 30% of all Linux web
servers using it, although Debian retook the lead in January 2012
End of support schedule

CentOS Release Full Updates Maintenance Updates

3 2006-07-20 2010-10-31

4 2009-03-31 2012-02-29

5 Q1 2014 2017-03-31

6 Q2 2017 2020-11-30

In accordance with the Red Hat Enterprise Linux Life Cycle


CentOS 5 and 6 will also be supported for 10 years. Previously, CentOS 4 had
been supported for 7 years.

System Requirements

• 1 GHz processor

• 512MB of system memory (RAM)

• 5GB of disk space (for OS files)

• Graphics card and monitor capable of 1024x768

• CD Drive, DVD Drive, or bootable USB Port

• Sound support, if you need sound.

• Internet access is helpful

Installation of CentOS

1. First Screen
2. For CD check (Skip this)
3. Starting CENTOS
4. Chose Language
5. Use Basic Storage Devices

Special Storage Devices are used for NFS (Network File


System/RAID)
6. Select Location
7. Enter Root User Password (“hidaya”)
8. Chose Disk

Here we can chose complete memory of Computer or just


unallocated memory of Computer

a. Use All Space (Remove All Partition on the Selected Device)

b. Replace Existing Linux System (Remove only Linux partition and


install new Linux OS)

c. Shrink Current System (Shrink existing partitions to create free


space )
9. Write changes ( Click to Create Linux Partitions)
10. Creating Partition
11. Chose installation Type
12. Starting Installation (Copying Files 1078

13. After all Reboot Your System


Now Experience Centos Desktop
Lecture #3 FHS (File Hierarchy System)
File System Structure

• A file system is the methods and data structures that an operating


system uses to keep track of files on a disk or partition; that is, the way
the files are organized on the disk.

• A file system organizes data in an efficient manner and is tuned to the


specific characteristics of the device.

FSSTND
• The FSSTND (Filesystem Standard), a filesystem hierarchy standard
specific to the Linux operating system, was released on 14 February
1994.

• The name has been changed into Filesystem Hierarchy Standard


(FHS) on 26 October 1997.

• Initial release 1.0 14 February 1994.

• Latest release 2.3 29 January 2004.

What is File?

• Files are collection of data items stored on disk. Or, it's device which
can store the information, data, music (mp3 files), picture, movie,
sound, book etc.

• In fact what ever you store in computer it must be in the form of a file.

• Files are always associated with devices like hard disk ,floppy disk etc.

• File is the last object in your file system tree.

What is a directory?

• Directory is group of files.


• Root directory - There is only one root directory in your system,
which is denoted by / (forward slash).

• It is root of your entire file system and can not be renamed or deleted.
Sub directory - Directory under root (/) directory is sub directory.
Directories are used to organize your data files, programs more efficiently.

Primary hierarchy root and root directory of the entire file system
/
hierarchy.
Essential command binaries that need to be available in single user
/bin
mode; for all users, e.g., cat, ls, cp.
/boot Boot loader files, e.g., kernels, initrd.
/dev Essential devices, e.g., /dev/null.
Host-specific system-wide configuration files
There has been controversy over the meaning of the name itself. In
early versions of the UNIX Implementation Document from Bell
labs, /etc is referred to as the etcetera directory,[25] as this directory
historically held everything that did not belong elsewhere (however,
/etc
the FHS restricts /etc to static configuration files and may not contain
binaries).[26] Since the publication of early documentation, the
directory name has been re-designated in various ways. Recent
interpretations include backronyms such as "Editable Text
Configuration" or "Extended Tool Chest".[27]
/etc/opt Configuration files for /opt/.
/etc/sgml Configuration files for SGML.
/etc/X11 Configuration files for the X Window System, version 11.
/etc/xml Configuration files for XML.
/home Users' home directories, containing saved files, personal settings, etc.
/lib Libraries essential for the binaries in /bin/ and /sbin/.
Mount points for removable media such as CD-ROMs (appeared in
/media
FHS-2.3).
/mnt Temporarily mounted filesystems.
/opt Optional application software packages.[28]
Virtual filesystem providing information about processes and kernel
/proc
information as files. In Linux, corresponds to a procfs mount.
/root Home directory for the root user.
/sbin Essential system binaries, e.g., init, ip, mount.
/srv Site-specific data which are served by the system.
Temporary files (see also /var/tmp). Often not preserved between
/tmp
system reboots.
Secondary hierarchy for read-only user data; contains the majority of
/usr
(multi-)user utilities and applications.[29]
Non-essential command binaries (not needed in single user mode);
/usr/bin
for all users.
/usr/include Standard include files.
/usr/lib Libraries for the binaries in /usr/bin/ and /usr/sbin/.
Tertiary hierarchy for local data, specific to this host. Typically has
/usr/local
further subdirectories, e.g., bin/, lib/, share/.[30]
Non-essential system binaries, e.g., daemons for various network-
/usr/sbin
services.
/usr/share Architecture-independent (shared) data.
/usr/src Source code, e.g., the kernel source code with its header files.
/usr/X11R6 X Window System, Version 11, Release 6.
Variable files—files whose content is expected to continually change
/var during normal operation of the system—such as logs, spool files, and
temporary e-mail files.
Application cache data. Such data are locally generated as a result of
time-consuming I/O or calculation. The application must be able to
/var/cache
regenerate or restore the data. The cached files can be deleted without
loss of data.
State information. Persistent data modified by programs as they run,
/var/lib
e.g., databases, packaging system metadata, etc.
/var/lock Lock files. Files keeping track of resources currently in use.
/var/log Log files. Various logs.
/var/mail Users' mailboxes.
Information about the running system since last boot, e.g., currently
/var/run
logged-in users and running daemons.
Spool for tasks waiting to be processed, e.g., print queues and unread
/var/spool
mail.
/
Deprecated location for users' mailboxes.[citation needed]
var/spool/mail
/var/tmp Temporary files to be preserved between reboots
Lecture # 4 Shell Commands

Commands

• A command is an instruction given by a user telling a computer to do


something, such a run a single program or a group of linked programs.

• Commands are generally issued by typing them in at the command


line (the all-text display mode) and then pressing the ENTER key, which
passes them to the shell.

• The first word is the command itself, which tells the shell “what” to
do. The remaining words are commands options. An option controls
“how” the command is to be performed.

Shell
• Shell is a UNIX term for the interactive user interface with an operating
system.

• The shell is the layer of programming that understands and executes


the commands a user enters. In some systems, the shell is called a
command interpreter.
How to Open Shell

Application  System Tool  Terminal.


Commands

1. ls

i. Lists the information about files and directories.

Syntax

ls

Options

ii. ls –l (long form)

iii. ls –lh (long and human readable form)

iv. ls –a (lists all files, also hidden files)

v. ls –t (sort by time)

vi. ls -s (sort by size)


vii. ls –r (reverse order)

viii. ls –ld (for perticular file)

ls –ld /home

2. cd (change Directory)

i. cd – (jump to old working directory )

ii. cd ~ (jump to home Directory of login users)

iii. cd .. (jump on previous back in directory on step back)

iv. cd ../../ (jump two steps back)

3. pwd (Path of user where is he standing right now)

4. mkdir (create a directory)

i. mkdir –p (create directory in directory –p is used for


parents)

mkdir –p A/B/C/D/E/F/G

5. rmdir (remove Directory)

6. touch (to create a file a blank file and we can update any info of
existing file/directory)

i. touch G-{1..1000} (This is the way we can create


thousands of files in a range G- will be common)

ii. mkdir G-{1..100} (This is the way we can create thousands


of Directories in a range G- will be common)

7. file (this command is used for command to check the files status like
for what this file is created )

8. rm (remove any file / Directory)

i. rm –r (-r used for directories)

ii. rm –f ( -f used for Files)

iii. rm –rf(-rf used for files and Directories)


iv. rm –irf (-rf used for remove directories and files but –i will
put us as prompt it will ask on deleting every file and files)

v. rm –Irf(it is same –i but it will ask only one time, (it is


capital i))

vi. rm –rf .*(.* will remove hidden files and folders)

9. mv (used for move files and directories)

mv –rf file new-location (to move a created file from one location to
another it can mv files and folders)

mv –rf file new-name (to rename a created file it can rename files and
folders)

Note: - for creating hidden files we use “.” in front of name (.file / .folder),
for rename we use mv command.

“.” Single dot mean same location “..” double mean one step
back in directories

10. cat (To view contents of file, Also used to create new text file.)

Syntax

i. cat file-name (to view the file contents)

ii. cat > file-name (to create a text file)

iii. cat >> file-name (to append/enter the text


existing file)

iv. Ctrl+d (to save contents of the file)

Options

b. cat -n (to view contents of file with line numbers)

11. cp (Use to copy the files and directories.)

Syntax

cp file1 file2
cp -f file1 file2 (to copy file forcely)

cp -r dir1 dir2 (to copy directory recursively)

12. echo (To print the string on the screen, Also used to create file.)

Syntax

i. echo string to print

ii. echo string to save > file-name

iii. echo string to append >> file-name

13. which (To locate the path of command or program.)

Syntax

i. which command (which ls)

14. cal (To display calendar.)

Syntax and Options

i. cal -y (to show the complete calendar)

ii. cal -m (calendar start from Monday)

iii. cal -j (to show Julian calendar)

iv. cal -3 (to show previous, current and next month


calendar)

15. wc (Print byte, word, and line counts.)

Syntax

wc file-name

Options

i. wc -c (to count characters of file)

ii. wc -w (to count words of file)

iii. wc -l (to count lines of file)

16. clear (to clear the window or use Shortcut keys ctrl+l or we can
set any alias easy like cls then whenever we type cls it will clear it)
17. who (Print information about users who are currently
logged in)

Syntax and Options

i. who (to see who is logged in from what computer because


if some one is logged in from ssh then it will show the IP)

ii. who -H (out put with heading)

iii. who -b (to show boot time)

18. whoami (Show current logged on user on terminal.)

19. more (To display the contents of the file from top to
bottom.)

Syntax

more file-name

Navigation keys

i. Enter key

ii. Use to page down line by line.

iii. Space key

iv. Use to page down page by page.

20. less (To display the contents of the file, We can navigate
the page up and down line by line and page by page.)

Syntax

less file-name

21. head (To display the first part of the file.)

Syntax

head file-name

Options

head -n (n stand for any number)


22. tail (To display the last part of the file. )

Syntax

tail file-name

Options

tail -n (n stand for any number)

tail -f (to follow the file updating)

23. | (Pipe line ,Redirect the output of one command into


another command.)

Syntax

commad1 | command2

ls -l | wc

ls -l /etc | less

24. history (To view the commands line history.

Syntax

history

Options

history -c (clear the history)

history -w (to save the history in text file)

Note: - History is saved in .bashrc_history file in every users home


directory and files are copied from /etc/skil/ whenever any new user is
created but when any new user is created with useradd –d (-d mean don’t
create users home directory) then these files are copied by own self.

25. tac (To view the contents of file in reverse, lines are reversed
not letters)

Syntax

tac file-name ( to view in reverse)

tac > file-name (to create a file in reverse)


tac >> file-name (to append a file in reverse)

26. grep (To matching pattern. To search the given pattern in


file)

Syntax

grep pattern file-name

cat file-name | grep pattern (here we use


pipeline which mean the result of one command is input for other
command)

Options

grep -i (to remove case sensitivity)

grep --color (to find and highlight them)

27. tr (To translate the contents of file)

Syntax

tr 'a-z' 'A-Z' < file-name (Here we take a file and


convert all the data in upper)

cat file-name | tr 'a-z' 'A-Z' (Here result will be


translated in upper)

cat file-name | tr 'a-z' 'A-Z' > new-file (Here


result will be translated in upper and stored in new-file)

28. hostname (To view the host/machine name. To change the


hostname of your machine)

29. ps (To view the current running process. ps is the shortage for
Process Status. The command should be used to display the currently
running processes on Unix/Linux systems)

i. ps -aux (To view the current running process of all


users. )

ii. ps -u user-name (To view the current running process of


given user.)

iii. ps –ejH (to view in tree form)


30. pgrep (To grep the PID any specific service or daemon.)

Syntax

pgrep service-name

31. kill (Terminate a process. Kill command in Linux is normally


used to kill a suspended or hanged process. kill -9 is used to forcefully
terminate a process in Linux. )

Syntax

kill -9 PID (where PID is the process ID of that


process)

32. pidof (Used to find Process ID of any program)

pidof firefox

33. find (To search/find the file or directory in current or given


directory .)

Syntax

find /path -name file-name (to find a particular file with


in current/given directory as well as in its subdirectories)

find –inum inum-of-any-file ( to find same inumberd file )

34. locate (To search/find the location of file-name containing the


matching pattern)

Syntax

locate file-name

Options

i. locate -c (to count the given file)

ii. locate -I (to search with limit)

iii. locate -b (to search file base name)

35. du (To view disk used space of directory.)

Syntax
du directory-name

Options

i. du -c (show the grand total)

ii. du -s (show only a total size )

iii. du -h (human readable form)

36. df (To view disk free space of directory.)

Syntax

du directory-name

Options

df -h (human readable form)

37. su (To switch an other user account )

Syntax:

su user-name

38. date (To display and change the date and time.)

Syntax

date

Option

i. date -s “MM/DD/YYYY hh:mm:ss” (to set date only Root


user can do it)

ii. date -s “DD jan YYYY hh:mm:ss”

iii. date -s “YYYY-MM-DD hh:mm:ss”

iv. date -s “YYYYMMDD hh:mm:ss”

39. Date format

i. date +%T or +%X (Time)

ii. date +%a or +%A (Day)


iii. date +%D or +%F or +%x (Date)

iv. date +%b or +%B or +%m (Month)

v. date +%G (Year)

40. ifconfig (To view or set the network interface setting.)

Syntax

i. ifconfig

ii. Ifconfig eth0 192.168.2.10 netmask 255.255.255.0

iii. ifconfig eth0 up (to activate network connection )

iv. ifconfig eth0 down (to deactivate network connection )

v. curl ifconfig.me (it will show the public IP)

Note: - 127.0.0.1 is a local-loop means every computer has same local loop.

41. Ifup (used to activate network connection)

Syntax:

Ifup <interface> (ifup eth0)

42. Ifdown (Used to deactivate network connection)

Syntax:

Ifdown <interface> (ifdown eth0)

43. route (To see or manipulate ip routing table.)

Syntax

route add default gw <gateway ip> (in a computer

44. ping (Send the echo-request to the hosts on the network


whether they are up or not.)

Syntax

ping <ip>

ping -c <number> <ip>


45. hash (A command use to see how many times a command is
executed.)

46. Whatis (A command use to view small discription of linux


commands.)

whatis <command> (whatis ping)

47. Whereis (A command use to view path and related documents


about linux commands.)

whereis <command> (whereis ping)

48. info (A command use to see info pages for a particular term. )

Syntax

i. Info <command> = q (press “q” key to exit


from manual)

49. man (This command is used to see the manual of any command)

50. & (To set as a background job.) = (command & ) (ping &)

51. ctrl+z (To set as a background job.) = (command ctrl+z) (ping


cltrl+z)

52. bg (To view the all background running jobs. show the total
jobs. )

53. jobs (To view the all background running jobs. jobs show the jobs
in sequence)

54. fg (To set a background job as a foreground job.)

fg job-num = (fg ping)

55. halt (To shut down the system.)

56. poweroff (To shut down the system.)

57. reboot (To re-start the system.)


Topic # 05 (Editors in Linux )
Editors
• A text editor is a computer program that lets a user to enter, change,
store, and usually print text.

• A text editor is any word processing program that you can use to type
and edit text.

Types of Editor in Linux

 Vi

 Gedit

 Nano

Vi Editor

• Vi is a screen-oriented text editor originally created for the Unix


operating system.

• The original code for vi was written by

Bill Joy in 1976.

• Developed in C

• License BSD (Berkeley Software Distribution)

• CLI and GUI based.

• There are Three modes in vi editor.

• Command mode.

• Insertion mode.

• Visual Mode for Selection

• Command line mode.


 The cursor is moved using either the arrow keys or the hjkl keys.
 h (left) j (down) k (up) l (right)
 To start Vim from the shell prompt type: vim FILENAME <ENTER>
 To exit Vim type: <ESC> :q! <ENTER> to trash all changes.
 OR type: <ESC> :wq <ENTER> to save the
changes.
 To delete the character at the cursor type :x <ENTER>
 To insert or append text type:
 i type inserted text <ESC> insert before the cursor
 A type appended text <ESC> append after the line

 NOTE: Pressing <ESC> will place you in Normal mode or will cancel an
unwanted and partially completed command.

o (Editing Command)

 To delete from the cursor up to the next word type :dw <ENTER>
 To delete from the cursor to the end of a line type: :d$ <ENTER>
 To delete a whole lines type: d<number of Lines>d <ENTER>
 To repeat a motion prepend it with a number: 2w <ENTER>
 To move to the start of the line use a zero: 0
 To undo previous actions, type: u (lowercase u)
 To undo all the changes on a line, type: U (capital U)
 To undo the undo's, type: CTRL-R
 To put back text that has just been deleted, type p . This puts the
deleted text AFTER the cursor (if a line was deleted it will go on the line
below the cursor).
 To replace the character under the cursor, type r and then the
character you want to have there.
 CTRL-G displays your location in the file and the file status.
 G moves to the end of the file.
 number G moves to that line number.
 gg moves to the first line.
 Typing / followed by a phrase searches FORWARD for the phrase.
 Typing ? followed by a phrase searches BACKWARD for the phrase.
o After a search type n to find the next occurrence in the same
direction or N to search in the opposite direction.
 CTRL-O takes you back to older positions, CTRL-I to newer positions.

 :!command executes an external command.


o Some useful examples are:
 (MS-DOS) (Unix)
 :!dir :!ls - shows a directory listing.
 :!del FILENAME :!rm FILENAME - removes file FILENAME.
 :w FILENAME writes the current Vim file to disk with name FILENAME. v
motion :w FILENAME saves the Visually selected lines in file
FILENAME.
 :r FILENAME retrieves disk file FILENAME and puts it below the
 cursor position.
 :r !dir reads the output of the dir command and puts it below the
 cursor position.
 Type o to open a line BELOW the cursor and start Insert mode.
 Type O to open a line ABOVE the cursor.
 Type a to insert text AFTER the cursor.
 Type A to insert text after the end of the line.
 The e command moves to the end of a word.
 The y operator yanks (copies) text, p puts (pastes) it.
 Typing a capital R enters Replace mode until <ESC> is pressed.
 Typing ":set xxx" sets the option "xxx". Some options are:
 'ic' 'ignorecase' ignore upper/lower case when searching
 'is' 'incsearch' show partial matches for a search phrase
 'hls' 'hlsearch' highlight all matching phrases
 You can either use the long or the short option name.
 Prepend "no" to switch an option off: :set noic
 Type :help cmd to find help on cmd .
 Type CTRL-W CTRL-W to jump to another window
 Type :q to close the help window
Nano Editor
• Nano is a text editor to working in UNIX and Linux.

• This is a GNU replacement for pico. Works and looks like pico, but it is
smaller, better, and licensed under the General Public License.

• CLI and GUI based.

• Introduced by Chris Allegretta in 1999

• Ctrl+x To exit from nano.

• Ctrl+o To save the file.

• Ctrl+r To insert an other file into current file.

• Ctrl+w To search matching pattern.

• Ctrl+y To move the previous screen.

• Ctrl+v To move the next screen.


Lecture # 06 (Installing Linux software
package)

Computer software is divided in the "systems" software and


"application" software.

Application software is therefore organized in "packages”.

What is package?

A package is basically a file that conceptually contains other files.

A package includes one "executable”.

When Linux developers create their software they typically bundle all the
executable and data files into a single file called a "package" file.

Types of Packages?
source code packages : suite of files related to one program: source
code, documentation, and configuration files.

Binary packages: source code packages that have been configured for
a particular Unix variant or package manager program. Usually contains
compiled code targeted to a specific architecture.

 Packages have different formats

 (apk, deb, RPM, tar.gz)

 Packages contain different control files

 Where the rest of the files should be placed

 The permissions they should have

 A list of prerequisite packages that are required for the package


to function correctly

Package management System


Collection of software tools to automate the process of installing,
upgrading, configuring, and removing software packages for a computer’s
operating system.Packages are distributions of software, applications and
data

A package, for package managers, denotes a specific set of files bundled


with the appropriate metadata for use by a package manager.

RPM (RedHat Package Manager) (.rpm)

Introduced by RedHat and has been adopted by many other distributions


(Fedora, Mandrake, SuSe) .

RPM command is used for installing, uninstalling, upgrading, querying,


listing, and checking RPM packages on your Linux system.

• With root privilege, you can use the rpm command with appropriate
options to manage the RPM software packages.

Installing a RPM Packages


RPM filename has packagename, version, release and architecture name.

For example, In the MySQL-client-3.23.57-1.i386.rpm

 MySQL-client – Package Name

 3.23.57 – Version
 1 – Release

 i386 – Architecture

Note: - noarch in architecture label:

 indicates this is a special architecture such that the files in the package
work on any architecture

 When you install a RPM, it checks whether your system is suitable for
the software the RPM package contains, figures out where to install the
files located inside the rpm package, installs them on your system, and
adds that piece of software into its database of installed RPM
packages.

Rpm command and Options


 Installing a RPM package Using rpm -ivh

o -i : install a package

o -v : verbose

o -h : print hash marks as the package archive is unpacked.

 You can use rpm command to query all the packages installed
in your system.

 rpm –qa

o -q query operation

o -a queries all installed packages

 After installation of a package to check the installation, you


can query a particular package and verify as shown below.

 rpm -q MySQL-client

Note: To query a package, you should specify the exact package name. If
the package name is incorrect, then rpm command will report that the
package is not installed.
 Let us say, you have list of files and you would want to know
which package owns all these files. rpm command has options
to achieve this.

 rpm –qf filename

 -f : file name

 rpm command provides a lot of information about an installed


package using rpm –qi

 rpm -qi package-name

 If you have an RPM file that you would like to install, but want
to know more information about it before installing, you can do
the following:

 rpm –qip package-name

o -i : view information about an rpm

o -p : specify a package name

 To list the content of a RPM package, use the following


command, which will list out the files without extracting into
the local directory folder.

 rpm –qlp package-name.rpm

o q : query the rpm file

o l : list the files in the package

o p : specify the package name

 rpm –Uvh package-name.rpm (Upgrading a package)

 rpm –e package-name.rpm (To remove an installed rpm


package)

YUM (YELLOWDOG UPDATER MODIFIER)

 Yum is dependency-resolving installer for RPM.


 Yum is used for installing and removing packages as much as
possible.

 Resume Capability in Yum

 Automatic updates over rpm

 User friendly

 Direct download from net

 Take time to check database

To install a package, do ‘yum install package-name’. This will also identify


the dependencies automatically and install them.

yum install package-name

By default ‘yum install’, will prompt you to accept or decline before


installing the packages. If you want yum to install automatically
without prompting, use -y option.

yum remove package-name (To remove any package)

yum update package-name (To update any package)

yum search package-name (To Search any package)


yum info package-name (To get info about any package)

yum list (To View the list of available packages)

yum list installed (To view installed packages )

yum provides file-name (Use ‘yum provides’ if you like to know


which package a particular file belongs to.)

yum repolist all ( When we add new Repolist from net


then we use this command to update)

yum history (To View the History of install yum list)

yum grouplist virtualization (To install several packages in a


group list)

wget –p –k www.google.com(to Download any file from net but we


must have complete address of that file accurate but here in –k –p it
will download complete webpage with pictures and links and css
coding HTML.)
lecture #07 Compression & Archiving
Techniques in Linux

File Compression and Archiving

It is useful to store a group of files in one file for easy backup, for
transfer to another directory, or for transfer to another computer. It is
also useful to compress large files; compressed files take up less disk
space and download faster via the Internet.

An archive file is a collection of files and directories stored in one file.


The archive file is not compressed — it uses the same amount of disk
space as all the individual files and directories combined.

A compressed file is a collection of files and directories that are stored


in one file and stored in a way that uses less disk space than all the
individual files and directories combined.

Note : An archive file is not compressed, but a compressed file can be


an archive file.

Compressing Files at the Shell Prompt

Linux provides the bzip2, gzip, and zip tools for compression from a
shell prompt.

The bzip2 compression tool is recommended because it provides the


most compression and is found on most UNIX-like operating systems.

The gzip compression tool can also be found on most UNIX-like


operating systems.

To transfer files between Linux and other operating system such as MS


Windows, use zip because it is more compatible with the compression
utilities available for Windows

Compression Tool File Extension Decompression Tools

bzip2 .bz2 bunzip2

gzip .gz gunzip


zip .zip unzip

Bzip2 and Bunzip2

bzip2 filename (To use bzip2 to compress a file, The file is


compressed and saved as filename.bz2)

bunzip2 filename.bz2 (To expand the compressed file, The


filename.bz2 compressed file is deleted and replaced with filename)

Gzip and Gunzip


gzip filename (To use gzip to compress a file, The file is
compressed and saved as filename.gz)

gunzip filename.gz (To expand the compressed file, The


filename.gz compressed file is deleted and replaced with filename)

You can use gzip to compress multiple files and directories at the
same time by listing them with a space between each one:

zcat filename.gz (To view the contents of a compressed text file,


like filename.gz )

Zip and Unzip


zip -r filename.zip dir (To compress a file with zip. –r option specifies
that you want to include all files contained in the filesdir directory
recursively.).

zipping a file in a directory

unzip filename.zip (To extract the contents of a zip file.)

Archiving File and Directory via tar

tar is a file archive technique, which is used to make archive and


compress/decompress the files or directories.

Some tar options included:


-c: Create archive.

-C: Extract the files in particular directory.

-f: Archive File name.

-t: Show the list of files in the tar file.

-v: Verbose, display progress while creating archive.

-x: Extract files from tar archive.

-z: Compress archive using gzip program.

-j: Compress archive using bzip2 program.

tar -cvf filename.tar file1 file2 file3 (To archiving multiple files.)

tar -cvf filename.tar dir1 dir2 dir3 (You can archiving multiple
files and directories at the same time.)

tar -tvf filename.tar (To list the contents of a archive/tar


file)

tar -xvf filename.tar (To extract the contents of a


archive/tar file)

By default the tar command does not compress the files or directory. To
create a tar and bzip2 compressed file, use the -j option with tar.

tar -cjvf filename.tar.bz2 dir OR tar -cjvf


filename.tbz dir

You can also expand and decompressed a bzip2 tar file by using following
command:

tar -xjvf filename.tar.bz2 OR tar -xjvf


filename.tbz
To create a tar and gzip compressed file, by using the -z option:

tar -czvf filename.tar.gz dir OR tar -czvf


filename.tgz dir

You can expand a gzip tar file by using following command:

tar -xzvf filename.tar.gz OR tar -xzvf


filename.tgz
Lecture #08 Links & Types of Links

Types of Links

1. Soft Link

2.Hard Link

1. Soft Link
• Refer to a symbolic path indicating the abstract location of another file

• Linux OS recognizes the data part of this special file as a reference to


another file path. The data in the original file can be accessed through
the special file, which is called as Soft Link.

• Soft link is also known as Symlink or symbolic link

2. Soft link

• A soft link can link to a directories as well as files.

• A soft link, like a Windows shortcut, becomes useless when you remove
the original file.

• Soft link can cross the file system boundaries.

• Soft link is denoted by as ---->

 ln -s source_file target_file (This is how we can create a


softlink with –s)

 ln -s /path/to/file1.txt /path/to/file2.txt

Hard Link
 Hard links cannot links directories.

 Hard links cannot cross file system boundaries.


 Hard links, refer to the specific location of physical data.

 Hard link not depend on the original file.

 Hard link refers to any file by its inode numbers.

What is inode
An inode (index node) is a data structure found in many Unix file systems.
Each inode stores all the information about a file system object.

ls -i /home/hiday/Desktop/file_name

Hard Link

 ln source_file destination_file

ln {file.txt} {hard-link}

ln /tmp/file link-here
lecture # 09 Manage Users Accounts and Groups Working
with users and groups in Linux
Manage users and group

 Linux user accounts

 Linux groups

Linux User Accounts

 How Linux user accounts work

 Where Linux user accounts are stored

 Creating and managing user accounts from the command line

How Linux User Accounts Work

 Username

 Password

 By default, all user home directories are created and maintained in


the /home

directory.

 However, the root user’s home directory is /root

 On a Fedora 12 Linux system, the first regular user account created on


the system is always assigned a UID of 500. The next user account will
be assigned a UID of 501...

 Other distributions may use a different numbering scheme for the UID.

 The root user account is always assigned a UID of 0 on most Linux


distributions.

 It’s this UID that the operating system actually uses to control access
to files and directories in the file system.
Files in Which accounts and Groups info and Passwords
Store

 /etc/passwd This file contains the user account information for your
system.

 /etc/shadow This file contains passwords for your user accounts.

 /etc/group This file contains your system’s groups.

Creating and Managing User Accounts from the Command Line

 Using useradd

 Using passwd

 Using usermod

Using userdel

 Syntax: useradd options username

useradd Waheed (a user Waheed is created with home


directory in /home/Waheed)

 Options

–c Includes the user’s full name.

–e Specifies the date when the user account will be


disabled. Format the date as yyyy-mm-dd.

–l (change the username)

-L (to Lock the User )

–g (Specifies the user’s default group.)

–G Specifies additional groups that the user is to be


made a member of.

–M Specifies that the user account be created without a home


directory.

–m Specifies the user’s home directory.


–r Specifies that the user being created is a system user.

–s Specifies the default shell for the user.

–u Manually specifies a UID for the user.

Using paswd command (The passwd utility is used to change an existing


user’s password)

 Syntax: passwd username

passwd waheed (this is how we can set the passwd of


Waheed user)

Using usermod command

 From time to time, you will need to modify an existing user account.
The syntax for usermod is very similar to that used by useradd.

Syntax: usermod options username

–c Edits the user’s full name.

–e Sets the date when the user account will be disabled.


Format the date as yyyy-mm-dd.

–g Sets the user’s default group.

–G Specifies additional groups that the user is to be made


a member of.

–l Changes the username.

–L Locks the user’s account. This option invalidates the


user’s password.

–s Specifies the default shell for the user.

–u Sets the UID for the user.

–U Unlocks a user’s account that has been locked.

Use of userdel command

Syntax: userdel username


userdel waheed (here we Delete the user Waheed
but his home directory is still existing with removing whome direcoty use –r
command)

ID –nG any-user ( To view the Users groups in which he is add if we use –ng
then it shows only primary group but here it will show the primary and
secondary group)

Managing groups from the command line

 Using groupadd (groupadd abc) abc group is created

 Using groupmod (To Modify a group) (–g to change the group ID) (-A to
add the users) (-R to remove the Users) (groupmod –A group user-
name)

 Using groupdel (To Delete any group) (groupdel hidaya)

 Chage (this command is used to set the setting of


user account like when this user will be expired or when his passwd will
be expired etc)

Chage –l user-name (to view the account info)

Pass_MAX_Days 999  default

Pass_Min_Days 0

Pass_MIN_LEN 5

Pass_WARN_AGE 7

Note: - #Finger command show the user and its home directory but first we
have to install finger command

# Minimum User ID is 500 and maximum is 6000 and the system users
has 0 to 499 user IDS root has 0 user ID. Usergroups has the same name and
GID of groups and default those groups are there primary groups

#UMASK = Permission =Delegation. UMASK is set for all the user for
system users UMASK is 022 (it will be minus from 777 for directories and 666
for files), and for simple user this mask is 002. vi /etc/login.defs
#For making any user equal to root user then we have to change this
thing in thing sudores file “vi /etc/sudores” OR “visudo”. Here we are
doing Delegation mean we can give permission to users what task they can
perform like they can create users and they can change IP etc but they have
to use “sudo” word before command.

#if we don’t want to use sudo word then we have to write alias in
.bashrc file which is hidden and present in home directory of every user.

Anyuser@sul ~] vi .bashrc #( for single user)

Type= alias su=”sudo su”

root@sul ~] vi /etc/bashrc #(for all users)

Type= alias su=”sudo su”

Then sourec .bashrc for updating the bashrc file


Lecture # 10 Ownership and Permissions
Permissions

We apply permissions to restrict unauthorized access to our files and


directories i.e. for security purposes.

There are three types of Permissions in Linux Operating system.

1.Read 4=(100), 5=(101), 6=(110), 7=(111)

2.Write 2=(010), 3=(011), 6=(110), 7=(111)

3.Execute 1=(001), 3= (011) 5=(101), 7=(111)

r = Read, w = Write, x = Execute

• Owner (Who create the file or Directory)

• Group (group that has been assigned by the owner or root).

• Others (all the other users who are not the owner or member of

the group assigned to the file or directory).

While in the terminal go to any directory and enter the command

“ls–lh”. You may see the following output.

drw-r-xr-x. 2 root root 4.0k 2012-03-03 10:07 .

-rw-r-xr-x. 2 root root 4.0k 2012-03-03 10:07 .bash_logout

-rw-r-xr-x. 2 root root 4.0k 2012-03-03 10:07 .bash_profile

-rw-r-xr-x. 2 root root 4.0k 2012-03-03 10:07 .bashrc


In above figure we come to know that following permissions are set

on the hidden file named “.bashrc‟.

Note: Dot (.) in front of the name of any file indicates that this is
hidden file.

•Owner has the permission to read and write but can’t execute.

•Group can read and execute but don’t have the permission to

write.

•Others can also read and execute but don’t have the permission

to write in this file.

Note: Hyphen (-) is placed in place of the permission that you want

to revoke from owner, group or others.

In Linux permissions may be set up by three methods.

METHOD-1: By Using Binary Numbers

In this method we set the permissions by using 3-bit binary

numbers. We set permissions by using following command.

[root@localhost~]# chmod 755 File_name

First number ‘7’ will set the read, write and execute
permissions for the owner of the file/directory.

Second number ‘5’ will set the read and execute


permissions for the group.

Third number ‘5’ will set the read and execute permissions for others.

6 = 110 (this will set the permissions for OTHERS as)


read, r = 1 (true)
write, w = 1 (true)
execute, x = 0 (false)
Method-2: By Using “=“, “+‟ and “-‟ Symbols

In this method we set the permissions simply by using the following

syntax.

chmod u-rwx, g-rw, o-wx file_name;

This command will only revoke the read and write permissions from the
owner (u),

execute permission from the group (g), and write permission from the
others (o).

chmod u+w, g+r, o+wx file_name

This command will only add the write permission to the owner (u),

read permission to the group (g), and write and execute permissions

to the others (o).

chmod u-rw, g-x, o-w file_name

This command will only revoke the read and write permissions from

the owner (u), execute permission from the group (g), and write

permission from the others (o).

But while using “+‟ and “-‟ symbols we are just adding or revoking

the permissions to the previously existing permissions without

altering them. i.e. Suppose a file has the following permissions.

--x r-x –w-

Now we enter the following command

Chmod u+rw, g+w, o+rx file_name

Then we get the following permissions

rwx rwxrwx
Note: While using “=“ symbol to set permissions, all the previous

permissions on the source file or directory are replaced by the new

ones. i.e. Suppose a file is having the following permissions

r---w—wx

Now we enter the following command

Chmod u=wx, g=rx, o=r file_name

Then we get the following permissions on this file/directory.

-wxr-x r--

Method-3: By Using “ugo” Letters

In this method we set the permissions by entering the following

Command

Chmod ugo+w file_name

By entering this command we are adding write permission to all the

three entities i.e. Owner, Group, and Others. For example we have

following permissions on a file.

r–-r–-r—

By entering above command, we have following permissions.

rw-rw-rw-

One another way to set permissions on our files and directories is as

follows.

Chmod a+r file_name

Chmod a+w file_name


Chmod a+x file_name

Chmod a-r file_name

Chmod a-w file_name

Chmod a-x file_name

We’ll use any one of the above mentioned commands if we want to

add or subtract any of the permissions on ALL of the entities at a

time (by using a single instance)

chgrp group-name file_name/Dir_Name (To change the Group


Ownership)

Chown user.group file_name (This will change the owner


User.Group of any file or Dir)

Chown user.group Dir_name -R (this will change the owner of any


file or Dir –R will recursively change the ownership of all the sub files)

Note: - If there is no proper [root@sul ~] shell and it show only sh-4.1 or


anything this thing happened when we type shell in command line or any
user which is newly created and it has no file like .bashrc , .bashr_history etc
in his home directory than we have to copy the files from /etc/skil/*.
Lecture # 11 Advance Ownership and
Permissions
Advance Permissions

Sticky Bit, Super Group ID, Set UserID, Change


attribute
What is Sticky Bit?

Sticky Bit is mainly used on folders in order to avoid deletion of a folder and its content by other
users though they having write permissions on the folder contents. If Sticky bit is enabled on a
folder, the folder contents are deleted by only owner who created them and the root user. No one
else can delete other users data in this folder(Where sticky bit is set). This is a security measure
to avoid deletion of critical folders and their content(sub-folders and files), though other users
have full permissions.

Learn Sticky Bit with examples:

Example: Create a project(A folder) where people will try to dump files for sharing, but they
should not delete the files created by other users.

How can I setup Sticky Bit for a Folder?

Sticky Bit can be set in two ways

1. Symbolic way (t,represents sticky bit)


2. Numerical/octal way (1, Sticky Bit bit as value 1)

3. Use chmod command to set Sticky Bit on Folder: /opt/dump/

4. Symbolic way:

5. chmod o+t /opt/dump/


or
chmod +t /opt/dump/

6. Let me explain above command, We are setting Sticky Bit(+t) to folder /opt/dump by
using chmod command.

7. Numerical way:

8. chmod 1757 /opt/dump/


9. Here in 1757, 1 indicates Sticky Bit set, 7 for full permissions for owner, 5 for read and
execute permissions for group, and full permissions for others.

10. Checking if a folder is set with Sticky Bit or not?

11. Use ls –l to check if the x in others permissions field is replaced by t or T

12. For example: /opt/dump/ listing before and after Sticky Bit set

13. Before Sticky Bit set:

14. ls -l

15. total 8

16. -rwxr-xrwx 1 xyz xyzgroup 148 Dec 22 03:46 /opt/dump/

17. After Sticky Bit set:

18. ls -l

19. total 8

20. -rwxr-xrwt 1 xyz xyzgroup 148 Dec 22 03:46 /opt/dump/

21. Some FAQ’s related to Sticky Bit:


22. Now sticky bit is set, lets check if user “temp” can delete this folder which is created xyz
user.

23. $ rm -rf /opt/dump

24. rm: cannot remove `/opt/dump’: Operation not permitted

25. $ ls -l /opt

26. total 8

27. drwxrwxrwt 4 xyz xyzgroup 4096 2012-01-01 17:37 dump


$

28. if you observe other user is unable to delete the folder /opt/dump. And now content in this
folder such as files and folders can be deleted by their respective owners who created
them. No one can delete other users data in this folder though they have full permissions.

29. I am seeing “T” ie Capital s in the file permissions, what’s that?


30. After setting Sticky Bit to a file/folder, if you see ‘T’ in the file permission area that
indicates the file/folder does not have executable permissions for all users on that
particular file/folder.

31. Sticky bit without Executable permissions:

32.

33. so if you want executable permissions, Apply executable permissions to the file.
chmod o+x /opt/dump/
ls -l command output:
-rwxr-xrwt 1 xyz xyzgroup 0 Dec 5 11:24 /opt/dump/
Sticky bit with Executable permissions:

34.

35.

36.

37. you should see a smaller ‘t’ in the executable permission position.

38. How can I find all the Sticky Bit set files in Linux/Unix.

39. find / -perm +1000

40. The above find command will check all the files which is set with Sticky Bit bit(1000).
41. Can I set Sticky Bit for files?

42. Yes, but most of the time it’s not required.

43. How can I remove Sticky Bit bit on a file/folder?

44. chmod o-t /opt/dump/

Sticky Bit
Chmod 1777 Dir_name (Sticky bit will give th access to everyone
“Other user who are not creator of that file/Dir and they are not
number of that group then those or will be called others) they can see
but they can’t delete any contents)

These are used for others can’t delete any file, in that
directory

Super Group ID

chmod 2777 Dir_name (This will help us to create a SGID on


any Directory and that group will can access and view content but they
can’t remove the data/file from that Directory)

Super User ID

Chmod 4777 Dir_name (In this we can control user create files,
file creator and root user will control them.

Chattr

Chattr +i Dir/file (To Protect)

Chattr -i Dir/file (To remove Protectection)

Now in chattr we have power to create a file/Dir which will be as


much powerful that even root will not be able to delete that until he
remove that permission from it. And only root user can use it.

Note: - In Other T is shown when we put Sticky bit if others have permission
than it is “t” not capital but when others don’t have permission it is “T”
capital on “X”.
For UID,GID bit there is “s” when Group and owner have permission but
when they don’t have permission then there is “S” on “X”.
Lecture # 12 What is WINE (WINE(WINdows Emulator)
Is Not Emulator )
What is Wine?
Wine Stands for (Wine is Not Emulator)

Wine is a free software application that aims to allow computer programs


written for Microsoft windows to run in Unix-Like Operating System.

Wine is a translation layer (a program Loader) capable of running Windows


application on Linux and Unix.

Windows programs running in WINE act as native programs would,


running with a similar look and feel to other application on your desktop.

HISTORY
 The name WINE initially was an acronym for Windows Emulator.

 Wine Is Not an Emulator In order to differentiate the software


from other emulators.

 Bob Amstadt and Eric Youngdate started the Wine project in


1993.

o In the start WINE was distributed under the linkage of MIT


(Massachusetts institute of technology)

o Now it is distributed at LGPL Licence.

Why we use wine

 As we know Linux Don’t support .exe format it only install .rpm format
(IN REDHAT)

 But through Wine we can install .exe format software’s in Linux

o Wine can install 32 and 64 bit software.

Install wine

# yum install wine


Installing windows application with wine

 Open the terminal  cd to the directory  then type wine the-name-


of-the-application.exe (e.g, wine realplayer_installer.exe)

Uninstalling wine Aplication

Open up a terminal window and type command below

 Wine uninstaller

Running an application in wine windows

 Wine explorer whatever.exe

 Wine explorer wordpad.exe


Lecture # 13 Run Levels

Rune Levels

 A run level is a software configuration of the system which allows only


a selected group of processes to exist.

 A run level is a preset operating state on a Unix-like operating system.

 A run level is a state of init and the whole system that defines what
system services are operating after booting a system.

 Run levels are identified by numbers.

 There are seven run levels in Linux OS.

System Booting Process

• 0  Halt  Immediately shuts down the system and


powers it off.
• 1  Single-user mode  Used for system maintenance, root in
CLI mode.

• 2  Multi-user mode  without networking in CLI mode.

• 3  Multi-user mode  with networking in CLI mode.

• 4  Un-defined  Not in used

• 5  GUI  A standard run level for most Linux OS.

• 6  Reboot  Used when the system restarts.

Note: -Don't set run level 0, 1 and 6 as default run level.

vi /etc/inittab  (Configuration file which is read when computer is booted


up. The configuration file of run levels. Change the runlevel in last line of this
file.

Runlevel 5 to 3

• id:5:initdefault: OR id:3:initdefault:

Note: - Change runlevel when u have mistakenly chosed 0 or 6

1. Restart PC

2. Go to centos menu to select OS

3. Now select CENTOS and press “a” to append

4. Now you are in grub mode, there is following things

5. “rhgb quite (after quite type your desired runlevel

ITS DONE

How to Change Root User Passwd

1. Restart your PC and go to OS Selection, Now press “e” to Edit.

2. Now you are again selection mode (select kernel word line and press
“e”)

3. Now what ever typed you just have to type “S” remember just “S” and
Enter
4. Now you are in signing in mode and you can change password
Lecture #13 Virtual Network Computing

VNC
• Virtual Network Computing is a remote display system which allows
you to view a computing `desktop' environment not only on the
machine where it is running, but from anywhere on the local area
network or Internet.

• It is implemented in a client/server model. This package provides a


fully functional X server, to which a VNC viewer can connect.

• To access the server desktop you need a vncviewer to see something.


However, this viewer may also be on a computer running other
operating systems in the local net. This package is an enhanced
version of VNC including TigerVNC.

• VNC uses the Remote Frame Buffer(RFB) protocol

• VNC is platform-independent

• VNC viewer on one operating system may connect to a VNC server on


the same or any other operating system.

• There are clients and servers for many GUI-based operating systems.

• Multiple clients may connect to a VNC server at the same time.

History

• VNC was originally developed at the Olivetti & Oracle Research Lab
in Cambridge, United Kingdom.

• The original VNC source code and many modern derivatives are open
source under the GNU General Public License.

What is VNC?

• The VNC server is the program on the machine that shares its screen.
The server passively allows the client to take control of it.

• The VNC client (or viewer) is the program that watches, controls, and
interacts with the server. The client controls the server.
• The VNC protocol (RFB) is very simple, based on one graphic
primitive from server to client ("Put a rectangle of pixel data at the
specified X,Y position") and event messages from client to server.

Install VNC

• yum install vnc-server  To install VNC server.

• yum install vnc  To install VNC viewer or VNC client.

• yum install vnc-server vnc  To install VNC server and client at a


time.

Setting up VNC Server

To access the server from client side, we have need to a connection id at


server side, by using that id client can access the server.

• vncserver :id <enter>

password :xxxxxx <enter>

Verify :xxxxxx <enter>

• To create connection id by using “vncserver” commanand,


and give the password for given id.

• id

• Id can be any integer number & client should enter the


same id number with the IP of server.

VNC Client

• Give the ip of VNC server with id at terminal,

• vncviewer ip-of-server:id <enter>

OR

• Go to

• Applications>Internet>TigerVNC Viewer
• To access the server desktop give the server’s IP with id of
that user and give the password.

Password of any user will be set for first id only other ids of same user will be
use same password.

• But if any other user will create new id he should set the password for
his id.

• All the VNC user’s id, password and log files stored in their home
directory

• /root/.vnc OR /home/hidaya/.vnc

• .vnc is hidden directory which stores the information of vnc user’s id,
password and log file.

Use of VNC server and client

1. yum install vnc-server and yum install vnc

2. now create any id (#] vncserver :3)

3. before these get Xvnc for viewing

4. now vnc client can access your computer with the id and password you
gave him, client will type this in VNC Tigerviewer

192.168.2.120:3
Lecture # 14 SSH (Secure Shell )
Secure SHell (SSH)

SSH is a protocol for secure remote access/login and other secure network
services to a machine over untrusted networks.

 developed by SSH Communications Security Corp., Finland

Two distributions are available:

 Commercial version

 Freeware (www.openssh.com)

SSH is not a shell like Unix Bourne shell and C shell

 OpenSSH is a suite of secure network connectivity tools that:


replaces telnet, rcp, rsh/rshd, rlogin/rlogind, and ftp/ftpd. Unlike
the tools it replaces, OpenSSH tools encrypt all traffic, including
passwords

 When OpenSSH starts, it first establishes an encrypted


connection and then authenticates the user. Once these two
tasks are completed, OpenSSH allows the two systems to send
information back and forth.

To run a secure shell on or securely copy a file to/from a remote system, the
following criteria must be met:

 The remote system must be running sshd daemon such as


OpenSSH,
you must have an account on the remote system, and the server
must positively identify itself to the client.

 When you connect to an OpenSSH server for the first time, the
OpenSSH client prompts you to confirm that you are connected
to the right system. This checking can help prevent a man-in-the-
middle attack.

The message is like this

 (The authenticity of host ‘hidaya (192.168.2.63)' can't be


established.
RSA key fingerprint is
c9:03:c1:9d:c2:91:55:50:e8:19:2b:f4:36:ef:73:78.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'grape,192.168.0.3' (RSA) to the list
of
known hosts.)

OpenSSH clients and servers rely on many files. Global files are kept in
/etc/ssh and user files in ~/.ssh

Using ssh and scp

The ssh and scp clients do not require setup beyond installing the
requisite packages,

although you can create and edit files that facilitate their use. To run a
secure shell on or securely copy a file to/from a remote system, the following
criteria must be met: The remote system must be running an RFC-compliant
sshd daemon such as OpenSSH, you must have an account on the remote
system, and the server must positively identify itself to the client.

Using ssh and scp

The following example shows a user logging in on 192.168.2.63 as


hidaya and

then giving an exit command to return to the shell on the local system

[[email protected]]# ssh [email protected]

[email protected] password:

[hidaya@localhost ~]$ exit

Connection to 192.168.2.63 closed.

[[email protected]]#

The first time you connect to a remote OpenSSH server, ssh or scp
asks you to confirm that you are connected to the right system

The following example copies file.txt from the working directory on the local
system to

Hidaya’s home directory on 192.168.2.63. The trailing colon is critical;


without it you will make a local copy of the file.
$scp local/sender client/receiver = $ scp file.txt
[email protected]:/home/

[email protected] password:

File.txt 100% |*****************************| 1311 00:00

The following example runs ls in the hist directory on the remote system
192.168.2.63

The example assumes that the user running the command ( has a login on

192.168.2.63 and that the hist’s directory is in local system’s home


directory on 192.168.2.63:

[[email protected]]# ssh 192.168.2.63 ls hist

The following example sends a message on the remote system


192.168.2.63

Ssh 192.168.2.63 wall “type your message here”

Or

Ssh 192.168.2.63 write hidaya(username) pts/0(terminal)

This will establish a session for messages to send

scp: Copies Files from/to a Remote System

The scp (secure copy) utility copies an ordinary or directory file


from one system to another on a network. This utility uses ssh to transfer
files and employs the same authentication mechanism as ssh; thus it
provides the same security as ssh.

The scp utility asks you for a password when one is required. The
format of an scp command is

scp [[user@]from-host:]source-file [[user@]to-host:][destination-file]


Ex.to copy file.txt from remote system(192.168.2.34) to remote system
(192.168.2.38) type as follow

Scp [email protected]:/home/file.txt [email protected]:/home

Denying SSH Connections from a specific IP

• Put the IP you want deny connection from in following file.

• Vi /etc/hosts.deny

• Sshd: 192.168.2.12

RSA vs DSA
Lecture #15 PuTTy
What is PuTTy?

• PuTTY is a free and open source terminal emulator application which


can act as a client for the SSH, Telnet, rlogin, and raw TCP computing
protocols and as a serial console client. The name "PuTTY" has no
definitive meaning, though "tty" is the name for a terminal in the Unix
tradition, usually held to be short for Teletype.

• PuTTY was originally written for Microsoft Windows

• PuTTY is teminal emulator

• Putty is GUI based tool for remote login

• PuTTY was written and is maintained primarily by Simon Tatham

• Control over the SSH encryption key and protocol version.

• License under MIT  The MIT License is a free software license


originating at the Massachusetts Institute of Technology (MIT).

Install Putty

• yum install putty (To install putty in Linux platform.)

• Download the PuTTY software in .exe format(To install putty in


Microsoft platform)

Putty is used in linux it is cross plateform just from windows to linux but we
can’t communicate linux to windonw.
Configuration files

/etc/ssh/ssh_config/.ssh/config

/etc/ssh/ssh_config: - To deny any user to allow connection with local host or


we can deny all the users

/etc/ssh/sshrc

/etc/rsh

/etc/hosts.deny (to deny any IP)

/etc/hosts.allow (to allow any specific IP)

/etc/passwd (it contains info about all the created users including
their ID’s and group ID complete name and home directories and login bash)

/sbin/nologin (This is a nologin bash it means user cannot


login it never prompt)

RFC = Request For Comments

Deny IPs in SSH

• Put the IP you want deny connection from in following file.

• Vi /etc/hosts.deny

• Sshd: 192.168.2.12
Lecture # 16 SCP and SFTP
SCP = Securely CoPy

SFTP = Secure File Transfer Protocol

How to Use SFTP

] $/# sftp [email protected]

passwd:

Sftp>

Now use commands here like checking which files are present here and
we can download and even we can upload from here

Sftp> put –p local-path remote-path

Sftp> put –p putty.ppt /home/hidaya/

To Download

Sftp> put –p remote-path local-path

Sftp> get –p putty.ppt /home/Hidaya


Lecture # 17 IP-SUBNET
IP = INTERNET PROTOCOL

 IP Address is a unique identification given to Host, network device, server


for data communication.

 IP Address stand for Internet Protocol address, it is an addressing scheme


used to identify a system on a network. It is a unique address that certain
electronic devices currently use to communicate with each other on a
network using internet protocol.

IPV4

 IPV4 is a 32 bit number represented in 4 decimal numbers, where each


decimal number is of 8 bit (an octet), where each octet is separated by a
dot in between.

IPV

 IPV6 is of 128 bits represented in 8 combination of 4 hexa decimal numbers


each, separated by a colon. Hence IPV6 is called a 16-bit Hexadecimal Colon-
delimited Block.

Class Address Range Supports


Class A 1.0.0.1 to 126.255.255.254 Supports 16 million hosts on each of 127
networks.
Class B 128.1.0.1 to 191.255.255.254 Supports 65,000 hosts on each of 16,000
networks.
Class C 192.0.1.1 to 223.255.254.254 Supports 254 hosts on each of 2 million
networks.
Class D 224.0.0.0 to 239.255.255.255 Reserved for multicast groups.
Class E 240.0.0.0 to 254.255.255.254 Reserved for future use, or Research and
Development Purposes.

Loop Back IP

127.0.0.1

This IP is the IP of all computers they can ping themselves


through this.

Private Address Ranges

Class A 10.0.0.0 to 10.255.255.255


Class B 172.16.0.0 172.31.255.255

Class C 192.168.0.0 192.168.255.255

Subnet Mask
A mask used to determine what subnet an IP address belongs to. An IP
address has two components, the network address and the host address.

A sub-network, or subnet, is a logically visible subdivision of an IP network.


The practice of dividing a network into two or more networks is called
subnetting.

Subnetting an IP network is to separate a big network into smaller multiple


networks for reorganization and security purposes.

All nodes (hosts) in a subnetwork see all packets transmitted by any node in
a network. Performance of a network is adversely affected under heavy
traffic load due to collisions and re transmissions

Subnetting a Class C network


So you understand why you want to subnet, but how do you do it? Your goal
is to look at an IP address and subnet mask of a host and then determine
three things quickly:

• The subnet the host is located in

• The broadcast address of the subnet

• The valid host range of the subnet used to configure hosts

Subnet
The default Class C mask is: 255.255.255.0. To make smaller networks, called
subnetworks, we will borrow bits from the host portion of the mask. Since the Class
C mask only uses the last octet for host addressing, we only have 8 bits at our
disposal. Therefore, only the following masks can be used with Class C networks .

Mask Binary Subnet Host bits Subnets Hosts


bits
255.255.255.128 10000000 1 7 2 126
255.255.255.192 11000000 2 6 2 62
255.255.255.224 11100000 3 5 6 30
255.255.255.240 11110000 4 4 14 14
255.255.255.248 11111000 5 3 30 6
255.255.255.252 11111100 6 2 62 2

Class C Sub-netting

You can see that the bits that are turned on (1s) are used for
subnetting, while the bits that are turned off (0s) are used for addressing of
hosts. You can use some easy math to determine the number of subnets and
hosts per subnet for each different mask.

To determine the number of subnets, use the 2x, where the x exponent
is the number of subnet bits in the mask.

To determine the number of hosts, use the 2x-2, where the x exponent is the
number of host bits in the mask.

For example, if you have eight networks and each requires 10 hosts,
you would use the Class C mask of 255.255.255.240. Why? Because 240 in
binary is 11110000, which means you have four subnet bits and four host
bits. Using our math, we’d get the following:
24=16 subnets
24-2=14 hosts

128+64+32+16+8+4+2+1

1 1 0 0 0 0 0 0

You can see that the bits that are turned on (1s) are used for subnetting,
while the bits that are turned off (0s) are used for addressing of hosts.

Broad Cast Address


A broadcast address is a logical address at which all devices connected
to a multiple-access communications network are enabled to receive
datagrams. A message sent to a broadcast address is typically received by
all network-attached hosts, rather than by a specific host.
Lecture # 18 NFS (Network File System)
 NFS is a way to share files between machines on a same network as if
the files were located on the local machine.

 NFS was developed to allow machines to sharing of files across the


network in Linux environment.

 NFS is an excellent way of sharing files between Linux and other UNIX
systems.

 While Samba is a great choice due to the compatibility with Windows, if


you’re in a Windows-less environment, NFS may be a better choice.

 NFS was developed by Sun Microsystems in 1984.

Installation of NFS

We can also install NFS by using yum command

• yum install nfs*

Note: - Disable the fire wall by using setup command

Daemon of NFS is nfs and we have service like service nfs


start/stop/reload etc.

How to configure nfs

Make a directory in root “/” directory and put data or files which you want to
share.

mkdir /dir

• Suppose we create a directory in root directory by name “system”

• vi /etc/exports

• A configuration file of NFS server.

• /dir *(ro,sync) # ro =read only and synchronize

• /dir *(rw,sync) # read Write and Synchronize


• Also set the chmod o+w file

• /system *(rw,no_root_squash)

• Put entries like above according to your required options.

• exportfs

• A command to view exported/shared data on your NFS


server.

• After then restart the service of NFS.

• chkconfig --level 35 nfs on

• A command to permanently start the service of NFS server


and portmap on run level 3 and 5.

• showmount -e 192.168.2.115

• A command to view the shares of given ip (NFS server),

• it will show the directory and location of that directory, which is


shared by NFS server.

How can client access the NFS shares

• Make a directory at client side system with any name.

• mkdir /mnt/system

• Suppose we create a directory in “/” root directory by


name /mnt/system

mount -t nfs 192.168.2.115:/system /mnt/system

 A command through which we can mount the shares of NFS


serve.

 In this whole command mount is a command -t mean type nfs,


given ip is the ip of NFS server's ip, /dir is a directory which is
exported or shared by our NFS server, /mnt/dir is a mounting
point at our client side machine.

Permanent mounting
• vi /etc/fstab

• 192.168.2.115:/sys tem /mnt/dir nfs defaults 0 0

– Put the above entry in /etc/fstab file at below position.

– And then go to the /mnt/dir directory to access the shares of


NFS server.

Note: if the service computer is not terned on or it is slowing


opening than the client will have to wait until this

 Chkconfig --list nfs (To show the list of nfs booting time in all
the run levels)

To put Ethernet on when computer is turned on, go to following file and do


little changing on “ONBOOT=”yes”” if there is no ONBOOT.

 File: vi /etc/sysconfig/network-scripts/ifconfig-eth0
Lecture # 19 LAMP (Linux Apache Mysql
PHP/Python/Perl/PgSQL)
LAMP is mostly used around the world whether you use Google, Facebook,
Yahoo etc. Most of the world’s top websites are running on this because here
user have authorities to do anything on his wish, but other platform’s are not
free and independent like this, so whenever you want to change something
deeply than you need to review your license or order for another license
mean more money. But in Linux platform no need of special licenses they all
are free for use and their code is also present and they want you to change
on your requirement by your own self.

http://toolbar.netcraft.com/site_report?url=http://www.google.com

Use above site to check about your desired site which platform they are
using.

Why are advanced and future web apps are running on


LAMP Stack?
 More Secure

 Highly Scalable

 Open Source

 Low costs

 Great Performance
But Then
Why are still few companies
afraid
of switching to it?

Linux

 Very reliable OS

 Extremely powerful

 Performs great even in less resources

 Powerful Programming supports

 Scalable

 No piracy issues

Apache

 Only web-server to run on all major platforms (*NIX, WINDOZ, MAC,


FREEBSD and any other you name it)

 Largest Market share holder for web servers since 1996 and still growing.

 The Apache HTTP Server, commonly referred to as Apache, is a web


server software program notable for playing a key role in the initial growth
of the World Wide Web. In 2009, it became the first web server software
to surpass the 100 million website milestone. Apache was the first viable
alternative to the Netscape

 Apache is developed and maintained by an open community of


developers under the auspices of the Apache Software Foundation. The
application is available for a wide variety of operating systems, including
Unix, FreeBSD, Linux, Solaris, Novell NetWare, OS X, Microsoft Windows,
OS/2, TPF, and eComStation. Released under the Apache License, Apache
is open-source software.

 Since April 1996 Apache has been the most popular HTTP server software
in use. As of June 2013, Apache was estimated to serve 54.2% of all active
websites and 53.3% of the top servers across all domains.
 Although the main design goal of Apache is not to be the "fastest" web
server, Apache does have performance similar to other "high-
performance" web servers.

 Original author(s) Robert McCool

 Developer(s) Apache Software Foundation

 Initial release 1995

 Stable release 2.4.4 (February 25, 2013; 4 months ago)

 Development status Active

 Written in C

 Operating system Cross-platform

 Available in English

 License Apache License 2.0

MYSQL
 World’s Fastest growing open source database servers.

 fast performance, high reliability and ease of use.

 It's used on every continent -- Yes, even Antarctica

 Work on more than 20 platforms including Linux, Windoz, OS/X, HP-UX,


AIX, Netware to name a few

PHP
 Open Source server-side scripting language designed specifically for the
web.

 Conceived in 1994, now used on +10 million web sites.

 Outputs not only HTML but can output XML, images (JPG & PNG), PDF files
and even Flash movies (using libswf and Ming) all generated on the fly.
Can write these files to the filesystem.
 Supports a wide-range of databases (20 + ODBC).

 Perl- and C-like syntax. Relatively easy to learn.

Installation of Apache

• Yum install httpd

• Daemon of apache is httpd

Service options Of Apache

• Service httpd start

• Service httpd restart

• Service httpd stop

• Service httpd status

• Service httpd reload

Documentation

• Configuration file of apache

• /etc/httpd/conf/httpd.conf

• Document root of apache

• /var/www/html

• Log files of apache

• /var/log/httpd/accees and error logs


Lecture # 19 Virtual-Hosting-Apache
What is Virtual-Hosting?

 The term Virtual Host refers to the practice of running more than one
web site (such as www.company1.com and www.company2.com) on a
single machine

 Using Apache Virtual Host, you can run several websites on the same
server.

 For example, I can run both abc.com and xyz.com on a single physical
server that has one Apache webserver running on it.

Types of Virtual Hosting

There are two types of Apache virtual host configurations:

1) IP-Based Virtual Host and

2) Name-based Virtual Host. Name-based virtual host is recommended for


most scenarios.

Ip-based Virtual Hosting

 In this configuration, when you are pointing two websites (with


different ip-address) to the server that runs Apache, that physical
server should have two different ip-address configured.

 This means that the server should have two ethernet cards, each one
of them configured to the ip-address of the corresponding website that
Apache virtual host will be serving. So, this is not practical for most
aspects, and you should not be using this.

 In the following example, the server contains two NIC cards. one is
configured with 192.168.1.1 ip-address for abc.com, another is
configured with 192.168.1.2 for xyz.com. Both these ip-address are
served by a single Apache webserver running on that server using IP-
Based virtual host.

Name Base Virtual Hosting


 In this configuration, when Apache webserver receives a request, it
looks for the hostname in the HTTP header, and depending on the
hostname, it servers different websites.

 This is very easy, as you need only one ip-address on that physical
server; but, you update the DNS with multiple website names pointing
to the same ip-address. For all practical purpose, you’ll be using only
Name-based virtual host configuration.

 In the following example, the server contains only one NIC card, which
is configured with 192.168.1.1 ip-address.

 The DNS entry for both abc.com and xyz.com website points to
192.168.1.1 ip-address. When Apache recives a request, it looks for the
hostname entry in the HTTP header, and serves the corresponding
website.

Setup Virtual Host

 Modify the configuration file of Apache /etc/httpd/conf/httpd.conf as


shown below to setup named-based virtual host setting for two hosts.

 There are 3rd section in apache configuration file virtual hosting


section.

<VirtualHost *:80>

ServerAdmin [email protected]

DocumentRoot /var/www/vhost/abc/

#This Location should be create by own self

ServerName abc.com

ErrorLog /var/www/abc/logs/access_log

CustomLog /var/www/abc/logs/error_log common

#These Files on Location should be create by own self. These access log and
error logs files are used to view who has been visiting our sites and what he
has been downloading.

</VirtualHost>
 NameVirtualHost *:80 – Indicates that all the name-based virtual hosts
will be listening on the default port 80

 <VirtualHost *:80> </VirtualHost> – Enclose all the apache


configuration parameters for each and every virtual host between
these VirtualHost tags. Any apache directives can be used within the
virtualhost container.

 In the following example, we are setting up virtual host for abc.com


and xyz.com listening on the same port 80. So, there will be two
<VirtualHost *:80> </VirtualHost>, one for each website.

Note: if we want to access any site that is hosted on any single computer
than we have to change in /etc/hosts file and type something like following.

192. 168.2.120 jokhio.com


Lecture # 20 Enterprise Level Virtual-Hosting-Apache
Above work we did was just a click how to do but here we will learn how to
create a site that is enterprise level. Enterprise level sites are handled by
computers through sftp/scp and the user have sbin/nologin shell than that
user is just logged in through sftp and he can change just his site not other
home files that are exist on our computer.

[root@sul]# useradd –d /var/www/vhost/ali ali

#User ali is created and /var/www/vhost/ali is his home directory.


Now set passwd too

[root@sul]# passwd ali

# Now give desired passwd that you want, and give him the authority
of that folder and subfolders with following command

[root@sul]# chown ali.ali /var/www/vhost/ali/ -R

# -R used for recursively mean if there is sub-files and folders than they will
be owned by ali user. Now add apache user in ali user than apache can open
that site of yours. Now restart service of httpd.

# If you want a user whose home directory is in /home/ali than use following
commands.

[root@sul]# getsebool

[root@sul]# setsebool –P httpd_enable_homedirs on

[root@sul]# setsebool –P httpd_read_user_content on

# Now apache can read files from users whom directory otherwise
apache can’t read them.
Lecture # 21 FTP (FILE TRANSFER PROTOCOL)
• File Transfer Protocol (FTP) is a standard network protocol used to
transfer files from one host to another host over a TCP-based network,
such as the Internet.

• The Daemon on FTP is Vsftpd (Very Secure FTP Daemon) is an FTP


server for UNIX-like systems, including CentOS / RHEL / Fedora and
other Linux distributions.

Install vsftpd

[root@sul]# yum install vsftpd

• Default port: TCP / UDP - 21 and 20

• The main configuration file: /etc/vsftpd/vsftpd.conf

• The document root for ftp: /var/ftp/pub

Turn on vsftpd
• Service vsftpd start/restart/reload/stop/status

• chkconfig vsftpd on

OR

• chkconfig --level 35 vsftpd on

Now Go to any browser:


ftp://127.0.0.1

ftp://192.168.2.119 #computers IP

ftp://localhost

FTP://hostname
• Yum install gftp = These Software’s are used to download the files that
you want to change and then change the file and re upload it.

• cuteftp (availble in exe) # This is for Windows

There are sites give us ftp connection like mirror-cybernet.lums.edu.pk. dig is


command through we can have all the info of that site.

[root@sul]# dig -x www.google.com = Now we can get IN (Inter


Name /PTR Pointer)

[root@sul]# host IP-Address

Username: anonymous = Internationally recognized

Password: Garbage = Internationally recognized


Lecture # 22 MySQL (Structure Query Language)
MySQL

What is Data?

Unprocessed Facts, Figures and statistics, which give no proper meaning.

CREATE - To create databases and tables in the database.

ALTER - Alters the structure of the database and tables.

DROP - Delete the database and tables from the database.

TRUNCATE - Remove all records from a table.

RENAME - To rename an object.

What is a Database?

A structured set of data held in a computer, esp. one that is accessible in


various ways.

What is Database Management System?

Software that handles the storage, retrieval, and updating of data in a


computer system.

What is the Database Server?

A database server is a computer program that provides database services to


other computer programs or computers,

What is a Database Client?

Provides an interface through which we can issue SQL statements and have
the results displayed.

What is DDL?

Data Definition Language (DDL) describes the portion of SQL that allows you to create,
alter, and destroy database objects.

What is DML?

Data Manipulation Language (DML) describes the portion of SQL that allows
you to manipulate or control your data.
What is DQL?

The SELECT statement retrieves data from the database. Following are the clauses of the
statement, which are demonstrated in the following sections:

 SELECT Lists the columns that are to be returned in the results


 FROM Lists the tables or views from which data is to be selected

 WHERE Provides conditions for the selection of rows in the results

 ORDER BY Specifies the order in which rows are to be returned

 GROUP BY Groups rows for various aggregate functions

MySQL
 MySQL "My S-Q-L" officially, but also called "My Sequel“

 The world's most used open source database management system


(DBMS) that runs as a server providing multi-user access to a number
of databases.

 The original developments of MySQL by Michael Widenius and David


Axmark beginning in 1994.

 Developer(s): Oracle 2010 (formerly Sun Microsystems 2008


formerly MySQL AB1995)

 Initial release: 23 May 1995

 Stable release: 5.6.10 / 5 February 2013;

 Written in: C, C++

 OS: Cross-platform

 License : GNU General Public License

 Configuration files /etc/my.cnf

 Log File /var/log/mysql.log

 Socket File /var/lib/mysql/mysql.sock

 Process Key/ID /var/run/mysql/mysql.pid


 Daemon of Mysql mysqld

 Port no 3306

Features Of Mysql

Open Source Free Portability (Cross Platform)

Speed and Reliability Ease of Use Multi user support

Dual license (free and non-free) Wide application support

Command Line as well as GUI support

Install

yum install mysql

yum install mysql-server

Connecting MySQL Server


#mysqladmin password ‘newpasswd’ ##for New
Passwd

#mysqladmin password ‘newpasswd’ –p ‘old-passwd ##for changing


Passwd

# mysql -u <username>

# mysql -h <hostname>

# mysql -D <database>

# mysql -p <password>

# mysql -u root -h linuxadmin -D hist -p

DDL Create Command


CREATE DATABASE hist;

CREATE TABLE student (std_id INT(7), name VARCHAR(20), program


VARCHAR(20), shift VARCHAR(10) );

DDL ALTER Command

ALTER TABLE student ADD COLUMN qualification


VARCHAR(20);

ALTER TABLE student DROP COLUMN qualification;

ALTER TABLE student CHANGE COLUMN qualification education


VARCHAR(20);

ALTER TABLE student MODIFY COLUMN qualification


VARCHAR(30);

ALTER TABLE student MODIFY COLUMN Id_int primary key


auto_increment;

DDL Truncate Command

TRUNCATE student;

DDL DROP Command


DROP DATABASE hist;

DROP TABLE student;

DML Statement
DML - Data Manipulation Language. It is used to retrieve, store, modify,
delete, insert and update data in the table.

INSERT - insert data into a table

INSERT INTO student (std_id, name, program, shift) VALUES (1,


”ali”, ”sysadmin”, ”morning”); OR

INSERT INTO student VALUES (1, ”ali”, ”sysadmin”, ”morning”);

SELECT - retrieve data from the a table


SELECT * FROM student;

SELECT name,shift FROM student;

SELECT name,shift FROM student WHERE


Program=“sysadmin”;

SELECT name,shift FROM student ORDER BY name;

UPDATE - updates existing data within a table

UPDATE student SET shift=“evening” WHERE std_id=123 ;

UPDATE student SET shift=“evening”;

DELETE - deletes all records from a table

DELETE FROM student WHERE std_id=123;

DELETE FROM student;

DQL Statements
DQL – Data Query Language is used to query the information from a
database or table.

SHOW DATABASES hist;

USE database hidaya; #By the help of this we can set any
database

SHOW TABLES hidaya;

DESCRIBE hidaya # This command will describe all the


fields(Columns).

RENAME table hidaya to interns #This command will rename


the hidaya table to interns.
Lecture # 23 phpMyAdmin

phpMyAdmin is a free software tool written in PHP, intended to handle the


administration of MySQL over the World Wide Web. phpMyAdmin supports a wide
range of operations with MySQL. The most frequently used operations are supported
by the user interface (managing databases, tables, fields, relations, indexes, users,
permissions, etc), while you still have the ability to directly execute any SQL
statement.

History
Tobias Ratschiller, an IT consultant and later founder of the
software company Maguma, started to work on a PHP-based web front-end
to MySQL in 1998, inspired by MySQL-Webadmin.

PHPMyADMIN
Developer(s) The phpMyAdmin Project

Initial release September 9, 1998

Stable release 4.0.4.1 (June 30, 2013)

Written in PHP, XHTML, CSS, JavaScript

Operating systemCross-platform

Available in Multilingual (64)

License GNU General Public License

Features
Web interface

Support for most MySQL features:

browse and drop databases, tables, views, fields and indexes

create, copy, drop, rename and alter databases, tables, fields and indexes

maintenance server, databases and tables, with proposals on server


configuration
manage MySQL users and privileges

Import data from CSV and SQL

Export data to various formats: CSV, SQL, XML, PDF

Creating PDF graphics of your database layout

Install phpmyadmin

• yum install phpmyadmin  To install phpMyAdmin

Configuration

• vi /etc/httpd/conf.d/phpMyAdmin.conf

• Go to configuration file and add these lines at bottom, for user to


allow because any user have the privilege to control
phpmyadmin. Default root user that is set for mysql is used here
before using this mysql should run or service mysqld or
chkconfig command is used.

<Directory "/usr/share/phpMyAdmin">

Order allow,deny

Allow from all

</Directory>
Lecture # 23 SAMBA
• Samba is software that can be run on a platform other than Microsoft
Windows, for example, UNIX, Linux, IBM System 390, OpenVMS, and
other operating systems.

• Samba uses the TCP/IP protocol that is installed on the host server.
When correctly configured, it allows that host to interact with a
Microsoft Windows client or server as if it is a Windows file and print
server.

• In computer networking, Server Message Block (SMB), also known as


Common Internet File System (CIFS) operates as an application-layer
network protocol mainly used for providing shared access to files and
printers communications between nodes on a network.

• Samba is a free software re-implementation of the SMB/CIFS


networking protocol, originally developed by Andrew Tridgell in 1992.

• Samba provides file and print services for Microsoft Windows clients.

Samba
Initial release 1992

Stable release 4.0.7 / July 2, 2013

Development status active

Written in C / C++ / Python

Operating system Multiplatform

Type Network file system

License GNU General Public License

• It works on port # 137, 138 and 139.

• 137 Netbios name service (IP or Name).

• 138 Netbios datagram service (sending message).

• 139 Netbios session service.


To install samba server.
yum install samba

The daemon of samba is smb.

• After installation start the service smb start of samba.


chkconfig smb on

Samba Configuration

• /etc/samba/smb.conf  Configuration file of samba.

Put following lines to share data/resources between window and


Linux computers.

[My-share]

comment = Shared Data

path = /share

browseable = yes

writable = no

valid users = hidaya

Configuring the samba server at Linux side to share data “/share” for
Microsoft windows systems over the network.

• smbpasswd -a user-name  To add a samba user and set password


to the user account.

Sharing files

smbclient -L ip-of-win -U user-name

smbclient -L 192.168.2.11 -U hidaya

 To view or lists shared data of Microsoft Windows at Linux side

How to access data from Win


There are two ways to access shared data of Microsoft Windows machine at

Linux side.

• 1. SMB mode.

• 2. Mounting

1. SMB mode

• smbclient //source -U user-name

• smbclient //192.168.2.11/share -U hidaya

• smb: \> get file-name

• To download file from windows pc.

• smb: \> put file-name

• To upload file on windows pc.

• smb: \> mget *.ppt

• To download multiple file having same extention.

Mounting

o mount -t cifs //source /destination -o username=user-name

o mount -t cifs //192.168.2.11/share /mnt/smb -o


username=hidaya

• To mount shared data of win-pc in /mnt/smb folder.

Permenant mounting
vi /etc/fstab

• //192.168.2.11/share /mnt/smb cifs


username=hidaya,password=xyz 0 0

• To permanent mount.
Lecture # 23 DHCP
DYNAMIC HOST CONFIGURATION PROTOCOL

DHCP (Dynamic Host Configuration Protocol) is a communications protocol


that lets network administrators centrally manage and automate the assignment of
Internet Protocol (IP) addresses in an organization's network.

Without DHCP, the IP address must be entered manually at each computer in


an organization and a new IP address must be entered each time a computer moves
to a new location on the network.

DHCP lets a network administrator supervise and distribute IP addresses from


a central point and automatically sends a new IP address when a computer is
plugged into a different place in the network.

DHCP uses the concept of a "lease" or amount of time that a given IP address
will be valid for a computer. The lease time can vary depending on how long a user
is likely to require the Internet connection at a particular location. It's especially
useful in education and other environments where users change frequently.

Using very short leases, DHCP can dynamically reconfigure networks in which
there are more computers than there are available IP addresses. The protocol also
supports static addresses for computers that need a permanent IP address, such as
Web servers

Normally the DHCP server provides the client with at least this basic
information:

IP Address

Subnet Mask

Default Gateway

Dns

Explain DHCP DORA process?

DORA = Discover Offer Request Acknowledge

Discover = When the computer start it search for DHCP then he Discover
and send a request.

When a client is configured with the ip setting to obtain Ip address


automatically. Then the client will search for DHCP server and the UDP Broadcast to
the server about the DHCP discover
Offer: Here the DHCP server offers the IPz to client computer

DHCP Server will offers a scope of ip address available in the pool.

Request: In response to the offer, the Client will requests for an ip address.

Acknowledge: In response to the request, server will responds with Ip


address, Mask, Gty, Dns info along with the acknowledgment packet.

DHCP PORTS
DHCP client, is executed on the client machine, it begins broadcasting
requests for configuration information. By default, these requests are on UDP port
68. The server replies on UDP 67, giving the client.

Installing DHCP server on Centos 6


[root@localhost ~]# yum install dhcp

After installing dhcp server.

Assign a static ip (eg: “192.168.2.119″) in the same DHCP range for the
listening interface ( eg : “eth0″ ).

Open /etc/sysconfig/network-scripts/ifcfg-eth0 file and make the changes as


per your requirement .

Now open /etc/sysconfig/dhcpd file and add the preferred interface name to
DHCPDARGS variable as below
# Command line options here DHCPDARGS=eth0

DHCP Configuration

open /etc/dhcp/dhcpd.conf file

#specify DNS server ip and additional DNS server ip

option domain-name-servers 192.168.1.10, 208.67.222.222;

#specify default lease time

default-lease-time 600;

#specify Max lease time

max-lease-time 7200;

#specify log method

log-facility local7;

#Configuring subnet and iprange

subnet 192.168.2.1 netmask 255.255.255.0 {

range 192.168.2.50 192.168.2.254;

option broadcast-address 192.168.2.255;

#Default gateway ip

option routers 192.168.2.1;

Fixed IP Address

#Fixed ip address based on MAC id

host Printer01 {

hardware ethernet 02:34:37:24:c0:a5;

fixed-address 192.168.1.55;

}
Service of DHCP
[root@localhost ~]# service dhcpd start/stop/status/reload

[root@localhost ~]# chkconfig --levels 35 dhcpd on

Note: Clients can get IP from DHCP server and Please ensure you don’t have any
other dhcp servers in the same network.

Practice
1. # yum install *dhcp*

2. After installation go and make an Ethernet active for dhcp so which can take
request from all the users and that ip will be responsible as DHCP, we use
these things when a computer have multiple Ethernet cards.

3. # vi /etc/sysconfig/dhcpd

There you will find following lines

 # command line option here

DHCPDARGS= eth0

Above line 2 will this happen, mean now eth0 is authorized to


take all the requests and it will work as DHCP

4. Now as DHCP work as an server the server should have an static IP that why
go in this file and do some changing.

5. Vi /etc/sysconfig/network-scripts/ifcfg-eth0

a. Device =eth0

b. BOOTPROTO=static

c. NM_CONTROLLED=”yes”

d. TYPE =”Ethernet”

e. UUID=”68e53b-2a58-4644-9904-31359f9bffe8

f. DEFROUT =”Yes”

g. IPV4_FAILURE_FATAL=”YES”
h. IPV6INT=”no”

i. NAME=”System eth0”

j. IPADDR=192.168.2.119

k. Prefix =24

l. GATEWAY =192.168.2.1

m. DN1=00:21:9b:2b:b9:2e

n. LAST_CONNECT=1374081461

6. Now set DNSIP

a. Vi /etc/resolve.conf

b. #Generated by Network Manager

c. nameserver 192.168.2.1

7. first time after installation it will tell you to go in


/usr/share/doc/dhcpd*/dhcpd.conf.sample file and copy then take it
/etc/dhcpd/dhcpd.conf and put it here without .sample and remove original
file.

8. Now open this file and do some changing

a. Remove comments simple from 8,9 line and 32 line where following
lines are present.

b. # This is very basic subnet declaration

Subnet 192.168.2.1 netmask 255.255.255.0 {

range 192.168.2.180 192.168.2.220

option routers rtr-239-0-1example.org

rtr-239-0-1example.org;

9. Now if we want to give any computer permanent IP then go to this

host any-hostname

Hardware Ethernet 00:21:9b:2b:cd:ba;


fixed address 192.168.2.202;

10. Now service DHCPD restart , and DHCP is ready


Lecture # 24 IPTABLES ( Firewall )

IPTABLES (Default FIREWALL of Linux)


• A software utility or hardware device that limits outside network access to a
computer or local network by blocking or restricting ports.

• Firewalls are a great step for helping prevent un-authorized access to a


company or home network.

• Network security is a primary consideration in any decision to host a website


as the threats are becoming more widespread and persistent every day.

• IPTables is the mechanism for the “packet”-filtering in modern Linux


distributions in addition to packet filtering, it also does other interesting
things such as “NAT”-ing and “mangle”-ing.

• This Linux based firewall is controlled by the program called IPTABLES to


handle filtering for IPv4, and ip6tables to handle filtering for IPv6.

• IP Tables is used to set up, maintain, and inspect the tables of IPv4 packet
filter rules in the Linux kernel.

• Several different tables may be defined. Each table contains a number of


built-in chains and may also contain user-defined chains.

• Each chain is a list of rules which can match a set of packets. Each rule
specifies what to do with a packet that matches. This is called a `target',
which may be a jump to a user-defined chain in the same table.

• IP Tables firewall is used to manage packet filtering and NAT rules.

• IP Tables comes with all Linux distributions.

• Understanding how to setup and configure IP Tables will help you manage
your Linux firewall effectively.

• On a high-level iptables might contain multiple tables. Tables might contain


multiple chains. Chains can be built-in or user-defined. Chains might contain
multiple rules. Rules are defined for the packets.

• So, the structure is: IPTABLES -> TABLES -> CHAINS -> RULES
Types Of IPTABLES

• There three tables in iptables

• Filter table: Used to filter packets.

• NAT(Network Address Translator) table: Used for NATing of source


and destination IP address(Used for sharing internet)

• Mangle table: Its a combination of Filter and NAT tables

Filter Table:
• This is the default table which contains three chains.

• INPUT Chain: To apply a rule on packets which are coming into the
system

• FORWARD Chain: For packets being routed through the system


• OUTPUT Chain: For packets locally generated which are going out
from the system

NAT Tables

• This table is having three chains.

• PREROUTING Chain: For altering the packets as soon as they come in


to the system

• OUTPUT Chain: For packets locally generated which are going out
from the system.

• POSTROUTING Chain: For altering the packets which are about to go


out from the system.

Mangle Table

• This is a combination of forwarding, security and translating packets. We can


say this one as hybrid table of both FILTER and NAT table.

• This contains five chains.

• PREROUTING

• OUTPUT

• INPUT

• FORWARD

• POSTROUTING

IPTABLES
• Chains have some rules

• DROP: For dropping a packet without informing the status of these


packets to the source/destination. So there is no information to
source/destination about the status of the packet.

• REJECT: Will reject the packets and information is sent to


source/destination about the rejection of packet by the server.

• ACCEPT – Will accept for the delivery of the packet to designated


destination.
Daemon of IP Tables is

• iptables

Syntax to make rules of iptables

• iptables -A chain firewall-rule

IPTABLES Option (These options specify the specific action to perform)

• -A (to append a rule)

• -D (to delete a rule)

• -I (to insert a rule)

• -L (to lists the rules)

• -P (to set a policy for chain)

• -F (to flush all rules)

Iptables Option

• -p (protocol)

• -d (destination)

• -j (jump to target)

• -s (source)

• -i (in-interface)

• -o (out-interface)

• -v (verbose out put)

• -n (display ip and ports in numeric)

To lists the IPTables rules.

• iptables -L

To lists IPTables rules verbose and IP an port numbers.

• iptables -L -vn .
To flush/delete all IPTables rules.

• iptables -F

PRACTICE
--line-number  All rules are numbers shown then we can add new rules
below or above them, or we can remove them from the list of IPTABLE, the rules are
applied/read by computer from top to bottom.

-A  Append the rule in last but if we want to add some rules in the top then we
must use –I (capital i).

# iptables -I INPUT -p tcp --dport 22 -j DROP

Iptables INSERT in INPUT on PROTOCOL TCP the DESTINATION PORT


number 22 JUMP to DROP

OR

#iptables -A INPUT -p tcp --dport 22 -j DROP

This rule will work same as above but if it is on the first line or before such lines
those allow the users.

#iptables -L INPUT (It will list only the input chain)

OR

#iptables -L INPUT --list-numbers (It will Work same as above with


line numbers)

Drop any Rule

#iptables -D INPUT 2 (Here number 2 represent the line number of


any rule)

Delete all rules at once.

#iptables -F INPUT (It will Flush all the rules of INPUT chain)

#iptables -F (it Will remove all the rules of iptables)


Mysql port No  3306

#Host –ta histpk.org or #host histpk.org (this will give all the info
about histpk server)

#iptables -I OUTPUT -p tcp --dport 20 -j DROP

(It will Block all the requests from our computer to anyother ftp 20 is a vsftpd
outgoing port)

#iptables -I INPUT -p tcp --dport 21 -j DROP

(It will Block all the requests from others computers to our ftp 21 is a vsftpd
incoming port)

Allow any specific user

#iptables -I INPUT -s 192.168.2.120 -p tcp --dport


20 -j ACCEPT

(-s= source)

Following command will not response the PING request (icmp is the protocol of ping)

#iptables -I OUTPUT -p icmp --icmp-type-echo-request -j DROP

#iptables -I INTPUT -p tcp --dport 22 -m --src-


range 192.168.2.11-192.168.2.120 -j ACCEPT

(Above rule will allow the range of IPz to communicate, other IPz will not be
connected).

To change the Table, because Filter is the Default table of chains, we can change
this.

#iptables -t mangle -L
Configuration File of IPTABLES

# vi /etc/sysconfig/iptables

Above rules will work for temporary time, but if we want to do it for permanent then
we use.

#/etc/init.d/iptables save

#service iptables save

Save iptables rules in backup/simple file for later use on another system or on the
same system.

# iptables-save > /home/Hidaya/Desktop/iptables.backup

For restoring the iptables

#iptablesres-restore < /home/Hidaya/Desktop/iptables.backup

To drop the entire incoming request, this command will make the drop policy default
for INPUT/incoming traffic.

#iptables -P INPUT DROP

Iptables is used from kernel 2.4 now we use kernel 4.6 in centos 6.3 version.

Study  How to create dedicated firewall for industry level.

Some firewall are used in industry level (IP Cops, Smooth Wall)
Lecture # 26 Shell Scripting
Kernel

 Kernel is the core component of Linux OS. It manages resource of Linux OS. It
provides facilities for example, facility to store data, print data on printer,
memory, file management etc.

 Kernel decides who will use this resource, for how long and when.

 The kernel acts as an intermediary between the computer hardware and


various programs/application/shell.

Shell
• Shell is the interpreter between User and Linux Kernel.

• Shell is a user program or it's environment provided for user interaction.

• Shell is a command language interpreter that executes commands read from


the standard input device (keyboard) or from a file.

• Shell is not a part of system kernel, but uses the system kernel to execute
programs.

Check Shells of Linux

chsh --list OR cat /etc/shells OR echo $SHELL


(Default Shell of User)

Shell Scripting

• Normally shells are interactive. It means shell accept command from you (via
keyboard) and execute them. But if you use command one by one (sequence
of number of commands) , you can store this sequence of command to a text
file and tell the shell to execute this text file, This is know as shell script.

• Shell script is a series of command written in plain text file.

• Practically all modern operating system shells can be used in both interactive
and batch mode, the latter usually by specifying the name of a text file with
commands listed therein.

• Batch mode use of shells usually involves structures, conditionals, variables,


and other elements of programming languages
Why should we use Shells

• Shell script can take input from user/file and output them on screen.

• Useful to create our own commands.

• Save lots of time.

• To automate some task of day to day life.

• System Administration part can be also automated.

SHELL SCRIPTING START

Shebang

#!/bin/bash Poem (Hash “#” Not “!” Slash “/” Bin “bin” Slash “/” Bash
“bash”)

How to Write Shell Script

• Use any editor like vi, nano or gedit to write shell script.

• After writing shell script set execute permission for your script as follows,
because simple file doesn’t have permission.

• chmod a+x script-file

• chmod 755 script-file

How to Execute Script File

• There are several ways to execute script file.

• ./script-file

• sh script-file

• bash script-file

You might also like