Hello,
I have may sas datasets into sub folder sas2001 until sas2024 and I looking for a Unix command to protect the folder and the sas datasets from being deleted.
I have executed the Kernel scirpt below
# Change directory to the target directory
cd /finsys/.../LEGO_6141_Restore_sasdatasets_in_sasdata_folder/Notes_LEGO_6141_test.txt
# Set permissions for all files
find . -type f -exec chmod 644 {} \;
# Set permissions for all directories
find . -type d -exec chmod 755 {} \;
But I was able to delete the file directly from winscp
Any suggestion ?
In UNIX, deleting a file starts with removing a directory entry. So the necessary permission for deleting a file is the write permission on the directory; if you also need to be able to create files there, removing the write permission is not feasible.
One trick you can do from the OS: create a second physical (within the same physical filesystem) link to the file (ln command). If you accidentally remove the first link, the second link will prevent the actual delete (which means removing the inode and freeing the used clusters), and you can recreate the original directory entry.
Having a system backup (daily/incremental) is a total must, of course.
Server backups are the usual way to protect against deletion. In my organisation I simply request a restore of the deleted files. That way you are protected regardless of how files are deleted or corrupted.
Whether or not you can delete a file depends on the permission of the directory the file lives in, not the permissions on the file.
Since you told Unix that you were allowed to write to the directory that means you can delete the file.
To prevent you from deleting the file remove the write bit from the directory. Or have the directory owned by someone else, like a system account.
I am not sure. But it is a desired way to try (adding a password to prevent from deleting).
data x(alter='xxx'); set sashelp.class; run; proc delete data=x;run;
In UNIX, deleting a file starts with removing a directory entry. So the necessary permission for deleting a file is the write permission on the directory; if you also need to be able to create files there, removing the write permission is not feasible.
One trick you can do from the OS: create a second physical (within the same physical filesystem) link to the file (ln command). If you accidentally remove the first link, the second link will prevent the actual delete (which means removing the inode and freeing the used clusters), and you can recreate the original directory entry.
Having a system backup (daily/incremental) is a total must, of course.
Check out this tutorial series to learn how to build your own steps in SAS Studio.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.