Solved

how to hide a file and directory in linux?

Posted on 2004-04-01
5
575 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Little introduction about CP: CP is a command on linux that use to copy files and folder from one location to another location. Example usage of CP as follow: cp /myfoder /pathto/destination/folder/ cp abc.tar.gz /pathto/destination/folder/ab…
Linux users are sometimes dumbfounded by the severe lack of documentation on a topic. Sometimes, the documentation is copious, but other times, you end up with some obscure "it varies depending on your distribution" over and over when searching for …
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.:
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses

628 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