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.
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 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 the mv 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
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
The author is the creator of nixCraft and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.