linux notes by v - i

55
Vipul Verma www.valferdo.com www.youthutility.com Linux Notes Unit 1

Upload: marin

Post on 30-Sep-2015

13 views

Category:

Documents


1 download

DESCRIPTION

Linux Notes by Vipul Vermawww.valferdo.comwww.youthutility.com

TRANSCRIPT

Vipul Verma

www.valferdo.com www.youthutility.com

Linux Notes

Unit 1

Overview of UNIX:

The UNIX operating system is a set of programs that act as a link between the computer and the user.

The computer programs that allocate the system resources and coordinate all the details of the computer's internals is called the operating system or kernel.

Users communicate with the kernel through a program known as the shell. The shell is a command line interpreter; it translates commands entered by the user and converts them into a language that is understood by the kernel.

UNIX was originally developed in 1969 by a group of AT&T employees at Bell Labs, including Ken Thompson, Dennis Ritchie, Douglas McIlroy, and Joe Ossanna.

There are various UNIX variants available in the market. Solaris UNIX, AIX, HP UNIX and BSD are few examples. Linux is also a flavor of UNIX which is freely available.

Several people can use a UNIX computer at the same time; hence UNIX is called a multiuser system.

A user can also run multiple programs at the same time; hence UNIX is called multitasking.

Why UNIX?

Hardware independence

operating system code is written in C language rather than a specific assembly language

operating system software can be easily moved from one hardware system to another

UNIX applications can be easily moved to other UNIX machines. Porting is usually as simple as transfer of the source and a recompile

Productive environment for software development

rich set of tools

versatile command language

Distributed processing and multi-tasking

UNIX Components

Kernel

The core of the UNIX system. Loaded at system start up (boot). Memory-resident control program.

Manages the entire resources of the system, presenting them to you and every other user as a coherent system. Provides service to user applications such as device management, process scheduling, etc.

Example functions performed by the kernel are:

Managing the machine's memory and allocating it to each process.

Scheduling the work done by the CPU so that the work of each user is carried out as efficiently as is possible.

accomplishing the transfer of data from one part of the machine to another

interpreting and executing instructions from the shell

enforcing file access permissions

You do not need to know anything about the kernel in order to use a UNIX system. These details are provided for your information only.

Shell

Whenever you login to a UNIX system you are placed in a shell program. The shell's prompt is usually visible at the cursor's position on your screen. To get your work done, you enter commands at this prompt.

The shell is a command interpreter; it takes each command and passes it to the operating system kernel to be acted upon. It then displays the results of this operation on your screen.

Several shells are usually available on any UNIX system, each with its own strengths and weaknesses.

Different users may use different shells. Initially, your system administrator will supply a default shell, which can be overridden or changed. The most commonly available shells are:

Bourne shell (sh)

C shell (csh)

Korn shell (ksh)

TC Shell (tcsh)

Bourne Again Shell (bash)

Each shell also includes its own programming language. Command files, called "shell scripts" are used to accomplish a series of tasks.

Utilities

UNIX provides several hundred utility programs, often referred to as commands.

Accomplish universal functions

editing

file maintenance

printing

sorting

programming support

online info

etc.

Modular: single functions can be grouped to perform more complex tasks

UNIX Architecture:

Here is a basic block diagram of a UNIX system:

The main concept that unites all versions of UNIX is the following four basics:

Kernel:

The kernel is the heart of the operating system. It interacts with hardware and most of the tasks like memory management, tash scheduling and file management.

Shell:

The shell is the utility that processes your requests. When you type in a command at your terminal, the shell interprets the command and calls the program that you want. The shell uses standard syntax for all commands. C Shell, Bourne Shell and Korn Shell are most famous shells which are available with most of the Unix variants.

Commands and Utilities:

There are various command and utilities which you would use in your day to day activities.cp, mv, catandgrepetc. are few examples of commands and utilities. There are over 250 standard commands plus numerous others provided through 3rd party software. All the commands come along with various optional options.

Files and Directories:

