0% found this document useful (0 votes)
240 views22 pages

Difference Between Windows and Linux: Mobile Operating Systems

An operating system (OS) is system software that manages computer hardware and software resources and provides common services for computer programs. The OS acts as an intermediary between programs and the computer hardware, scheduling tasks for efficient use of the system. Examples of popular modern OSes include Android, iOS, Linux, macOS, Windows, and others derived from Unix. OSes can be single- or multi-tasking, single- or multi-user, distributed, embedded, real-time, or library-based depending on their design and purpose.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
240 views22 pages

Difference Between Windows and Linux: Mobile Operating Systems

An operating system (OS) is system software that manages computer hardware and software resources and provides common services for computer programs. The OS acts as an intermediary between programs and the computer hardware, scheduling tasks for efficient use of the system. Examples of popular modern OSes include Android, iOS, Linux, macOS, Windows, and others derived from Unix. OSes can be single- or multi-tasking, single- or multi-user, distributed, embedded, real-time, or library-based depending on their design and purpose.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 22

An operating system or simply an OS is a software program that enables the communication and

operation of the computer hardware and computer software. Without the operating system, all
components of a computer such as hardware and software will be useless and a computer without an OS
is just a dumb metal. In other words, an OS describes a software program, which designed to run all other
software programs on a computer. In a pure techie perspective, the OS is the backbone of a computer,
which manages both hardware and software resources. The OS is comprised of system software and all
the fundamental files a computer needs while booting. Devices such as   desktop computer, laptop, tablet
and a smartphone use an OS that facilitates the basic functionality that the device needs while startup.

The most common operating systems includes the Windows family of operating systems developed by
Microsoft, the Macintosh OS from Apple and the UNIX family of operating systems and many other
special purpose operating systems that are used with mainframes, robotics, real-time control systems,
manufacturing etc. (Read difference between Windows and Linux) Each OS may be different, but they all
provide GUI or graphical user interface, which has a desktop and the capability of files and folders
management.

Mobile Operating Systems


Similar to computers, the mobile devices like tablets and smartphones also has operating system that
provides GUI and other functionalities to run various applications. The common mobile operating
systems include iOS [Apple I pads], Android [Android Phones], Symbian and Windows Phone. These
operating systems developed for portable devices that use touchscreen input.Unlike the earlier mobile
OSes, the recently developed mobile OSes have come up with advanced features found in desktop
computers.The recent OS versions use a GUI that employ pointing devices such as mouse for taking
input. The mobile OSes helps the users to watch movies, play games, and browse on the net, managing
calendar and many more.
 
Types of Operating Systems
There are different types of operating systems such as multi-user, multi-tasking, multi-threading, multi-
processing, and real-time operating systems. A multi-user OS allows multiple users to run applications at
the same time. This OS is used for less number of people say a group of hundred people. However, some
multi-user Operating systems allow thousands of people to run applications simultaneously. A multi-
tasking OS allows its users to run multiple programs at the same done. Multi-threading OS enables the
users to run various parts of a program known as threads to be used at the same time. Multi-processing
operating system allows a single program or process to run on multiple CPU’s at the same time. A real-
time OS is designed to enable computers to respond and process inputs instantly. Typically an RTOS has
very limited user interface capability and it doesn’t have any end user utilities.
 
Functions of Operating Systems
In a simplest level, an OS performs mainly two functions:
Manages the hardware as well as software resources of any system in which the OS resides. Such
resources in a desktop computer are – CPU, memory [RAM, ROM], disk space and that of a cellphone
are – the display screen, keypad, address book etc.

Enables the applications to deal with the hardware in a consistent and stable way without knowing entire
details of the hardware.
The most important function of OS is managing the hardware and resources, where various input
methods and programs compete with each other to achieve the CPU attention, demand storage, memory
and I/O bandwidth etc. Here the OS ensures that every application gets necessary resources while
keeping the other applications nicely and also the processes are running fine for all users. The second
task is where a consistent API [application programming interface] is provided .Here it is important to
have multiple computers using the same type of OS or an OS that is open to any changes to the
hardware. A consistent API helps a software developer to create an application that runs on different
types of computers with varied memory or storage space. An OS ensures the different applications
continue to run in case of a hardware upgrade or a security patch updates. This is how an OS manages
both the hardware and software resources of a computer.
  
Since the OS is the fundamental user interface for a computer, it definitely affects how you interact with
the devices. Because of this people may set their own preferences for selecting a specific OS for their
perusal. Say for example one user may prefer using Linux or BSD where the other person may opt for
Windows 7 or any other version from the windows operating system family. A mobile user may choose an
Android phone or smartphone instead of an iPhone that runs on iOS. Depending on the capacity of an
application to run on multiple platforms it is important to choose an OS accordingly when you purchase a
computer

An operating system (OS) is system software that manages computer hardware and software resources and


provides commonservices for computer programs. The operating system is an essential component of the system
software in a computer system.Application programs usually require an operating system to function.

Time-sharing operating systems schedule tasks for efficient use of the system and may also include accounting
software for cost allocation of processor time, mass storage, printing, and other resources.

