LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This 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


Reply
  Search this Thread
Old 05-18-2016, 04:35 PM   #1
Abhiandy108
LQ Newbie
 
Registered: May 2016
Posts: 2

Rep: Reputation: Disabled
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?
 
Old 05-18-2016, 04:56 PM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 18,316

Rep: Reputation: 3878Reputation: 3878Reputation: 3878Reputation: 3878Reputation: 3878Reputation: 3878Reputation: 3878Reputation: 3878Reputation: 3878Reputation: 3878Reputation: 3878
Quote:
Originally Posted by Abhiandy108 View Post
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?
 
1 members found this post helpful.
Old 05-18-2016, 04:58 PM   #3
dolphin_oracle
Member
 
Registered: Dec 2013
Posts: 335

Rep: Reputation: Disabled
they are pointers, not really directories.

. is the current folder
.. is the parent folder
 
1 members found this post helpful.
Old 05-18-2016, 10:20 PM   #4
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,422

Rep: Reputation: 2815Reputation: 2815Reputation: 2815Reputation: 2815Reputation: 2815Reputation: 2815Reputation: 2815Reputation: 2815Reputation: 2815Reputation: 2815Reputation: 2815
The first thing you should do is look up what those directories are for, that way you would see why this is not an option.
 
Old 05-18-2016, 11:02 PM   #5
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,654

Rep: Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255
Quote:
Originally Posted by Abhiandy108 View Post
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).
 
1 members found this post helpful.
Old 05-18-2016, 11:22 PM   #6
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Debian, Mageia, and whatever VMs I happen to be playing with
Posts: 11,657
Blog Entries: 12

Rep: Reputation: 2894Reputation: 2894Reputation: 2894Reputation: 2894Reputation: 2894Reputation: 2894Reputation: 2894Reputation: 2894Reputation: 2894Reputation: 2894Reputation: 2894
As an aside,

Code:
cd ..   <--change directory to the parent directory
cd ../[some directory]  <--change directory to some other subdirectory of the parent directory
are most useful commands.

Last edited by frankbell; 05-18-2016 at 11:24 PM.
 
Old 05-18-2016, 11:43 PM   #7
JJJCR
Senior Member
 
Registered: Apr 2010
Posts: 1,120

Rep: Reputation: 190Reputation: 190
Cool

Quote:
Originally Posted by frankbell View Post
As an aside,

Code:
cd ..   <--change directory to the parent directory
cd ../[some directory]  <--change directory to some other subdirectory of the parent directory
are most useful commands.
just an addition:

cd - (goes back to previous directory)

cd ~ user directory


check out this link:

http://www.linuxnix.com/23-linux-cd-command-examples/
 
1 members found this post helpful.
Old 05-19-2016, 09:12 AM   #8
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 7,480

Rep: Reputation: 2376Reputation: 2376Reputation: 2376Reputation: 2376Reputation: 2376Reputation: 2376Reputation: 2376Reputation: 2376Reputation: 2376Reputation: 2376Reputation: 2376
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.
 
Old 05-19-2016, 10:06 AM   #9
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 8,491

Rep: Reputation: 2429Reputation: 2429Reputation: 2429Reputation: 2429Reputation: 2429Reputation: 2429Reputation: 2429Reputation: 2429Reputation: 2429Reputation: 2429Reputation: 2429
Quote:
Originally Posted by dolphin_oracle View Post
they are pointers, not really directories.

. is the current folder
.. is the parent folder
they are hardlinks to the current/parent folders, therefore real directories, not pointers.
 
Old 05-19-2016, 06:54 PM   #10
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,654

Rep: Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255
Quote:
Originally Posted by pan64 View Post
they are hardlinks to the current/parent folders, therefore real directories, not pointers.
All file names are only pointers to an inode.

It just so happens these pointers point to a directory.
 
Old 05-19-2016, 08:19 PM   #11
Keith Hedger
Senior Member
 
Registered: Jun 2010
Location: Wiltshire, UK
Distribution: Linux From Scratch, Slackware64, Partedmagic
Posts: 2,307

Rep: Reputation: 566Reputation: 566Reputation: 566Reputation: 566Reputation: 566Reputation: 566
Quote:
Originally Posted by pan64 View Post
they are hardlinks to the current/parent folders, therefore real directories, not pointers.
You can only hard link to a filr not a folder.
 
Old 05-19-2016, 08:28 PM   #12
Keith Hedger
Senior Member
 
Registered: Jun 2010
Location: Wiltshire, UK
Distribution: Linux From Scratch, Slackware64, Partedmagic
Posts: 2,307

Rep: Reputation: 566Reputation: 566Reputation: 566Reputation: 566Reputation: 566Reputation: 566
Quote:
Originally Posted by JJJCR View Post
just an addition:

cd - (goes back to previous directory)

cd ~ user directory


check out this link:

http://www.linuxnix.com/23-linux-cd-command-examples/
Never knew about using '-' for prvious directory I've been typing
Code:
cd $OLDPWD
for years, this is much quicker.
 
Old 05-19-2016, 10:49 PM   #13
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 7,480

Rep: Reputation: 2376Reputation: 2376Reputation: 2376Reputation: 2376Reputation: 2376Reputation: 2376Reputation: 2376Reputation: 2376Reputation: 2376Reputation: 2376Reputation: 2376
"Aye, gentlebeings, ye are but splitting hairs here ...!"
 
2 members found this post helpful.
Old 05-20-2016, 01:35 AM   #14
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 8,491

Rep: Reputation: 2429Reputation: 2429Reputation: 2429Reputation: 2429Reputation: 2429Reputation: 2429Reputation: 2429Reputation: 2429Reputation: 2429Reputation: 2429Reputation: 2429
Quote:
Originally Posted by jpollard View Post
All file names are only pointers to an inode.
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.

https://en.wikipedia.org/wiki/Hard_link

Quote:
Originally Posted by Keith Hedger View Post
You can only hard link to a fil not a folder.
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.
 
Old 05-20-2016, 09:38 AM   #15
onebuck
Moderator
 
Registered: Jan 2005
Location: Midwest USA, Central Illinois
Distribution: Slackware®
Posts: 12,601
Blog Entries: 25

Rep: Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981
Member response

Hi,

Welcome to LQ!

Quote:
Originally Posted by Abhiandy108 View Post
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?
Hope this helps.
Have fun & enjoy!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Command-line "find" to include hidden files and directories? sundialsvcs Linux - Newbie 2 10-14-2015 11:29 AM
Need solution to "failed to fork PTY" and "error creating the child process" problems Gnusboy Linux - Newbie 4 01-02-2010 08:54 AM
"more" and "less" piped commands : the mystery of the hidden stdin ! Gerbillaz Linux - General 12 06-01-2009 08:23 AM
Shell and batch operations on hidden files but not on ".." & "." danielsbrewer Linux - Software 5 09-12-2007 09:06 AM
K3b: - Howto re-dock "Directories" and "Contents" windows back into the main window? hagies Linux - Software 4 04-26-2006 09:38 AM


All times are GMT -5. The time now is 11:30 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration