Sunteți pe pagina 1din 40

LINUX ESSENTIALS & ADMINISTRATION

By
BALA KRISHNAN M
gdfdgdfdh fhfjdfhjgfh gfgjdfhgjd hffkkfjgkfj
11-1

Background on Linux

Version of UNIX Linus Torvalds Creator of Linux Open Source Operating System Free Software Source Code Available

11-2

Unix Architecture

11-3

What is Linux?

A Fully-networked 32/64 bit Unix-like Operating System A famous open source Version of UNIX Operating System Free to use, distribute, modify under a compatible licence Produced by a large developer and user community Multi-user, Multitasking, Multiprocessor Has the X Windows GUI Runs On Multiple Platforms Includes the Source Code
11-4

Purpose Of Operating System


To Manage hardware and software resources in a system Memory, Processor, Disk space, Programs To ensure the system behaves in a predictable way To provide a stable, consistent high-level interface to the hardware

11-5

When Is an Operating System Needed?


When you want to abstract way from the hardware - You want your program to run on different hardware platforms When Systems must be Multi-functional - To run on different kinds of programs

11-6

History of Linux
In 1969, A&T Employees at Bell Labs developed the unix operating system Features - Multi-threaded, multi-user - Extensibly Networkable (Support TCP/IP/IP) - Supported on Many systems (but not PCs) Was originally free and source code available By Late 1980s it was commercial, expensive, non available source and came in many flavors

11-7

Linux - What can it do for you?

Full operating system Works well on a variety of hardware, including older hardware You can adapt it to fit your needs Thousands of programs available Secure by design Supports a wide range of programming languages Scalable
11-8

Where is Linux Used?

75% of respondents were already using Linux and another 14% were evaluating it 43% of all web sites use Linux servers, running the Apache Web server

11-9

How is Linux Used?


Personal Workstation File and Print Server Internet Service Provider Three-tier Client/Server Mobile Phones IPODs Notebook Computers Mainframes Supercomputers Games Machines
11-10

Why Use Linux?


Multi-user and Muti-tasking Costs less Stable Reliable Extremely powerful Needed to work with Embedded devices/Robots Importance of Understanding Different Operating Systems

11-11

Using Linux on Personal Computers

Linux kernel for free Kernel is central component Kernel can be customized to users needs

11-12

Linux Distributions/Flavors
Ubuntu CentOS Debian GNU/Linux Mandrake Linux Red Hat Linux Fedora Linux Slackware SUSE Linux TurboLinux ALT Linux Lycoris Linux

11-13

File System Structure


What is a Filesystem? File system is a method for storing and organizing computer files Examples of disk file systems include, Static & Dynamic Dynamic files /home /var /opt /etc /tmp /mnt Static files /usr /sbin /dev /stand

11-14

File system
.

the current directory .. the parent of the current directory So if I'm at /home/bala and wish to specify the path above in a relative fashion I could use: ../condron/source/xntp Every directory and file is listed in its parent directory. A directory is a file that contains a table listing the files contained within it, giving file names to the inode numbers in the list.
UFS UNIX EXT2, EXT3, EXt4 LINUX FILE SYSTEM SOLARIS UFS ..CURRENTLY ZFS UNDER PROCESS
11-15

File System Structure


What is a File system ? A file system is a logical method for organising and storing large amounts of information in a way which makes it easy to manage. The Standard system directories are shown below

11-16

File System Structure


/bin The bin directory was where all the executables binaries were kept in early Unix. Over time, as more and more executables were added to Unix, it became quite unmanageable to keep all the executables in one place and hence the bin directory split into multiple parts(/bin, /sbin, /usr/bin) /dev Device drivers (screen, keyboard, hard disks etc.) /etc Unix designates the etc directory as the storage place for all the administrative files and information. /etc/services /lib If programs want to include certain features, they can refer just the shared copy of that utility in the Unix library rather than having a new unique copy. /mnt The mnt directory is an empty directory reserved for mounting removable file systems like hard disks, removable cartridge drives and so on. /tmp The tmp directory contains temporary files created by Unix system programs. You can remove any temporary file that does not belong to a running program. /usr The usr directory consists of several subdirectories that contain additional Unix commands and data files. /home default location of user home directories. /var 11-17 Logfiles, spools (mailqueue)

Working with the Shell