For hardware functions such as input and output and memory allocation, the operating system acts as an
intermediary between programs and the computer hardware,[1][2] although the application code is usually executed
directly by the hardware and frequently makes system calls to an OS function or be interrupted by it. Operating
systems are found on many devices that contain a computer—from cellular phones and video game consoles to web
servers and supercomputers.

Examples of popular modern operating systems include Android, BlackBerry, BSD, Chrome OS, iOS, Linux, OS


X, QNX, Steam OS,Microsoft Windows (and variant Windows Phone),[3] and z/OS. The first nine of these examples
share roots in Unix. Popular hard real-time operating systems include FreeRTOS, Micrium and VxWorks.

Types of operating systems[edit]


Single- and multi-tasking[edit]
A single-tasking system can only run one program at a time, while a multi-tasking operating system allows more than
one program to be running in concurrency. This is achieved by time-sharing, dividing the available processor time
between multiple processes which are each interrupted repeatedly in time-slices by a task scheduling subsystem of
the operating system. Multi-tasking may be characterized in pre-emptive and co-operative types. In pre-emptive
multitasking, the operating system slices the CPU time and dedicates a slot to each of the programs. Unix-like
operating systems, e.g., Solaris, Linux, as well as AmigaOS support pre-emptive multitasking. Cooperative
multitasking is achieved by relying on each process to provide time to the other processes in a defined manner. 16-
bit versions of Microsoft Windows used cooperative multi-tasking. 32-bit versions of both Windows NT and Win9x,
used pre-emptive multi-tasking.
Single- and multi-user[edit]
Single-user operating systems have no facilities to distinguish users, but may allow multiple programs to run in
tandem.[4] A multi-user operating system extends the basic concept of multi-tasking with facilities that identify
processes and resources, such as disk space, belonging to multiple users, and the system permits multiple users to
interact with the system at the same time. Time-sharing operating systems schedule tasks for efficient use of the
system and may also include accounting software for cost allocation of processor time, mass storage, printing, and
other resources to multiple users.

Distributed[edit]
A distributed operating system manages a group of distinct computers and makes them appear to be a single
computer. The development of networked computers that could be linked and communicate with each other gave rise
to distributed computing. Distributed computations are carried out on more than one machine. When computers in a
group work in cooperation, they form a distributed system.[5]

Templated[edit]
In an OS, distributed and cloud computing context, templating refers to creating a single virtual machine image as a
guest operating system, then saving it as a tool for multiple running virtual machines (Gagne, 2012, p. 716). The
technique is used both in virtualization and cloud computing management, and is common in large server
warehouses.[6]

Embedded[edit]
Embedded operating systems are designed to be used in embedded computer systems. They are designed to
operate on small machines like PDAs with less autonomy. They are able to operate with a limited number of
resources. They are very compact and extremely efficient by design. Windows CE and Minix 3 are some examples of
embedded operating systems.

Real-time[edit]
A real-time operating system is an operating system that guarantees to process events or data within a certain short
amount of time. A real-time operating system may be single- or multi-tasking, but when multitasking, it uses
specialized scheduling algorithms so that a deterministic nature of behavior is achieved. An event-driven system
switches between tasks based on their priorities or external events while time-sharing operating systems switch tasks
based on clock interrupts.[citation needed]

Library[edit]
A library operating system is one in which the services that a typical operating system provides, such as networking,
are provided in the form of libraries. These libraries are composed with the application and configuration code to
construct unikernels — which are specialised, single address space, machine images that can be deployed to cloud
or embedded environments.

Real-time operating systems[edit]


Main article: Real-time operating system

A real-time operating system (RTOS) is an operating system intended for applications with fixed deadlines (real-time
computing). Such applications include some small embedded systems, automobile engine controllers, industrial
robots, spacecraft, industrial control, and some large-scale computing systems.
An early example of a large-scale real-time operating system was Transaction Processing Facility developed
by American Airlines and IBM for the Sabre Airline Reservations System.

Embedded systems that have fixed deadlines use a real-time operating system such
as VxWorks, PikeOS, eCos, QNX, MontaVista Linux and RTLinux. Windows CE is a real-time operating system that
shares similar APIs to desktop Windows but shares none of desktop Windows' codebase.[citation needed] Symbian OS also
has an RTOS kernel (EKA2) starting with version 8.0b.

Some embedded systems use operating systems such as Palm OS, BSD, and Linux, although such operating
systems do not support real-time computing.

How Computer Boots up?


Have you ever given it a thought that when you press the power button on your laptop
or PC, what happens behind the logo of Windows XP/Vista/Seven or Linux? From the
pressing of the power button to the appearance of the login screen there are more than
hundred components/peripherals that are initialized and thousand lines of code is
executed during the process of booting. But what is booting? We will look inside the
machine, that actually what all happens. So let us start…
 
What is Booting?
Booting is a process or set of operations that loads and hence starts the operating
system, starting from the point when user switches on the power button.
 
What is Booting Sequence?
Basically documents related to booting are generally confusing as they are often related
to some specific operating system that is Linux machine or Windows machine. But I will
keep it as general as possible.

sequence comprises of the following steps:

