this post was submitted on 16 Sep 2025
115 points (97.5% liked)

Linux

58221 readers
1505 users here now

From Wikipedia, the free encyclopedia

Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).

Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.

Rules

Related Communities

Community icon by Alpár-Etele Méder, licensed under CC BY 3.0

founded 6 years ago
MODERATORS
 

That was a "fun" debugging session...

top 24 comments
sorted by: hot top controversial new old
[–] HiddenLayer555@lemmy.ml 9 points 18 hours ago* (last edited 18 hours ago)

Worse, it preserves "special" files like the ones in /dev or /var which aren't removable by anyone other than root. Love extracting a system file backup in my file server as a regular user in order to get just a few files out of it, and promptly not being able to fully delete it afterward without SSHing into the server and using sudo.

I don't get how a regular user can even create files like that. Sounds like a security vulnerability.

[–] IsoKiero@sopuli.xyz 15 points 1 day ago* (last edited 1 day ago) (1 children)

Since no one has yet mentioned, by default if you're running tar as a non-root user it extracts files with owner/umask of the current user and if you run it as root (or superuser) it'll preserve ownership and permissions. From tar man page:

--no-same-owner

Extract files as yourself (default for ordinary users).

--no-same-permissions

Apply the user's umask when extracting permissions from the archive (default for ordinary users).

As mentioned, with root the defaults are to keep UID/permissions as they are in the archive. (--preserve-permissions and --same-owner).

[–] TheMadBeagle@lemmy.ml 4 points 1 day ago

Really good callout! Thanks for adding that

[–] Lemmchen@feddit.org 32 points 1 day ago (2 children)

That's a feature, not a bug. It's an archive after all.

[–] syklemil@discuss.tchncs.de 12 points 1 day ago (1 children)

It's even a tape archiving tool. Just pretty much nobody uses it in the original way any more.

Very much one of those "if it ain't broke, don't replace it" tools.

[–] ReversalHatchery@beehaw.org 1 points 1 day ago

but also the way it puts file data one after the other can be beneficial for compression, especially if you can define the order of the files somehow

[–] lorty@lemmy.ml 3 points 1 day ago (1 children)

I just assumed that whenever it would be expanded that the contents would have the default permissions for that user.

It's actually a cool feature I just feel dumb for how long it took me to realize this was the issue.

[–] ReversalHatchery@beehaw.org 2 points 1 day ago

that can be done too. tarballed software normally doesn't have permissions attached I think

[–] tetris11@lemmy.ml 22 points 1 day ago* (last edited 1 day ago)

Just bear in mind that uid 1001 on one machine is not generally uid 1001 on another, and that if you copy the tar off machine you're more than likely giving permission to somebody other than the intended target

[–] cmnybo@discuss.tchncs.de 61 points 1 day ago

That's what an archiving program is supposed to do.

[–] vk6flab@lemmy.radio 21 points 1 day ago (1 children)

You can even archive extended attributes with the ‘--xattrs flag.

[–] MonkderVierte@lemmy.zip 5 points 1 day ago

Good to know if you use xattrs as a tagging system.

[–] frongt@lemmy.zip 20 points 1 day ago (3 children)

I've never heard of an archiving program that didn't.

[–] slock@lemmy.world 11 points 1 day ago (1 children)

IIRC zip can, but doesn't by default. Source : wasted 8 hours trying to figure out why something didn't work anymore (had to switch from tar to zip because stupid security system wouldn't let me transfer the tar file)

[–] Zykino@programming.dev 6 points 1 day ago* (last edited 20 hours ago) (1 children)
tar -czf <folder>
mv folder.{tar.gz,zip}
[–] InnerScientist@lemmy.world 4 points 1 day ago

Just use archive.pdf

[–] lorty@lemmy.ml 3 points 1 day ago (1 children)

I thought that, since users would be different between machines, there's no point in keeping this kind of information.

[–] TankieTanuki@hexbear.net 6 points 1 day ago

You can sync user and daemon UIDs across machines with LDAP and SSSD.

And even if you don't do that, keeping the information is useful when restoring to the same machine

[–] ReversalHatchery@beehaw.org 1 points 1 day ago

mostly anything on windows

[–] monovergent@lemmy.ml 12 points 1 day ago (1 children)

Learned to make use of this the hard way when transferring a directory over a FAT32 USB drive messed up the permissions.

[–] ki9@lemmy.gf4.pw 2 points 18 hours ago

I uses to use 7z for my archives but it dropped the permissions. Now I tar it first into a .tar.7z aka .t7z when I want maximum compression.

[–] daggermoon@lemmy.world 4 points 1 day ago (1 children)

Yeah I did notice that. Never really had a use for such a feature though.

[–] ki9@lemmy.gf4.pw 2 points 18 hours ago (1 children)

Well having the wrong permissions in system files will mess up your system. So when you restore from backup and want the backed-up permissions too.

[–] daggermoon@lemmy.world 1 points 16 hours ago

Never thought of using .tar folders for that. Makes sense.