All data in UNIX is organized into files. All files are organized into directories. These directories are organized into a tree-like structure called the filesystem.

Linux:

Linux is one of popular version of UNIX operating System. It is open source as its source code is freely available. It is free to use. Linux was designed considering UNIX compatibility. It's functionality list is quite similar to that of UNIX.

Linux Architecture

User Utility Program

User Management

Compilers

Process Management

System Shared Libraries

Linux Kernel

Loadable Linux Kernel Modules

Loadable Kernel Modules

All the task of the kernel are broken into small functions or kernel modules. These modules can be loaded when and where required and once their task is completed they can again be removed from the memory.

Linux Kernel

Kernel is used to manage all the functions of the OS such as memory management, process management etc. Linux kernel is the backbone of the operating system and helps the working of the operating system.

System Shared Libraries

These are set of functions that are available to the user programs to interact with the kernel. It acts as an interface between the kernel and the user program.

User program and management

Here all the programs that the user interacts with to perform different operations in the Linux.

Components of Linux

Kernel

System Libraries

System Utilities

Kernel

It manages all the basic operations of an operating system such as memory management, process management etc. There are kernel modules which help perform these tasks.

System Libraries

They are set of the functions and task that help the user program to interact with the Linux kernel. The functions are used to load unload kernel modules.

System utilities

They are independent program that perform different tasks. They generally run for some time and then are unloaded from the memory while others stay in the memory for a long time and are call daemons.

Discuss the salient features of UNIX and Linux?

UNIX is a multiprocessing, multi-user family of OS that runs on a variety of architectures. It is a popular OS developed by ATNT in 1969.

A widely used open source UNIX like OS. Linux was released by its inventor named Linus Torbaed in 1991.

Linux is an OS which use UNIX as its base & gives further more facilities & applications. Eg - (GUI) Red Hat, MANDRAA, FEDORA, etc.

Similarities between Linux and UNIX

Linux and UNIX have many similarities, but Linux has many features that most Unix do not have, and some current UNIX implementations (like Solaris) have some features that have yet to be implemented in Linux (like dtrace).

Some ways that UNIX and Linux are functionally similar:

Both are capable of true multitasking.

Both run on a variety of hardware platforms.

Both are well-known for security and reliability.

Both are highly modular (one piece can easily be removed and replaced without breaking the whole system)

Both are capable of using both a command line and a GUI.

Both support multiple users, and support different privileges between users

MS-DOS

Linux / Unix

attrib

chmod

backup

tar

dir

ls

cls

clear

copy

cp

del

rm

deltree

rm -Rrmdir

edit

vipico

format

fdformatmountumount

move / rename

mv

type

less

cd

cdchdir

more < file

more file

md

mkdir

win

startx

1.

Linux is open-source, whereas UNIX is not. Linux commands are very much similar to those of UNIX, but most Linux implementations go beyond the standard options that UNIX provides. Being an open-source operating system, it is much easier to write applications on Linux than on UNIX.

2.

Linux is a derivative of UNIX or we can say that LINUX is one of the flavours of UNIX available in market. Other flavors include OS such as "SOLARIS".Therefore most of the commands used in UNIX like "grep" , "Include", "ls" ,"pwd" etc will also work on Linux

Features of Linux

PORTABILITY Linux is portable means it can transfer from one place to another. This feature is not available in UNIX.

MULTITASKING Linux has the multitasking feature means it performs multiple tasks simultaneously and it contains only one CPU.

DEMAND LOAD EXECUTABLES In this required part needs to be run. This method is also known as copy-on-write.

DYNAMIC CACHE FOR HARD DISK If physical memory is not available then this cache memory is provided. Such programs are known as SMART DRIVE.

SHARED LIBRARY Also known as Dynamic Linked Library.

TCP/IP, SLIP and PPP This is only supported in Linux & networking.

Features of UNIX

MULTIUSER SYSTEM In UNIX, the resources are actually shared between all users. Multi-user technology is the great socializer that has time for everyone.

