- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: command problem
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-23-2003 09:16 AM
тАО04-23-2003 09:16 AM
command problem
2. How to prevent a file from being removed?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-23-2003 09:40 AM
тАО04-23-2003 09:40 AM
Re: command problem
$ . script.sh
(dot space bar script name)
2.- You can do it in two ways
a) chmod 444 file_name
but with rm -f file_name, if you are the owner the file is removed anyway.
b) chmod 444 file_name and changing the owner of the file,
chown root.root file_name. But, at this way, you can't access the file anymore.
Frank.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-23-2003 09:48 AM
тАО04-23-2003 09:48 AM
Re: command problem
If you're talking about shell scripts only, your can source the script file with the . command, e.g.
. /path/to/script
Keep in mind that, if your shell script executes an exit command, your session will be terminated, just as if you had used the exec command. In this case, replace exit with return.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-23-2003 03:16 PM
тАО04-23-2003 03:16 PM
Re: command problem
The 2nd answer however, there are a number of solutions, depending on how much you want the file to stay.
The method Francisco should be fine if you don't want to protect the file from it's owner.
If you want further protection, you can use 'chattr'.
One of the flags you can give files are 'i' (immutable).
This might be more protection than you want however. From the man page of '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 can set or clear this attribute.
.. Just another option for you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-24-2003 05:58 AM
тАО04-24-2003 05:58 AM
Re: command problem
# . ./script_name
or
# exec ./script_name
2. chattr +i file
Now even root cannot delete file. Unless he also runs the command on that file and then tries rm again
Regards,
Trystan