this post was submitted on 16 Sep 2025
124 points (97.7% liked)

Linux

58380 readers
621 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 25 comments
sorted by: hot top controversial new old
[–] cmnybo@discuss.tchncs.de 63 points 6 days ago

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

[–] Lemmchen@feddit.org 35 points 6 days ago (2 children)

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

[–] syklemil@discuss.tchncs.de 13 points 6 days 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 5 days 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 4 points 6 days 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 5 days ago

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

[–] tetris11@lemmy.ml 24 points 6 days ago* (last edited 6 days 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

[–] IsoKiero@sopuli.xyz 18 points 5 days ago* (last edited 5 days 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 5 days ago

Really good callout! Thanks for adding that

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

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

[–] MonkderVierte@lemmy.zip 5 points 6 days ago

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

[–] PseudoSpock@lemmy.dbzer0.com 4 points 4 days ago

For those wishing they could do that with zip and 7zip, you can add a permissions file to the archive that you first make with getfacl, and then on the target after extracting said archive, restore permissions and ownership with setfacl from that file.

Handy for certain support organizations that insist on a zip but that later want the permissions. (Looking at you SAP and IBM).

[–] HiddenLayer555@lemmy.ml 10 points 5 days ago* (last edited 5 days 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.

[–] frongt@lemmy.zip 20 points 6 days ago (3 children)

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

[–] slock@lemmy.world 11 points 6 days 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 7 points 6 days ago* (last edited 5 days ago) (1 children)
tar -czf <folder>
mv folder.{tar.gz,zip}
[–] InnerScientist@lemmy.world 4 points 6 days ago

Just use archive.pdf

[–] lorty@lemmy.ml 3 points 6 days 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 6 days 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 5 days ago

mostly anything on windows

[–] monovergent@lemmy.ml 12 points 6 days 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 5 days 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 6 days ago (1 children)

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

[–] ki9@lemmy.gf4.pw 2 points 5 days 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 5 days ago

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