Find the answer to your Linux question:
Results 1 to 9 of 9
Hi, I need to hide a file from the directory but when i use the command ls -a the file should not be shown in the hidden files list.is there ...
  1. #1
    Just Joined!
    Join Date
    Feb 2010
    Posts
    1

    Need script for hiding the file

    Hi,
    I need to hide a file from the directory but when i use the command ls -a the file should not be shown in the hidden files list.is there any script to perform that task?


    Thanks in advance

  2. #2
    Just Joined!
    Join Date
    Nov 2008
    Posts
    29
    Not to my knowledge. But tell us why you want to hide a file in the first place? Can you set permissions so that it is not readable by most users?

  3. #3
    Linux Guru Irithori's Avatar
    Join Date
    May 2009
    Location
    Munich
    Posts
    2,096
    I am not 100% sure if I understood correctly.

    Are you saying, that dot files do not offer enough hiding for you?
    Question would be, what is the purpose of hiding here?

    Regular dot files are used for config storing, maintained (mainly) by their applications.
    So the hiding of dotfiles and directories is convenient for the user to keep directory listings short and focused on datafiles.
    But sometimes you want/need to see and edit them, thus ls -a will show dot files.

    If you have reason to *really* not show some files, the fuse overlay cmdfs might be usefull:
    http://cmdfs.sourceforge.net/
    You must always face the curtain with a bow.

  4. #4
    Linux Guru Irithori's Avatar
    Join Date
    May 2009
    Location
    Munich
    Posts
    2,096
    and yes, setting permissions as guus.leeuw.jr suggested, might also be effective.
    You must always face the curtain with a bow.

  5. #5
    Linux Guru Lazydog's Avatar
    Join Date
    Jun 2004
    Location
    The Keystone State
    Posts
    2,281
    I do not believe there is a way to stop the listed on any hidden file when using the '-a' for that is what it is designed to do, list all files. Changing the permissions will also no change this. For example in /etc/ do 'ls -al' you will see that there are files with root only access that are still displayed.

    Regards
    Robert

    Linux
    The adventure of a life time.

    Linux User #296285
    Get Counted

  6. #6
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
    Posts
    8,974
    AFAIK, the only way to hide files listed in a directory entirely is to make the directory unreadable by anyone other than the owner and/or group. IE: chmod dirname o=-wrx will block access to a directory to all but the owner and group that the directory belongs to. Basically, none of the files there will be visible to "others".
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  7. #7
    Linux Guru Irithori's Avatar
    Join Date
    May 2009
    Location
    Munich
    Posts
    2,096
    Lazydog: My thought was: no permission, no access: content hidden
    But of course, you are right.
    Setting permissions on a file wont hide it.

    Ruberman: There is another way, the above mentioned fuse module
    http://cmdfs.sourceforge.net/
    Basically: If a file does not meet certain criteria, it is not shown in the fusemounted directory.

    But I admit, this might be a bit overkill
    You must always face the curtain with a bow.

  8. #8
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
    Posts
    8,974
    Yes, a fuse-based virtual file system would work, though the cmdfs that Irithori mentions only filters based on file names, not on the user trying to view the directory, which is what I think rajkumarlynx is trying to do. However, the source for cmdfs would be a good place to start to create a filtering file system with those characteristics.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  9. #9
    Linux Enthusiast meton_magis's Avatar
    Join Date
    Oct 2006
    Location
    arizona
    Posts
    665
    This makes me think of when I .... had a friend who would hide files in c:\windows\system32\temp\hidden\dont\look\here\stu ff.jpg .... I mean ... stuff. extension.

    make it so people couldn't find it and .... determine what it was


    Then I .... told my friend .... he could tar the files up on linux, and run them through gpg so that they're encrypted .....
    .....
    ........
    .........


    Suckers, they'll never figure out what I'm talking about ....
    New to the internet, technical forums, or the hacker / open source community??
    Read this to learn good posting habits http://www.catb.org/~esr/faqs/smart-questions.html

    RHCE for RHEL version 5
    RHCT for RHEL version 4

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...