LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-22-2016, 12:45 AM   #1
vijay_18
LQ Newbie
 
Registered: Feb 2016
Posts: 1

Rep: Reputation: Disabled
Hide files from unauthorized users


Dear All,

I would like to know a thing in Unix. Can we hide a files from user who doesn't have any permissions(read/write/execute) under a directory?

I mean, by default a user can see all file names under any directory though he doesn't have read access. When he try to open/access the file only he will get error.

But i don't want such scenario in my Unix box. he shouldn't see any file names if he doesn't have any access.

Could anyone please explain how to achieve this?

Thank you in advance!!


Thanks,
Vijay
 
Old 02-22-2016, 01:01 AM   #2
descendant_command
Senior Member
 
Registered: Mar 2012
Posts: 1,464

Rep: Reputation: 379Reputation: 379Reputation: 379Reputation: 379
If they don't have read access to the dir, they can't get a list of the contents,
 
Old 02-22-2016, 01:33 AM   #3
JJJCR
Senior Member
 
Registered: Apr 2010
Posts: 1,205

Rep: Reputation: 197Reputation: 197
set proper access rights, no read permissions they can't see the file.

user is member of any group? and the group has read permissions that's why user can see or read the directory.
 
Old 02-22-2016, 08:55 AM   #4
TxLonghorn
Member
 
Registered: Feb 2004
Location: Austin Texas
Distribution: Mandrake 9.2
Posts: 655

Rep: Reputation: 212Reputation: 212Reputation: 212
I created a very unconventional way to completely hide a directory, and it works fine.
Create a small partition on your hard drive. (It can be VERY small - 1MB). (Or you can use an existing partition that is not normally mounted - like the / partition for a different OS.)
You can put a few files on there for someone to look at, so that it is not empty.
Let's say that partition is /dev/sda6
Then, if you want to completely hide the contents of the folder /home/yourusername/finances you would edit /etc/fstab and enter the line:
/dev/sda6 /home/yourusername/finances ext4 nodev,nosuid,relatime 0 2
Then when you reboot, your /dev/sda6 is mounted using the folder you want to hide (/home/yourusername/finances) as the mount point. So any attempt to access /home/yourusername/finances shows nothing except the files on /dev/sda6
The original files in /home/yourusername/finances are completely inaccessable by any user and invisible to any user. The only way they can be accessed is to unmount /dev/sda6 - then they magically re-appear.

You can do it the conventional way, as mentioned above:
Code:
sudo chmod go-rwx /home/yourusername/finances/*

Last edited by TxLonghorn; 02-22-2016 at 09:25 AM.
 
1 members found this post helpful.
Old 02-22-2016, 07:17 PM   #5
JJJCR
Senior Member
 
Registered: Apr 2010
Posts: 1,205

Rep: Reputation: 197Reputation: 197
Thumbs up

Quote:
Originally Posted by TxLonghorn View Post
I created a very unconventional way to completely hide a directory, and it works fine.
Create a small partition on your hard drive. (It can be VERY small - 1MB). (Or you can use an existing partition that is not normally mounted - like the / partition for a different OS.)
You can put a few files on there for someone to look at, so that it is not empty.
Let's say that partition is /dev/sda6
Then, if you want to completely hide the contents of the folder /home/yourusername/finances you would edit /etc/fstab and enter the line:
/dev/sda6 /home/yourusername/finances ext4 nodev,nosuid,relatime 0 2
Then when you reboot, your /dev/sda6 is mounted using the folder you want to hide (/home/yourusername/finances) as the mount point. So any attempt to access /home/yourusername/finances shows nothing except the files on /dev/sda6
The original files in /home/yourusername/finances are completely inaccessable by any user and invisible to any user. The only way they can be accessed is to unmount /dev/sda6 - then they magically re-appear.

You can do it the conventional way, as mentioned above:
Code:
sudo chmod go-rwx /home/yourusername/finances/*
wow..creative.. but as you said one line can also do the job.
 
Old 02-22-2016, 07:51 PM   #6
yancek
LQ Guru
 
Registered: Apr 2008
Distribution: PCLinux, Slackware
Posts: 7,217

Rep: Reputation: 1348Reputation: 1348Reputation: 1348Reputation: 1348Reputation: 1348Reputation: 1348Reputation: 1348Reputation: 1348Reputation: 1348Reputation: 1348
Quote:
Can we hide a files from user who doesn't have any permissions(read/write/execute) under a directory?
If you are referring simply to a directory and not a partition, change the owner to the user you want to have access and set the permissions to 700. root user will still have access but others will get permission denied.
 
Old 02-22-2016, 09:18 PM   #7
BW-userx
Senior Member
 
Registered: Sep 2013
Location: MID-SOUTH USA
Distribution: Void Linux / Slackware 14.2
Posts: 4,124

Rep: Reputation: 719Reputation: 719Reputation: 719Reputation: 719Reputation: 719Reputation: 719Reputation: 719
you,can,also,for.added,proection,just,put,a,dot,in,front,of,the,directoryNa..e,and,or,
file,na..e,then,by,co..ention,they,will,beco..e,in..isable,until,one,askes,to,show,
hidden,files,this,is,added,to,the,pe..issions,to,the,files,and,or,directory,one,needs,to,..odify.
 
Old 02-22-2016, 10:11 PM   #8
robert.coder
LQ Newbie
 
Registered: Feb 2016
Posts: 4

Rep: Reputation: Disabled
I heard this episode awhile back on HPR on hiding your files outside the filesystem using the dd command.

http://hackerpublicradio.org/eps.php?id=1693

Not the most intuitive way, but an interesting idea to try.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Shell script to get email when unauthorized users on our network ananthkadalur Linux - Newbie 6 09-19-2011 11:57 PM
Security - New Users added to my server - Unauthorized Jack_Fedora Linux - Security 1 05-13-2008 04:06 PM
Hide files users do not have access to vonedaddy Linux - Newbie 5 01-05-2008 02:29 AM
to hide users from 'net' Ygrex Linux - Networking 0 11-24-2005 11:20 AM
Is it possible to hide users from the 'who' and 'w' commands? BxBoy General 8 03-30-2003 01:33 AM


All times are GMT -5. The time now is 12:39 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration