Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 620
  • Last Modified:

how to hide a file and directory in linux?

how to hide a file and directory in linux? for administrative  purpose i want to hide a file in /root/bin/
that i written in that directory so that no one can see its existence but only i can run it by that name?
0
b123coder
Asked:
b123coder
  • 2
  • 2
1 Solution
 
willy134Commented:
preceed the filename with a dot like .bash_profile or .Desktop

to see the files you need to do a ls -a

direcotries are the same
0
 
willy134Commented:
also change the permissions on the file to be rwx------
that way only the owner can run the file

to do that do a chmod
chmod 700 .myhiddenfile


(again it works the same for directories.
0
 
paullamhkgCommented:
well for a non Unix/Linux users yes they will not see the files/folder with a dot, but if the user(s) user ls -al the dotted file(s)/folder(s) will come out and willy give you a good hint on disallow the other users to access, I think this is a good way.

also, you can thinking of using the chroot, which will lock up the login users only get into their own folder(s) and can't get into other folder(s), for more detail abt chroot check here http://www.tjw.org/chroot-login-HOWTO/
0
 
sdwoodCommented:
Convention wouldn't dictate prepending a script file with a dot, which are normally reserved for configuration, cache, and temporary files.  Dots are for convenience, not security.  People will always be able to see it using 'ls -a' which many users have as an alias for 'ls' anyhow.  In the end, prepending a dot will have little effect other than breaking convention.

You can't really "hide" the existence of a file in any directory that a user has read access to.  

You are best to:
a) Prevent them from reading the contents of the script by setting the permissions on the file to rwx------ as willy is suggesting,
    or
b) truly hide the -existence- of the file from all users except those in the root group by restricting access to the entire directory with:

  chown root:root /root/bin
  chmod 750 /root/bin

(700 if you want to keep other root-level accounts out as well)
0
 
paullamhkgCommented:
Thanks sdwood to support willy and my suggestion and explain it in more detail :)
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now