MULTITASKING SYSTEM A single user can also run multiple tasks concurrently.

BUILDING-BLOCK APPROACH The designers never attempted to pack too many features into a few tools. Instead, they felt small is beautiful, & developed a few hundred commands each of which performed one simple job only.

UNIX TOOLKIT There are general-purpose tools, text manipulation utilities (called filters), compilers & interpreters, networked applications & system administration tool & shells also.

PATTERN MATCHING The *(known as metacharacter) isnt the only special character used by the UNIX system; there are several others. UNIX features elaborate pattern matching schemes that use several characters from this metacharacter set.

PROGRAMMING FACILITY The UNIX shell is also a programming language; it was designed for a programmer, not a casual end user. These features are used to design shell scripts- programs that can also invoke the UNIX commands.

GNU/FSF

This page lists theGNU/Linuxdistributions that are entirelyfreeas in freedom. All of the distributions that follow are installable to a computer's hard drive; most can be run live.

The Free Software Foundation recommends and endorses these GNU/Linux distros, although we do not try to judge or compare them based on any criterion other than freedom; therefore, we list them in alphabetical order. We encourage you to read these brief descriptions and to consult their respective web sites and other information to choose the one best for you.

Or

The GNU General Public License (GNU GPL or GPL) is the most widely used free software license, which guarantees end users (individuals, organizations, companies) the freedoms to use, study, share (copy), and modify the software. Software that allows these rights is called free software and, if the software is copylefted, requires those rights to be retained. The GPL demands both. The license was originally written by Richard Stallman of the Free Software Foundation (FSF) for the GNU project.

SECOND EXTENDED FILE SYSTEM (EXT2)

Figure: Physical Layout of the EXT2 File system

The Second Extended File system was devised (by Rmy Card) as an extensible and powerful file system for Linux. It is also the most successful file system so far in the Linux community and is the basis for all of the currently shipping Linux distributions.

The EXT2 file system, like a lot of the file systems, is built on the premise that the data held in files is kept in data blocks. These data blocks are all of the same length and, although that length can vary between different EXT2 file systems the block size of a particular EXT2 file system is set when it is created (using mke2fs).

Every file's size is rounded up to an integral number of blocks. If the block size is 1024 bytes, then a file of 1025 bytes will occupy two 1024 byte blocks. Unfortunately this means that on average you waste half a block per file. Usually in computing you trade off CPU usage for memory and disk space utilization.

In this case Linux, along with most operating systems, trades off a relatively inefficient disk usage in order to reduce the workload on the CPU. Not all of the blocks in the file system hold data, some must be used to contain the information that describes the structure of the file system. EXT2 defines the file system topology by describing each file in the system with an inode data structure. An inode describes which blocks the data within a file occupies as well as the access rights of the file, the file's modification time and the type of the file. Every file in the EXT2 file system is described by a single inode and each inode has a single unique number identifying it. The inodes for the file system are all kept together in inode tables. EXT2 directories are simply special files (themselves described by inodes) which contain pointers to the inodes of their directory entries.

The figure above shows the layout of the EXT2 file system as occupying a series of blocks in a block structured device. So far as each file system is concerned, block devices are just a series of blocks that can be read and written. A file system does not need to concern itself with where on the physical media a block should be put, that is the job of the device's driver. Whenever a file system needs to read information or data from the block device containing it, it requests that its supporting device driver reads an integral number of blocks. The EXT2 file system divides the logical partition that it occupies into Block Groups.

Each group duplicates information critical to the integrity of the file system as well as holding real files and directories as blocks of information and data. This duplication is neccessary should a disaster occur and the file system need recovering. The subsections describe in more detail the contents of each Block Group.

One benefit of the ext2fs over the extfs is the size of the file systems that can be managed. Currently (after some enhancements in the VFS layer), the ext2fs can access file systems as large as 4TB. In contrast to other UNIXs, the ext2fs uses a variable length directory and can have files names that are as long as 255 characters.

