Solved

how to hide a file and directory in linux?

Posted on 2004-04-01
5
570 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Internal CA server 6 134
Disabling security updates Ubuntu 3 68
exchange, squid, proxy, linux 6 89
need a help to fix one if else shell script issue 6 33
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 …
Fine Tune your automatic Updates for Ubuntu / Debian
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
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.

710 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