·         Turn on the Power button.


·         CPU pins are reset and registers are set to specific value.
·         CPU jump to address of BIOS (0xFFFF0).
·         BIOS run POST (Power-On Self Test) and other necessary checks.
·         BIOS jumps to MBR(Master Boot Record).
·         Primary Bootloader runs from MBR and jumps to Secondary Bootloader.
·         Secondary Bootloaders loads Operating System.

BIOS-Basic Input Output System


As we have seen that at power up CPU is reset and its registers are set to the default
value, which is an address pointing or directing to the hardware containing BIOS.
Generally the hardware is EEPROM containing the BIOS. The tasks performed by BIOS
are categorized as follows:
·         POST- Power on Self Test is the foremost routine which checks and tests the basic
hardware. If it fails then it displays error.
·         Initialization of the hardware devices by letting them run their individual BIOS( eg.
video card have their own inbuilt BIOS code).
·         Searching for the Master Boot Record and reading it.
·         Copying the boot sector code to RAM and then switching the control to it.

Boot Sectors
A sector is a part of the hard disk having length of 512 bytes. A sector is termed as boot
sector because of its location and because this sector is responsible for the further boot
process of the system. This boot sector is generally called Master Boot Record. The
MBR is a 512-byte sector, which is located in the first sector on the disk (sector 1 of
cylinder 0, head 0). As soon as BIOS gets the boot sector, it tends to copy MBR to RAM
and switches the execution authority to it.
·         In the MBR the first 446 bytes are the primary boot loader, which is also referred as
PBL.
·         The next sixty-four bytes are the partition table, which has the record for each of the
partitions.
·         The MBR ends with two bytes that should be 0xAA55. These numbers act as
validation that this sector is the boot sector or Master Boot Record.
The following are the 6 high level stages of a typical Linux boot process.

1. BIOS
• BIOS stands for Basic Input/Output System
• Performs some system integrity checks
• Searches, loads, and executes the boot loader program.
• It looks for boot loader in floppy, cd-rom, or hard drive. You can press a key (typically F12 of F2, but it
depends on your system) during the BIOS startup to change the boot sequence.
• Once the boot loader program is detected and loaded into the memory, BIOS gives the control to it.
• So, in simple terms BIOS loads and executes the MBR boot loader.

2. MBR
• MBR stands for Master Boot Record.
• It is located in the 1st sector of the bootable disk. Typically /dev/hda, or /dev/sda
• MBR is less than 512 bytes in size. This has three components 1) primary boot loader info in 1st 446
bytes 2) partition table info in next 64 bytes 3) mbr validation check in last 2 bytes.
• It contains information about GRUB (or LILO in old systems).
• So, in simple terms MBR loads and executes the GRUB boot loader.

3. GRUB
• GRUB stands for Grand Unified Bootloader.
• If you have multiple kernel images installed on your system, you can choose which one to be executed.
• GRUB displays a splash screen, waits for few seconds, if you don’t enter anything, it loads the default
kernel image as specified in the grub configuration file.
• GRUB has the knowledge of the filesystem (the older Linux loader LILO didn’t understand filesystem).
• Grub configuration file is /boot/grub/grub.conf (/etc/grub.conf is a link to this). The following is
sample grub.conf of CentOS.
#boot=/dev/sda

default=0

timeout=5

splashimage=(hd0,0)/boot/grub/splash.xpm.gz

hiddenmenu

title CentOS (2.6.18-194.el5PAE)

root (hd0,0)

kernel /boot/vmlinuz-2.6.18-194.el5PAE ro root=LABEL=/

initrd /boot/initrd-2.6.18-194.el5PAE.img

• As you notice from the above info, it contains kernel and initrd image.
• So, in simple terms GRUB just loads and executes Kernel and initrd images.

4. Kernel
• Mounts the root file system as specified in the “root=” in grub.conf
• Kernel executes the /sbin/init program
• Since init was the 1st program to be executed by Linux Kernel, it has the process id (PID) of 1. Do a ‘ps
-ef | grep init’ and check the pid.
• initrd stands for Initial RAM Disk.
• initrd is used by kernel as temporary root file system until kernel is booted and the real root file
system is mounted. It also contains necessary drivers compiled inside, which helps it to access the
hard drive partitions, and other hardware.

5. Init
• Looks at the /etc/inittab file to decide the Linux run level.
• Following are the available run levels
• 0 – halt
• 1 – Single user mode
• 2 – Multiuser, without NFS
• 3 – Full multiuser mode
• 4 – unused
• 5 – X11
• 6 – reboot
• Init identifies the default initlevel from /etc/inittab and uses that to load all appropriate program.
• Execute ‘grep initdefault /etc/inittab’ on your system to identify the default run level
• If you want to get into trouble, you can set the default run level to 0 or 6. Since you know what 0 and 6
means, probably you might not do that.
• Typically you would set the default run level to either 3 or 5.