When creating the file system, the ext2fs enables you to choose what size block you want. Using larger blocks will speed up the data transfer because the head disk does not need to look (seek) as much. However, if you have a lot of small files, a larger block size means you waste more space.

Also to speed up access, the ext2fs uses a technique called a "fast symbolic link." On many UNIX systems, the files to which symbolic links point are stored as files themselves. This means that each time a file is read as a symbolic link, the disk is accessed to get the inode of the link, the path is read out of the file, and its inode needs to be read, and then the actual file can be accessed.

With a fast symbolic link, the path to the file is stored in the inode. This not only speeds up access but also saves the space that the file is no longer taking on the hard disk. The only drawback is that when the path to the real file has more than 60 characters, it cannot fit in the inode and must sit in a file. Therefore, if you are using symbolic links and want to increase performance, make sure the path has fewer than 60 characters.

Another advantages of the ext2fs is its reliability. The ext2fs is made of what are called "block groups." Each block group has a block group descriptor, which provides an information copy of the superblock, as well as a block bitmap, inode bitmap, a piece of the inode table, and data blocks.

There is also an entry that contains the number of directories within the group block. When creating a new directory, the system will try to put the directory into the block group with the fewest directories. This makes accessing any one directory quicker.

Because the block group contains copies of the primary control structures, it can be repaired by these copies should the superblock at the start of the disk get corrupted? In addition, because the inode table, as such, is spread out across the disk, you have to search less. Plus, the distance between the inode table and the data block is reduced, thereby increasing performance ever further.

There's still more! The ext2fs will preallocate up to eight adjacent blocks when it allocates a block for a file. This gives the file a little room to grow. By preallocating the blocks, you have a file that is located in the same area of the disk. This speeds up all sequential accesses.

The directories entries in the ext2fs are in a singly linked list, as compared to an array with fixed entry lengths on some systems. Within the directory entry, you will find the name of the file as well as the inode number. Note that this is the only place where the name of the file appears. In addition, there's a field that has the total length of the record in bytes (which is always a multiple of 4) that is then used to calculate the start of the next block. Therefore, there are no pointers as in other linked lists.

When a file is deleted, the inode is set to 0 and the previous entry "takes over" the slot. This saves time because no shifts are required. There may be a slight loss in space, but if a new entry that will fill up the old slot is created, it will fill up the old slot. Because of this scheme, you can implement long file names without wasting space. In some systems, specific-length fields are set aside. If the file name doesn't fill up the slot, the space is just wasted.

THIRD EXTENDED FILE SYSTEM (EXT3)

The ext3 or third extended file system is a journal file system that is commonly used by the Linux operating system. It is the default file system for many popular Linux distributions. Stephen Tweedie first revealed that he was working on extending ext2 in a February 1999 kernel mailing list posting and the file system was merged with the mainline Linux kernel in November 2001. Its main advantage over ext2 is journaling which improves reliability and eliminates the need to check the file system after an unclean shutdown.

What are the advantages of ext3?

Four main reasons: availability, data integrity, speed, and easy transition.

Availability

After an unclean system shutdown (unexpected power failure, system crash), each ext2 file system cannot be mounted until its consistency has been checked by the e2fsck program. The amount of time that the e2fsck program takes is determined primarily by the size of the file system, and for today's relatively large (many tens of gigabytes) file systems, this takes a long time. Also, the more files you have on the file system, the longer the consistency check takes. File systems that are several hundreds of gigabytes in size may take an hour or more to check. This severely limits availability.

By contrast, ext3 does not require a file system check, even after an unclean system shutdown, except for certain rare hardware failure cases (e.g. hard drive failures). This is because the data is written to disk in such a way that the file system is always consistent. The time to recover an ext3 file system after an unclean system shutdown does not depend on the size of the file system or the number of files; rather, it depends on the size of the "journal" used to maintain consistency. The default journal size takes about a second to recover (depending on the speed of the hardware).

Data Integrity

