0% found this document useful (0 votes)
22 views35 pages

ITEC 221 6 - File Management

ueje

Uploaded by

casquiolloyd03
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views35 pages

ITEC 221 6 - File Management

ueje

Uploaded by

casquiolloyd03
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 35

ITEC 221: PLATFORM TECHNOLOGIES

File Management

Vencel Angelo R. Sanglay Camarines Sur Polytechnic Colleges


Instructor I COLLEGE OF COMPUTER STUDIES
File
What is a File?
A ile is a named collection of related information
that is recorded on secondary storage such as
magnetic disks, magnetic tapes, and optical disks.
In general, a ile is a sequence of bits, bytes, lines, or
records whose meaning is de ined by the ile
creator and user.
A computer has three types of iles:
• application iles
• data iles
• system iles
f
f
f
f
f
f
f
f
Types of computer files
Program Files
An application ile or program ile describes a ile
that stores the code to run a program. This type
of ile is commonly called an executable ile.
With more than one ile, program iles are the iles
that allow a program to run on your computer.
Most programs have different types of iles, for
instance, DLL (dynamic-link library) iles or data
iles used with the executable ile.
f
f
f
f
f
f
f
f
f
f
f
f
Types of computer files
Data Files
A data ile is any ile containing information, but not code;
it is only meant to be read or viewed and not executed.
For example, this Keynote presentation, a document you
write in a word processor, and a text ile are all considered
data iles.
Programs may also rely on data iles to get information.
For instance, a data ile may contain the settings of a
program that tell the program how to display information.
f
f
f
f
f
f
Types of computer files
System Files
These are iles critical to the proper function of an
operating system which, if deleted or modi ied, may
cause it to no longer work.
Often these iles are hidden and cannot be deleted
because they are in use by the operating system.
A system ile is also an attribute that can be added to
any ile in Windows or DOS using the .sys ile extension.
Although this process allows the operating system to
know the ile is important, it does not make the ile a
system ile.
f
f
f
f
f
f
f
f
f
File Attributes
File Attributes
Each ile has characteristics like ile name, ile type, date (on which ile was created), etc. These
characteristics are referred to as File Attributes. The operating system associates these attributes with
iles.
• Name. This is the only information stored in a human-readable format. A name is given to each ile.
One directory cannot contain two iles with the same name.
• Extension. This attribute is required for systems that support different ile types. For example, a text
ile has a .txt extension and a video ile has a .mp4 extension.
• Location refers to the location of the ile on the device. The ile system has several places where
you can save your iles. Each ile contains its location as an attribute.
• Size means the number of bytes captured by the ile in memory.
• Identi ier. Each ile is identi ied by a unique tag number within the ile system called an identi ier.
• Protection. This attribute assigns and controls access to read, write, and execute iles. Computer
administrators may need different protection for each ile. Therefore, each ile has its own
permissions on different user groups.
• Compression. It tells the type of compression there is.
• Time, date, and user identi ication. This information tells us about the date and time on which the
ile was created, last modi ied, created, and modi ied by which user, etc.
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
File Operations
File operations
• Creating: Creating a ile involves two steps. First, check if there is free space. You must create a
new directory ile entry if you have enough space.
• Opening: This is a common operation performed on a ile. After you create a ile, you need to
open it before you can perform any ile processing operations. If the user wants to open the
ile, call a system call to instruct the operating system to open the ile and pass the ile name to
the ile
• Writing: To write a ile, you need to know two things. One is the name of the ile and the other
is the information or data written to the ile
• Deleting: To delete a ile, irst, browse the directory of the named ile, then free up the ile area
and delete the directory entry.
• Truncating: To truncate a ile, delete only the contents of the ile, but don’t delete its ile
structure.
• Close File: After editing the ile, you need to close the ile to free up any permanent changes
made and occupied resources. Finally, the internal descriptor created when the ile
was opened is released.
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
File Systems
What is a file system?
A ile system is a set of rules that decides how to store
and organize data on storage devices like hard drives,
lash drives, CD ROMs, etc.
Without a ile system, data placed in a storage
medium would be one large body of data with no way
to tell where a piece of data stops and the next
begins.
In a word, ile systems keep everything tidy and
minimize loss of storage space by logically organizing
data. There are multiple ile system types and each of
them with unique structure and logic, properties of
speed, lexibility, security, size, etc.
f
f
f
f
f
-
f
Types of File Systems
in Windows
Types of file system: Windows
File allocation table (FAT)
• FAT is a simple and reliable ile system that at one time was used extensively by earlier versions
of Windows operating systems.
• Designed in 1977 for loppy disks, the ile system was later adapted for hard disks. The FAT ile
system got its start with the introduction of MS DOS, or Microsoft Disk Operating System, and
is still in use today, but it has evolved over the years to accommodate growing data volumes.
• Originally, FAT was an 8-bit system, but it was later updated to FAT12 (12-bit), then FAT16 (16-
bit), and inally FAT32 (32-bit), which is the primary version still in use. All versions of Windows
starting from Windows 95 are supported by FAT32.
• While ef icient and compatible with most current OSes, FAT cannot match the performance
and scalability of more modern ile systems since it has a single ile size limit of 4GB.
• FAT32 works with all versions of Windows, Mac, Linux, game consoles, and nearly anything
with a USB port. It is widely used on removable storage devices like USB lash drives, microSD
cards, and small external hard drives.
f
f
f
f
f
f
-
f
f
f
Types of file system: Windows

