We often take files for granted, but they're really important. In this video, explore what files are and how they work.
- [Instructor] On Linux, as with other operating systems, we organize information into files and we organize those files into folders. Files are collections of data that represent different kinds of information. From text files to binaries like applications, photos, videos and music. And files even represent hardware on the system, process information and kernel parameters. But whatever a file represents, it's just a series of binary information or bits on the disk. These bits are stored in blocks on the disk. And the locations of these blocks are tracked by the file system.
This information about the location of each files blocks are kept in a data structure called an inode. And the inodes are kept in an inode table. So while the actual data for files is scattered around the disk in blocks of binary information, we view the contents of the file system as a hierarchy of folders within folders. Like branches of a tree. What we see as files in this structure are really hard links to each files inode. And when you request the contents of a file in order to run it, edit it or view it, the system goes out and looks up all the blocks that represent pieces of that file and return the data from them.
File systems and how they represent data are a pretty interesting area to explore, if you're so inclined. But I'll leave that there for now. How the data that makes up a file is represented is one part of the story. But what's more important to many users is what the file represents. Sometimes we'll use files that have an extension. You're probably familiar with dot txt files, dot jpg files, dot html, dot css and dot js, if you're a web developer and so on. We use extensions as a kind of shorthand to indicate to humans and to software what a particular file is intended for.
The extension is added to the end of a file name. Separated by a dot or a period. But it's still just part of the files name. One of the aspects of metadata that the file systems stores. There are other elements of metadata for files. Their size, their creation and modification dates, settings for permissions or who can access them and in what way, ownership information and more. If I have a photo like cat dot jpg and I rename the file to just cat or cat dot mp3, it doesn't change the fact that the file represents a photo of a cat.
The information on disk that the file entry refers to remains the same even though photo management programs might stop recognizing the file as an image. Because file extensions aren't reliable indicators of what a file contains, we can use some other tools to get a better idea of what our file is. Files are stored in particular formats that are defined so that a program knows how to use the information that a file represents. And most of these file formats can be recognized by what's called a magic number. A particular value at the beginning of the file that more reliably represents what's in a file.
We can use the file command to read these magic numbers and tell us what kind of file something actually is. Alright, file cat dot jpg. And here I can see that this is JPEG image data. I also have a few files here that don't have extensions so let's figure out what those are. Alright, file mysterious file one. And it turns out this ones a JPEG as well. Mysterious file two is some text.
And mysterious file three is an audio file. In this case, an MPEG layer three or MP3 file. We can also find out more about our files metadata with the stack command. This shows the file size. How many blocks it takes up. And a bunch of other information that can be helpful to know about. I'll write stat cat dot jpg. And here I can see it takes up about 3.1 megabytes, 6200 blocks. Resides at inode 5259774.
And so on. While files are somewhat more complicated than they look at first glance, there's nothing mysterious about them. Even though there is a little bit of magic involved.
Author
Updated
3/2/2021Released
10/3/2017Skill Level Intermediate
Duration
Views
Related Courses
-
Linux: Bash Shell and Scripts
with Kevin Dankwardt2h 46m Intermediate -
Linux: Files and Permissions
with Grant McWilliams1h 49m Intermediate -
Linux: Multitasking at the Command Line
with Scott Simpson39m 1s Intermediate
-
New this Week:
-
Docker on Linux5m 24s
-
-
Introduction
-
Welcome1m 4s
-
-
Foundations
-
Foundations: What's Linux?5m 26s
-
Foundations: Distros10m 50s
-
Foundations: USB installer7m 46s
-
Linux on Azure7m 21s
-
Google Cloud Platform3m 37s
-
Linux on DigitalOcean6m 39s
-
-
System Basics
-
Bash operators6m 55s
-
Logs5m 4s
-
Grub3m 19s
-
SysV init4m 43s
-
Systemd5m 29s
-
Cron8m 7s
-
Understanding chroot3m 16s
-
Backing up data with rsync5m 35s
-
Working with dotfiles1m 43s
-
Exploring the PATH variable3m 51s
-
Finding or locating files3m 52s
-
Working with swap4m 29s
-
Read and write caches3m 5s
-
Filesystem Basics
-
Files on Linux4m 10s
-
File system basics: Archives6m 22s
-
Loop devices4m 35s
-
Overlay file systems4m 17s
-
Bind mounts2m
-
-
Working with Text
-
Working with text: Vim 1015m 15s
-
Working with text: Emacs 1015m 42s
-
Working with text: nano 1015m 29s
-
Working with text: grep4m 23s
-
Working with text: sed7m 24s
-
Working with text: AWK2m 51s
-
Working with text: ed 1016m 17s
-
-
Package Management
-
Package management: Basics6m 59s
-
aptitude5m 43s
-
dpkg2m 20s
-
yum and DNF4m 58s
-
RPM3m 24s
-
Creating your own packages3m 12s
-
Zypper4m 17s
-
Using Flatpak4m 11s
-
Using snaps3m 15s
-
-
Working Remotely
-
Remote files: curl and wget4m 42s
-
SSH: Secure access8m 8s
-
SSH: Tunnels3m 46s
-
X11 forwarding2m 52s
-
Using a SOCKS proxy4m 53s
-
Using a Squid proxy8m 43s
-
-
Process Management
-
Process management: ps4m 30s
-
Process management: top4m 53s
-
Process management: htop6m 11s
-
Customizing tmux3m 32s
-
-
Security
-
Firewall basics4m 5s
-
Understanding iptables6m 41s
-
File checksums3m 48s
-
Encrypting files7m 14s
-
Encrypted filesystems6m 58s
-
AppArmor4m 2s
-
Security systems: SELinux4m 33s
-
-
System Administration
-
Disks and partitions6m 42s
-
Logical volume management9m 59s
-
Create a RAID array9m 10s
-
Repairing a RAID array4m 44s
-
Local IP address5m 15s
-
DNS5m 40s
-
VPN1m 43s
-
Drivers and modules4m 16s
-
Understanding QEMU and KVM2m 49s
-
Private networking6m 37s
-
Routing and forwarding4m 26s
-
DHCP4m 55s
-
Network troubleshooting7m 42s
-
Wi-Fi on Linux4m 14s
-
-
Desktops and Displays
-
Desktops: Basics3m 8s
-
Desktops: GNOME4m 41s
-
Desktops: Xfce4m 5s
-
Desktops: KDE Plasma Desktop2m 28s
-
Desktops: LXQt3m 42s
-
-
Exploration Topics
-
Windows Subsystem for Linux7m 20s
-
Exploring virtualization5m 28s
-
Exploring containers5m 19s
-
Exploring Fedora3m 8s
-
Changing the default shell3m 30s
-
Exploring other shells2m 5s
-
Exploring CentOS2m 6s
-
Exploring Zsh5m 41s
-
Osquery4m 28s
-
Exploring fish5m 21s
-
Exploring csh and tcsh2m 34s
-
Using diff to compare files3m 54s
-
Using xargs3m 41s
-
Job control3m 59s
-
Using watch and time3m 5s
-
Recording a terminal session3m 14s
-
Exploring Debian1m 49s
-
Exploring SUSE Linux7m 33s
-
Exploring Arch Linux16m 44s
-
Exploring Alpine Linux6m 18s
-
Exploring Linux Mint5m 14s
-
Exploring Amazon Linux5m 8s
-
Terminal on the go5m 1s
-
FUSE and SSHFS3m 54s
-
Removing Linux4m 44s
-
WSL distros on Windows 103m 13s
-
Embedded Linux4m 25s
-
Exploring Netboot2m 43s
-
Exploring ZFS3m 53s
-
Troubleshooting Topics
-
Projects
-
Linux on an old PC6m 7s
-
Hosting email services3m 7s
-
Create a network PDF printer4m 37s
-
Remote logging with Rsyslog7m 12s
-
Set up a Git server4m 16s
-
NGINX web server4m 11s
-
Set up an NFS server3m 58s
-
Monitoring your server2m 49s
-
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.
CancelTake notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.
Share this video
Embed this video
Video: Files on Linux