6. Runlevel programs
• When the Linux system is booting up, you might see various services getting started. For example, it
might say “starting sendmail …. OK”. Those are the runlevel programs, executed from the run level
directory as defined by your run level.
• Depending on your default init level setting, the system will execute the programs from one of the
following directories.
• Run level 0 – /etc/rc.d/rc0.d/
• Run level 1 – /etc/rc.d/rc1.d/
• Run level 2 – /etc/rc.d/rc2.d/
• Run level 3 – /etc/rc.d/rc3.d/
• Run level 4 – /etc/rc.d/rc4.d/
• Run level 5 – /etc/rc.d/rc5.d/
• Run level 6 – /etc/rc.d/rc6.d/
• Please note that there are also symbolic links available for these directory under /etc directly. So,
/etc/rc0.d is linked to /etc/rc.d/rc0.d.
• Under the /etc/rc.d/rc*.d/ directories, you would see programs that start with S and K.
• Programs starts with S are used during startup. S for startup.
• Programs starts with K are used during shutdown. K for kill.
• There are numbers right next to S and K in the program names. Those are the sequence number in
which the programs should be started or killed.
• For example, S12syslog is to start the syslog deamon, which has the sequence number of 12.
S80sendmail is to start the sendmail daemon, which has the sequence number of 80. So, syslog
program will be started before sendmail.

In computing, booting (or booting up) is the initialization of a computerized system. The system can be


a computer or a computer appliance. The booting process can be "hard", after electrical power to the CPU is
switched from off to on (in order to diagnose particular hardware errors), or "soft", when those power-on self-
tests (POST) can be avoided. Soft booting can be initiated by hardware such as a button press, or by software
command. Booting is complete when the normal, operative, runtime environment is attained.

A boot loader is a computer program that loads an operating system or some other system software for the
computer after completion of the power-on self-tests; it is the loaderfor the operating system itself, which has its own
loader for loading ordinary user programs and libraries. Within the hard reboot process, it runs after completion of the
self-tests, then loads and runs the software. A boot loader is loaded into main memory from persistent memory, such
as a hard disk drive or, in some older computers, from a medium such as punched cards, punched tape, or magnetic
tape. The boot loader then loads and executes the processes that finalize the boot. Like POST processes, the boot
loader code comes from a "hard-wired" and persistent location; if that location is too limited for some reason, that
primary boot loader calls a second-stage boot loader or a secondary program loader.

On modern general purpose computers, the boot up process can take tens of seconds, and typically involves
performing a power-on self-test, locating and initializing peripheral devices, and then finding, loading and starting
an operating system. The process of hibernating or sleeping does not involve booting. Minimally, some embedded
systems do not require a noticeable boot sequence to begin functioning and when turned on may simply run
operational programs that are stored in ROM. All computing systems are state machines, and a reboot may be the
only method to return to a designated zero-state from an unintended, locked state.

Boot is short for bootstrap[1][2] or bootstrap load and derives from the phrase to  pull oneself up by one's bootstraps.[3] The
usage calls attention to the requirement that, if most software is loaded onto a computer by other software already
running on the computer, some mechanism must exist to load the initial software onto the computer.[4] Early
computers used a variety of ad-hoc methods to get a small program into memory to solve this problem. The invention
of read-only memory (ROM) of various types solved this paradox by allowing computers to be shipped with a start up
program that could not be erased. Growth in the capacity of ROM has allowed ever more elaborate start up
procedures to be implemented.

Network booting
Most computers are also capable of booting over a computer network. In this scenario, the operating system is stored
on the disk of a server, and certain parts of it are transferred to the client using a simple protocol such as the Trivial
File Transfer Protocol (TFTP). After these parts have been transferred, the operating system takes over the control of
the booting process.

As with the second-stage boot loader, network booting begins by using generic network access methods provided by
the network interface's boot ROM, which typically contains aPreboot Execution Environment (PXE) image. No drivers
are required, but the system functionality is limited until the operating system kernel and drivers are transferred and
started. As a result, once the ROM-based booting has completed it is entirely possible to network boot into an
operating system that itself does not have the ability to use the network interface.

Early minicomputer boot loader examples[edit]


In a minicomputer with a paper tape reader, the first program to run in the boot process, the boot loader, would read
into core memory either the second-stage boot loader (often called a Binary Loader) that could read paper tape
with checksum or the operating system from an outside storage medium. Pseudocode for the boot loader might be as
simple as the following eight instructions:

• Set the P register to 9


• Check paper tape reader ready
• If not ready, jump to 2
• Read a byte from paper tape reader to accumulator
• Store accumulator to address in P register
• If end of tape, jump to 9
• Increment the P register
• Jump to 2

Booting the first microcomputers[edit]

The earliest microcomputers, such as the Altair 8800 and an even earlier, similar machine (based on the Intel 8008
CPU) had no bootstrapping hardware as such. When started, the CPU would see memory that would contain
executable code containing only binary zeros—memory was cleared by resetting when powering up. The front panels
of these machines carried toggle switches, one switch per bit of the computer memory word. Simple additions to the
hardware permitted one memory location at a time to be loaded from those switches to store bootstrap code.
Meanwhile, the CPU was kept from attempting to execute memory content. Once correctly loaded, the CPU was
enabled to execute the bootstrapping code. This process was tedious and had to be error-free.

Modern boot loaders[edit]