Using the ext3 file system can provide stronger guarantees about data integrity in case of an unclean system shutdown. You choose the type and level of protection that your data receives. You can choose to keep the file system consistent, but allow for damage to data on the file system in the case of unclean system shutdown; this can give a modest speed up under some but not all circumstances. Alternatively, you can choose to ensure that the data is consistent with the state of the file system; this means that you will never see garbage data in recently-written files after a crash. The safe choice, keeping the data consistent with the state of the file system, is the default.

Speed

Despite writing some data more than once, ext3 is often faster (higher throughput) than ext2 because ext3's journaling optimizes hard drive head motion. You can choose from three journaling modes to optimize speed, optionally choosing to trade off some data integrity.

One mode, data=writeback, limits the data integrity guarantees, allowing old data to show up in files after a crash, for a potential increase in speed under some circumstances. (This mode, which is the default journaling mode for most journaling file systems, essentially provides the more limited data integrity guarantees of the ext2 file system and merely avoids the long file system check at boot time.)

The second mode, data=ordered (the default mode), guarantees that the data is consistent with the file system; recently-written files will never show up with garbage contents after a crash.

The last mode, data=journal, requires a larger journal for reasonable speed in most cases and therefore takes longer to recover in case of unclean shutdown, but is sometimes faster for certain database operations.

The default mode is recommended for general-purpose computing needs. To change the mode, add the data=something option to the mount options for that file system in the /etc/fstab file, as documented in the mount man page (man mount).

Easy Transition

It is easy to change from ext2 to ext3 and gain the benefits of a robust journaling file system, without reformatting. That's right, there is no need to do a long, tedious, and error-prone backup-reformat-restore operation in order to experience the advantages of ext3. There are two ways to perform the transition:

The Red Hat Linux installation program offers to transition your file systems when you upgrade your system. All you have to do is select one checkbox per file system.

The tune2fs program can add a journal to an existing ext2 file system. If the file system is already mounted while it is being transitioned, the journal will be visible as the file .journal in the root directory of the file system. If the file system is not mounted, the journal will be hidden and will not appear in the file system. Just run tune2fs -j /dev/hda1 (or whatever device holds the file system you are transitioning) and change ext2 to ext3 on the matching lines in /etc/fstab. If you are transitioning your root file system, you will have to use an initrd to boot. Run the mkinitrd program as described in the manual and make sure that your LILO or GRUB configuration loads the initrd. (If you fail to make that change, the system will still boot, but the root file system will be mounted as ext2 instead of ext3 you can tell this by looking at the output of the command cat /proc/mounts.) More information on tune2fs can be found in the tune2fs man page (man tune2fs).

Fourth Extended File System (EXT4)

The ext4 or fourth extended filesystem is a journaling file system for Linux, developed as the successor to ext3.

It was born as a series of backward compatible extensions to ext3 meant to extend storage limits and add other performance improvements. However, other Linux kernel developers opposed accepting extensions to ext3 for stability reasons, and proposed to fork the source code of ext3, rename it as ext4, and do all the development there, without affecting the current ext3 users. This proposal was accepted, and on 28 June 2006, Theodore Ts'o, the ext3 maintainer, announced the new plan of development for ext4. A preliminary development version of ext4 was included in version 2.6.19 of the Linux kernel. On 11 October 2008, the patches that mark ext4 as stable code were merged in the Linux 2.6.28 source code repositories, denoting the end of the development phase and recommending ext4 adoption. Kernel 2.6.28, containing the ext4 filesystem, was finally released on 25 December 2008.On 15 January 2010, Google announced that it would upgrade its storage infrastructure from ext2 to ext4.

Features/ Advantage

Large file system

The ext4 filesystem can support volumes with sizes up to 1 exabyte and files with sizes up to 16 terabytes. The current e2fsprogs can only handle a filesystem of 16 TB, but support for larger drives is under development.