Extended File Allocation Table (exFAT)


• The exFAT ile system is a successor to FAT32.
• It retains much of the simplicity of FAT as well as its ease of implementation.
• However, exFAT is a 64-bit ile system, so it can support larger capacity storage devices
as well as applications that rely on large iles.
• The ile system also incorporates extensibility into its design, making it easier to adapt
to changes in storage and usage.
• It works with all versions of Windows and modern versions of Mac OS X. It is
compatible with Linux, but it requires additional software.
f
f
f
f
Types of file system: Windows
New Technology File System (NTFS)
• Also known as NT ile system, NTFS has been the default Windows ile system since
Windows NT 3.1.
• Compared with FAT32 and exFAT, NTFS has some advantages. For instance, it supports
pretty large iles, enables you to set ile permissions, and allows you to compress iles,
folders, or drives.
• NTFS is also supported in the Linux OS through a free, open-source NTFS driver. In
addition, macOS includes read-only support for NTFS.
• This Windows ile system can work with Windows NT/XP/Vista/7/8/10/11. Actually,
modern Windows versions use NTFS by default. NTFS drives are read-only on Mac and
Linux devices, which means that they can’t be modi ied or written any data.
f
f
f
f
f
f
f
Types of File Systems
in MacOS
Types of file system: MacOS
Hierarchal File System (HFS)
• Also referred to as Mac OS Standard, HFS was developed for
use with Mac operating systems.
• HFS was originally introduced in 1985 for loppy and hard disks,
replacing the irst Macintosh ile system. It can also be used
on CD ROMs.
• HFS was a hierarchal ile system that organized iles in a tree-
like structure, creating a root directory on each disk and
organizing iles into subfolders of that root directory.
• It was used by all Macintosh computers until 1998 and was
eventually succeeded by Mac OS Extended, which has since
given way to the Apple File System (APFS).
-
f
f
f
f
f
f
Types of file system: MacOS
MacOS Extended (HFS+)
• MacOS Extended, also known as HFS+ or HFS Plus, is a ile system used
on all Macs from 1998 until 2017 when the fourteenth major release of the
macOS replaced it with APFS.
• On macOS High Sierra, it’s used on all mechanical and hybrid drives. It’s
used by default for all drives on older versions of macOS.
• You can access HFS+ drives on Windows only with the help of third-party
apps.