When a computer is turned off, its software—including operating systems, application code, and data—remains
stored on nonvolatile data storage devices such as hard disk drives, CDs, DVDs, flash memory cards (SD cards, for
example), USB flash drives, and floppy disks. When the computer is powered on, it typically does not have an
operating system or its loader in random access memory (RAM). The computer first executes a relatively small
program stored in read-only memory (ROM) along with a small amount of needed data, to access the nonvolatile
device or devices from which the operating system programs and data can be loaded into RAM.

The small program that starts this sequence is known as a bootstrap loader, bootstrap or boot loader. This small
program's only job is to load other data and programs which are then executed from RAM. Often, multiple-stage boot
loaders are used, during which several programs of increasing complexity load one after the other in a process
of chain loading.

System configuration
A system configuration (SC) in systems engineering defines the computers, processes, and devices that compose
the system and its boundary. More general the system configuration is the specific definition of the elements that
define and/or prescribe what a system is composed of.

Alternatively the term system configuration can be used to relate to a model (declarative) for abstract generalized
systems. In this sense the usage of the configuration information is not tailored to any specific usage, but stands
alone as a data set. A properly-configured system avoids resource-conflict problems, and makes it easier to upgrade
a system with new equipment.

Sample Configuration[edit]
The following is a basic SC XML System Configuration:

<system_configuration>
<site name="MyHouse" >
<hosts>
<host_ref name="host1"/>
</hosts>
</site>
<group name="mysql" gid="500"/>
<user name="mysql" uid="500">
<groups>
<group_ref name="mysql"/>
</groups>
</user>
<host name="host1" >
<users>
<user_ref name="mysql">
</users>
<profiles>
<profile_ref name="workstation"/>
</profiles>
</host>
<profile name="workstation" >
<components>
<component_ref name="user-setup" >
<component_ref name="mysql-db" >
</components>
</profile>
<component name="user-setup">
</component>
<component name="mysql-db">
</component>
</system_configuration>

Description: This provides information about a single "site" (MyHouse) and specifies that there is one host with user-
setup and mysql-db components. The host must have an account on it for a user named mysql, with appropriate
parameters. Notice that the configuration schema requires no XML tags that are Windows- or UNIX-specific. It simply
presents data' as standalone information – with no pretense for how the data is to be used.

This is the hallmark for a good system configuration model.


he above model can be extended. For example, the user could have more attributes like "preferences" and
"password". The components could depend on other components. Properties can be defined that are passed into
sub-elements. The extensions can be endless (WATCHOUT: complexity) and must be managed and well-thought-out
to prevent "breaking" the idea of the system configuration.

Usage[edit]
The usage for the model in practical terms falls into several categories: documentation, deployment & operations.

Documentation[edit]
One use of the configuration is to simply record what a system is. This documentation could in turn become quite
extensive, thus complicating the data model. It is important to distinguish between configuration data
and descriptive data. Of course comments can be applied at any level, even in most tools, however the bloating of
the data can reduce its usefulness. For example, the system configuration is not a place to record historical changes,
or descriptions of design and intent for the various elements. The configuration data is simply to be "what it is" or
"what we want it to be", not "how to get it there" or "what it was".

Deployment[edit]
Deployment involves interpreting a configuration data set and acting on that data to realize the configure the system
accordingly. This may simply be a validation of what's there to confirm that the configuration is in effect.

Examples include a Perl library launched from the command line to read the configuration and begin launching
processes on the local or remote hosts to install components. Also while the system is running, there may be
a SystemConfiguration service that provides an interface (i.e. CORBA IDL interfaces) for other system applications to
use to access the configuration data, and perform deployment-like actions.

Operations[edit]
When the system is in operation, there may be uses for the configuration data by specific kinds of services in the
system. For example, a Secnager may access the configuration to acquire the MD5 passwords for the user accounts
that are allowed to login to hosts remotely. A system monitor service (see: system monitoring) may use the data to
determine "what to monitor" and "how to monitor" the system elements. A PresentationManager might use the data to
access menu-items and views based on user access privileges.

Volume (computing)
In the context of computer operating systems, a volume or logical drive is a single accessible storage area with a
single file system, typically (though not necessarily) resident on a single partition of a hard disk. Although a volume
might be different from a physical disk drive, it can still be accessed with an operating system's logical interface.
However, a volume differs from a partition. In Linux systems, volumes are usually handled by the Logical Volume
Manager or the Enterprise Volume Management System and manipulated using mount(8). In NT-based versions
of Microsoft Windows, volumes are handled by the kernel and managed using the Disk Management MMC snap-in or
the Diskpart command line tool.

Differences between volume and partition[edit]


A volume is not the same thing as a partition. For example, a floppy disk might be accessible as a volume, even
though it does not contain a partition, as floppy disks cannot be partitioned with most modern computer software.
Also, an OS can recognize a partition without recognizing any volume associated with it, as when the OS cannot
interpret the filesystem stored there. This situation occurs, for example, when Windows NT-based OSes encounter
disks with non-Microsoft OS partitions, such as the ext3 filesystem commonly used with Linux. Another example
occurs in the Intel world with the "Extended Partition". While these are partitions, they cannot contain a filesystem
directly. Instead, "logical drives" (aka volumes) must be created within them. This is also the case with NetWare
volumes residing inside of a single partition. In short, volumes exist at the logical OS level, and partitions exist at the
physical, media specific level. Sometimes there is a one-to-one correspondence, but this is not guaranteed.

