How to create hidden files in Linux?

前端 未结 8 871
悲哀的现实
悲哀的现实 2021-01-22 16:02

In my program, I have to make a file hidden in order to avoid removal or modification of the file.

PATH=/etc/
NAME = file

Is there a function in

8条回答
  •  深忆病人
    2021-01-22 16:41

    First: others argue with security arguments here. For those: Hidden files have nothing to do with security nor will it prevent somebody from deleting a file if he has propper permission and wants to do that.

    Hidden means only that tools like ls, bash globs or a graphical file managers will not display the files with their default settings. This can be useful to prevent from accidents (see explanation below) or just to keep directory listings more clean. You may try the commands ls -l $HOME and ls -al $HOME in order to see the differences.

    On GNU/Linux systems and UNIXs it is by convention that files which's name begins with a dot . will not being displayed by default meaning they are hidden. Like $HOME/.bashrc

    Solution: Prefix the file name with a dot:

    .file
    

    About accidents. Hiding a file can prevent you from accidently removing it when you type something like:

    rm *
    

    The glob above will not list hidden files so they won't get deleted.

提交回复
热议问题