Shell is a command Interpreter that interprets the commands entered by the user and gets that command executed by the Kernel Types of shells Sh ( Standard job control shell) Csh (Shell command interpreter with C like syntax) Ksh ( Korn shell standard shell ) Rsh (Remote shell ) Features Shell is interface with the UNIX system, the middleman between you and the kernel. Shell is a type of program called an interpreter. An interpreter operates in a simple loop: It accepts a command, interprets the command, executes the command, and then waits for another command. Shell displays a "prompt," to notify you that it is ready to accept your command. #echo $SHELL
11-18

Linux Directory Structure

Store drives Accessing data using folders Root directory: - beginning of file system

11-19

Subdirectories
Examples of Subdirectories /root /home /devDevice /etc /etc/init.d directory, starting point of the directory tree (private) directories of users files that represent hardware components Important files for system configuration Boot scripts/usr/binGenerally accessible programs

11-20

Basic Linux Commands


cat file Concatenate or type out a file cat file1 file2 ... Type out a number of files cd directory1 Change current directory to directory1 cd /usr/bin Change current directory to /usr/bin cd Change back to your home directory clear Clear the current screen ls List the files in the current directory ls /usr/bin List the files in the /usr/bin directory cp <from_path> <to_path> copy a file more file Look at the content of a file with paging, use q to get out mkdir directory Create a directory mv <from_path> <to_path> move a filerm file rm file1 file2 ... Remove a number of files rm -r directory Remove a directory include the sub-directory rmdir directory Remove a directory touch To create a file ln is used to make a link between files. A link allows a filename in one directory to point to a file in another directory ln -s ActualFilename LinkFileName Alias l=ls ls
11-21

Basic Linux Commands


man cp man -k keyword passwd pwd uptime users who w whoami finger user finger name finger email-address date cal year Locate Displays on-line manual for the cp command Displays manual help file related to the keyword Changes your login password Displays the path name of where you are Tells you how long the machine has been up, running Tells you who is logging in Tells you who is logging-in in detail Tells you who is logging in and doing what! Shows you the owner of this account Finds out the personal information of a user To find the persons info. by his/her name To find the persons info across the network Displays todays time and date Displays the calendar of the specified year (e.g. 1997) To find files in the specified path
11-22

User Accounts
Add user # useradd -c des" -d /home/<name> -m -s "/usr/bin/ksh" <name> # change group for jsmith #chgrp <gname> <gname> # change <useraccount> password # passwd <accountname> # change <username> description usermod -c <username>" <username> User passwords are maintained in /etc/passwd

11-23

Linux Permissions
Permission sequence found at the beginning of a directory listing (first 10 characters): d rwx r-x r-x The first character represents whether the listing is a directory. If it is a directory, a d will appear in the first character; otherwise, you should normally see a dash (-). d rwx r-x r-x Read Permission 1st position in a triplet: r stands for Read; grants permission to view the contents of a file or directory (Value is r or -). Write Permission 2nd position in a triplet: w stands for Write; grants permission to modify a file or the contents of a directory (Value is w or -). Execute Permission 3rd position in a triplet: x stands for eXecute; grants permission to run an application or open a directory (Value is x or -).
11-24

Linux Permissions
Octal Value
4 -Read 2 Write 1- Execute

Permissions r r r r w w x x

Octal 4 5 6 7

Typically, directories and executable files are given 755 permissions While other files are given 644 permissions Unix permission Chmod -- To modify the file permission Chown -- To change the ownership Chgrp -- To change the group Examples: chmod 777 <filename> chgrp R <group> <folder name> chown <username> <filename>
11-25

Finding Files
How do we find a file with the name kernel ? $ find /usr/src name kernel How do we find files with extension mp3? $ find / -name *.mp3 How do we find which files in our home directory were changed in the past two days ? $ find ~ -mtime 2 How do we find files accessed in the last 2 hours? $ find ~ -amin -120 How do we find files with size greater than 1MB, but less than 2 MB ? $ find / -size +1024 size 2048 How do we find files in the current directory newer than a file test? $ find ~ -newer test
11-26

Disk & Process Monitoring Commands


-Disk free human readable the output will be on GB

Disk free

m -Disk free human readable the output will be on MB

Calculate used disk space

Typing ps alone would list the current running processes

ef - Displays full information about each of the processes currently running.

me Tells how long the system has been up and running orming the above command would display something similar to the below example. 9:07 up 18 days, 4:15, 78 users, load average: 0.00, 0.06, 0.14 ent timeStatusDays upHours /min up em load averages for the past 1, 5, and 15 minutes.

