I'm a first semester student, searched everywhere with no luck, I have 2 questions in an assignment that are basically the same - or at least that's what I think.
First: You want to protect yourself from deleting with your DEL command your program named PROG.EXE. Specify some ways to do this.
Second: Write a command through which a file Pass.log
could be protected by deleting with a command del Pass.log
Is there a way to protect them from DEL command within cmd?
On windows:
You can set the file as read only . (Right click on file -> properties -> General Tab -> check the "read only" checkbox)
Or using command: Attrib +R 1.txt
Using Security tab you can add a "Deny" on the modify privilege from the file. (Right click on file -> properties -> Security tab -> Edit for each line check the Deny near Modify)
On Unix/Linux:
You can remove the write privilege from every one using chmod
command. like chmod -w PROG.EXE
Attrib +R 1.txt
command will set the file as read only.icacls 1.txt /deny <User>:M
command will set the security deny for User for Modification and deletion. you shoud put your user instead of <User>
icacls 1.txt /deny <User>:D
command will prevent you only the deletion of the file not the modification of it (even to an empty file)