I have my computer set up to use the same home folder / user profile for Linux and Windows. As a consequence I have files like NTUSER.DAT that are hidden on Windows showing up when I ls and in my file manager. Is there any way to make Linux hide the hidden files?
Asked
Active
Viewed 6,322 times
12
-
You have a secondary consequence: Using NTFS for your Linux home directory will break Linux permissions because NTFS does not support them. – Thomas Ward Dec 27 '15 at 03:52
1 Answers
21
Add the files you want to hide to a file named .hidden with 1 file per line inside the directory those files are. Somehing like ls {files} >.hidden will work to quickly do this.
You can hide files looking from Windows with
C:\>attrib +h D:\*.hidden /S(this will hide the.hiddenfile from the previous method). The directory I assumed D:.You can hide these files from
lson Linux by adding this into your~./bashrc:ls () { if [ -f .hidden ]; then declare GLOBIGNORE="$GLOBIGNORE:.*:$(tr '\n' ':' < .hidden)" ls "$@" fi }This will hide the files when using
lsandlsonly. It also assumes you do not already have an alias forls.ls -lwill still show them but that is just another alias.
The last command I found on superuser. Please upvote that answer ;)
-
3Hmmm... if I understand well, the OP is thinking using an NTFS filesystem as home dir... they should read your answer here: http://askubuntu.com/questions/330356/is-it-bad-to-have-home-on-an-ntfs-partition – Rmano Dec 26 '15 at 12:32
-
-
For nautilus yes, only the 1st part is needed for that. The 3rd part is for command line. Not sure about other managers though. The .hidden method might be Nautilus feature. – Rinzwind Dec 26 '15 at 20:48
-
-
@Rinzwind It causes other problems though: if you try to run
ls -lbashpasses the-lflag to the lasexport:( – 0x539 Dec 28 '15 at 15:48 -
“please upvote” ITYM downvote, that code didn't have a chance of doing anything useful except when
lswas called with no argument in a directory containing a.hiddenfile and the code to restoreGLOBIGNOREdidn't work at all. – Gilles 'SO- stop being evil' Feb 26 '17 at 21:13 -
This sounded interesting...until I realized that executing the Windows command into the Linux WSL home folder is not possible: it's part of the linux image and is not visibile from outside. You can do the opposite with /mnt/C, but it doesn't solve the problem :Y – funder7 Dec 05 '22 at 17:02
-