ITEC 221 6 - File Management
ITEC 221 6 - File Management
File Management
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.
Read Can read the ile Can list iles in the directory
- 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
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
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