Buy this Domain

Community Discussions

Explore the latest discussions and community conversations related to this domain.

What exactly is a "file"?

Main Post:

I have been using linux for 10 months now after using windows for my entire life.

In the beginning, I thought that files are just what programs use e.g. Notepad (.txt), Photoshop etc and the extension of the file will define its purpose. Like I couldn't open a video in a paint file

Once I started using Linux, I began to realise that the purpose of files is not defined by their extension, and its the program that decides how to read a file.

For example I can use Node to run .js files but when I removed the extension it still continued to work

Extensions are basically only for semantic purposes it seems, but arent really required

When I switched from Ubuntu to Arch, having to manually setup my partitions during the installation I took notice of how my volumes e.g. /dev/sda were also just files, I tried opening them in neovim only to see nothing inside.

But somehow that emptiness stores the information required for my file systems

In linux literally everything is a file, it seems. Files store some metadata like creation date, permissions, etc.

This makes me feel like a file can be thought of as an HTML document, where the <head> contains all the metadata of the file and the <body> is what we see when we open it with a text editor, would this be a correct way to think about them?

Is there anything in linux that is not a file?

If everything is a file, then to run those files we need some sort of executable (compiler etc.) which in itself will be a file. There needs to be some sort of "initial file" that will be loaded which allows us to load the next file and so on to get the system booted. (e.g. a the "spark" which causes the "explosion")

How can this initial file be run if there is no files loaded before this file? Would this mean the CPU is able to execute the file directly on raw metal or what? I just cant believe that in linux literally everything is a file. I wonder if Windows is the same, is this fundamentally how operating systems work?

In the context of the HTML example what would a binary file look like? I always thought if I opened a binary file I would see 01011010, but I don't. What the heck is a file?

Top Comment: Good question. Rare to see these in this sub filled with "I want to try linux. I do gaming and web browsing, which is the best distro". See, a file is an abstraction of how data is represented. Most computers nowdays follow the Von Neumann architecture, which is a model where CPU and RAM are tightly interconnected and talk to each other during execution as the RAM holds both the code of the program and the data to work with. Data can get inside and outside this duo. But his model does not consider storage, much less files. In order to store data, you need a medium where two distinct states can be read and manipulated at will. Floppy drives, hard disks and magnetic tapes do that by polarizing each region with either north or south magnetization. CDs, DVDs and BluRays do that by putting some notches on the shiny surface so a laser pointed at it either reflects back or scatters. SD cards, USB drives and Solid Stata Drives do it by storing electrons in small chamber or releasing them. Heck, even some developers are working on storing data on DNA by assinging zero and one to certain combinations of Adenine, Timine, Guanine and Citosine. But having a way to store info is just the first step. Now we need to store that in a way that makes sense. That is where filesystems come in. In a nutshell, they use some of the bits of the storage media to hold "scaffolding data", this is, data that does not belong to a file, but instead are there to organize it: tables of where a file starts and ends, tables of contents of certain regions of storage, the "meta-data" of a file such as name, date of creation, permissions, etc. The OS in the end reads all that info and presents it to you in the form of some folders and icons, but in the end that is just a projection. Smoke and Mirrors. Well, Linux and other UNIX-like OSes use those 'smoke and mirrors' and use them to represent devices, info about the system, and other kinds of things. This is the principle known as "eveything is a file". This means some things you see on the filesystem aren't actual files on the disk, but instead illusions the OS plants on the filesystem so you can access some resources on your system by using the same means you use to read an acual file. Think of it like in Star Wars when some of the members of the council had to attend meetings remotely: they proyected an hologram on their chair so it will seem they were present, but they werent. The same thig happens in the /dev folder about devices, and also in the /proc folder, where you can find info about the system like the files open by all the programs or the details about the CPU and memory on your computer. About the "initial file": when you boot the system, there is no files, so there is not much sense to talk about an intial "file". After all, your CPU does not know what a file is. The CPU only knows to grab and put data from RAM, and execute some instructions like adding two numbers, checking if one number is bigger than other, or jumping to a certain instruction if the result of the previous operation was zero. Well, all CPUs are wired so when they turn on they read the data stored in some memory address and start executing it. In modern computers a flash memory chip is wired to that location, and the firmware of the computer is stored in there. That firmware is the BIOS/UEFI. In that way, when the computer gets powered on, it runs the code that makes that firmware, which instructs the CPU to bring up the computer. From there, the firmware will instruct the CPU to load data from a disk to boot an OS from. In the old BIOS system the computer would read direclty the first 400 or so bytes of data stored on the disk and execute that. As UEFI is more advanced we can make the computer understand filesystems, so UEFI boots by browsing a given partition on a disk and then executing files on it compiled so the UEFI bootloader can run them. From there, you can do whatever you want. For example Linux boots by coping into RAM the contents of a file called the Initial RAM FileSystem (initramfs), which contains an entire disk image of a basic yet complete OS. That OS is capable of reading filesystems and executing programs, and it uses that to load the actual system you have installed in your disk, and when it finished doing that, it passes control to it and unloads istelf from RAM. There is even a project called No More BootLoader (nmbl) which tries to use the fact that UEFI can browse files and launch executable programs to directly run the Linux kernel, no initramfs or bootloaders needed. At last, about what you saw when you opened the disk file on nano: yes, all data in the computer is zeroes and ones, but how you interpret them will vary. For examplea text editor may read each byte and then translate them using the ASCII table into letters. But a RAW image viewer may read groups of three bytes and then conver each into a number between 0 and 255 indicating how much red, green and yellow has a pixel. Here is an example: a binary file that contains 01001000 01100101 01111001 00100011 00101000 00101001 11000011 10000101 11000011 10110111 00100001. If we read it like a text file, interpeting each byte as some letter on the ASCII table, we see that it reads Hey#()Å÷!, but if we read it like raw color data as I said, it describes 3 colors: #486579, #232829 and #c5f721 in HTML notation. Check it out yourself by consulting an ASCII table and also converting each byte to it's equivalent in base 16. When you opened up the /dev/sda file into the text editor you saw nothing because of two reasions: the first is that the vast majority of the ASCII table are non-printable characters, as they are used for things like line break, command to star writing from right to left, carrige return, and other things are are "invisible" in a text editor. The second is that nor all files are created equal. Disks work by blocks, meaning that you are forced to always read and write data onto the device in blocks of bits, and in drive a block usually measures 512 bytes or 4096 bytes. The text editor app could not read on those block units, so it caused a wrong output. If you want to see the raw data of files, there are programs that let you do so. hexdump works on the terminal, and for GUI you have GHex and Okteta. Keep in mind that many of them will convert between the binary (base 2) into base 16 as that is more compact and has some advantages, but there are options to display things in binary. Hope this clears your doubts, and if not, I will clarify them if I can.

