未加星标

How to hide files and directories in Linux

字体大小 | |
[系统(linux) 所属分类 系统(linux) | 发布者 店小二05 | 时间 2019 | 作者 红领巾 ] 0人收藏点击收藏

I am a new linux user. How do I hide files and directories in Linux operating systems using the command line interface?

Introduction In Linux and Unix-like systems, if a file or directory (folder) name starts with a period ( . ), then the file becomes hidden by default. To see all hidden files in Linux run ls -al command

. This page shows how to hide files in Linux using various methods.

What is the difference between a hidden file and an ordinary file in Linux?

The main difference between a hidden file and an ordinary file is that the file name of a hidden file starts with a period or dot ( . ). Often known as dot files in Linux. The dot file is not a security feature. It is for your convenience and to reduce clutter in your home directory.

How to view hidden files in Linux

You can pass the -a options to the ls command to see hidden file:

ls -a ls -al ls -al | more ls -al | grep 'bash'


How to hide files and directories in Linux
Linux / Unix: Find And List All Hidden Files Recursively How do I hide files and directories in Linux?

To hide a file or directory in Linux, rename it with a period ( . ) at the start of its name using themv command. Say, you need to hide a file named foo.txt, run:

mv foo.txt .foo.txt

Verify by running the ls command:

ls ls -al

Let us create a new file in Linux named foo.txt for demo purpose $ echo "Isolation doesn't bother me at all. It gives me a sense of security."> foo.txt $ ls $ mv foo.txt .foo.txt $ ls $ ls -al
How to hide files and directories in Linux
Click to enlarge Look ma files are hidden in GUI file managers too

Open folder or directories in your GUI file manager. Press CTRL+H to see or hide hidden files along with regular files.


How to hide files and directories in Linux
Show or hide all hidden files by pressing CTRL+H in Linux How do I hide folders/directories in Linux?

Use themv command by adding a . at the beginning of the directory name:

mv -v my-folder .my-folder mv -v dir1 .dir1 mv -v dir2 .newdir2

How do I unhide a file or folder in Linux?

To unhide a file called .foo.txt, rename it to foo.txt i.e. remove a dot/period . at the beginning of its name:

ls -la mv -v .foo.txt foo.txt mv -v .dir1 dir1 mv -v .newdir2 dir2 ls -l

How to hide and password protect my files

To encrypt a single file, use the gpg command as follows:

gpg -c foo.txt

Now hide it:

mv -v foo.txt.gpg .foo.txt.gpg

Delete the original file in Linux using the rm command:

rm foo.txt ls -la
How to hide files and directories in Linux

To decrypt file use the gpg command again as follow:

gpg --output foo.txt --decrypt .foo.txt.gpg rm .foo.txt.gpg

For more information see my post “ Linux Encrypt And Decrypt Files With A Password “.

How to compress and protect a folder in Linux using a password

Use the tar command to compress the whole folder named dir1 in the current working directory:

tar -cz dir1 | openssl enc -aes-256-cbc -e > dir1.tar.gz.enc

Hide it:

mv -v dir1.tar.gz.enc .dir1.tar.gz.enc

Delete the original directory in Linux using the rm command:

rm -rf dir1

To decrypt, run:

openssl enc -aes-256-cbc -d -in dir1.tar.gz.enc | tar xz
How to hide files and directories in Linux

Related How do I Compress a Whole Linux or UNIX Directory?

Conclusion

This page demonstrated various ways to hide and use a password to protect files in Linux.

本文系统(linux)相关术语:linux系统 鸟哥的linux私房菜 linux命令大全 linux操作系统

分页:12
转载请注明
本文标题:How to hide files and directories in Linux
本站链接:https://www.codesec.net/view/628078.html


1.凡CodeSecTeam转载的文章,均出自其它媒体或其他官网介绍,目的在于传递更多的信息,并不代表本站赞同其观点和其真实性负责;
2.转载的文章仅代表原创作者观点,与本站无关。其原创性以及文中陈述文字和内容未经本站证实,本站对该文以及其中全部或者部分内容、文字的真实性、完整性、及时性,不作出任何保证或承若;
3.如本站转载稿涉及版权等问题,请作者及时联系本站,我们会及时处理。
登录后可拥有收藏文章、关注作者等权限...
技术大类 技术大类 | 系统(linux) | 评论(0) | 阅读(25)