Trying to remove current directory using rmdir

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP












0














I created a directory dir at Desktop and then i keyed in cd dir so as to make dir as my current directory and then i typed in the terminal rmdir /home/user_name/Desktop/dir from the dir directory itself, and surprisingly this removed the dir directory but when i checked my current working directory using pwd it was still showing that i am in the dir directory,So my question is that how it is possible that i am working in a directory that has already been deleted.i am currently working on Ubuntu










share|improve this question





















  • Try and create a file in that directory and you will see it doesn't actually exist. Also if you do ls -la you will notice that . and .. no longer exist. I'm not sure what you expected to happen but to me this doesn't seem like an issue at all. Do you want it to kick you back a directory? Automagically move you to your home directory? Complain that you can't delete a directory that you are currently working from? I don't think any of those would be better or worse than the current behavior.
    – Jesse_b
    Dec 19 '18 at 18:46










  • my issue is that rmdir is simply deleting a directory(on which i am currently working) and it does not even give a error,you are absolutely right that no new file or directory can be made through this directory now but still on using pwd it is still showing a directory that actually do not exist in the file system
    – Noshiii
    Dec 19 '18 at 18:51










  • What are you suggesting should have happened? rmdir will only complain if the directory is non-empty. It's akin to deleting a file form the filesystem that a program is currently reading from or writing to. No issues.
    – Kusalananda
    Dec 19 '18 at 19:16











  • All of this, including the behaviour of pwd, is already covered at unix.stackexchange.com/questions/434417 .
    – JdeBP
    Dec 19 '18 at 19:21















0














I created a directory dir at Desktop and then i keyed in cd dir so as to make dir as my current directory and then i typed in the terminal rmdir /home/user_name/Desktop/dir from the dir directory itself, and surprisingly this removed the dir directory but when i checked my current working directory using pwd it was still showing that i am in the dir directory,So my question is that how it is possible that i am working in a directory that has already been deleted.i am currently working on Ubuntu










share|improve this question





















  • Try and create a file in that directory and you will see it doesn't actually exist. Also if you do ls -la you will notice that . and .. no longer exist. I'm not sure what you expected to happen but to me this doesn't seem like an issue at all. Do you want it to kick you back a directory? Automagically move you to your home directory? Complain that you can't delete a directory that you are currently working from? I don't think any of those would be better or worse than the current behavior.
    – Jesse_b
    Dec 19 '18 at 18:46










  • my issue is that rmdir is simply deleting a directory(on which i am currently working) and it does not even give a error,you are absolutely right that no new file or directory can be made through this directory now but still on using pwd it is still showing a directory that actually do not exist in the file system
    – Noshiii
    Dec 19 '18 at 18:51










  • What are you suggesting should have happened? rmdir will only complain if the directory is non-empty. It's akin to deleting a file form the filesystem that a program is currently reading from or writing to. No issues.
    – Kusalananda
    Dec 19 '18 at 19:16











  • All of this, including the behaviour of pwd, is already covered at unix.stackexchange.com/questions/434417 .
    – JdeBP
    Dec 19 '18 at 19:21













0












0








0







I created a directory dir at Desktop and then i keyed in cd dir so as to make dir as my current directory and then i typed in the terminal rmdir /home/user_name/Desktop/dir from the dir directory itself, and surprisingly this removed the dir directory but when i checked my current working directory using pwd it was still showing that i am in the dir directory,So my question is that how it is possible that i am working in a directory that has already been deleted.i am currently working on Ubuntu










share|improve this question













I created a directory dir at Desktop and then i keyed in cd dir so as to make dir as my current directory and then i typed in the terminal rmdir /home/user_name/Desktop/dir from the dir directory itself, and surprisingly this removed the dir directory but when i checked my current working directory using pwd it was still showing that i am in the dir directory,So my question is that how it is possible that i am working in a directory that has already been deleted.i am currently working on Ubuntu







ubuntu directory directory-structure mkdir pwd






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Dec 19 '18 at 18:42









Noshiii

2717




