Solved

how to hide a file and directory in linux?

Posted on 2004-04-01
5
557 Views
Last Modified: 2013-12-15
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
Comment
Question by:b123coder
  • 2
  • 2
5 Comments
 
LVL 5

Expert Comment

by:willy134
Comment Utility
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
 
LVL 5

Accepted Solution

by:
willy134 earned 30 total points
Comment Utility
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
 
LVL 12

Expert Comment

by:paullamhkg
Comment Utility
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
 

Expert Comment

by:sdwood
Comment Utility
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
 
LVL 12

Expert Comment

by:paullamhkg
Comment Utility
Thanks sdwood to support willy and my suggestion and explain it in more detail :)
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Daily system administration tasks often require administrators to connect remote systems. But allowing these remote systems to accept passwords makes these systems vulnerable to the risk of brute-force password guessing attacks. Furthermore there ar…
Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now