How VPS - How to use/setup VPS
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon
No Result
View All Result
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon
No Result
View All Result
How VPS - How to use/setup VPS
No Result
View All Result
Home Operating System Linux

How to Make File and Directory Undeletable, Even By Root in Linux

How VPS by How VPS
November 2, 2018
in Linux, Operating System
0
0
SHARES
47
VIEWS
Share on FacebookShare on Twitter

Contents

  1. How to Make File Undeletable in Linux
  2. How to Recursively Make Directory Undeletable in Linux

On Unix-like operating systems including Linux, root is the account or user name that by default can modify all directories and files on a system. In this article, we’ll show how to make directories or files unremovable even by the root user in Linux.

To make a file undeletable by any system user, including root, you need to make it unmodifiable using using the chattr command. This command changes file attributes on a Linux file system.

How to Make File Undeletable in Linux

The command below makes /backups/passwd file immutable (or undeletable). This implies that the file can’t be modified in any way: it can’t be deleted or renamed. You can’t even create a link to it and no data can be written to the file as well.

Note that you need superuser privileges to set or remove this attribute, using the sudo command:

$ sudo chattr +i /backups/passwd
OR
$ sudo chattr +i -V /backups/passwd
How to Make File and Directory Undeletable, Even By Root in Linux

Make File Undeletable in Linux

To view attributes of a file, use the lsattr command as shown.

$ lsattr /backups/passwd 
How to Make File and Directory Undeletable, Even By Root in Linux

View Linux File Attributes

Now try to remove the immutable file, both as a normal user and as a root.

$ rm /backups/passwd
$ sudo rm /backups/passwd
How to Make File and Directory Undeletable, Even By Root in Linux

Delete Immutable File in Linux

How to Recursively Make Directory Undeletable in Linux

Using the -R flag, you can recursively change attributes of directories and their contents as follows.

$ sudo chattr +i -RV /backups/  
How to Make File and Directory Undeletable, Even By Root in Linux

Make Directory Undeletable in Linux

To make a file mutable again, use -i sign to remove the above attribute, as follows.

$ sudo chattr -i /backups/ passwd

For more information, read this article: 5 ‘chattr’ Commands to Make Important Files IMMUTABLE (Unchangeable) in Linux

You will find these related article useful:

  1. How to Manage Users and Groups in Linux
  2. Managing Users & Groups and Enabling sudo Access on Users
  3. How to Find Files With SUID and SGID Permissions in Linux
  4. Translate rwx Permissions into Octal Format in Linux

That’s it! In this article, we showed how to make files unremovable even by the root user in Linux. You can ask any questions via the feedback form below.

Source: tecmint.com

Tags: Linux Commandslinux guidelinux vps setup guide
How VPS

How VPS

Related Posts

Failed to download metadata for repo 'appstream' on Centos 8
CentOS

How to fix error: Failed to download metadata for repo ‘appstream’ on Centos 8

February 25, 2022
How to Install Apache Tomcat 8 on CentOS 7
Linux

How to Install Apache Tomcat 8 on CentOS 7?

February 11, 2020
Install Arch Linux With Btrfs Snapshotting
Uncategorized

Install Arch Linux With Btrfs Snapshotting

February 13, 2020
Next Post

Disable Certain Package Updates using YUM in RHEL / CentOS / Fedora

10 ‘free’ Commands to Check Memory Usage in Linux

12 Practical Examples of Linux Xargs Command for Beginners

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Follow Us

  • 121 Followers
  • 87.2k Followers

Recommended

How to Install BlogoText CMS on a CentOS 7 LAMP VPS

3 years ago

How to Install CFEngine on Ubuntu 16.04

3 years ago

How to Install ARK: Survival Evolved on Debian 9

3 years ago

How to Create Your Own Debian Mirror Proxy Using Apt-Cache

3 years ago

Instagram

    Please install/update and activate JNews Instagram plugin.

Categories

  • Arch
  • Authentication
  • Backups
  • BSD
  • Centmin Mod
  • CentOS
  • Control Panels
  • CoreOS
  • CWP
  • Debian
  • Directadmin
  • Encryption
  • Fedora
  • Firewalls
  • Hocvps Script
  • Hosting providers
  • Kloxo-MR
  • Linux
  • Mitigations
  • Operating System
  • Plesk
  • Reviews
  • Securing VPS/Servers
  • Security Patches
  • SSL Certificates
  • Uncategorized
  • Upgrading
  • VPS/Servers management guides
  • Vulnerability Detection
  • Web servers software
  • Webhosting Control Panel

Topics

Apache Web Server Bluehost Review 2019 Bluehost Review 2020 Bluehost Review 2021 Centmin Mod CentminMod centos install htop fsck htop install HTTP DoS attack Install Snort on an Ubuntu install Zabbix on CentOS install Zabbix on CentOS 7 Linux Commands linux guide linux install htop linux vps setup guide MariaDB MariaDB Error Mysql mysqld error optimize MariaDB optimize Mysql snort Ubuntu
No Result
View All Result

Highlights

Top Free Web Hosting Control Panels To Manage VPS/Dedicated Servers

Webmin Reviews

Virtualmin Reviews

CentOS Web Panel Reviews

Ajenti Reviews

ISPConfig Reviews

Trending

Failed to download metadata for repo 'appstream' on Centos 8
CentOS

How to fix error: Failed to download metadata for repo ‘appstream’ on Centos 8

by How VPS
February 25, 2022
0

I tried to update some extensions by use yum on centOs which I specified in Dockerfile. After...

How to Fix MySQL Error "Plugin 'InnoDB' registration as a STORAGE ENGINE failed"?

How to Fix MySQL Error “Plugin ‘InnoDB’ registration as a STORAGE ENGINE failed”?

November 17, 2020
How to optimize Mysql or MariaDB

How to optimize Mysql or MariaDB

November 3, 2020
Top Free Web Hosting Control Panels To Manage VPS/Dedicated Servers

Top Free Web Hosting Control Panels To Manage VPS/Dedicated Servers

February 17, 2020
Webmin Reviews

Webmin Reviews

February 17, 2020
How VPS – How to use/setup VPS

We bring you the best Premium WordPress Themes that perfect for news, magazine, personal blog, etc. Visit our landing page to see all features & demos.
LEARN MORE »

Recent News

  • How to fix error: Failed to download metadata for repo ‘appstream’ on Centos 8 February 25, 2022
  • How to Fix MySQL Error “Plugin ‘InnoDB’ registration as a STORAGE ENGINE failed”? November 17, 2020
  • How to optimize Mysql or MariaDB November 3, 2020

Categories

  • Arch
  • Authentication
  • Backups
  • BSD
  • Centmin Mod
  • CentOS
  • Control Panels
  • CoreOS
  • CWP
  • Debian
  • Directadmin
  • Encryption
  • Fedora
  • Firewalls
  • Hocvps Script
  • Hosting providers
  • Kloxo-MR
  • Linux
  • Mitigations
  • Operating System
  • Plesk
  • Reviews
  • Securing VPS/Servers
  • Security Patches
  • SSL Certificates
  • Uncategorized
  • Upgrading
  • VPS/Servers management guides
  • Vulnerability Detection
  • Web servers software
  • Webhosting Control Panel

[mc4wp_form]

© 2018 JNews - City News Magazine WordPress theme. All rights belong to their respective owners.
JNews is a top selling 2018 WordPress News, Blog, Newspaper & Magazine Theme.

No Result
View All Result
  • Home

© 2023 JNews - Premium WordPress news & magazine theme by Jegtheme.