Top is a tool that gives you a continual status on the processes running on system such as current uptime, memory usage, swap usage, system load age,CPU usage,processes.
11-27

Crontab
What is crontab ? cron is a unix, solaris utility that allows tasks to be automatically run in the background at regular intervals by the cron daemon. These tasks are often termed as cron jobs in unix . Crontab Commands crontab -e Edit your crontab file, or create one if it doesn't already exist. crontab -l Display your crontab file. crontab -r Remove your crontab file. crontab -v Display the last time you edited your crontab file. (This option is only available on a few systems.) Crontab syntax :A crontab file has five fields for specifying day , date and time followed by the command to be run at that interval. * * * * * command to be executed - - - - | | | | | | | | | +----- day of week (0 - 6) (Sunday=0) | | | +------- month (1 - 12) | | +--------- day of month (1 - 31) | +----------- hour (0 - 23) +------------- min (0 - 59)
11-28

How to find Unix Os Kernel bit version ?


Kernel Bits Linux : #getconf LONG_BIT Solaris: #isainfo -kv HP-UNIX: #getconf KERNEL_BITS AIX: #bootinfo -K Uname: #uname -a Network Command #ifconfig a ->Displays the network settings #netstat a ->Shows the active ports #ping ->is a tool used to test whether a particular is reachable across an network.

11-29

LINUX OS Monitoring
Where do you check for operating system error messages ? Linux Solaris AIX HP Unix /var/log/messages /var/adm/messages /var/adm/messages /var/adm/syslog/syslog.log

List all common used run levels and their differences Init 0 All the services , process,file system are properly unmounted and shutdown Init 1 Single user mode (Maintenance Mode) Init 2 Multi-user mode without NFS Init 3 Multi-user mode with NFS Init 4 Not used Init 5 Shutdown with power off Init 6 Reboot Init (s S) Single user mode #Who r will display the current run level.
11-30

Mount & Unmount


Mounting a CDROM Device. #mount /dev/cdrom /mnt/cdrom How do you mount a unix-network share from the command-prompt? #mount <server name>:/<shared directory> /mnt/<mounting point> Network name | Shared dir name | mounting point-local Note: The above commands are not for permanent mounting To mount the file system permanently add an entry in directory /etc/fstab file. Therefore whenever the machine reboots entry in the /etc/fstab are automatically mounted. UMOUNT #umount /mnt/cdrom

11-31

LINUX VS WINDOWS

Financial Differences Technical Differences End-User Differences

11-32

Financial Differences
COST
LINUX WINDOWS Online Downloads Retail Price, CD Free $50 Not Available $300

Cost for Businesses -Companies have to spend millions for licenses for ever individual windows computer -For Linux companies dont have to spend anything
11-33

Technical Differences
Open Source, users can edit its OS and design new OS Comes from Different Companies Flavors Red Hat, Suse, Mandrake, Ubuntu Keeping up to date - By Upgrading, Linux upgrades faster than Windows Compatibility - Linux upgrades faster than Windows - Linux is Backward Compatible unlike Windows Licensing Freedom On-line Peer Support Support Dynamic Caching and Multi-user Support

11-34

End-User Differences
Proprietary vs. Open Source Windows is a Proprietary Technology Applications will only work on Windows Linux Open Source Complete information needed for download Technical help Available on Internet (user must be comfortable with UNIX system)

11-35

In The Commercial Arena


Linux
Linux tougher environment Linux requires learning multi-user issues built into Unix-file permissions Linux programmer-based culture Linux textual interface (with X-Window) But for complex jobs, Linux gives a powerful set of tools

11-36

In The Commercial Arena


Windows NT
NT easier environment NT requires less effort to get a starter server up and running But in NT you have to solve multi-user issues for each and every subsystem NT graphical interfaces, wizards and easy-to-grasp metaphors But as server chores become more customized, NT cannot handle it NT easy for non-programmer

11-37

Why is it Significant?

Growing Popularity Powerful - Runs on Multiple Hardware Platforms - Users like its speed and stability - No requirement for latest hardware Its Free - Licensed Under GNU-GPL - Vendors are distributors who package Linux

11-38

Conclusion

When is it best to use Linux and when should some other operating system be preferred? It all depends on the user

11-39

Questions?

11-40

S-ar putea să vă placă și