f
Types of file system: MacOS
Apple File System (APFS)
• APFS refers to the Apple File System initially released with macOS High Sierra. It has been the
default ile system on Mac computers since macOS 10.13.
• It is also used on iOS, iPadOS, tvOS, and watchOS devices.
• It’s optimized for solid-state drives and other lash storage devices. Even so, it works on
mechanical and hybrid drives too.
• It supports encryption, snapshots, increased data integrity, etc.
• APFS is much faster at basically everything—data handling, copying, and pasting are quicker.
It is also more reliable, leading to less ile corruption when compared to Mac OS Extended.
• The biggest downside to using APFS is that Macs with older macOS versions (macOS 10.12.6
Sierra and older) can't read, write, or access drives that use it.
f
f
f
Types of File Systems
in Linux
Types of file system: Linux
Extended File System (ext)
• Implemented in 1992, this ile system was designed speci ically for Linux and is still
widely used on Linux systems.
• Ext2 is the irst Linux ile system that allows managing two terabytes of data. Ext3 is
developed through Ext2; it is an upgraded version of Ext2 and contains backward
compatibility. The major drawback of Ext3 is that it does not support servers because
this ile system does not support ile recovery and disk snapshots.
• The current version, ext4, builds on ext3, which added journaling capabilities to reduce
data corruption. The ext4 version provides better performance and reliability while
supporting greater scalability.
• It is the default ile system for multiple Linux distributions, including Ubuntu and Debian,
and it is the primary ile system used on Android devices.
f
f
f
f
f
f
f
f
File
Permissions
File Permissions
File permissions provide a way of controlling whether other people can
read (or even modify) your iles.

File Permission File Directory

Read Can read the ile Can list iles in the directory

Can create and delete iles in


Write Can edit the ile
the directory

Can run the ile as a


Execute Can change to the directory
program
f
f
f
f
f
f
Basic Terminal Commands
in macOS
Basic macOS Terminal Commands
• The cd command (or change directory command) is used to navigate to the directory or folder the user
wishes to access.
• The ls command (or list command) lists the contents of the working directory.
- ls -a will list all iles including hidden iles ( iles with names beginning with a dot).

- ls -F gives a full listing, indicating what type iles are by putting a slash after directories and a star
after executable iles (programs you can run).
- ls -l gives a long listing of all iles.

- ls -R gives a recursive listing, including the contents of all subdirectories and their subdirectories,
and so on.
- ls -t lists the iles in order of the time when they were last modi ied (newest irst) rather than in
alphabetical order.
- ls -r lists the iles in the reverse of the order that they would otherwise have been listed in. Thus, ls
-lrt will give a long listing, oldest irst, which is handy for seeing which iles in a large directory have
recently been changed.
• The pwd (or print working directory) command is a quick shortcut command an operator can enter to
reveal the current working directory
f
f
f
f
f
f
f
f
f
f
f
f
The cat and less Command
The cat command is very common and allows you to create single or multiple iles, view the content of a
ile, concatenate iles, and redirect output in the terminal or iles.
• To display the contents of a ile:
cat filename
• To create a ile:
cat > filename

This will open up a new ile and you can start typing. Once done, press Ctrl + D to save and exit.
• You can also append to a ile:
cat >> filename

This will open up the ile and you can start typing. Once done, you can press Ctrl + D to save and
exit.
• To show line numbers:
cat -n filename

The less command is used to view the contents of a ile. It is similar to cat but allows you to scroll up
and down.
less filename

To exit the less command, just press q.


f
f
f
f
f
f
f
f
f
f
The nano Command
The nano command is a text editor that is installed by default on most
Linux distributions, and MacOS and you can even use it with Git Bash on
Windows.
You can open an existing ile to edit or create a new ile and open it with:
nano filename

When you're ready to exit, just hit Ctrl + X and then Y to save and N to
not save.
f
f
The head and tail Command
The head command is used to output the irst part of the iles. By default, it
outputs the irst 10 lines of each ile. You can also specify the number of lines to
output.
head filename
You can also specify the number of lines to output:
head -n 5 filename