In Microsoft Windows Server 2008 and onward the term "volume" is used as a superset that includes "partition" as
well.[1][2][3]

It isn't uncommon to see a volume packed into a single file. Examples include ISO9660 disc images (CD/DVD
images, commonly called "ISOs"), and installer volumes for Mac OS X (DMGs). As these volumes are files which
reside within another volume, they certainly are not partitions.

Benefits of keeping files within one volume[edit]


Speed of data management[edit]
Files within a volume can generally be moved to any other place within that volume by manipulating the filesystem,
without moving the actual data. However, if a file is to be moved outside the volume, the data itself must be relocated,
which is a much more expensive operation.

In order to better visualize this concept, one might consider the example of a large library. If a non-fiction work is
originally classified as having the subject "plants", but then has to be moved to the subject "flora", one does not need
to refile the book, whose position on the shelf would be static, but rather, one needs only to replace the index card.
However, to move the book to another library, adjusting index cards alone is insufficient. The entire book must be
moved.

Special functions of advanced filesystems and volumes[edit]


Some filesystems, such as the Unix File System (ufs), Microsoft's NTFS filesystem, and ext3, allow multiple
pseudonyms (known as "hard links") to be created for a single file within the same volume. Hard links allow a file to
be referenced by two separate filenames, without its data being stored in two places on the disk (and thereby
consuming twice as much space). Hard links cannot be created for files between volumes; this is comparable to
moving the file in the library example above. To return to the library analogy, this is like filing two index cards for the
same book: one could file the above book under both 'flora' and 'plants'. In general, deleting one hard link does not
immediately effect other hard links, while deleting the final hard link for a file frees the disk space occupied by that
file. However, modifying the data of the file referred to by one hard link will impact all other hard links as well. In the
library, this is comparable to writing in the book. Hard links should not be confused with aliases (Mac
OS), shortcuts (Windows), or soft links (another type of link under Unix and variants), which can refer to files on
another volume or no file at all. FAT filesystems, such as FAT32, do not support hard or soft links as such, although
the Windows operating system supports 'links', which are somewhat less capable.

Volume label and serial number


A volume label is the name given to a specific volume in a filesystem. In the FAT filesystem, the volume label was
traditionally restricted to 11 characters (reflecting the 8.3restrictions, but not divided into name and extension fields)
even when long file name was enabled, stored as an entry within a disk's root directory with a special volume-
labelattribute bit set, and also copied to an 11-byte field within the Extended BIOS Parameter Block of the disk's boot
sector. The label is always stored as uppercase in FAT and VFATfilesystems, and cannot contain special
characters that are also disallowed for regular filenames. In the NTFS filesystem, the length of its volume label is
restricted to 32 characters, and can include lowercase characters and even Unicode. The label command is used
to change the label in DOS, Windows, and OS/2. For GUI systems likeWindows Explorer, F2 can be pressed while
the volume is highlighted, or a right-click on the name will bring up a context menu that allows it to be renamed, either
of which is the same process as for renaming a file. Changing the label in Windows will also change the volume
creation timestamp to the current date and time for FAT filesystems. NTFS partitions have the System Volume
Information folder, whose creation timestamp is set when Windows creates the partition, or when it first recognizes a
repartitioning (the creation of a new volume) by a separate disk utility.
What is a Volume Label?

A volume label, sometimes called a volume name, is a unique name assigned to a drive, disc, or other
media.
In Windows, a volume label is not required but it's often useful to give a name to a drive to help identify its
use in the future.

A drive's volume label can be changed at any time but is usually set during the formatting of the drive.

Volume Label Restrictions

Certain restrictions apply when assigning volume labels depending on which file system is on the drive
- NTFS or FAT:
Volume Label on NTFS Drives:
• Maximum of 32 characters
• No tabs

Copying, Moving and Renaming Files and Directories


By now, you've learned a little about the structure of the filesystem; and you've
learned how to create files and directories.
But just because you know how to create files and directories doesn't mean that you're
stuck with the changes you've made. What if you want to rename and/or move files
and directories?
Let's start with the copy command.
Copying Files
Like so many Linux features, you have a variety of options from which to choose
when you want to manipulate files and directories. You can also use wildcards when
you're copying, moving, or deleting files and directories.
Basically, the copy command is not much more complex than typing:
cp <source> <destination>

so to copy the file sneakers.txt to the directory tigger in your login directory, just


type:
cp sneakers.txt tigger

