Can i use one .htaccess file for different folders on Linux server

Solution 1:

Instead of putting the same file in all the different folders, you could restrict access to a common parent folder instead. E. g. like this:

/parent            <-- this folder is protected by .htaccess
/parent/admin1
/parent/admin2
/parent/admin3

This way you would only have to maintain a single .htaccess file.

A different would be linking the same .htaccess file into all three folders using symlinks (if you are on a *nix based OS / on Windows you might use junctions when on NTFS). But I am not sure if Apache allows symlinks as .htaccess files

Solution 2:

Yes, there are two options.

Option 1)
Have similar, or the same .htaccess files in every directory you wish to protect, which reference a single .htpassword file:

AuthUserFile /etc/httpd/.htpasswd
AuthName "Some Secret FIles"
AuthType Basic
require valid-user

Option 2) Symlink a single .htaccess file into every directory (This means if you change anything in your master .htaccess file all the symlinks will be updated