Tag Info

New answers tagged

1

This should do (note that this is untested): #!/bin/bash BASE_DIR="/var/www/testing" NEW_BASE_DIR="/var/www/testing/old" FILE_EXTENSIONS_TO_MOVE="zip" # If the new directory doesn't exist, create it if [ ! -d ${NEW_BASE_DIR} ] ; then echo "Creating ${NEW_BASE_DIR}" mkdir ${NEW_BASE_DIR} fi echo "Moving files with extension .${FILE_EXTENSION} in ...


0

Assuming source.txt is formatted as follows: myfolder\mynewdir1 myfolder\mynewdir2 myfolder2\subdir\mynewdir3 Batch: @echo off setlocal set folders=C:\source.txt for /f %%d in ("%folders%") do ( md %%d ) Powershell: $folders=@(Get-Content 'C:\source.txt') ForEach ($folder in $folders) { New-Item -ItemType directory -Path C:\$folder ...


1

On Linux the immutable flag is only supported on some types of file system (most of the native ones like ext4, xfs, btrfs...) On filesystems where it's not supported, another option is to bind-mount the file over itself in read-only mode. That has to be done in two steps: mount --bind file file mount -o remount,bind,ro file That has to be done at each ...


2

In a comment to the answer by Kevin, Jerry mentions: Well, of course the file is being backed-up regularly, I just wanted another layer of protection against users which are sometimes working on the box with root user permissions. – I'm going to assume that you can't change this practice, as it's a really, really bad idea. All of the suggestions ...


4

Linux has so-called bind-mount option which is rather powerful and useful feature to know: % cd $TMP && mkdir usebindmountluke && cd usebindmountluke % echo usebindmountluke > preciousfile % sudo mount -B preciousfile preciousfile % sudo mount -oremount,ro preciousfile % echo sowhat > preciousfile zsh: read-only file system: ...


2

Why not create an ISO 9660 image, which is read-only by design? Mount the ISO image, and it'll look like a CD-ROM, but with the performance of a hard drive, and files on the mounted image will be just as safe from deletion as files on a physical CD-ROM. The idea of burning the sensitive file to a CD and running it from a CD-ROM is interesting, assuming ...


24

Create a file system image. Mount the image. Copy the file to the mounted image. Unmount the image and remount it as read-only. Now you can't delete it. Example: # dd if=/dev/zero of=readonly.img bs=1024 count=1024 # mkfs.ext2 readonly.img # mkdir readonlyfolder # mount readonly.img readonlyfolder/ # echo "can't delete this" > ...


72

Burn it to a CD. Put the CD in a CD-ROM drive and access it from there.


5

Others have answered your question as you've asked it. As @Sven mentioned in a comment, the general solution to the question, "How do I make sure I never lose a file?" is to create a backup of the file. Make a copy of the file and store it in multiple places. In addition, if the file is extremely important and your company has a policy for backing up ...


4

You should create multiple hard links to the file as well. These should be in various locations that regular users can't access. This way, even if they do manage to override your chattr protection, the data will remain and you can easily restore it where your application is looking for it.


109

Yes, you can change the attributes of the file to read-only. The command is: chattr +i filename And to disable it: chattr -i filename From man chattr: A file with the i attribute cannot be modified: it cannot be deleted or renamed, no link can be created to this file and no data can be written to the file. Only the superuser or a process ...


0

You were on the right track with puppet. Have the puppetmaster serve as the source of truth, house them in the server that runs your puppetmaster, and declare the files that should exist and the canonical versions there. You may even want to version the files that you are making available in the puppetmaster server using something like SVN or GIT. This ...


0

I got curious and tried it out: [root@localhost vagrant]# cat test.pp file { '/tmp/path2': ensure => directory, source => 'file:///tmp/path1', recurse => true, purge => true, force => true, } [root@localhost vagrant]# ls -lR /tmp/path1 /tmp/path1: total 4 -rw-r--r-- 1 root root 0 Nov 29 01:55 bar drwxr-xr-x 2 root root ...



Top 50 recent answers are included