Notice that you also used relative pathnames to copy the file. You can use both
relative and absolute pathnames with cp. Our login directory is the parent of the
directory tigger; meaning that tigger is one directory down from ours.
Read the cp man page (man cp) for a full list of the options available with cp. But
among the options you can use with cp are:
• -i --interactive. Prompts you to confirm if the file is going to overwrite a file
in your destination. This is a handy option because it can help prevent you from
making mistakes.
• -r --
recursive. Rather than just copying all the files and directories, copies the
whole directory tree, subdirectories and all, to another location.
• -f --force. Copies without prompting you for confirmation that the file should
be overwritten. Unless you're sure you want to force the copy, you probably
don't want to make friends with this option right now.
• -v - verbose. Will show the progress of the files being copied.
Just by using cp alone, you won't see much when the command is executed. Using an
option, such as -i, can make the process a little more useful, because if you want to
copy a file to a location that already has a file with the same name, you'll be asked
first if you really want to overwrite -- meaning replace -- the file that's already there.
Don't be too "forceful"

Remember that among your options is -f (force), which can overwrite files without asking
  you if you're certain. Make sure, when you use the force option, that you really want to
overwrite a file.

Now that we have the file sneakers.txt in the tigger directory, let's use cp -i to copy
the file again to the same location.
[newuser@localhost newuser]$ cp -i sneakers.txt tigger
cp: overwrite 'tigger/sneakers.txt'?

To overwrite the file that's already there, press [Y] and then [Enter]. Don't want to
overwrite the file? Now is the time to press [N] and [Enter].
Moving Files
To move files, use the mv command (man mv), which is similar to the cp command,
except that with mv the file is physically moved from one place to another, instead of
being duplicated, as with cp.
Common options available with mv include:
• -i -- interactive. Will prompt you if the file you've selected will overwrite an
existing file in the destination directory. This is a good option, because like
the -i option in cp, you'll be given the chance to make sure you want to replace
an existing file.
• -f --force. Overrides the interactive mode and moves without prompting.
Unless you know what you're doing, this option doesn't play nice; be very
careful about using it until you become more comfortable with your system.
• -v -- verbose. Shows a list of the files being moved.
If you want to move a file out of your home directory and into another directory, you
would type:
mv sneakers.txt tigger

or, mv sneakers.txt /home/newuser /home/newuser/tigger using absolute pathnames.


Renaming Files
Actually, we've already covered half of renaming, because when you copy or move
files, you can also rename.
To copy the file sneakers.txt from our login directory to our tigger subdirectory, just
type:
cp sneakers.txt tigger

To copy and rename that file from sneakers.txt to piglet.txt, type:


cp sneakers.txt tigger/piglet.txt

To move and rename the file, just substitute mv for cp in the above example.


If you cd to tigger and use ls, you'll see the file piglet.txt.
If you just want to rename the file and keep its location, just mv in your current
directory:
mv sneakers.txt piglet.txt

Deleting Files and Directories


We talked about creating files with the touch command and by using redirection
in Chapter 13. And we created the directory tigger using mkdir.
But we haven't discussed how to delete files and directories.
Deleting files and directories with the rm command (man rm) is a straightforward
process.
Let's take our new file piglet.txt, and delete it from the tigger directory with
the rm command:
rm piglet.txt
o remove a file using a wildcard, you would type:
rm pig*

You can also remove more than one file in one command, as in:
rm piglet.txt sneakers.txt

Options for removing files -- and directories -- include:


• -i -- interactive. Prompts you to confirm the deletion. This is good.
• -f --force. Overrides interactive mode and removes the file(s) without
prompting. This might not be good, unless you know exactly what you're
doing.
• -v -- verbose. Shows a listing of files as they're being removed.
• -r --recursive. When removing directories, will remove all of the files and the
subdirectories of the specified directory. This can also get rid of an empty
directory.
To remove directories with rm, you must specify the -r option.
For example, if you want to recursively remove the directory tigger you would type:
rm -r tigger

And if you want to combine options, such as forcing a recursive deletion, you can
type:
rm -rf tigger

 Manipulating Files in Your Current Working Directory


Below is a summary of basic shell commands:

Action Command Format Details


Copy a file cp cp filename destination Copies the file filename to the
location destination.

List ls ls The ls command lists files in the


Directory current working directory.
Contents

Move a file mv mv which_file To move a file from one


destination directory to another, use mv.

Rename a mv mv oldname newname The use of the mv command


file changes the name of the file
from oldname to newname.

Table 4-2. Commands for Manipulating Files


Each of the commands listed above have options that may be specified on the command line. More
information about each is provided below.

4.5.1. Viewing Directory Contents with ls


To see what is in your current working directory, use the ls command.
Many options are available with the ls command. The ls command, by itself, does not
show all of the files in the directory. Some files are hidden files (also called dot files) and
can only be seen with an additional option specified to the ls command.

Tip

To view all ls command options, read the man page by entering man ls at a shell
 
prompt. To print the man page, enter man ls | col -b | lpr at the prompt.

Enter the command ls -a. Now you an view the hidden "dot" files.
Viewing all the files using the ls -a command can give you plenty of detail, but you can
view still more information by using multiple options.
To see the size of a file or directory, when it was created, and so on, add the long option
(-l) to the ls -a command. This command shows the file creation date, its size,
ownership, permissions, and more.
You do not have to be in the directory whose contents you want to view to use
the ls command. For example, to see what is in the /etc/ directory from your home
directory, type:
ls -al /etc