Forum: r/linuxquestions

How does a FILE pointer in C work? - Stack Overflow

Main Post: How does a FILE pointer in C work? - Stack Overflow

Forum: stackoverflow.com

python - what does the __file__ variable mean/do? - Stack Overflow

Main Post: python - what does the __file__ variable mean/do? - Stack Overflow

Forum: stackoverflow.com

'I don't care about Direct File': IRS chief says agency plans to end free filing program : technology

Main Post: 'I don't care about Direct File': IRS chief says agency plans to end free filing program : technology

Forum: r/technology

Warning to NEVER install the Files App for an "improved" files explorer experience

Main Post:

I just lost approx. 20GB of files, including some work files from a few days ago. I got absolutely lucky that the files app did not delete my ENTIRE laptop files.

I know many like this app, and I myself used this app for a year or so without problems... But if you have one, oh boy, be prepared to have your day/week/month ruined.

What happened? Almost all my files and folders have their root on the Desktop. I was trying to cut & paste a few image files that I downloaded to a work folder. But for some reason, the files app basically did a "select all" and then I unknowingly cut & pasted all files on my desktop into that particular folder.

Well, no biggie, you'd think. Just move all the files back that you didn't want to move, right?

But the cut & paste operation failed. I think because I tried to copy & paste a folder into a folder with the same name. So midway of cutting & pasting, it failed. Well... Here is how Files App cuts and pastes: It DELETES all files, then moves them. So if something goes wrong in the middle of it, CTRL+Z/undo only recovers the files that were successfully moved. So, since I still had like 50% of all my files pending to be moved, the files app basically deleted a LARGE CHUNK of all my files on my laptop. I literally only got lucky that my most crucial files managed to get pasted successfully before the cut & paste failure.

This is such a common sense scenario yet it's not tested. I reported this on GitHub and the main author asked " I meant what's the behavior in File Explorer if you cut, paste and then undo?", seriously implying that the dev doesn't know that the normal file explorer doesn't swallow your files whole. I can't believe that he/she/they never considered that you shouldn't just force delete all files BEFORE successfully having moved all of them. What the actual F. Imagine you had a cut & paste failure after file #2 with 10000 files pending. ALL 10000 files would be gone forever.

