Create zip file from root owned fstab

I want to zip up my fstab file for backup purposes.

This does not work because of permission issues.

cd /etc/
zip -u fstab.zip fstab

Can I use this with zip?

echo xxx | sudo -S

or change fstab owner to me?

cd
cat /etc/fstab | zip -u fstab.zip -

--- Post updated at 09:48 ---

unzip -p fstab.zip > fstab.txt

It made a file fstab.zip, but the compressed file is named -.

Seems clumsy, but works.

unzip fstab.zip
mv - fstab

Use -j to junk the path element, i.e. zip -u -j this.zip /etc/fstab and you need not run it from inside /etc any more.

1 Like