1

I am new in Linux and Ubuntu. I have no idea if it's possible. I want to protect some files inside /etc/somefolder/somefiles/. I want to protect files so that nobody can access these files or folders without me even not root user. If anybody wants to change anything they should contact me.

is this possible?

  • 1
    /etc would be the wrong place to do this. If you want to encrypt stuff, use the standard Ubuntu encryption tools. – heynnema Jun 16 at 2:20
  • Encrypt and keep on USB key that is in your pocket. Then you'll know when anyone tries to access it without permission. – xiota Jun 16 at 2:33
0

I want to protect files so that nobody can access these files or folders without me even not root user.

No. The root user can do anything to your system.

You, as a not root user are not allowed to do changes to the system outside your /home/ unless the admin gave you permission to do so.

How To Password Protect or Encrypt Files Inside /etc/somefolder

That depends on what "somefolder" is. If this is a generic Linux folder: no. There is no generic method for the system to ask for a password and the system will always expect files to be accessible.

As an example: mysql uses /etc/my.cnf for its settings and would not understand why it can not open the file. It would error out or try to find a my.cnf elsewhere on the system.

If "somefolder" is part of your own software then yes it is possible. pgp is the command to use:

GPG(1)                       GNU Privacy Guard 2.2                      GPG(1)

NAME
       gpg - OpenPGP encryption and signing tool

SYNOPSIS
       gpg [--homedir dir] [--options file] [options] command [args]

DESCRIPTION
       gpg  is the OpenPGP part of the GNU Privacy Guard (GnuPG). It is a tool
       to provide digital encryption and signing services  using  the  OpenPGP
       standard.  gpg  features  complete key management and all the bells and
       whistles you would expect from a full OpenPGP implementation.

From command line go to the file you want to protect and do

gpg -c {file}

where {file} is your file. Enter a password for the file. It will ask for the password twice. You would then need to alter your software to ask for the password to open the file and make it accessible.

This only works for files you have access to. A normal user will not be able to do this on files in /etc/ if the admin secured the files as should be done. If you own a file in /etc/ as a not admin user you can.

It would be smart to have an unprotected version of the file somewhere else (on a USB or google drive) If you do forget the password the file is lost forever.

  • hi @Rinzwind thank you for guideline I will try that. – Prince John Jun 17 at 3:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.