Imagine you have a Binance account, you send money from your wallet to let's say a Binance investment fund, but while moving, Binance had a bug... AND THE MONEY IS GONE FOREVER. That is the level of idiocracy of this app. This app has no quality assurance whatsoever. I worked in tech for nearly 10 years. This isn't even an edge-case scenario. Basically, the Files App has no fallback to recover files during cut & paste. Ridiculous. Thanks for deleting a gigantic pile of my files.

Don't get this app.

Update: After talking about the issue on GitHub, the devs found what caused the issue to happen.

Quote from the post:

Here's what I did:

My Desktop had many folders, one of them was the folder that I copied into but a sub-folder within that one. I performed this action from within the files app, being located in the desktop folder.

So the files app selected all files on the desktop folder. Not sure why it did that. I just shift selected a few files.

Note: This all files issue might have happened because of another bug of the Files app, mentioned in the GitHub issue.

Then continuing on:

The structure is roughly

Desktop|-- many subfolders|-- subfolder1 |-- subfolder|-- new folder created in this subfolder & trying to paste into that folder

So from within the Desktop root, it selected all folders, then I cut, and pasted into the new folder.

I, unfortunately, forgot the exact error message that it threw. But my best guess is that it errored because I tried to cut & paste subfolder 1 into "new folder", which obviously can't work.

So that's essentially what caused the error. Basically, trying to copy a folder into itself. Details about reproduction etc are in the GitHub issue:

Bug: Cut and paste into the source folder causes source folder to be deleted · Issue #11174 · files-community/Files (github.com)

Update 2: They implemented a fix for the issue. Tbh, I don't fully understand it since I am not interested in using Files anymore. I think the data would no longer get deleted, although I'm not 100% sure that it actually means the data is recoverable (because I think the data would still be cut into oblivion). I assume the devs would have the answer to that and considered this though, so if you're curious, ask on GitHub.

Top Comment: Man, I love the idea of the app and wish all the best for its devs, but I just can’t trust it with important tasks. Any load whatsoever is enough to drag its performance to the ground, and the app tends to crash in the worse possible times. It’s a beautiful app and the devs are very passionate about the project, but the old and reliable file explorer is the way to go for me.

Forum: r/Windows11

Files v2.1 just got released

Main Post:

Looking for an alternative for File explorer in Windows 10? Files is definitly worth trying out. It's completely free. And it just got even better with the latest 2.1 update. Check the blogpost to see what's new!

Files - Introducing Files v2.1

Files V2.1

Top Comment: it's definitely slow. I love the design, I'll see how long I can handle the slowness

Forum: r/Windows10

Do you know of a good way to transfer files?

Main Post:

Hi good people of Reddit!

I'm a video editor, and recently started working with a client that is located in a different country. They use about 300-500 gigs of footage for one video and we are now searching for a good way to transfer it regularly, besides Google Drive and sending over hard drives.

Do you know any ways to do so?

Top Comment: I've been using Massive for a while now to transfer HUGE uncompressed 8k+ files back and forth between clients. I've gotten great results with it, and find the cost to be quite reasonable.

Forum: r/editors

What to use for sharing files with the outside?

Main Post:

Hi!

My users occasionally need to share files with parties outside of the organization. Long time ago something like FTP was the only option (outside of external drives) but who uses that nowadays? What are your preferred ways? Any recommendations?

Top Comment: Much of reddit is currently restricted or otherwise unavailable as part of a large-scale protest to changes being made by reddit regarding API access. r/sysadmin has made the decision to not close the sub in order to continue to service our members, but you should be aware of what's going on as these changes will have an impact on how you use reddit in the near future. More information can be found here . If you're interested in alternative r/sysadmin communities during the protests, you can join our Discord or IRC (#reddit-sysadmin on libera.chat). I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

Forum: r/sysadmin

How can I upload a Google doc file on Reddit?

Main Post:

This is for a script, I swear.

Top Comment:

You don't. You share the document and create a link to it. You then post that to reddit. You might be able to export it as a pdf and then attach that... But it's really just easier to create the link, mark it as read only and share that.

Forum: r/Screenwriting

Separate dump files for the top 20k subreddits

Main Post:

This data has been replaced with a newer version here!

https://www.reddit.com/r/pushshift/comments/1akrhg3/separate_dump_files_for_the_top_40k_subreddits/

Top Comment: This is awesome. I'll help to seed later. Thank you

Forum: r/pushshift

Windows 10 Large file search...How?

Main Post: Windows 10 Large file search...How?

Top Comment: Just do something like "size: >1gb". You can type your own parameters.

Forum: r/Windows10