The tail command is used to output the last part of the iles. By default, it outputs
the last 10 lines of each ile. You can also specify the number of lines to output.
tail filename

You can also specify the number of lines to output:


tail -n 5 filename
f
f
f
f
f
f
Copying Files and Directories
Short for "copy," the cp command is used to copy iles and directories locally.
- To copy a single ile:
cp file_path destination_directory_path

- To copy and rename a ile:


cp file_path renamed_file_path

- To copy a folder and its contents:


cp -R folder_path destination_directory_path

- To copy contents of one directory to another:


cp -R source_directory/ destination_directory_path

- To copy a speci ic ile type to another directory


cp *.file_type destination_directory_path
f
f
f
f
f
Moving and Renaming Files
The mv program can move a ile from one directory to another. It has the
same syntax as the cp command:
mv file_path destination_directory_path

The mv command also lets you quickly rename iles. What you do is
essentially move a ile to the same location, but change its name. If you
specify a name for its destination, the mv command changes the ile’s name
when it moves the ile.
mv current_filename new_filename
f
f
f
f
f
File and Directory Wildcards
When you have several iles named in series (for example, chap1.doc to chap12.doc) or ilenames with common characters
(such as aegis, aeon, and aerie), you can use wildcards to save yourself lots of typing and match multiple iles at the same time.

Notation De initon

An asterisk stands for any number of characters in a ilename. For example, ae* matches any
ilename that begins with “ae” (such as aegis, aerie, aeon, etc.) if those iles are in the same
* directory. You can use this to save typing for a single ilename (for example, al* for alphabet.txt)
or to choose many iles at once (as in ae*). A * by itself matches all ile and subdirectory names in a
directory, with the exception of any starting with a period. To match all your dot iles, try .??*.

? A question mark stands for any single character (so h?p matches hop and hip, but not hp or help).

Square brackets can surround a choice of single characters (i.e., one digit or one letter) you’d like to
match. For example, [Cc]hapter would match either Chapter or chapter, but chap[12] would
[] match chap1 or chap2. Use a hyphen (-) to separate a range of consecutive characters. For
example, chap[1-3] matches chap1, chap2, or chap3.

A list of two or more subpatterns that are matched consecutively. The pattern a{b,c,d}e would
match abe, ace, and ade, but not aee because the middle e isn’t inside the curly braces. This is most
{,} commonly used to reference multiple iles within a subdirectory, as in Mail/{drafts,inbox} which is
functionally identical to typing both Mail/drafts and Mail/inbox.
f
f
f
f
f
f
f
f
f
f
f
f
Compressing Files
There are three compression programs included with Mac OS X, though the
most popular is gzip (the others are compress and bzip2).
gzip is actually a compression program that does a very good job of
shrinking down individual iles for storage and transmission. The syntax is:
gzip [-v] file(s)

The -v lag offers verbose output, letting the program indicate how much
space it saved by compressing the ile.
f
f
f
Creating Directories (Folders)
You can also create new directories (a.k.a. folders). You’ll do this with
the mkdir (make directory) command:
mkdir directory_name

You can make multiple directories with a single command:


mkdir directory_name1 directory_name2 directory_name3
Removing Files and Directories
The rm program removes iles. The syntax is:
rm filename
One important thing to point out here, though, is that rm permanently removes the ile from
the ilesystem. But there is a safety net: the -i (interactive) lag. So if you’re feeling cautious,
you could run the above commands with this lag as follows:
rm -i filename
To delete a directory, use the rmdir command.
rmdir directory_name
As a precaution, rmdir won’t let you delete directories that contain any iles or subdirectories;
the directory must irst be empty. To delete a directory and everything in it, use -R, otherwise
known as the recursive option.
rmdir -R directory_name
f
f
f
f
f
f
f

You might also like