[SOLVED] Creating new directory without including "." and ".." hidden directories
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Creating new directory without including "." and ".." hidden directories
I was trying to remove the "." and ".." directories within any random directory. Got an error :refusing to remove "." and ".." directories.
So if we can't remove these 2 hidden directories is there a way to create a directory that doesn't contain these 2 directories?
I was trying to remove the "." and ".." directories within any random directory. Got an error :refusing to remove "." and ".." directories. So if we can't remove these 2 hidden directories is there a way to create a directory that doesn't contain these 2 directories?
No, you can't, ever. You can HIDE them in a list or for your program, but they'll always be there. Is there some reason, or some goal you're trying to accomplish?
I was trying to remove the "." and ".." directories within any random directory. Got an error :refusing to remove "." and ".." directories.
You can't remove them. The directory heirarchy is a tree structure. The . entry points to the current directory, the .. entry points to its parent directory.
Quote:
So if we can't remove these 2 hidden directories is there a way to create a directory that doesn't contain these 2 directories?
Not really. You could use a Windows directory structure --- FAT/VFAT don't have these on disk. They only exist when the filesystem is mounted, but the "." and ".." directories are simulated only as memory structures to allow the standard tools/commands/programs to work.
Of course, using non-native filesystems have security problems, and usage (FAT/VFAT don't support user identity, and NTFS doesn't either - users have to be faked into a Windows identity... or it won't be Windows compatible).
Also, you should know that these two "directory entries" never consume any actual resources. By definition, every directory has a relative-path entry pointing to itself and pointing to its parent. These are furnished directly by the filesystem.
Yes, "hidden files" customarily begin with a period, and those are real.
And hardlink means several directory entries point to the same inode.
The entries . and .. uses the same pointers (inodes) as the corresponding entries in the parent directory, so these are hardlinks.
Yes, folders are not allowed to be hardlinked by any user (including root), but it does not mean it is not possible at all, just not allowed because of the difficulties it may cause. The only "exception" is . and .. which are created automatically.
I was trying to remove the "." and ".." directories within any random directory. Got an error :refusing to remove "." and ".." directories.
So if we can't remove these 2 hidden directories is there a way to create a directory that doesn't contain these 2 directories?
You have some great replies from fellow LQ members. I suggest that you look at: Linux File System
Especially within the above linked information for detailed filesystem information;
Quote:
Understanding UNIX/Linux file system: Part I <- Understanding Linux filesystems Part II <- Understanding Linux superblock Part III <- An example of Surviving a Linux Filesystem Failures Part IV <- Understanding filesystem Inodes Part V <- Understanding filesystem directories Part VI <- Understanding UNIX/Linux symbolic (soft) and hard links Part VII <- Why isn’t it possible to create hard links across file system boundaries?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.