Professional Documents
Culture Documents
What is a system administrator? System Admin Tasks and Duties: install systems (including clients/servers): hardware, software and o.s. upgrade systems: hardware, software and o.s. backups start/stop system (reboot)
Other Duties create accounts (add/delete), passwords, account management job scheduling security performance monitoring and tuning
Some More Duties documentation and testing communication and help (with user community and internal) networking (client/server) handling printers, tape drives, modems, disks, UPS, and other peripherals Memory Management
Almost The Last Duties disk space management (formatting, partitions, quotas) writing/modifying scripts (perl, shell, C, etc..) running specialized services/servers (email server, web server, DNS etc..) problem resolution
Last Duties
Training (others and oneself) Fixing Bugs Automate Tasks Maintain system files Analysis of logs/systems, collect stats, reports Planning and Recommendations Work with vendors, customers Research New Technologies
Network Interface
Interface Names
Default names for network interfaces
Ethernet interface: eth prefix and numerical suffix
Examples: eth0, eth1, eth2
10
Multiple Interfaces Example: eth0, eth1, eth2, etc. Challenge: match physical connectors to proper name Order of driver loading determines interface naming Two methods for ordering interface detection
Plug and Play logic in the case of PCI interface Hardware settings in case of ISA bus cards
11
Interface Drivers
Implemented as kernel modules Kernel modules appear below /lib/modules directory View modules loaded using lsmod command
Display example: e1000 76956 2 (autoclean)
e1000 refers to Intel Gigabit Ethernet interface
12
Techniques common to all Linux distributions Two traditional commands: ifconfig and route ip program is replacing older commands
Part of the new IPROUTE2 package
13
14
15
16
Wireless Interfaces
Unique features: radio receiver and transmitter Wireless-specific parameters to display and configure
Frequency, transmit power, data rate, encryption key Selecting between ad hoc or access point mode
iwconfig: main tool for configuring wireless interfaces iwconfig syntax: iwconfig interface option
interface corresponds to interface name option corresponds to wireless-specific parameters
Example: freq number sets transmitter's frequency
17
18
19
20
Using ARP
Address Resolution Protocol
Obtains hardware address of host given its IP address Available through arp command
21
22
23
24
Using traceroute Using traceroute to Examine Routing traceroute provides greater detail than ping Basic traceroute functions
Relies on TTL field and ICMP packet timed out data Identifies each router (each hop) between you and host Attempts to reach host within 30 hops (may be reset)
IP address and host name shown for each router Probe packets supply three timing values for each hop
25
26
27
Name Services
Domain: collection of computers using common name
Examples: yahoo.com or amazon.com
Name services map domains names to IP addresses Name services as an Application-layer program
Returns IP address when name is input Returns name when IP address is input
Name resolution: converts name to IP address Name server: computer providing name services
28
Sample output
127.0.0.1 192.168.1.35 localhost.msit.com localhost sundance.msit.com
29
Configuring the DNS Resolver Manually Resolver as the client part of DNS
Makes requests to DNS server on behalf of program Example: Web browser uses Linux resolver
Configuring resolver
Go to /etc/resolv.conf file Enter nameserver plus IP address of DNS server
Include up to three DNS servers in file Advisable to select servers close to network segment
30
Configuring the DNS Resolver Manually One domain statement may be included in resolv.conf
Only one domain name in a domain statement Example: domain course.com
Helps resolver construct fully qualified name Domain string would be added to command ping www
31
Configuring the DNS Resolver etc/host.conf file specifies order for resolving names
Example: order hosts, bind
Resolver first checks etc/host for name to be resolved If no name present, resolver makes DNS query using resolv.conf The word bind refers to BIND software
32
33
Shells
Interprets and executes commands 4 - 5 different shells are installed by default Each shell has slightly different environment & features Examples
bash - most common, powerful csh - C shell, less features than bash sh - Bourne shell, oldest zsh - new, quite powerful type echo $SHELL should return something like /bin/bash
Navigating directories
To find out the current directory: pwd - returns the current directory To change to another directory: cd /path/to/dir . is the current directory .. is the parent directory
ITEC4611 Network Management 35
Linux (as Windows) has hierarchical directory structure Each component is seperated by forward slash - / / is the root directory Examples
/usr/bin/ /home/admin
starts with the root directory /home/raheel/paper.txt , /usr/local/bin in relation to the current directory pwd -> /home/admin, cd hw -> /home/admin/hw cd .. -> /home/admin
36
Relative
Important directories
/bin : essential Unix commands, like ls /usr/bin : some extra Unix commands /usr/sbin : for super user, system administration /boot : kernel and other files for booting /etc : system services - networking, mail, disk management /var : administrative files, such as logs /usr/local : locally added programs and files by sys. admin. /dev : device files - interface b/w hardware and filesystem /proc : running processes
37
mkdir dirname creates new directory under current one mkdir /path/to/dirname creates new directory under the exact path Rmdir, rm r removes a directory
38
Listing files
ls - the most popular command lists the directory contents lots of options available with arguments
argument - option given to a command lists current directorys contents lists the contents of /home directory list hidden files with the -a argument long information about contents. Very useful
39
ls ls /home ls -a ls -l
What is a command?
Small (big) program provided by UNIX/Linux Can make your own commands too Command is simply a file
Have to mark it executable Put it somewhere special (in command path)
Path : directories where shell looks for a given command find out path by echo $PATH /usr/local/bin/:/usr/bin:/bin/ Sometime have to specify full (absolute path) to a command
command not in path more than one name for same command
40
Command (contd.)
Add a directory to path export PATH=$PATH:/new/directory/path current directory usually not in path use ./command-name Help for commands Put a command in background ls & -> [1] 23142 Bring it back fg %1 or fg 23142 Commands and shell provided features
type ls type cd
41 ITEC4611 Network Management
man command-name man 2 command-name : for 2nd section apropos edit : displays all commands related to editing
Typing shortcuts
Word Completions
Dont have to type full command or path Type Tab after typing a couple of letters cd /usr/inc - then hit Tab
would complete it as cd /usr/include/ completes the path Type mor and then hit Tab Will complete it as the command more Type cd /usr/l and hit Tab Would display lib and local because they begin with l
42
Can edit previously typed commands Commands are stored once typed
Can recall previous commands and use them Up arrow - previous command Down arrow - next command Left and right arrow to navigate Ctrl-U to delete whole line if mistyped Ctrl-A : beginning of line Ctrl-E : end of line
43
history N history -c !!
!N
44
paper1.doc
* says match as many characters as possible in place of * ? says match one character in place of ?
ls paper?.doc gives
45
More wildcards
paper2.doc paper3.doc
46
cat command
Linux command used to display (or concatenate) the entire contents of a text file to the screen
47
tac command
Linux command that displays a file to the screen beginning with the last line of the file and ending with the first line of the file
48
tail command
By default, displays the last 10 lines (including blank lines) of a text file to the terminal screen Can also take a numeric option specifying a different number of lines to display
49
50
The more and less commands can also be used in conjunction with the output of other commands if that output is too large to fit on the terminal screen
51
strings commands
Linux command used to search for and display text characters in a binary file
52
53
54
Searching for Text within Files Text tools and programming languages that use regular expressions include:
grep awk sed vi emacs
55
Searching for Text within Files Text tools and programming languages that use regular expressions include (continued):
ex ed C++ PERL Tcl
56
Regular Expressions
Differences between regular expressions and wildcard metacharacters include:
Wildcard metacharacters are interpreted by the shell
Regular expressions are interpreted by a text tool program
Wildcard metacharacters match characters in filenames (or directory names) on a Linux filesystem
Regular expressions match characters within text files on a Linux filesystem
57
Regular Expressions
Differences between regular expressions and wildcard metacharacters include (continued):
Wildcard metacharacters typically have different definitions than regular expressions There are more regular expressions than wildcard metacharacters Regular expressions are divided into two different categories:
Common extended
58
Regular Expressions
Regular Description Expression
* Matches 0 or more occurrences of the previous character Matches 0 or 1 occurrences of the previous character Matches 1 or more occurrences of the previous character Matches 1 character of any type
Example
letter* matches lette, letter, letterr, letterrrr, letterrrrrr etc. letter? matches lette, letter letter+ matches letter, letterr, letterrrr, letterrrrrr etc. letter. matches lettera, letterb, letterc, letter1, letter2, letter3, etc. Letter[1238] matches letter1, letter2, letter3, & letter8
Type
Common
? +
Extended Extended
. (period)
Common
[]
Common
59
Regular Expressions
Regular Expression [ ] Description Matches 1 character NOT from the range specified within the braces Matches a specific range or number of the previous character Matches the following characters if they are the first characters on the line Matches previous characters if they are the last characters on the line Matches either of the two sets of characters Example letter[1238] matches letter4, letter5, letter6, lettera, letterb, etc. (any character except 1,2,3 or 8) letter{3} matches letterrr letter{2,4} matches letterr, letterrr and letterrrr ^letter matches letter if letter is the first set of characters in the line letter$ matches letter if letter is the last set of characters in the line (mother|father) matches the word mother or father Type Common
{}
Extended
Common
Common
(|)
Extended
60
Use the egrep command to display lines of text that match extended regular expressions The fgrep command does not interpret any regular expressions and consequently returns results much faster than the egrep command
61
The vi Editor One of the oldest and most popular visual text editors available for UNIX operating systems
Its Linux equivalent (known as vimvi improved) is standard on almost every Linux distribution as a result
Though not the easiest of the editors to use when editing text files, it has the advantage of portability
62
The vi Editor The vi editor is called a bi-modal editor as it functions in one of two modes:
Command mode
Allows a user to perform any available text editing task that is not related to inserting text into the document
Insert mode
Allows the user to insert text into the document but does not allow any other functionality
63
The vi Editor
Key l A O Shift-I Shift-A Shift-O [Esc] Description Changes to insert mode and places the cursor before the current character for entering text Changes to insert mode and places the cursor after the current character for entering text Changes to insert mode and opens up a new line underneath the current line for entering text Changes to insert mode and places the cursor at the beginning of the current line for entering text Changes to insert mode and places the cursor at the end of the current line for entering text Changes to insert mode and opens up a new line above the current line for entering text Changes back to command mode while in insert mode
64
The vi Editor
Key w, W, e, E b, B 53G G 0,^ $ x 3x dw d3w, 3dw dd d3d, 3dd d$ d^, d0 Description Moves the cursor forward one word Moves the cursor backward one word Moves the cursor to line 53 Moves the cursor to the last line in the document Moves the cursor to the beginning of the line Moves the cursor to the end of the line Deletes the character the cursor is on Deletes three characters starting from the character the cursor is on Deletes one word starting from the character the cursor is on Deletes three words starting from the character the cursor is on Deletes the whole line starting from the line the cursor is on Deletes three whole lines starting from the line the cursor is on Deletes from the cursor character to the end of the current line Deletes from the cursor character to the beginning of the current line
65
The vi Editor
Key gg yw y3w, 3yw yy y3y, 3yy y$ y^, y0 p Description Moves the cursor to the beginning of the document Copies one word (starting from the character the cursor is on) into a temporary buffer in memory for later use Copies three words (starting from the character the cursor is on) into a temporary buffer in memory for later use Copies the current line into a temporary buffer in memory for later use Copies three lines (starting from the current line) into a temporary buffer in memory for later use Copies the current line from the cursor to the end of the line into a temporary buffer in memory for later use Copies the current line from the cursor to the beginning of the line into a temporary buffer in memory for later use Pastes the contents of the temporary memory buffer underneath the current line
66
The vi Editor
Key P J [Ctrl]-g u . /pattern ?pattern n N Description Pastes the contents of the temporary memory buffer above the current line Joins the line underneath the current line to the current line Displays current line statistics Undoes the last function (undo) Repeats the last function (repeat) Searches for the first occurrence of the pattern in the forward direction Searches for the first occurrence of the pattern in the reverse direction Repeats the previous search in the forward direction Repeats the previous search in the reverse direction
67
The vi Editor
Function :q :q! :wq :w filename :!date :r !date :r filename :set all :set :s/the/THE/g :1,$ s/the/THE/g Description Quits from the vi editor if no changes were made Quits from the vi editor and does not save any changes Save any changes to the file and quits from the vi editor Saves the current document to a file called filename Executes the date command using a BASH shell Reads the output of the date command into the document under the current line Reads the contents of the text file called filename into the document under the current line Displays all vi environment settings Sets a vi environment setting to a certain value Searches for the regular expression the and replaces each occurrence globally throughout the current line with the word THE Searches for the regular expression the and replaces each occurrence globally from line 1 to the end of the document with the word THE
68
69
Startup files
Used to customize environment before starting the shell Every shell has its own startup file; hidden
Bash has .bashrc and .bash_profile
70
FileSystem
71
Filesystem : Introduction
Filesystem: Device or part of a device (partition) formatted to store files Device: CD, DVD, hard drive, floppies, etc. Type (format) of filesystem is transparent to user
Different formats for different purposes Random access devices only can have filesystems
Filesystem types
and even obscure ones new types are being added experimental drivers available contains list of supported FSs not complete
Type
ext2 ext3 minix NFS vfat ntfs .....
74
Mounting filesystems
To access a filesystem, it should be mounted Mounting, maps a filesystem to a given directory CDs/DVDs etc. are usually automounted May need to mount/unmount sometimes A filesystem can be mounted
mount command
Used to mount any filesystem mount - tells all mounted filesystems Need to know
the filesystem type the location of the device where to mount it
The mount point defines the location of a filesystem Flexibility in mounting any device anywhere (in any directory) man mount
ITEC4611 Network Management 76
Filesystem
for managing storage and access to files and dirs. used by applications
create files and directories open and modify existing ones delete specify access controls
77
Filesystem
File: single item for storing information Directory: hierarchical collection of files & other directories
root directory: / , topmost, every other dir. or file lives under it sub directories: a directory under root dir. directories help in organization
78
Filesystem layout
79
80
Partitions
Different directories can be on seperate partitions Every filesystem is on a seperate partition Advantage
Higher data security Flexible storage options Seperation of different kinds of data
Two types
swap partitions data partitions
df command for all active non-swap partitions fdisk for partition management
81
Basic Accounting
82
Accounts
Linux is a multiuser operating system Account for a user identified by username password for authentication Password file: used for authentication username:password:uid:gid:gecos:homedir:shell Two types of accounts
Root
Called super user Every Linux system has one Can create other accounts for users Restricted Can be given more permissions
User
Accounts..
One or more user accounts as well Potentially dangerous prompt for the users password
Shouldnt login using root account Can change into any user using su user
Accounts
Creating new users only admins can do this adduser command most default options are ok New users should change their password: passwd root can do this for a user: passwd user Deleting users accounts: userdel -r username Disabling a user temporarily Remove the entry from /etc/passwd
ITEC4611 Network Management 85
Permissions
Very critical in multi-user environment Maintain access over files for different users
Other users cannot access your files Critical files can only be accessed by root Similar users can be grouped together Easy to maintain permissions for a group Easy to share files within a group A user can belong to more than one group groups command User Group Others
86
Permissions
Ownership - who owns the file The creator of a file becomes its owner
Creators default group becomes the group owner Ownership can be changed later Can modify ownership Can change access rights
87
Write
Execute
88
Permissions
89
Changing Ownership
Rre to do this To change ownership: chown chown username file_or_dir To change group ownership: chgrp chgrp groupname file_or_dir combine if username & group name are same
90
Changing Permissions
chmod command
standard way to change permissions a : all u : current user (who is using chmod) g : files current group o : other users, not in g + : add an attribute - : remove an attribute = : set (absolutely) a permission r, w, x: read, write, execute
root can change permissions to any file/directory Besides root, only the owner can change permissions
91
Changing Permissions
chmod +x filename: gives permission to everyone to only yourself: chmod u+x filename to yourself and group: chmod ug+x filename multiple: chmod ug+rwx filename remove a permission: chmod o-x filename give write permission to all: chmod a+w filename remove all permissions and set file readable by user only
92
93
Software installation
Software update
ITEC4611 Network Management 94
Software installation
Installation options
Package system
not all software will have package file for every distribution same goes for binary files
95
Using RPM
RPM (RedHat Package Manager) Automates install/upgrade/uninstall of software Keeps track of individual software files Maintains dependencies (pre-requisite software) To install
rpm -ivh software-file.rpm Will complain about dependencies if not available To upgrade rpm -Uvh software-file.rpm
96
Using apt
Software installs with less errors usually Automatically downloads and installs from sources Keeps track of dependencies and installs required ones
Using apt
Requires sudo previliges for most tasks To update the list of software from repositories sudo apt-get update To upgrade all available software sudo apt-get upgrade To install a software
repositories
sudo apt-get install software_name apt downloads and installs software and dependencies from
To search for software in repositories sudo apt-cache search gedit To look for information on a particular software
sudo
apt-cache show gedit
98 ITEC4611 Network Management
Using Synaptic
GUI front-end to apt Easy to use and configure apt with Synaptic Install apt first with Synaptic Available under System>Administration Can edit and add repositories
ITEC4611 Network Management 99
Compression
gzip
Powerful compression utility Working Amount of compression depends on the kind of file
For eg., JPEG or PNG images are already compressed To find out how much compression was done:
Compress a file, big_file save compressed file as big_file.gz remove original file
gzip -l big_file.gz
Using tar
Options:
create a new archive extract files from archive list contents of archive append to archive filename of archive verbose
To archive two files a.txt and b.txt into arch.tar: tar cvf arch.tar a.txt b.txt To archive a directory temp into temp.tar
tar
cvf temp.tar temp
102 ITEC4611 Network Management
Using tar
To extract an archive mt.tar tar xvf mt.tar To view the contents of the archive tar tvf mt.tar Using with gzip use the z option when compressing into a gzip file To archive & compress a.txt and b.txt into f.tar.gz tar cvzf f.tar.gz a.txt b.txt To extract the above compressed archive tar xvzf f.tar.gz To view the contents
tar
tvzf f.tar.gz
ITEC4611 Network Management 103
rpm and apt packges of a software may not always be available Use the latest release of the software
Source Binary Available as compressed files Extract the files, which contain the necessary programs Make sure the extracted program is in the PATH Extract the files, compile and install the program
Binary
Source
104
Hardest way to install a program Necessary for installing latest version of the software May require root privileges Usual steps
Download the required tar compressed file Extract the files using tar Run its configuration program (usually ./configure) Run make for compiling Run make install (usually with sudo) for installation Cleaning (optional): make clean shared libraries compiling problems
105
END
106