2717











  • Try and create a file in that directory and you will see it doesn't actually exist. Also if you do ls -la you will notice that . and .. no longer exist. I'm not sure what you expected to happen but to me this doesn't seem like an issue at all. Do you want it to kick you back a directory? Automagically move you to your home directory? Complain that you can't delete a directory that you are currently working from? I don't think any of those would be better or worse than the current behavior.
    – Jesse_b
    Dec 19 '18 at 18:46










  • my issue is that rmdir is simply deleting a directory(on which i am currently working) and it does not even give a error,you are absolutely right that no new file or directory can be made through this directory now but still on using pwd it is still showing a directory that actually do not exist in the file system
    – Noshiii
    Dec 19 '18 at 18:51










  • What are you suggesting should have happened? rmdir will only complain if the directory is non-empty. It's akin to deleting a file form the filesystem that a program is currently reading from or writing to. No issues.
    – Kusalananda
    Dec 19 '18 at 19:16











  • All of this, including the behaviour of pwd, is already covered at unix.stackexchange.com/questions/434417 .
    – JdeBP
    Dec 19 '18 at 19:21
















  • Try and create a file in that directory and you will see it doesn't actually exist. Also if you do ls -la you will notice that . and .. no longer exist. I'm not sure what you expected to happen but to me this doesn't seem like an issue at all. Do you want it to kick you back a directory? Automagically move you to your home directory? Complain that you can't delete a directory that you are currently working from? I don't think any of those would be better or worse than the current behavior.
    – Jesse_b
    Dec 19 '18 at 18:46










  • my issue is that rmdir is simply deleting a directory(on which i am currently working) and it does not even give a error,you are absolutely right that no new file or directory can be made through this directory now but still on using pwd it is still showing a directory that actually do not exist in the file system
    – Noshiii
    Dec 19 '18 at 18:51










  • What are you suggesting should have happened? rmdir will only complain if the directory is non-empty. It's akin to deleting a file form the filesystem that a program is currently reading from or writing to. No issues.
    – Kusalananda
    Dec 19 '18 at 19:16











  • All of this, including the behaviour of pwd, is already covered at unix.stackexchange.com/questions/434417 .
    – JdeBP
    Dec 19 '18 at 19:21















Try and create a file in that directory and you will see it doesn't actually exist. Also if you do ls -la you will notice that . and .. no longer exist. I'm not sure what you expected to happen but to me this doesn't seem like an issue at all. Do you want it to kick you back a directory? Automagically move you to your home directory? Complain that you can't delete a directory that you are currently working from? I don't think any of those would be better or worse than the current behavior.
– Jesse_b
Dec 19 '18 at 18:46




Try and create a file in that directory and you will see it doesn't actually exist. Also if you do ls -la you will notice that . and .. no longer exist. I'm not sure what you expected to happen but to me this doesn't seem like an issue at all. Do you want it to kick you back a directory? Automagically move you to your home directory? Complain that you can't delete a directory that you are currently working from? I don't think any of those would be better or worse than the current behavior.
– Jesse_b
Dec 19 '18 at 18:46












my issue is that rmdir is simply deleting a directory(on which i am currently working) and it does not even give a error,you are absolutely right that no new file or directory can be made through this directory now but still on using pwd it is still showing a directory that actually do not exist in the file system
– Noshiii
Dec 19 '18 at 18:51




my issue is that rmdir is simply deleting a directory(on which i am currently working) and it does not even give a error,you are absolutely right that no new file or directory can be made through this directory now but still on using pwd it is still showing a directory that actually do not exist in the file system
– Noshiii
Dec 19 '18 at 18:51












What are you suggesting should have happened? rmdir will only complain if the directory is non-empty. It's akin to deleting a file form the filesystem that a program is currently reading from or writing to. No issues.
– Kusalananda
Dec 19 '18 at 19:16





What are you suggesting should have happened? rmdir will only complain if the directory is non-empty. It's akin to deleting a file form the filesystem that a program is currently reading from or writing to. No issues.
– Kusalananda
Dec 19 '18 at 19:16













