How do I cd down one level ?

I wouldn't say it 'fails' so much as it 'does what is intended'. It doesn't throw an error and leaves you in the current directory. As you know, the . is the current directory. It's just as unuseful as just using the cd command without any directory specified.
No I mean, when the directory you're in, no longer exists. As something that can happen with removable disks


But on a side note, I think "cd" without parameters goes to your home directory. My memory isn't perfect but I think that is what happens when you run : cd $thisisanemptyvariable
and you haven't filled that variable
 


No I mean, when the directory you're in, no longer exists. As something that can happen with removable disks


But on a side note, I think "cd" without parameters goes to your home directory. My memory isn't perfect but I think that is what happens when you run : cd $thisisanemptyvariable
and you haven't filled that variable

Right. That's what that does. In my head I recalled it just sitting in the same directory.

Meh... At the end of the day, we/re kinda beating a dead horse. The OP's information was shared within the first half dozen replies. I'm not sure what prompted the extra commentary.
 
Depends how strict you are about off-topic

Not very.

I'm a horrible mod.

I'm generally okay with it - once OP has been helped and as long as it's tangentially related. Sometimes, that 'off-topic' stuff leads to more information available to the OP.

I frown on it a bit when the thread is old. By then, OP (who probably hasn't been back since) doesn't really need the email notifications, nor do all the thread participants.
 
Not very.

I'm a horrible mod.

I'm generally okay with it - once OP has been helped and as long as it's tangentially related. Sometimes, that 'off-topic' stuff leads to more information available to the OP.

I frown on it a bit when the thread is old. By then, OP (who probably hasn't been back since) doesn't really need the email notifications, nor do all the thread participants.

I was never mod (of a forum) but I can feel the pain there.
If you would close the thread, nobody can ever reply anymore ... Not to post crap, but also not to post anything interesting (if that would still be an option). And even the threadstarter can't. So, that's not so good either.
I hate it when I read a thread, find the answers not correct or complete, and then unable to add any post because the thread is closed.
So, I feel the pain ... that's why I'm never a forum mod, I have enough problems in my profession. Which is IT related, obviously. And maybe even admin. But, something else. In the end, IT is about human behavior, more than about code.
I guess we're really off-topic now.
 
No I mean, when the directory you're in, no longer exists. As something that can happen with removable disks


But on a side note, I think "cd" without parameters goes to your home directory. My memory isn't perfect but I think that is what happens when you run : cd $thisisanemptyvariable
and you haven't filled that variable
This is an example of using "cd ." in a directory that no longer exists:

Basically: a directory dir1 is created.
Directory moredir1 is created inside dir1.
User navigates to moredir1.
User removes dir1, which, as the parent of moredir1, removes moredir1 whilst the user is still present in moredir 1.
When the user tries to list files of dir1, (the parent of moredir1) none appear, since moredir1 is no longer present.
When the user runs "cd ." an error message occurs, but the user doesn't move directories.
Then running "cd" leads to the user returning home.

Code:
[tom@min ~/lemon]$ cd a9
[tom@min ~/lemon/a9]$ ls
[tom@min ~/lemon/a9]$ mkdir dir{1..4}
[tom@min ~/lemon/a9]$ ls
dir1  dir2  dir3  dir4
[tom@min ~/lemon/a9]$ cd dir1
[tom@min ~/lemon/a9/dir1]$ mkdir moredir{1..4}
[tom@min ~/lemon/a9/dir1]$ ls
moredir1  moredir2  moredir3  moredir4
[tom@min ~/lemon/a9/dir1]$ cd moredir1
[tom@min ~/lemon/a9/dir1/moredir1]$ rm -rf ~/lemon/a9/dir1
[tom@min ~/lemon/a9/dir1/moredir1]$ pwd
/home/tom/lemon/a9/dir1/moredir1
[tom@min ~/lemon/a9/dir1/moredir1]$ ls ..
[tom@min ~/lemon/a9/dir1/moredir1]$ cd .
cd: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
[tom@min ~/lemon/a9/dir1/moredir1/.]$ cd
[tom@min ~]$
 
I was never mod (of a forum) but I can feel the pain there.

This will be a longer reply than you probably expected.

I try to use the moderation tools as little as possible.

Other than spam, I can't recall the last time I banned someone.

I also try to forget quickly and easily. If you make a mistake and I have to step in, I'll have moved on the following day. Unless it's something drastic, I don't hold it against folks in the long term.

Then, I compartmentalize. While I share a lot here, I have my home life and I have my mod life. I'm checking the forum regularly for a set number of hours. (Those may fluctuate a little.) Once I move on for the night, I seldom return until the following day.

I use a light touch approach - but the rules are the rules. You will avoid taboo subjects and you will remain civil.

Other than dealing with spam (which, ideally, you don't ever see), it's mostly just tedious stuff like moving a thread now and then. I sometimes have to remind folks to be civil or warn folks away from taboo subjects.

It's also important that I didn't create the rules. They are not of my creation. I did help make them clear but I did not author them. Though, I'm not sure what I'd change if I was tasked with creating the rules. They seem more or less effective. If one wishes to discuss taboo subjects, there are places to do that.

I also recognize reality.

Religion is off-topic. It is strictly off-topic.

I won't say anything about folks wishing each other a merry Christmas. I will say something when they start discussing the tenets of their beliefs.

So, there's a bit of a ramble...

I didn't immediately accept the position and I accepted the position with some caveats. It's not a task to be taken lightly and the obligations are many. It was during the pandemic, so I had more free time.
 
This is an example of using "cd ." in a directory that no longer exists:

Basically: a directory dir1 is created.
Directory moredir1 is created inside dir1.
User navigates to moredir1.
User removes dir1, which, as the parent of moredir1, removes moredir1 whilst the user is still present in moredir 1.
When the user tries to list files of dir1, (the parent of moredir1) none appear, since moredir1 is no longer present.
When the user runs "cd ." an error message occurs, but the user doesn't move directories.
Then running "cd" leads to the user returning home.

Code:
[tom@min ~/lemon]$ cd a9
[tom@min ~/lemon/a9]$ ls
[tom@min ~/lemon/a9]$ mkdir dir{1..4}
[tom@min ~/lemon/a9]$ ls
dir1  dir2  dir3  dir4
[tom@min ~/lemon/a9]$ cd dir1
[tom@min ~/lemon/a9/dir1]$ mkdir moredir{1..4}
[tom@min ~/lemon/a9/dir1]$ ls
moredir1  moredir2  moredir3  moredir4
[tom@min ~/lemon/a9/dir1]$ cd moredir1
[tom@min ~/lemon/a9/dir1/moredir1]$ rm -rf ~/lemon/a9/dir1
[tom@min ~/lemon/a9/dir1/moredir1]$ pwd
/home/tom/lemon/a9/dir1/moredir1
[tom@min ~/lemon/a9/dir1/moredir1]$ ls ..
[tom@min ~/lemon/a9/dir1/moredir1]$ cd .
cd: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
[tom@min ~/lemon/a9/dir1/moredir1/.]$ cd
[tom@min ~]$

Perfect,
and you can get the exitode of the " cd . " command no doubt
If ever you want to know if your current working directory still exists
 

Staff online

Members online


Top