Figure 4-3. Sample ls Output for the /etc Directory


The following is a brief list of options commonly used with ls. Remember, you can view
the full list by reading the ls man page (man ls).
• -a (all)— Lists all files in the directory, including hidden files (.filename).
The .. and . at the top of your list refer to the parent directory and the current
directory, respectively.
• -l (long) — Lists details about contents, including permissions (modes), owner,
group, size, creation date, whether the file is a link to somewhere else on the
system and where its link points.
• -F (filetype) — Adds a symbol to the end of each listing. These symbols
include /, to indicate a directory; @, to indicate a symbolic link to another file;
and *, to indicate an executable file.
• -r (reverse) — Lists the contents of the directory in reverse sort order.
• -R (recursive) — Lists the contents of all directories below the current directory
recursively.
• -S (size) — Sorts files by their sizes.
The ls command can also be used with wildcards to display information on files or
directories that match a certain pattern. To list all files and directories that begin with the
letter "a", enter the following command.
ls -al a*
Remember that Linux is case-sensitive. The above command will not display
information on files that start with "A".

4.5.2. Copying files with cp


To create a copy of an existing file, use the cp command.
While cp does have options, they are not used as often as those of other commands. To
view these options, read the man page by entering man cp at a shellprompt.
To copy a file within the current directorym specify the new name as the third wod on
the command line.
cp original_file new_file
This command creates a new file, named new_file, with the same content as the
original file.
To copy a file to a different direcoty, specify a path as the third word on the command
line:
cp original_file /dir1/dir2/
This command creates a copy of original_file in dir2/. If the last part of the path is a
filename instead of a directory, the copy has that new name.
cp original_file /dir1/dir2/new_file
This creates a new file named new_file with the contents of original_file in dir2/.
Alternatively, if you know where the file is and would like to place a copy of it in your
current directory, enter the path as word two and "." as the third word.
cp /dir1/dir2/filename .
The above command places a copy of filename in your current working directory.
4.5.3. Moving files with mv
To move a file or directory from one location to another, use the command mv.
Common useful options for mv include:
• -i (interactive) — Prompts you if the file you have selected overwrites an existing
file in the destination directory.
• -f (force)
— Overrides the interactive mode and moves without prompting. Be
very careful about using this option.
• -v (verbose) — Shows the progress of the files as they are being moved.
To move a file from the current directory to another location, enter a path as the third
word on the command line.
mv filename /dir1/
This command would remove filename from the current working directory and place it
in /dir1/.
Alternatively, a path to the location of the file may be entered as the second word and
"." as the thrid word. This moves the file from the location specified in word two into your
current working directory.
mv /tmp/filename .
The above command moves the file filename from the /tmp/ directory into your current
working directory.
Finally, both words two and three may be paths.
mv ../../filename /tmp/new_name
The command above moves the file filename from a directory two levels up to
the /tmp/ directory while renaming the file new_name.

Note

You can only move files to a directory that already exists: Linux will not create a
 
new directory with the mv command.

4.5.4. Renaming files with mv


To rename a file or directory, use the mv command.
To rename a file with mv, the third word on the command line must end in the new
filename.
mv original_name new_name
The above command renames the file original_name to new_name.
mv ../original_name new_name
The above command moves the file original_name from one directory up to the current
directory and renames it new_name.
mv original_name /dir1/dir2/dir3/new_name
The above command moves the file original_name from the current working directory to
directory dir3/ and renames it new_name.

4.5.5. Delete files with rm


Caution

  Deleting a file with rmis permanent — you cannot un-delete it.

To delete a file using rm enter the following at a shell prompt:


rm filename
The second word can also be a path, but must end in a file.
rm ../../filename
There are many options to rm. To view them all, enter man rm at the shell prompt.
• -i (interactive)
— Prompts you to confirm the deletion. This option can stop you
from deleting a file by mistake.
• -f (force)
— Overrides interactive mode and removes the file(s) without
prompting. This might not be a good idea, unless you know exactly what you are
doing.
• -v (verbose) — Shows the progress of the files as they are being removed.
• -r (recursive) — Deletes a directory and all files and subdirectories it contains.

Tip

  The interactive, or -i, option for rm causes it to ask if you are sure before
permanently deleting a file or directory. You can make this the default behavior
for rm by editing the .bashrc file. This file is located in your home directory. You
can edit the file with any text editor.
gedit /home/user/.bashrc
Add the following line somewhere in the file. The end of the file is a good
location.
alias rm='rm -i'
Save the file. At the command line, enter the following command.
source .baschrc
Now you will be asked to enter [Y] before deleting a file or directory with rm

4.5.6. Deleting directories


There are two commands that can be used to delete directories. The first is rmdir and the
second is rm.
The rmdir command will only delete directories that are empty. If you are concerned
about accidentally deleting a directory that is not empty, use this command.
rmdir directory/
The above command permanently deletes directory/ if it is empty.
If you want to delete a directory and all of its contents, use the command rm -rf. Note that
if you enter rm -rf, the shell will not ask if you are sure before permanently deleting the
directory.
rm -rf /dir1/

You might also like