[An exabyte is a unit of information or computer storage equal to one quintillion bytes (short scale). The unit symbol for the exabyte is EB. When used with byte multiples, the unit indicates a power of 1000. 1 EB = 1,000,000,000,000,000,000 B = 1018 bytes = 1 billion gigabytes = 1 million terabytes]

Extents

Extents are introduced to replace the traditional block mapping scheme used by ext2/3 file systems. An extent is a range of contiguous physical blocks, improving large file performance and reducing fragmentation. A single extent in ext4 can map up to 128 MB of contiguous space with a 4 KB block size. There can be 4 extents stored in the inode. When there are more than 4 extents to a file, the rest of the extents are indexed in an Htree.

Backward compatibility

The ext4 filesystem is backward compatible with ext3 and ext2, making it possible to mount ext3 and ext2 filesystems as ext4. This will slightly improve performance, because certain new features of ext4 can also be used with ext3 and ext2, such as the new block allocation algorithm.

The ext3 file system is partially forward compatible with ext4, that is, an ext4 filesystem can be mounted as an ext3 partition (using "ext3" as the filesystem type when mounting). However, if the ext4 partition uses extents (a major new feature of ext4), then the ability to mount the file system as ext3 is lost.

Persistent pre-allocation

The ext4 filesystem allows for pre-allocation of on-disk space for a file. The current method for this on most file systems is to write the file full of 0s to reserve the space when the file is created. This method is no longer required for ext4; instead, a new fallocate() system call was added to the Linux kernel for use by filesystems, including ext4 and XFS, that have this capability. The space allocated for files such as these would be guaranteed and would likely be contiguous. This has applications for media streaming and databases.

Delayed allocation

Ext4 uses a filesystem performance technique called allocate-on-flush, also known as delayed allocation. It consists of delaying block allocation until the data is going to be written to the disk, unlike some other file systems, which may allocate the necessary blocks before that step. This improves performance and reduces fragmentation by improving block allocation decisions based on the actual file size.

Break 32,000 subdirectory limit

In ext3 the number of subdirectories that a directory can contain is limited to 32,000. This limit has been raised to 64,000 in ext4, and with the "dir_nlink" feature it can go beyond this (although it will stop increasing the link count on the parent). To allow for continued performance given the possibility of much larger directories, Htree indexes (a specialized version of a B-tree) are turned on by default in ext4. This feature is implemented in Linux kernel 2.6.23. Htree is also available in ext3 when the dir_index feature is enabled.

Journal checksumming

Ext4 uses checksums in the journal to improve reliability, since the journal is one of the most used files of the disk. This feature has a side benefit; it can safely avoid a disk I/O wait during the journaling process, improving performance slightly. The technique of journal checksumming was inspired by a research paper from the University of Wisconsin titled IRON File Systems (specifically, section 6, called "transaction checksums").

fsck time/Inode Count(ext3 vs. ext4)

Faster file system checking

In ext4, unallocated block groups and sections of the inode table are marked as such. This enables e2fsck to skip them entirely on a check and greatly reduces the time it takes to check a file system of the size ext4 is built to support. This feature is implemented in version 2.6.24 of the Linux kernel.

Multiblock allocator

When a file is being appended to, ext3 calls the block allocator once for each block individually; with multiple concurrent writers, files can easily become fragmented on disk. With delayed allocation, however, ext4 buffers up a larger amount of data, and then allocates a group of blocks in a batch. This means that the allocator has more information about what's being written and can make better choices for allocating files contiguously on disk. The multiblock allocator is used when delayed allocation is enabled for a file system, or when files are opened in O_DIRECT mode. This feature does not affect the disk format.

Improved timestamps

As computers become faster in general and as Linux becomes used more for mission critical applications, the granularity of second-based timestamps becomes insufficient. To solve this, ext4 provides timestamps measured in nanoseconds. In addition, 2 bits of the expanded timestamp field are added to the most significant bits of the seconds field of the timestamps to defer the year 2038 problem for an additional 204 years.