All of this, including the behaviour of pwd, is already covered at unix.stackexchange.com/questions/434417 .
– JdeBP
Dec 19 '18 at 19:21




All of this, including the behaviour of pwd, is already covered at unix.stackexchange.com/questions/434417 .
– JdeBP
Dec 19 '18 at 19:21










1 Answer
1






active

oldest

votes


















3














If you want to understand why this is, you need to understand the difference between files and inodes. rm, rmdir and mv all take action on the inodes describing the file/directory, not the actual file. If you have a file/dir open (e.g. by being in the directory), the inode information is removed, but the actual data file associated with the file/dir is not removed until all file handles pointing to it are closed. So, when you "cd .." the filesystem can swoop in and remove the directory and all its contents.



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



http://www.grymoire.com/Unix/Inodes.html






share|improve this answer




















  • that is the exact explanation that i wanted ,thank you so much
    – Noshiii
    Dec 19 '18 at 19:18










Your Answer








StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f489978%2ftrying-to-remove-current-directory-using-rmdir%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









3














If you want to understand why this is, you need to understand the difference between files and inodes. rm, rmdir and mv all take action on the inodes describing the file/directory, not the actual file. If you have a file/dir open (e.g. by being in the directory), the inode information is removed, but the actual data file associated with the file/dir is not removed until all file handles pointing to it are closed. So, when you "cd .." the filesystem can swoop in and remove the directory and all its contents.



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



http://www.grymoire.com/Unix/Inodes.html






share|improve this answer




















  • that is the exact explanation that i wanted ,thank you so much
    – Noshiii
    Dec 19 '18 at 19:18















3














If you want to understand why this is, you need to understand the difference between files and inodes. rm, rmdir and mv all take action on the inodes describing the file/directory, not the actual file. If you have a file/dir open (e.g. by being in the directory), the inode information is removed, but the actual data file associated with the file/dir is not removed until all file handles pointing to it are closed. So, when you "cd .." the filesystem can swoop in and remove the directory and all its contents.



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



http://www.grymoire.com/Unix/Inodes.html






share|improve this answer




















  • that is the exact explanation that i wanted ,thank you so much
    – Noshiii
    Dec 19 '18 at 19:18













3












3








3






If you want to understand why this is, you need to understand the difference between files and inodes. rm, rmdir and mv all take action on the inodes describing the file/directory, not the actual file. If you have a file/dir open (e.g. by being in the directory), the inode information is removed, but the actual data file associated with the file/dir is not removed until all file handles pointing to it are closed. So, when you "cd .." the filesystem can swoop in and remove the directory and all its contents.



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



http://www.grymoire.com/Unix/Inodes.html






share|improve this answer












If you want to understand why this is, you need to understand the difference between files and inodes. rm, rmdir and mv all take action on the inodes describing the file/directory, not the actual file. If you have a file/dir open (e.g. by being in the directory), the inode information is removed, but the actual data file associated with the file/dir is not removed until all file handles pointing to it are closed. So, when you "cd .." the filesystem can swoop in and remove the directory and all its contents.



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



http://www.grymoire.com/Unix/Inodes.html







share|improve this answer












share|improve this answer



share|improve this answer










answered Dec 19 '18 at 19:11









Ian McGowan

53928




53928











  • that is the exact explanation that i wanted ,thank you so much
    – Noshiii
    Dec 19 '18 at 19:18
















  • that is the exact explanation that i wanted ,thank you so much
    – Noshiii
    Dec 19 '18 at 19:18















that is the exact explanation that i wanted ,thank you so much
– Noshiii
Dec 19 '18 at 19:18




that is the exact explanation that i wanted ,thank you so much
– Noshiii
Dec 19 '18 at 19:18

















draft saved

draft discarded
















































Thanks for contributing an answer to Unix & Linux Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f489978%2ftrying-to-remove-current-directory-using-rmdir%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown






Popular posts from this blog

How to check contact read email or not when send email to Individual?

Displaying single band from multi-band raster using QGIS

How many registers does an x86_64 CPU actually have?