Solved

how to hide a file and directory in linux?

Posted on 2004-04-01
5
560 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
ID: 10733381
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
ID: 10733399
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
ID: 10737731
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
ID: 10737848
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
ID: 10738104
Thanks sdwood to support willy and my suggestion and explain it in more detail :)
0

Featured Post

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is the error message I got (CODE) Error caused by incompatible libmp3lame 3.98-2 with ffmpeg I've googled this error message and found out sometimes it attaches this note "can be treated with downgrade libmp3lame to version 3.97 or 3.98" …
SSH (Secure Shell) - Tips and Tricks As you all know SSH(Secure Shell) is a network protocol, which we use to access/transfer files securely between two networked devices. SSH was actually designed as a replacement for insecure protocols that sen…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
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.

867 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

19 Experts available now in Live!

Get 1:1 Help Now