Ext4 also adds support for date-created timestamps. But, as Theodore Ts'o points out, while it is easy to add an extra creation-date field in the inode (thus technically enabling support for date-created timestamps in ext4), it is more difficult to modify or add the necessary system calls, like stat() (which would probably require a new version), and the various libraries that depend on them (like glibc). These changes would require coordination of many projects. So, even if ext4 developers implement initial support for creation-date timestamps, this feature will not be available to user programs for now.

1 EB = 1,000,000,000,000,000,000 B = 1018 bytes = 1 billion gigabytes = 1 million terabytes

DisadvantagesDelayed allocation and potential data loss

Because delayed allocation changes the behavior that programmers have been relying on with ext3, the feature poses some additional risk of data loss in cases where the system crashes or loses power before all of the data has been written to disk. Other Linux file systems like XFS have never offered ext3-like behavior. Due to this, ext4 in kernel versions 2.6.30 and later automatically detects these cases and reverts to the old behavior.

The typical scenario in which this might occur is a program replacing the contents of a file without forcing a write to the disk with fsync. There are two common ways of replacing the contents of a file on Unix systems:

open("file", O_TRUNC); write(fd, data); close(fd);

In this case, an existing file is truncated at the time of open (due to O_TRUNC flag), then new data is written out. Since the write can take some time, there is an opportunity of losing contents even with ext3, but usually very small. However, because ext4 can delay allocating file data for a long time, this opportunity is much greater.

open("file.new"); write(fd, data); close(fd); rename("file.new", "file");

A new temporary file ("file.new") is created, which initially contains the new contents. Then the new file is renamed over the old one. Replacing files by the "rename" call is guaranteed to be atomic by POSIX standards i.e. either the old file remains, or it's overwritten with the new one. Because the ext3 default "ordered" journalling mode guarantees file data is written out on disk before metadata, this technique guarantees that either the old or the new file contents will persist on disk. ext4's delayed allocation breaks this expectation, because the file write can be delayed for a long time, and the rename is usually carried out before new file contents reach the disk.

Using fsync more often to reduce the risk for ext4 could lead to performance penalties on ext3 filesystems mounted with the data=ordered flag (the default on most Linux distributions). Given that both file systems will be in use for some time, this complicates matters for end-user application developers. In response, ext4 in Linux kernels 2.6.30 and newer detect the occurrence of these common cases and force the files to be allocated immediately. For a small cost in performance, this provides semantics similar to ext3 ordered mode and increases the chance that either version of the file will survive the crash. This new behavior is enabled by default, but can be disabled with the "noauto_da_alloc" mount option.

The new patches have become part of the mainline kernel 2.6.30, but various distributions chose to backport them to 2.6.28 or 2.6.29. For instance Ubuntu made them part of the 2.6.28 kernel in version 9.04.

These patches don't completely prevent potential data loss or help at all with new files. No other filesystem is perfect in terms of data loss either, although the probability of data loss is lower on ext3. The only way to be safe is to write and use software that does fsync when it needs to. Performance problems can be minimized by limiting crucial disk writes that need fsync to occur less frequently.

Assignment 1

Linux Lab

Q1. Run the command date and show the command that gives you the output as month only.

Q2. Whoami Command.

Q3. uname Command.

Q4. uptime Command.

Q5. cal Command.

Q6. bc Command. Basic Calculator

Q7. ls Command.

ls

ls -a

ls l

ls -al

Q8. ps Command.

Q9. Create a new file using the cat command.

Q10. Use ls again to verify that the new file exists.

Q11. Display the contents of this file.

Q12. Create a directory.

Q13. Create two files in it.

Q14. List the directory contents of your directory. The output should be multi column and output should contain the hidden files.

Q15. Compare both the files.

Q16. Delete the directory.

Q17. Create a file and count the no. of lines, words and character in that particular file.

Q18. How can you obtain a short description of what the ls and wc command does?

Q19. What command line option would you use to display a long listing of files with human-readable size descriptions?

Q20. Echo Command.

Q21. How you will find out in which directory you are currently working.

pwd command