NSA Note
NSA Note
What is system?
….a system
the computer(s)
the network
the user(s)
Hardware
Software
Data
User
Administration?
1
System administration functions include installation, configuration, and maintenance of network
equipment and computer systems.
Is the branch of engineering that is responsible for maintaining reliable computer systems in a
multi-user environment
A person who works a system administration is called system administrator, or sys admin,
system admin
Sys administrator: one who manages IT infrastructure, (the h/w, s/w, users)
Sysadmin is responsible for their company’s IT services (email, file storage, running website) is
responsible for the day-to-day operation of a technology system
IT infrastructure is the s/w, the h/w, network, and service required for an organization to operate
in an enterprise IT env’t
Systems Administration…
Morning of systems/software.
Automating operations
2
The Goal of System Administration
Supervise system functionality. Every system must work and be connected to the
network.
Allocating disks spaces and relocating quotas when the needs grows
To ensures that the users of networks receive the information and technically serves with
quality of services they expect
Network provisioning
Network operations
Network maintenance:
3
Responsibilities of the Network Administrator
As a network administrator, your tasks generally fall into the following areas:
4
The Job of
Hardware management
Maintain documentation
Audit security
1. User Management
Active directory in windows provides centralized user management and access control
for computers.
5
Any user management system has the following basic components:
Users: Users are consumers who interact with your organizational applications,
databases, and other systems. A user can be a person, a device, or another
application/program within or outside of the organization's network. Because users
interact with internal systems and access data, organizations need to define which data
and functionality each user can access by assigning permissions.
o User Ids
6
1. Hardware Management
o Capacity planning
o Verifying media
Disaster recovery
Onsite/Offsite
Periodic testing
Multiple copies
7
3. Software Installation and Maintenance
Evaluation of software
o Package management
4. Troubleshooting
o Often difficult
Problem identification
o By user notification
8
5. Monitoring
Two Kinds:
6. Local Documentation
o Hardware
Location
Description, configuration, connections
o Software
9
Network setting
7. Security Concerns
System logging and audit facilities
o Evaluation and implementation
o Monitoring and analysis
o Traps, auditing and monitoring programs
Unexpected or unauthorized use detection
Monitoring of security advisories
o Security holes and weaknesses
o Live exploits
8. Helping Users
Request tracking system
Customer oriented
o Communication skills
Technical knowledge
Time management
10
o Ability to prioritize tasks: urgency and importance.
Principles of SA
Simplicity
Clarity
Choose a straightforward solution that’s easy to change, maintain, debug, and explain to
other SAs.
Generality
Automation
Communication
Be sure that you’re solving the right problems and that people know what you’re doing.
Basics First
A. documentation
C. logging
F. Announce user
G. Add skill
11
Documentation
o Employ redundancy
o Regularly check your log files for any errors and warnings, so they can alert you
to problems before they become a threat to your servers and everything they
support.
o best disaster recovery plans are not designed for “if” something happens, but
“when” something happens.
Automate anything you have to do more than three times and anything that is
complicated
o Capture your most clever commands in aliases, functions, and scripts – and give
them meaningful names.
o Commit the complicated processes that you perform to scripts so that you don't
have to figure out the steps required and the complex commands more than once.
o You'll save yourself a lot of time and effort over the long haul and have a much
easier time if and when you need someone else to do the work for you.
12
Keep users informed
o “If you are not moving ahead, you are falling backward”
13
Team organize/ shield /day2day+project tasks
Handle emergencies quickly.
Use request system to avoid interruptions.
Policies
Good working practices are the threads that tie together the tasks performed by the
Sysadmin.
Good practices make tasks easier to reproduce, preserve system security/robustness, and
maintain system functionality.
o Knowing how a system is configured, what patches have been applied, what
services the system needs or provides, and any number of other items is a
tremendous aid in solving problems.
Avoid using root or administrator as much as possible. Use a less privileged account, for
which mistakes will be less drastic.
Avoid using wildcard characters, such as the asterisk (*), when running as root or
administrator.
Look for answers in manuals, newsgroups, and archive of mailing lists. Usually “google”
helps for most common problems.
Write down problems and solutions in a log book, and write down experiences.
14
Remember to tidy things up regularly.
After learning something new, ask yourself “How does this apply to my work?”
Administration Challenges
• It is about planning and designing an efficient community of computers so that real users
will be able to get their jobs done.
That means:
Need
o 24x7 availability
Requires:
o Breadth of knowledge:
15
operating system concepts
TCP/IP networking
programming
Depth of knowledge:
certain OS flavor
Types of Administrators/Users
In a larger company, following may all be separate positions within a computer support
or Information Services (IS) department.
In a smaller group they may be shared by a few sysadmins, or even a single person.
Database Administrator
Network Administrator
Security Administrator
Web Administrator
Technical support
computer operator
A web administrator maintains web server services (such as IIS or Apache) that allow
for internal or external access to web sites. Tasks include managing multiple sites,
16
administering security, and configuring necessary components and software.
Responsibilities may also include software change management.
Technical support staff respond to individual users' difficulties with computer systems,
provide instructions and sometimes training, and diagnose and solve common problems.
17
Chapter Two
Access Control
• Identification
– Presenting credentials
• Authentication
• Authorization
18
• Object
– Specific resource
• Subject
• Operation
19
Access Control Models
20
• Four major access control models
– Two elements
• Labels
• Levels
– Subject must have equal or greater level than object to be granted access
– Lattice model
– Bell-LaPadula model
• Lattice model
• Bell-LaPadula
21
– Subjects may not create a new object or perform specific functions on lower-level
objects
• Example of MAC implementation
– Used on operating systems such as most types of UNIX and Microsoft Windows
• DAC weaknesses
22
– Trojans are a particular problem with DAC
23
– Dynamically assigns roles to subjects based on a set of rules defined by a
custodian
– When user attempts access, system checks object’s rules to determine access
permission
– Separation of duties
– Job rotation
– Least privilege
– Implicit deny
– Mandatory vacations
• Separation of duties
– Fraud can result from single user being trusted with complete control of a process
24
– Requiring two or more people responsible for functions related to handling money
• Job rotation
• Least privilege
25
• Implicit deny
– Example: network router rejects access to all except conditions matching the rule
restrictions
• Mandatory vacations
– Limits fraud, because perpetrator must be present daily to hide fraudulent actions
• Specifies which subjects may access the object and what operations they can perform
26
• Each entry in the ACL table is called access control entry (ACE)
Group Policies
27
– Used to configure settings for systems not part of AD
Account Restrictions
• Account expiration
– Orphaned accounts: accounts that remain active after an employee has left the
organization
28
• Recommendations for dealing with orphaned or dormant accounts
– Monitor logs
• Account expiration
• Password expiration sets a time when user must create a new password
Authentication Services
• Authentication
29
• Authentication services provided on a network
RADIUS
– Developed in 1992
• RADIUS client
30
• RADIUS user profiles stored in central database
Kerberos
• Kerberos ticket
– Difficult to copy
31
– Expires after a few hours or a day
• Directory service
– X.500
• X.500 standard defines protocol for client application to access the DAP
• LDAP
32
– Encodes protocol elements in simpler way than X.500
– An open protocol
• Weakness of LDAP
Summary
• Access control is the process by which resources or services are denied or granted
– Separation of duties
– Job rotation
– Least privilege
– Mandatory vacations
• Access control lists define which subjects are allowed to access which objects
CHAPTER THREE
33
An Operating System (OS) is a software that acts as an interface between computer
hardware components and the user.
Every computer system must have at least one operating system to run other programs.
Applications like Browsers, MS Office, Notepad Games, etc., need some environment
to run and perform its tasks.
The OS helps you to communicate with the computer without knowing how to speak
the computer’s language.
It provides services that are used to control applications running on other computers.
If you have one computer and want to use it for personal purposes, you will install an
operating system on it.
If you have many computers and want to control all computers from a single
computer, you will install a network operating system on the computer that you want
to use to control the remaining computers, and on the remaining computers, you will
install the operating system that supports the installed network operating system.
Companies that make a NOS also make an OS that takes commands from the NOS and
executes them on the local computer.
The OS that accepts commands from the NOS is called a client OS.
For example, Microsoft makes NOS under the brand name Windows Server.
34
Such a system can consist of a wireless network, Local Area Network (LAN), or even
two or three computer networks connected together.
Here each computer will have its memory, hardware and may run on different
operating systems.
These independent computers are capable to process and undertake the functions of a
single user.
Usually, these Network Operating System (NOS) are runnel on large and powerful
computers with more hardware resources.
This computer act as a server that connects and manages the data from a different
independent system.
It helps to share the tasks between the computers connected to the network.
You can easily assign tasks, communicate, and securely access different
workstations.
Some of the famous Network Operating System is Novel Netware, Microsoft Windows
Server, UNIX, and Linux.
Here are the primary features that every Network Operating System will have:
35
It has basic operating system features like protocol support, hardware detection,
multiprocessing for application, processor support, and hardware that make up the
system etc…
It allows the user to use their backup database and web services.
It allows every user to create their user account and manage user logging in and
logging out and what files and services each user has access to
An NOS (network operating system) controls the utilities, users, and devices that
make up a network
While similar to a computer OS, NOS contain utilities that ensure data is transmitted
to the correct user, computer, and other devices.
NOS manage all printing, storage, backup, and duplication services for computers
and users accessing a network.
It also control access to the internet, local-area (LAN) and wide-area networks
(WAN), port routing, and internal web services (Intranet).
Network Operating System allows to manage email for those using the NOS.
There are two types of Network Operating System. They are as follow:
1.Peer-to-Peer:
Peer-to-peer network operating systems allow users to share the memory, data, files
located on their computers with others and also grant access to the data and resources
available with other computers.
Here all the independent computers (users) are considered the same all of them have an
equal level of access and right in the shared network.
This type of Networking is mostly practiced in the small and medium Local Area
Network (LAN) in the workplace.
This allows them to share, assign, and work on the tasks. Windows for the workplace
is the best example of a Peer-to-Peer network operating system.
36
Advantages of Peer-to-peer Network Operating System
Easy to install and setup and the setup cost is also low.
It has no centralized memory storage. Each system has its memory and storage capacity.
In this type, Network Operating System runs on a server machine that is connected
with multiple client computers.
This server acts as the centralized hub for all the client computers.
The client computer will request the information or access, then the server machine
will reply by providing the requested service.
The client computer will have memory, resources, and a separate normal operating
system to process, however, if large calculations or processing is needed it is done in
the client-server.
It is the most used Network Operating System type in today’s modern world.
The shared resources can be accessed at the same time by multiple clients.
The setup cost is very high, not affordable for small firms.
37
Network failure and a huge amount of client requests may affect the process.
Functions of a NOS
Preventing users from storing files outside the allowed storage locations.
Monitoring the system and security, to provide proper security against viruses,
hackers, and data corruption.
38
Providing network administration utilities (such as SNMP, or Simple Network
Management Protocol).
NOS services
A NOS provides several services. Most of them are inbuilt. If you need more services,
you can install them separately. The most common services are the following.
DHCP Services:
DNS Services:
These services allow the administrator to map hostnames with related IP addresses.
E-mail Services:
These services allow the administrator to configure the server to send and receive e-
mail using the Simple Mail Transfer Protocol (SMTP).
Web Services:
These services allow the administrator to host websites and related applications on
the server.
These services allow the administrator to share files and printers among clients.
Directory Services:
Group Policies:
39
These services allow an administrator to deploy settings down to the client operating
systems from a central point.
Some of the types of settings that can be applied to clients through group policies are
user rights, folder redirection, file permissions, and installation of software.
Multitasking
This means, if one service fails, it does not affect other services. Other services will be
running without any lag.
Stability
A NOS can run for years without crashing. Most services running on the NOS can be
restarted without a system-level restart.
Multiusers
A NOS allows a user to log into the same system at the same time as another user.
The hot plug feature allows the administrator to replace or upgrade most of the hardware
without shutting down the system.
User management and support for logon and logoff, remote access; system
management, administration and auditing tools with graphical interfaces.
40
Authentication of data, restrictions on required data, authorizations of users etc.
It also provides basic network administration utilities like access to the user.
It also provides priority to the printing jobs which are in the queue in the network.
UNIX/Linux
Artisoft’s LANtastic
Banyan’s VINES
Network resources refer to forms of data, information, and hardware devices that can
be accessed by a group of computers through the use of a shared connection.
They are important in work environments where collaboration is essential for the
successful operation of tasks.
For example, the most common types of network resources in an office environment
are hardware, such as:
Data files are also important network resources shared by those who must collaborate on
projects.
Network resources are also infrastructure resources that are capable of transferring
data.
Locations, which represent the named location of a Wide Area Network (WAN).
41
Repeaters
Servers
Server Rack
Routers
Switches
Firewalls
Application Software's
Load balancers
CCTV cameras
UPS
Client Computers
Shared Databases
Network Toolkits
IP address pools, which are assigned based on BMC Network Automation container
blueprint policies.
42
Network resources are organized by pods, network containers, and network zones.
BMC Network Automation defines and provides network resources for clouds defined
by BMC Cloud Lifecycle Management.
Networks, virtual firewalls, and virtual load balancers reside at the network
container level.
A network container does not have to have a zone. Neither firewalls nor load
balancers are required to reside in zones.
Multiple networks can share the same BMC Cloud Lifecycle Management network
label.
1. Locations
2. Pods
Because these resources reside physically close to each other, pods are useful for
organizing network resources by geographic location.
Pods can physically overlap in order to make efficient use of the hardware involved.
43
Pods are created in BMC Network Automation using pod blueprints, which define the
pod architecture and include a definition of the physical pod topology.
After a pod is created, you can then on-board the pod into BMC Cloud Lifecycle
Management.
3. Network Containers
Network containers are built from network container blueprints, which define the
network container architecture.
They can include definitions for firewalls, routers, load balancers, networks, and
zones.
4. Network Zones
The need for this level of structure is driven by security and performance
requirements.
A network resource can be within a single zone or it can exist outside of zones
completely.
5. Networks
You can define networks at the pod level and the container level.
For example, you might use a pod-level network to allow BMC Cloud Lifecycle
Management components to communicate, and a container-level network to allow
communication between the infrastructure resources that are provisioned as a result
of service requests.
44
The following figure shows a sample network configuration, in which a single pod
contains four network containers.
6. IP Address Management
45
IP address pools can also be configured at the pod level to manage networks spanning
multiple network containers within that pod.
BMC Network Automation uses two addressing schemes for IP address management
(IPAM) to define resources:
Pod-oriented Addressing
Container-oriented Addressing
When a server is added to a network container, the IPAM system acquires addresses
for its NICs from address pools within the container.
When the server is removed, the addresses that the server used are released back to
the IPAM system.
The term network service is used to describe a wide range of software and connectivity
tools that are managed by a central group and distributed to the networked
computers.
The computers are able to access shared files and utilities from a central location.
However, the client and server components can both be run on the same machine.
1. Directory Services
Mapping between name and its value, which can be variable value or fixed.
This software system helps to store the information, organize it, and provides various
means of accessing it.
46
A. Accounting
In an organization, a number of users have their user names and passwords mapped to
them.
Directory Services provide means of storing this information in cryptic form and
make available when requested.
User credentials are checked to authenticate a user at the time of login and/or
periodically.
User accounts can be set into hierarchical structure and their access to resources can
be controlled using authorization schemes.
DNS is widely used and one of the essential services on which internet works.
This system maps IP addresses to domain names, which are easier to remember and
recall than IP addresses.
Because network operates with the help of IP addresses and humans tend to remember
website names, the DNS provides website’s IP address which is mapped to its name
from the back-end on the request of a website name from the user.
2. File Services
File services include sharing and transferring files over the network.
A. File Sharing
One of the reasons which gave birth to networking was file sharing.
File sharing enables its users to share their data with other users.
User can upload the file to a specific server, which is accessible by all intended users.
As an alternative, user can make its file shared on its own computer and provides
access to intended users.
47
B. File Transfer
This is an activity to copy or move file from one computer to another computer or to
multiple computers, with help of underlying network.
Network enables its user to locate other users in the network and transfers files.
3. Communication Services
A. Email
When a user sends email to other user, it is actually transferred between users with
help of email server.
B. Social Networking
The computer savvy peoples, can find other known peoples or friends, can connect
with them, and can share thoughts, pictures, and videos.
C. Internet Chat
Internet chat provides instant text transfer services between two hosts.
Two or more people can communicate with each other using text-based Internet
Relay Chat services.
These days, voice chat and video chat are very common.
D. Discussion Boards
It enables the users to put queries, questions, suggestions etc. which can be seen by all
other users. Other may respond as well.
48
E. Remote Access
This service enables user to access the data residing on the remote computer.
This can be done via some remote device, e.g. mobile phone or home computer.
4. Application Services
These are nothing but providing network-based services to the users such as web
services, database managing, and resource sharing.
A. Resource Sharing
To use resources efficiently and economically, network provides a mean to share them.
B. Managing Databases
It stores data and information, processes it, and enables the users to retrieve it
efficiently by using queries.
C. Web Services
It is used to connect to the internet, and access files and information services provided
by the internet servers.
A remote location may refer to a computer in the next room or one on the other side
of the world.
49
Generally, remote administration is essentially adopted when it is difficult or
impractical to a person to be physically present and do administration on a system’s
terminal.
A. Internet connection
Any computer with an Internet connection, TCP/IP or on a Local Area Network can
be remotely administered.
The user must install or enable server software on the host system in order to be
viewed.
Then the user/client can access the host system from another computer using the
installed software.
Usually, both systems should be connected to the Internet, and the IP address of the
host/server system must be known.
Remote administration is therefore less practical if the host uses a dial-up modem,
which is not constantly online and often has a Dynamic IP.
B. Connecting
When the client connects to the host computer, a window showing the Desktop of the
host usually appears.
The client may then as if he/she were sitting right in front of it.
50
Tasks/Services of Remote Administration
User management,
Software installation/configuration,
Network management,
Network Security/Firewalls,
VPN,
Infrastructure Design,
The following are some of the tasks/ services for which remote administration need to
be done:
1. General Management
Controlling one’s own computer from a remote location (e.g. to access the software
or data on a personal computer from an Internet café).
3. Shutdown a computer
4. Accessing Peripherals
51
5. Modifying System Services and Settings
7. Hacking
Computers infected with malware, such as Trojans, sometimes open back doors
into computer systems which allow malicious users to hack into and control the
computer.
Such users may then add, delete, modify or execute files on the computer to their
own ends.
And some people realize that X Windows output can be redirected back to
the client workstation.
But many people don’t realize that it is easy to use an entire desktop over
the network.
52
A. SSH (Secure Shell)
Secure Shell (SSH) is a proprietary cryptographic network tool for secure data
communication between two networked computers that connects, via a secure channel
over an insecure network, a server and a client (running SSH server and SSH client
programs, respectively).
The protocol specification distinguishes between two major versions that are referred to
as SSH-1 and SSH-2.
The best-known application of the tool is for access to shell accounts on Unix-like
operating systems- GNU/Linux, OpenBSD, FreeBSD, but it can also be used in a similar
fashion for accounts on Windows.
SSH is generally used to log into a remote machine and execute commands.
It also supports tunnelling, forwarding TCP ports and X11 connections, it can transfer
files using the associated SSH file transfer (SFTP) or secure copy (SCP) protocols. SSH
uses the client-server model.
An SSH tunnel can provide a secure path over the Internet, through a firewall to a virtual
machine.
It was created as an open-source alternative to the proprietary Secure Shell software suite
offered by SSH Communications Security.
53
C. Telnet
Most network equipment and operating systems with a TCP/IP stack support a Telnet
service for remote configuration (including systems based on Windows NT).
Experts in computer security, recommend that the use of Telnet for remote logins should
be discontinued under all normal circumstances, for the following reasons:
Telnet, by default, does not encrypt any data sent over the connection (including
passwords), and so it is often practical to eavesdrop on the communications and use the
password later for malicious purposes; anybody who has access to a router, switch, hub
or gateway located on the network between the two hosts where Telnet is being used can
intercept the packets passing by and obtain login, password and whatever else is typed
with a packet analyzer.
Several vulnerabilities have been discovered over the years in commonly used Telnet
daemons.
D. rlogin
rlogin is a utility for Unix-like computer operating systems that allows users to log in on
another host remotely through network, communicating through TCP port 513.
rlogin has several serious security problems- all information, including passwords is
transmitted in unencrypted mode.
Due to serious security problems, rlogin was rarely used across distrusted networks (like
the public Internet) and even in closed networks.
54
D. rsh
The remote shell (rsh) can connect a remote host across a computer network.
The remote system to which rsh connects runs the rsh daemon (rshd).
The daemon typically uses the well-known Transmission Control Protocol (TCP) port
number 514.
In security point of view, it is not recommended.
E. VNC (Virtual Network Computing)
VNC is a remote display system which allows the user to view the desktop of a remote
machine anywhere on the Internet.
It can also be directed through SSH for security.
Install VNC server on a computer (server) and install client on local PC. Setup is
extremely easy and server is very stable.
On client side, set the resolution and connect to IP of VNC server.
F. FreeNX
FreeNX allows to access desktop from another computer over the Internet.
One can use this to login graphically to a desktop from a remote location.
One example of its use would be to have a FreeNX server set up on home computer, and
graphically logging in to the home computer from work computer, using a FreeNX client.
Remote administration software has recently started to appear on wireless devices such as
the BlackBerry, Pocket PC, and Palm devices, as well as some mobile phones.
Generally, these solutions do not provide the full remote access seen on software such as
VNC or Terminal Services, but do allow administrators to perform a variety of tasks,
such as rebooting computers, resetting passwords, and viewing system event logs, thus
reducing or even eliminating the need for system administrators to carry a laptop or be
within reach of the office.
AetherPal and Netop are some of the tools used for full wireless remote access and
administration on Smartphone devices.
Wireless remote administration is usually the only method to maintain man-made objects
in space.
55
G. Remote Desktop Connection (RDC)
It is done through a Remote Desktop Service (RDS) or a terminal service that uses the
company’s proprietary Remote Desktop Protocol (RDP).
Typically, RDC requires the remote computer to enable the RDS and to be powered
on.
On authentication, the local computer has full or restricted access to the remote
computer.
Besides desktop computers, servers and laptops, RDC also supports connecting to
virtual machines.
56
Disadvantages of Remote Administration
Remote administration has many disadvantages too apart from its advantages.
Due to open ports, the hackers/attackers take advantage to compromise the system.
Access Services
Network access services provide businesses with communication links to carrier and
service provider wide area networks.
A telephone is connected via twisted-pair copper wire (the local loop) to the public
telephone network where switches connect calls.
Internet users can connect to the Internet over the same local loop or use a variety of
other services, including cable TV connections, wireless connections, and fibber-optic
connections.
Access Service means access to a local exchange network for the purpose of enabling a
provider to originate or terminate telecommunication services within the local
exchange.
Except for end-user common line services, access service does not include access
service to a person who is not a provider
57
Switched Access Service means the offering of transmission and switching services to
Interexchange Carriers for the purpose of the origination or termination of telephone
toll service.
Wireless service means any service, using licensed or unlicensed wireless spectrum,
including the use of Wi-Fi, whether at a fixed location or mobile, provided to the public
using a network node.
It does not include software and services provided under separate license terms
Support Services means support in relation to the use of, and the identification and
resolution of errors in, the Hosted Services, but shall not include the provision of
training services;
Integrated Services Digital Network (ISDN) means a switched network service that
provides end-to-end digital connectivity for the simultaneous transmission of voice
and data.
58
Chapter Four
File system is a method for storing and organizing computer files and the data they
contain to make it easy to find and access them.
Most file systems make use of an underlying data storage device such as Hard Disks that
offers access to an array of fixed-size blocks which is the smallest logical amount of disk
space that can be allocated to hold a file.
File systems typically have directories which associate file names with files, usually by
connecting the file name to an index in a file allocation table of some sort, such as the
FAT in a DOS file system, or an incode in a Unix-like file system.
File names are simple strings, and per-file Metadata is maintained which is the book
keeping information, typically associated with each file within a file system.
Metadata could contain file attributes such as file size, data and time of creation or
modification of the file, owner of the file, access permissions etc.
A disk file system is a file system designed for the storage of files on a data storage
device, most commonly a disk drive e.g. FAT, NTFS, etx2, ext3 etc.
A network file system is a file system that acts as a client for a remote file access
protocol, providing access to files on a server e.g. NFS(Network File System),
SMB(Server Message Block) etc.
A flash file system is a file system designed for storing files on flash memory devices.
59
File System and OS
Operating systems provide a file system, as a file system is an integral part of any modern
operating system.
Other flavors of Operating Systems may support other File Systems like UFS in many
UNIX Operating Systems and HFS in MAC OS X.
All Operating Systems provide a user interface like Command Line (CLI) or File
Browser to access and manage File System information.
The File Allocation Table (FAT) file system was initially developed for DOS Operating
System and was later used and supported by all versions of Microsoft Windows.
It was an evolution of Microsoft's earlier operating system MS-DOS and was the
predominant File System in Windows versions like 95, 98, ME etc.
All the latest versions of Windows still support FAT file system although it may not be
popular.
FAT had various versions like FAT12, FAT16 and FAT32. Successive versions of FAT
were named after the number of bits in the table: 12, 16 and 32.
NTFS or the NT File System was introduced with the Windows NT operating system.
NTFS allows ACL-based permission control which was the most important feature
missing in FAT File System.
Later versions of Windows like Windows 2000, Windows XP, Windows Server 2003,
Windows Server 2008, and Windows Vista also use NTFS.
NTFS has several improvements over FAT such as security access control lists (ACL)
and file system journaling.
60
File System in Linux
Linux supports many different file systems, but common choices for the system disk
include the ext family (such as ext2 and ext3), XFS, JFS and Reiser FS.
The ext3 or third extended file system is a journaled file system and is the default file
system for many popular Linux distributions.
It is an upgrade of its predecessor ext2 file system and among other things it has added
the journouling feature.
A journaling file system is a file system that logs changes to a journal (usually a circular
log in a dedicated area) before committing them to the main file system. Such file
systems are less likely to become corrupted in the event of power failure or system crash.
FAT
61
FAT Limitations
62
FAT32
By smaller clusters.
root folder became an ordinary cluster chain; thus, it can be located anywhere on
the drive.
NTFS
Design Objectives
Fault-tolerance
Security
Scalability
Scalability
Thus, even with small sized clusters, NTFS can map disks up to sizes that we
won't likely see even in the next few decades.
63
Reliability
Under NTFS, a log of transactions is maintained so that CHKDSK can roll back
transactions to the last commit point in order to recover consistency within the file
system.
Under FAT, CHKDSK checks the consistency of pointers within the directory,
allocation, and file tables.
It allows you to access files on remote hosts in exactly the same way you would access
local files.
Data accessed by all users can be kept on a central host, with clients
mounting this directory at boot time.
For example, you can keep all user accounts on one host and have all hosts
on your network mount /home from that host.
If NFS is installed beside NIS, users can log into any system and still
work on one set of files.
Data consuming large amounts of disk space can be kept on a single host.
For example, all files and programs relating to LaTeX and METAFONT can be kept and
maintained in one place.
There is no need to use rcp to install the same stupid file on 20 different machines.
64
NTFS Metadata Files
NTF
S : MFT record
65
MFT record for directory
66
Open (file…) under the hood
67
1. Ordinary files
Used to represent a real physical device such as a printer, tape drive or terminal, used for
Input/Ouput (I/O) operations.
Device or special files are used for device Input/Output(I/O) on UNIX and Linux
systems.
4. Pipes
68
5. Sockets
A Unix socket (or Inter-process communication socket) is a special file which allows for
advanced inter-process communication.
6. Symbolic Link
Symbolic link is used for referencing some other file of the file system.
To an end user, symbolic link will appear to have its own name, but when you try reading
or writing data to this file, it will instead reference these operations to the file it points to.
If we delete the soft link itself, the data file would still be there.
If we delete the source file or move it to a different location, symbolic file will not
function properly
Syslog is a way for network devices to send event messages to a logging server – usually
known as a Syslog server.
System logs deal primarily with the functioning of the Ubuntu system, not necessarily
with additional applications added by users.
Examples include authorization mechanisms, system daemons, system messages, and the
all-encompassing system log itself, syslog.
69
Types of Files
Regular Files: - Most files used directly by a human user are regular files. For example,
executable files, text files, and image files are regular files.
Devices
Character Devices
Block Devices
Sockets and Named Pipes
Symbolic Links: is a pointer or an alias to another file.
Files and Directories
Directories
70
Inodes (index node) :- contains details about each file, such as the node, owner, file,
location of file
Standard directories and their contents
71
Device Files
Character Devices
Example: /dev/console
Block Devices
Examples: /dev/hda
Device Numbers
Socket
Example: X Windows
72
Named Pipe
FIFO
Link Files
Hard Link
Pointer to Inode
Magic Numbers
RedHat: /usr/share/magic
Filesystem Test
Language Test
73
MS File/Directory Attributes
74
Viewing File Attributes
File Type
Permissions
Link Count
Ownership
File Size/Device #
Modification Date
File Name
75
Ownership
Permissions
76
Changing Access
Numeric/Symbolic Permissions
77
Default Permissions
Special Attributes
Symbolic: s
Numeric: 4000
Symbolic: s
Numeric: 2000
78
Sticky Bit
Purpose
Directory: Cannot remove file unless you own the file or directory
Symbolic: t
Numeric: 1000
Example: /tmp
Microsoft Permissions
Read
Create
Write
Append
Delete
Execute
Search
Ownership
Access Control
GUI and Command Line (cacls) tools to manage
Examples:
79
CHAPTER FIVE
The kernel is the programming code that is the core of the operating system.
Computer hardware consists of physical devices such as the central processing unit
(CPU), circuit boards, the monitor and keyboard, and disk drives.
Rack-mounted server – CPU boxes mounted in racks(rack) that can hold multiple
servers
80
Blade servers – looks like a card that fits into a blade enclosure
Medium and large organizations use blade servers to help conserve space and to
consolidate server management
A basic task of an OS is to take care of input/output (I/O) functions, which let other
programs communicate with the computer hardware
Handle input from the keyboard, mouse, and other input devices
Manage network communications, such as for a local network and the Internet
Enable multimedia use for voice and video composition or reproduction, such as
recording video from a camera or playing music
81
Role of a Server Operating System
Web server
Active Directory
Fax Server
Similar to Standard.
User base varies from small businesses to corporations with large departments
82
Windows 2008 Standard Edition
64-bit version can install one virtual instance of Server 2008 Standard Edition with
Hyper-V
Can’t be purchased as individual license, only through volume license or through OEMs
original equipment manufacturer(pre-installed)
Typically used when roles such as Active Directory or Terminal Services are not required
83
Windows Server 2008 Core Technologies
Active Directory
Disk Management
Windows networking
NTFS
Successor to FAT/FAT32
Native support for long filenames, file and folder permissions, support for large files and
volumes, reliability, compression, and encryption
Most significant is the added ability for more granular file access control
Active Directory
Uses snap-ins, which are designed to perform specific administrative tasks (such as disk
management or active directory configuration)
Multiple snap-ins can be combined into a single MMC, providing quicker access to
commonly used tools
84
Disk Management
Shadow copies
Disk quotas
Distributed File System (DFS)
Also possible to configure options that allow redundancy, version control, and user
storage restrictions.
Windows Networking Concepts
A domain controller is a Windows server that has Active Directory installed and
is responsible for allowing client computers access to domain resources
85
Windows Networking Components
Network Interface
Composed of two parts; the network interface card (NIC) and the device driver
software
Network Protocol
Network server software receives requests for shared network resources and
makes those resources available to a network client
Modular design
Extensibility
Manageability
Delegated administration; can assign control over some aspects of the website to
developers and content owners
Appcmd.exe provides the ability to manage IIS via scripts and batch files
Server features provide functions that enhance or support an installed role or add a stand-
alone function
86
Active Directory Certificate Services
The Active Directory Certificate Services role provides services for creating, issuing, and
managing digital certificates
Active Directory Domain Services (AD DS) installs Active Directory and turns Windows
Server 2008 into a domain controller
Application Server
Applications for this role usually built with one or more of the following technologies:
IIS, ASP.NET, Microsoft .NET Framework, COM+, and Message Queuing
87
DHCP Server
Can provide default gateway address, DNS server addresses, WINS server addresses, and
other options
Windows Server 2008’s DHCP server role provides support for IPv6
DNS Server resolves the names of Internet computers and computers that are members of
a Windows Domain to their assigned IP addresses.
When installing Active Directory, you can specify an existing DNS server or install DNS
on the same server as Active Directory
Fax Server
Provides tools to managed shared fax resources and allow users to send and receive faxes
File Services
Provide high availability, reliable, shared storage to Windows and other client OSs
Installing File Services role installs the File Server service automatically
Hyper-V
Provides services to create and manage virtual machines on a Windows Server 2008
computer
Installing an OS on a virtual machine is done using the same methods used on a physical
machine
88
Network Policy and Access Services
Print Services
Line Printer Daemon (LPD) role service provides compatibility with Linux/UNIX clients
Terminal Services
Other roles
TS Sessions Broker
TS Gateway
TS Web Access
UDDI Services
89
Web Server (IIS)
Consists of role services Web Server, management tools, and FTP publishing
Can install and remotely configure Windows Vista and Server 2008 systems
Server Manager
Server Core
Hyper-V virtualization
Networking enhancements
Server Manager
I. Provides a single interface for installing, configuring, and removing a variety of server
roles and features on a server.
III. Includes tools to diagnose problems, manage storage, and perform general configuration
tasks
90
Server Core
DNS Server
File Services
Print Server
Web Server
Hyper-V
Windows Backup
Multipath I/O
Telnet client
91
Server Core lacks the ability to install the following server roles (and their optional
features):
Application Server
Fax Server
UDDI Services
Terminal Services
92
Hyper-V
Hyper-V Requirements:
A server running a 64-bit processor with virtualization support and hardware data
execution protection.
Enough free memory and disk space to run virtual machines and store virtual hard
drives. Virtual machines use the same amount of memory and disk space
resources as a physical machine.
93
Storage Management Enhancements
Storage Explorer
SMB 2.0
Networking Enhancements
DHCPv6
Load balancing
94
Windows Deployment Services
WDS can multicast deployment of disk images, reducing network bandwidth required
Provides tighter integration for applications that require large amounts of data
retrieval. Does not require a domain controller or domain
Helps the author of a document decide how a document can be used or modified,
and deny unauthorized user’s access
RemoteApp
Allows secure, encrypted connections using Secure HTTP (HTTPS) without the
need for a VPN
95
Summary
Windows Server 2008 is available in four editions: Standard, Enterprise, Datacenter, and
Windows Web Server 2008
Core technologies in Windows Server 2008 include NTFS, Active Directory, MMC, disk
management, file and printer sharing, networking components, and IIS
Windows Server 2008 updates previously available services with additional functionality,
while adding several new services.
Controlling Processes
Control process
With no options, ps will list processes that belong to the current user and have a
controlling terminal.
In Linux, an executable stored on disk is called a program, and a program loaded into
memory and running is called a process.
When a process is started, it is given a unique number called process ID (PID) that
identifies that process to the system.
If you ever need to kill a process, for example, you can refer to it by its PID.
Each process is assigned a parent process ID (PPID) that tells which process started it.
For example, if process1 with a PID of 101 starts a process named process2, then
process2 will be given a unique PID, such as 3240, but it will be given the PPID of 101.
A single parent process may spawn several child processes, each with a unique PID but
all sharing the same PPID.
Unix-like operating systems identify users within the kernel by a value called a user
identifier, often abbreviated to UID or User ID.
96
The UID, along with the GID and other access control criteria, is used to determine
which system resources a user can access.
The password file maps textual usernames to UIDs, but in the kernel, only UID's are
used.
The effective UID (euid) of a process is used for most access checks. It is also used as the
owner for files created by that process.
GID:
at the very least, a GID can be between 0 and 32,767, with one restriction: the login
group for the superuser must have GID 0.
nice -20 is the maximum priority (only administrative users can assign negative
priorities), nice 20 is the minimum priority.
You must be root to give a process a higher priority, but you can always lower the
priority of your own processes...
Example:
nice -20 make Would execute make and it would run at maximum priority.
The difference is that PR is a real priority of a process at the moment inside of the kernel
and NI is just a hint for the kernel what the priority the process should have.
PR = 20 + NI.
Thus the process with niceness 3 has the priority 23 (20 + 3) and the process with
niceness -7 has the priority 13 (20 - 7).
when a signal is delivered to a process, the process will stop what it’s doing, either handle
or ignore the signal, or in some cases terminate, depending on the signal.
Signals may also be delivered in an unpredictable way, out of sequence with the program
due to the fact that signals may originate outside of the currently executing process.
Asynchronous events occur when portions of the program execute out of order.
Asynchronous events typically occur due to external events originating at the hardware or
operating system; the signal, itself, is the way for the operating system to communicate
these events to the processes so that the process can take appropriate action.
Signals are used for a wide variety of purposes in Unix programming, and we've already
used them in smaller contexts.
For example, when we are working in the shell and wish to "kill all cat programs" we
type the command:
#> killall cat the killall command will send a signal to all processes named cat that says
"terminate."
but the process does not actually have to terminate … more on that later.
1. Periodic process
98
1. What is cron?
Cron is a standard Unix utility that is used to schedule commands for automatic
execution at specific intervals.
For instance, you might have a script that produces web statistics that you want to run
once a day automatically at 5:00 AM.
The ACC has a built-in interface for cron. We recommend that all customers use the
ACC cron interface, although advanced users may use cron manually.
Chapter Six
99
Dynamic Host Configuration Protocol (DHCP)
Introduction
Computers configured to be DHCP clients have no control over the settings they
receive from the DHCP server.
• The most common settings provided by a DHCP server to DHCP clients include:
• However, a DHCP server can also supply configuration properties such as:
Print Server
100
• Manual allocation (MAC address)
Using DHCP to identify the unique hardware address of each network card
connected to the network.
Continually supplying a constant configuration each time, the DHCP client makes
a request to the DHCP server using that network device.
The DHCP server will assign an IP address from a pool of addresses (sometimes
also called a range or scope) for a period of time or lease.
This way, the clients will be receiving their configuration properties dynamically
and on a "first come, first served “basis
When a DHCP client is no longer on the network for a specified period, the
configuration is expired and released back to the address pool for use by other
DHCP Clients.
• Automatic allocation
DHCP is used to assign a temporary address to a client, but a DHCP server can
allow an infinite lease time.
Configuration
101
Most commonly, what you want to do is assign an IP address randomly.
This can be done with settings as follows:
default-lease-time 600;
max-lease-time 7200;
This will result in the DHCP server giving clients an IP address from the range
192.168.1.150-192.168.1.200.
It will lease an IP address for 600 seconds if the client doesn't ask for a specific
time frame.
The server will also "advise" the client to use 192.168.1.254 as the default-
gateway
• After changing the config file you have to restart the dhcpd:
102
• The Domain Name System (DNS) is a distributed database.
This allows local control of the segments of the overall database, yet the data in
each segment is available across the entire network through a client-server
scheme.
Each domain name is essentially just a path in a large inverted tree, called the
domain name space.
• DNS's tree can branch any number of ways at each intersection point, or node.
Name Server …
Each node in the tree has a text label (without dots) that can be up to 63 characters
long.
Domain names are always read from the node toward the root, with dots
separating the names in the path.
When the root node's label appears by itself, it is written as a single dot (.) for
convenience.
Restriction guarantees that a domain name uniquely identifies a single node in the
tree.
103
• The domain name of a domain is the same as the domain name of the node at the very top
of the domain.
• So for example, the top of the purdue.edu domain is a node named purdue.edu
• Because a domain name can be in many subtrees, it can also be in many domains.
• For example, the domain name pa.ca.us is part of the ca.us domain and also part of the us
domain
104
Internet Domain Name Space
• The original top-level domains divided the Internet domain name space organizationally
into seven domains:
com
edu
gov
mil
net
105
org
int
Delegation
It can freely change the data, and even divide up its subdomain into more
subdomains and delegate those.
A domain may have several delegated subdomains and also contain hosts that
don't belong in the subdomains.
For example, the Ambo University has a campus at Awaro and Woliso. So it
might have a awaro.ambou.edu.et subdomain and a woliso.ambou.edu.et
subdomain.
106
Name Servers and Zones
• The programs that store information about the domain name space are called name
servers.
• Name servers generally have complete information about some part of the domain name
space (a zone), which they load from a file or from another name server.
• The name server is then said to have authority for that zone. Name servers can be
authoritative for multiple zones, too.
• All top-level domains, and many domains at the second level and lower, such as
berkeley.edu and hp.com, are broken into smaller, more manageable units by delegation.
• Most entries in zone data files are called DNS resource records.
• DNS lookups are case-insensitive, so you can enter names in your zone data files in
uppercase, lowercase, or mixed case.
107
Types of DNS Resource Records
• SOA record
• NS record
• A record
Name-to-address mapping
• PTR records
Address-to-name mapping
• CNAME records
• MX records
Example
108
Resolver
• Resolvers are the clients that access name servers. Programs running on a host that need
information from the domain name space use the resolver.
• Name servers are adept at retrieving data from the domain name space.
• Not only can they give you data from zones for which they're authoritative, they can also
search through the domain name space to find data for which they're not authoritative.
Resolution…
• Because the namespace is structured as an inverted tree, a name server needs only one
piece of information to find its way to any point in the tree:
A name server can issue a query to a root name server for any domain name in the
domain name space, and the root name server starts the name server on its way.
Resolution Process
109
Adding More Name Servers
In large networks it is a good idea to define name servers and give them authority.
The name implies that the only function this server performs is looking up data
and caching it.
BIND
• BIND (Berkeley Internet Name Domain) is the default name server for Linux OS.
Update your server and Install BIND on it. Execute the following commands one
by one.
Add "-4" to the OPTIONS variable. Then save and exit. It should look like the
following:
OPTIONS="-4 -u bind"
110
Chapter 7
Mail Server Basics
Linux OS Perspective
• E-Mail is a mechanism by which peoples send and receive electronic message over the
Internet.
• It gives us the ability to contact any person in the world in a matter of seconds.
• With E-Mail, on can compose a message, attach any necessary files, and send it to the
recipient.
• The main components of an e-mail system that facilitate sending and receiving of e-mails
on Internet are:
An e-mail client
An E-Mail Client
• If you use e-mails for online communication the you would definitely be using an e-mail
client.
Provides a list of messages that people have sent to you. Each entry in the list
contains the name of sender, a subject, a few words from the message body and
the time/date on which it was received.
Provides the ability to compose a new message and send it to the desired
recipients.
Delete a message.
111
• The e-mail clients could be:
• There could be many advanced abilities that e-mail clients may provide.
But whatever the type of e-mail client be, the core abilities described above are
provided by all type of clients.
An E-Mail Server
• Whenever you send a message from your e-mail client, it goes to an e-mail server.
else it follows the standard procedure to send the message over Internet to the
destined person.
112
• An e-mail server comes into the picture twice if e-mail is sent over Internet to a remote
destination.
First it’s the sender’s e-mail server that sends the e-mail over the Internet
Second is the receiver’s e-mail server that receives the e-mail and makes sure that
it is delivered to the recipient’s system.
• On the other hand, an E-mail server comes into picture only once when the
recipient is on the same subnet.
• SMTP servers are widely used as e-mail servers all over the internet. An SMTP server is
also known as Mail Transfer Agent (MTA).
• The flow of e-mail on the Internet is managed by the SMTP (Simple Mail Transfer
Protocol).
• The SMTP server is simply a computer running SMTP, and which acts more or less
like the postman.
Sender sends mail using mail client its address (e.g. biyansa@ambou.edu.et) to a
given recipient (e.g. abebe@aau.edu.et).
The message is sent normally via port 25 to an SMTP server (named for instance
mail.ambou.edu.et)
Note that SMTP defines only the message's transmission, and doesn't deal
with its body content.
Then, if the domain where your recipient has his account is directly connected to
the server, the email is immediately delivered.
If it's not the case, the SMTP hands it to another incoming server closer to the
recipient.
If the receiving server is down or busy, one of the following will happen:
113
The SMTP host simply drops the message to a backup server: if none of
them is available, the email is queued and the delivery is retried
periodically.
If there are no issues, however, the final segment is controlled by POP, another
protocol that picks up the email from the receiving server and puts it into the
recipient's inbox.
114
POP and IMAP Servers
• These servers come into the picture when a message is received by SMTP server and it
needs to be forwarded to the actual recipient.
• POP
A POP (or POP3) server in it’s simplest form stores the messages for a particular
user in a text file.
The file for a particular user is appended with information each time an e-mail is
received by a POP server.
A POP server requires the log-in credentials of a user that are sent through e-mail
client.
Once a user is authenticated, the POP server provides access to user’s e-mails.
As with any client server architecture, the e-mail client interacts with the POP
server through a predefined set of commands.
The e-mail client connects to port 110 on the server where POP service is
running.
115
POP in Picture
IMAP
• This protocol is also used to access e-mails but it is far more capable than POP.
One of the most prominent feature an IMAP server provides is the central access
to e-mails.
Unlike POP server, an IMAP server keeps the e-mails on the server itself and so
you can access e-mails from any machine or device.
• This server also provides easy management of e-mails like searching, categorizing the e-
mails and placing them into various sub-folders etc.
The only problem that one could imagine with IMAP server is that you always
need an Internet connection so that the e-mail client is able to fetch e-mails from
the IMAP server.
To interact with IMAP server, the e-mail client connects to server machine on
port 143.
116
IMAP in Picture
SMTP Relaying
• If you work for company A and want to send an email to someone in company B, you
connect to your SMTP server which then relays your message to the SMTP server owned
by company B.
The notion that an SMTP server accepts an email that is destined for a different
SMTP server is called relaying.
User Authentication
Open Relay
117
Mail Administration Basics in Linux
• A linux system administrator can follow the following basic configuration to configure
mail server:
Eg. mail.ambou.edu.et
• Spam is any kind of email that you don’t want and that you didn’t sign up to receive.
Some spam is annoying but harmless, but some might be part of an identity theft
scam or other kind of fraud.
• When one use e-mail, he/she can use different mechanisms to deal with spammers using
features provided by e-mail clients:
Add people you know to your safe sender list and unwanted senders to your
blocked list.
Report junk mail. If you get an email message that looks like spam or a phishing
scam, report it.
118
Remote Administration & Mgmt
• Webmin
Normally you need to manually edit configuration files and run commands
to create accounts, set up a web server or manage email forwarding.
Webmin lets you perform these tasks through an easy to use web interface, and
automatically updates all of the required configuration files for you.
Export files and directories to other systems with the NFS protocol.
Set up Disk Quotas to control how much space users can use up with their files.
Install, view and remove software packages in RPM and other formats.
Change your system's IP address, DNS Server settings and routing configuration.
Create and configure virtual web servers for the Apache Webserver.
119
Webmin in pictures
Exposes everything that you send or receive over that telnet session is visible in
plain text on your local network, and the local network of the machine you are
connecting to.
120
• SSH was designed and created to provide the best security when accessing another
computer remotely.
X session forwarding,
port forwarding and more so that you can increase the security of other
protocols.
UNIX Introduction
What is UNIX?
UNIX is an operating system which was first developed in the 1960s, and has been under
constant development ever since. By operating system, we mean the suite of programs which
make the computer work. It is a stable, multi-user, multi-tasking system for servers, desktops and
laptops.
UNIX systems also have a graphical user interface (GUI) similar to Microsoft Windows which
provides an easy-to-use environment. However, knowledge of UNIX is required for operations
which aren't covered by a graphical program, or for when there is no windows interface
available, for example, in a telnet session.
Types of UNIX
There are many different versions of UNIX, although they share common similarities. The most
popular varieties of UNIX are Sun Solaris, GNU/Linux, and MacOS X.
Here in the School, we use Solaris on our servers and workstations, and Fedora Linux on the
servers and desktop PCs.
The kernel
The kernel of UNIX is the hub of the operating system: it allocates time and memory to
programs and handles the filestore and communications in response to system calls.
As an illustration of the way that the shell and the kernel work together, suppose a user types rm
myfile (which has the effect of removing the file myfile). The shell searches the filestore for the
file containing the program rm, and then requests the kernel, through system calls, to execute the
program rm on myfile. When the process rm myfile has finished running, the shell then returns
the UNIX prompt % to the user, indicating that it is waiting for further commands.
121
The shell
The shell acts as an interface between the user and the kernel. When a user logs in, the login
program checks the username and password, and then starts another program called the shell.
The shell is a command line interpreter (CLI). It interprets the commands the user types in and
arranges for them to be carried out. The commands are themselves programs: when they
terminate, the shell gives the user another prompt (% on our systems).
The adept user can customise his/her own shell, and users can use different shells on the same
machine. Staff and students in the school have the tcsh shell by default.
The tcsh shell has certain features to help the user inputting commands.
Filename Completion - By typing part of the name of a command, filename or directory and
pressing the [Tab] key, the tcsh shell will complete the rest of the name automatically. If the
shell finds more than one name beginning with those letters you have typed, it will beep,
prompting you to type a few more letters before pressing the tab key again.
History - The shell keeps a list of the commands you have typed in. If you need to repeat a
command, use the cursor keys to scroll up and down the list or type history for a list of previous
commands.
122
In the diagram above, we see that the home directory of the undergraduate student "ee51vn"
contains two sub-directories (docs and pics) and a file called report.doc.
The full path to the file report.doc is "/home/its/ug1/ee51vn/report.doc"
An UNIX Terminal window will then appear with a % prompt, waiting for you to start entering
commands.
123
UNIX Tutorial One
1.1 Listing files and directories
ls (list)
When you first login, your current working directory is your home directory. Your home
directory has the same name as your user-name, for example, ee91ab, and it is where your
personal files and subdirectories are saved.
To find out what is in your home directory, type
% ls
The ls command ( lowercase L and lowercase S ) lists the contents of your current working
directory.
There may be no files visible in your home directory, in which case, the UNIX prompt will be
returned. Alternatively, there may already be some files inserted by the System Administrator
when your account was created.
ls does not, in fact, cause all the files in your home directory to be listed, but only those ones
whose name does not begin with a dot (.) Files beginning with a dot (.) are known as hidden files
124
and usually contain important program configuration information. They are hidden because you
should not change them unless you are very familiar with UNIX!!!
To list all files in your home directory including those whose names begin with a dot, type
% ls -a
As you can see, ls -a lists files that are normally hidden.
125
% cd unixstuff
Type ls to see the contents (which should be empty)
Exercise 1a
Make another directory inside the unixstuff directory called backups
1.5 Pathnames
pwd (print working directory)
Pathnames enable you to work out where you are in relation to the whole file-system. For
example, to find out the absolute pathname of your home-directory, type cd to get back to your
home-directory and then type
% pwd
The full pathname will look something like this -
/home/its/ug1/ee51vn
which means that ee51vn (your home directory) is in the sub-directory ug1 (the group
directory),which in turn is located in the its sub-directory, which is in the home sub-directory,
which is in the top-level root directory called " / " .
126
Exercise 1b
Use the commands cd, ls and pwd to explore the file system.
(Remember, if you get lost, type cd by itself to return to your home-directory)
127
would list?
What do you think
% ls ~/..
would list?
Summary
Command Meaning
cd change to home-directory
cd ~ change to home-directory
128
UNIX Tutorial Two
2.1 Copying Files
cp (copy)
cp file1 file2 is the command which makes a copy of file1 in the current working directory and
calls it file2
What we are going to do now, is to take a file stored in an open access area of the file system,
and use the cp command to copy it to your unixstuff directory.
First, cd to your unixstuff directory.
% cd ~/unixstuff
Then at the UNIX prompt, type,
% cp /vol/examples/tutorial/science.txt .
Note: Don't forget the dot . at the end. Remember, in UNIX, the dot means the current directory.
The above command means copy the file science.txt to the current directory, keeping the name
the same.
(Note: The directory /vol/examples/tutorial/ is an area to which everyone in the school has read
and copy access. If you are from outside the University, you can grab a copy of the file here. Use
'File/Save As..' from the menu bar to save it into your unixstuff directory.)
Exercise 2a
Create a backup of your science.txt file by copying it to a file called science.bak
129
2.3 Removing files and directories
rm (remove), rmdir (remove directory)
To delete (remove) a file, use the rm command. As an example, we are going to create a copy of
the science.txt file then delete it.
Inside your unixstuff directory, type
% cp science.txt tempfile.txt
% ls
% rm tempfile.txt
% ls
You can use the rmdir command to remove a directory (make sure it is empty first). Try to
remove the backups directory. You will not be able to since UNIX will not let you remove a
non-empty directory.
Exercise 2b
Create a directory called tempstuff using mkdir , then remove it using the rmdir command.
cat (concatenate)
The command cat can be used to display the contents of a file on the screen. Type:
% cat science.txt
As you can see, the file is longer than than the size of the window, so it scrolls past making it
unreadable.
less
The command less writes the contents of a file onto the screen a page at a time. Type
% less science.txt
Press the [space-bar] if you want to see another page, and type [q] if you want to quit reading.
As you can see, less is used in preference to cat for long files.
head
The head command writes the first ten lines of a file to the screen.
130
First clear the screen then type
% head science.txt
Then type
% head -5 science.txt
What difference did the -5 do to the head command?
tail
The tail command writes the last ten lines of a file to the screen.
Clear the screen and type
% tail science.txt
Q. How can you view the last 15 lines of the file?
131
Try some of them and see the different results. Don't forget, you can use more than one option at
a time. For example, the number of lines without the words science or Science is
% grep -ivc science science.txt
wc (word count)
A handy little utility is the wc command, short for word count. To do a word count on
science.txt, type
% wc -w science.txt
To find out how many lines the file has, type
% wc -l science.txt
Summary
Command Meaning
132
wc file count number of lines/words/characters in file
133
UNIX Tutorial Three
3.1 Redirection
Most processes initiated by UNIX commands write to the standard output (that is, they write to
the terminal screen), and many take their input from the standard input (that is, they read it from
the keyboard). There is also the standard error, where processes write their error messages, by
default, to the terminal screen.
We have already seen one use of the cat command to write the contents of a file to the screen.
Now type cat without specifing a file to read
% cat
Then type a few words on the keyboard and press the [Return] key.
Finally hold the [Ctrl] key down and press [d] (written as ^D for short) to end the input.
What has happened?
If you run the cat command without specifing a file to read, it reads the standard input (the
keyboard), and on receiving the 'end of file' (^D), copies it to the standard output (the screen).
In UNIX, we can redirect both the input and the output of commands.
Exercise 3a
Using the above method, create another file called list2 containing the following fruit: orange,
plum, mango, grapefruit. Read the contents of list2
134
peach
grape
orange
^D (Control D to stop)
To read the contents of the file, type
% cat list1
You should now have two files. One contains six fruit, the other contains four fruit.
We will now use the cat command to join (concatenate) list1 and list2 into a new file called
biglist. Type
% cat list1 list2 > biglist
What this is doing is reading the contents of list1 and list2 in turn, then outputing the text to the
file biglist
To read the contents of the new file, type
% cat biglist
3.4 Pipes
To see who is on the system with you, type
% who
One method to get a sorted list of names is to type,
135
% who > names.txt
% sort < names.txt
This is a bit slow and you have to remember to remove the temporary file called names when
you have finished. What you really want to do is connect the output of the who command
directly to the input of the sort command. This is exactly what pipes do. The symbol for a pipe is
the vertical bar |
For example, typing
% who | sort
will give the same result as above, but quicker and cleaner.
To find out how many users are logged on, type
% who | wc -l
Exercise 3b
Using pipes, display all lines of list1 and list2 containing the letter 'p', and sort the result.
Answer available here
Summary
Command Meaning
cat file1 file2 > file0 concatenate file1 and file2 to file0
136
UNIX Tutorial Four
4.1 Wildcards
The * wildcard
The character * is called a wildcard, and will match against none or more character(s) in a file
(or directory) name. For example, in your unixstuff directory, type
% ls list*
This will list all files in the current directory starting with list....
Try typing
% ls *list
This will list all files in the current directory ending with ....list
The ? wildcard
The character ? will match exactly one character.
So ?ouse will match files like house and mouse, but not grouse.
Try typing
% ls ?list
project.txt project
File names conventionally start with a lower-case letter, and may end with a dot followed by a
group of letters indicating the contents of the file. For example, all files consisting of C code may
be named with the ending .c, for example, prog1.c . Then in order to list all files containing C
code in your home directory, you need only type ls *.c in that directory.
137
4.3 Getting Help
On-line Manuals
There are on-line manuals which gives information about most commands. The manual pages
tell you which options a particular command can take, and how each option modifies the
behaviour of the command. Type man command to read the manual page for a particular
command.
For example, to find out more about the wc (word count) command, type
% man wc
Alternatively
% whatis wc
gives a one-line description of the command, but omits any information about options etc.
Apropos
When you are not sure of the exact name of a command,
% apropos keyword
will give you the commands with keyword in their manual page header. For example, try typing
% apropos copy
Summary
Command Meaning
* match any number of characters
? match one character
man command read the online manual page for a command
whatis command brief description of a command
apropos keyword match commands with keyword in their man pages
138
Each file (and directory) has associated access rights, which may be found by typing ls -l. Also,
ls -lg gives additional information as to which group owns the file (beng95 in the following
example):
-rwxrw-r-- 1 ee51ab beng95 2450 Sept29 11:52 file1
In the left-hand column is a 10 symbol string consisting of the symbols d, r, w, x, -, and,
occasionally, s or S. If d is present, it will be at the left hand end of the string, and indicates a
directory: otherwise - will be the starting symbol of the string.
The 9 remaining symbols indicate the permissions, or access rights, and are taken as three groups
of 3.
The left group of 3 gives the file permissions for the user that owns the file (or directory)
(ee51ab in the above example);
the middle group gives the permissions for the group of people to whom the file (or directory)
belongs (eebeng95 in the above example);
the rightmost group gives the permissions for all others.
The symbols r, w, etc., have slightly different meanings depending on whether they refer to a
simple file or to a directory.
139
Some examples
-rwxrwxrwx a file that everyone can read, write and execute (and delete).
a file that only the owner can read and write - no-one else
-rw------- can read or write and no-one has execution rights (e.g. your
mailbox file).
u user
g group
o other
a all
r read
+ add permission
140
For example, to remove read write and execute permissions on the file biglist for the group and
others, type
% chmod go-rwx biglist
This will leave the other permissions unaffected.
To give read and write permissions on the file biglist to all,
% chmod a+rw biglist
Exercise 5a
Try changing access permissions on the file science.txt and on the directory backups
Use ls -l to check that the permissions have changed.
141
% sleep 1000
You can suspend the process running in the foreground by typing ^Z, i.e.hold down the [Ctrl]
key and type [z]. Then to put it in the background, type
% bg
Note: do not background programs that require user interaction e.g. vi
ps (process status)
Alternatively, processes can be killed by finding their process numbers (PIDs) and using kill
PID_number
142
% sleep 1000 &
% ps
PID TT S TIME COMMAND
20077 pts/5 S 0:05 sleep 1000
21563 pts/5 T 0:00 netscape
21873 pts/5 S 0:25 nedit
To kill off the process sleep 1000, type
% kill 20077
and then type ps again to see if it has been removed from the list.
If a process refuses to be killed, uses the -9 option, i.e. type
% kill -9 20077
Note: It is not possible to kill off other users' processes !!!
Summary
Command Meaning
143
UNIX Tutorial Six
Other useful UNIX commands
quota
All students are allocated a certain amount of disk space on the file system for their personal
files, usually about 100Mb. If you go over your quota, you are given 7 days to remove excess
files.
To check your current quota and how much of it you have used, type
% quota -v
df
The df command reports on the space left on the file system. For example, to find out how much
space is left on the fileserver, type
% df .
du
The du command outputs the number of kilobyes used by each subdirectory. Useful if you have
gone over quota and you want to find out which directory has the most files. In your home-
directory, type
% du -s *
The -s flag will display only a summary (total size) and the * means all files and directories.
gzip
This reduces the size of a file, thus freeing valuable disk space. For example, type
% ls -l science.txt
and note the size of the file using ls -l . Then to compress science.txt, type
% gzip science.txt
This will compress the file and place it in a file called science.txt.gz
To see the change in size, type ls -l again.
To expand the file, use the gunzip command.
% gunzip science.txt.gz
zcat
zcat will read gzipped files without needing to uncompress them first.
% zcat science.txt.gz
If the text scrolls too fast for you, pipe the output though less .
% zcat science.txt.gz | less
144
file
file classifies the named files according to the type of data they contain, for example ascii (text),
pictures, compressed data, etc.. To report on all files in your home directory, type
% file *
diff
This command compares the contents of two files and displays the differences. Suppose you
have a file called file1 and you edit some part of it and save it as file2. To see the differences
type
% diff file1 file2
Lines beginning with a < denotes file1, while lines beginning with a > denotes file2.
find
This searches through the directories for files and directories with a given name, date, size, or
any other attribute you care to specify. It is a simple command but with many options - you can
read the manual by typing man find.
To search for all fies with the extention .txt, starting at the current directory (.) and working
through all sub-directories, then printing the name of the file to the screen, type
% find . -name "*.txt" -print
To find files over 1Mb in size, and display the result as a long listing, type
% find . -size +1M -ls
history
The C shell keeps an ordered list of all the commands that you have entered. Each command is
given a number according to the order it was entered.
% history (show command history list)
If you are using the C shell, you can use the exclamation character (!) to recall commands easily.
% !! (recall last command)
% !-3 (recall third most recent command)
% !5 (recall 5th command in list)
% !grep (recall last command starting with grep)
You can increase the size of the history buffer by typing
% set history=100
145
UNIX Tutorial Seven
7.1 Compiling UNIX software packages
We have many public domain and commercial software packages installed on our systems,
which are available to all users. However, students are allowed to download and install small
software packages in their own home directory, software usually only useful to them personally.
There are a number of steps needed to install the software.
Locate and download the source code (which is usually compressed)
Unpack the source code
Compile the code
Install the resulting executable
Set paths to the installation directory
Of the above steps, probably the most difficult is the compilation stage.
configure
As the number of UNIX variants increased, it became harder to write programs which could run
on all variants. Developers frequently did not have access to every system, and the characteristics
146
of some systems changed from version to version. The GNU configure and build system
simplifies the building of programs distributed as source code. All programs are built using a
simple, standardised, two step process. The program builder need not install any special tools in
order to build the program.
The configure shell script attempts to guess correct values for various system-dependent
variables used during compilation. It uses those values to create a Makefile in each directory of
the package.
The simplest way to compile a package is:
1. cd to the directory containing the package's source code.
2. Type ./configure to configure the package for your system.
3. Type make to compile the package.
4. Optionally, type make check to run any self-tests that come with the package.
5. Type make install to install the programs and any data files and documentation.
6. Optionally, type make clean to remove the program binaries and object files from the source
code directory
The configure utility supports a wide variety of options. You can usually use the --help option to
get a list of interesting options for a particular configure script.
The only generic options you are likely to use are the --prefix and --exec-prefix options. These
options are used to specify the installation directories.
The directory named by the --prefix option will hold machine independent files such as
documentation, data and configuration files.
The directory named by the --exec-prefix option, (which is normally a subdirectory of the --
prefix directory), will hold machine dependent files such as executables.
147
% tar -xvf units-1.74.tar
Again, list the contents of the download directory, then go to the units-1.74 sub-directory.
% cd units-1.74
% echo $HOME
to show the contents of this variable. We will learn more about environment variables in a later
chapter.
If configure has run correctly, it will have created a Makefile with all necessary options. You can
view the Makefile if you wish (use the less command), but do not edit the contents of this.
148
share Shared data files
To run the program, change to the bin directory and type
% ./units
As an example, convert 6 feet to metres.
You have: 6 feet
You want: metres
* 1.8288
If you get the answer 1.8288, congratulations, it worked.
To view what units it can convert between, view the data file in the share directory (the list is
quite comprehensive).
To read the full documentation, change into the info directory and type
% info --file=units.info
149
units: ELF 32-bit LSB executable, Intel 80386, version 1, dynamically linked (uses shared libs),
stripped
Sometimes you can use the make command to install pre-stripped copies of all the binary files
when you install the package. Instead of typing make install, simply type make install-strip
150
UNIX Tutorial Eight
8.1 UNIX Variables
Variables are a way of passing information from the shell to programs when you run them.
Programs look "in the environment" for particular variables and if they are found will use the
values stored. Some are set by the system, others by you, yet others by the shell, or any program
that loads another program.
Standard UNIX variables are split into two categories, environment variables and shell variables.
In broad terms, shell variables apply only to the current instance of the shell and are used to set
short-term working conditions; environment variables have a farther reaching significance, and
those set at login are valid for the duration of the session. By convention, environment variables
have UPPER CASE and shell variables have lower case names.
151
prompt (the text string used to prompt for interactive commands shell your login shell)
152
% nedit ~/.cshrc
Add the following line AFTER the list of other commands.
set history = 200
Save the file and force the shell to reread its .cshrc file buy using the shell source command.
% source .cshrc
Check this has worked by typing
% echo $history
153