2

I was reading a book published in 2018 titled "Linux Basics for Hackers: Getting Started with Networking, Scripting, and Security in Kali" from no starch press.

And this was written there that you can move up as many levels as you want using the corresponding number of double dots separated by spaces:

  • You would use .. to move up one level
  • You would use .. .. for two levels
  • You would use .. .. .. to move up three levels, and so on.

So, for example, to move up two levels, enter cd followed by two sets of double dots with a space in between.

This is the page from the book:

text as above

Was that ever working? It is not working in 2020.

1
12

This is an error in the book which the publisher addresses in the "Updates" section on the book's "homepage" (https://nostarch.com/linuxbasicsforhackers#updates):

Updates

Page 7

The following text regarding moving up through directory levels is incorrect:

  • You would use .. to move up one level.
  • You would use .. .. to move up two levels.
  • You would use .. .. .. to move up three levels, and so on.

This text should read:

  • You would use .. to move up one level.
  • You would use ../.. to move up two levels.
  • You would use ../../.. to move up three levels, and so on.

The errata does not mention the example that you also quote, which shows cd .. .., but this is obviously also wrong.

Some shells support a cd command with two arguments, where the second argument replaces whatever matches the first argument in the pathname of the current working directory, and the resulting pathname is changed into. But the pathname of current directory, as found by pwd and in $PWD, would not contain .., and even if it did, the cd .. .. command would not change directory at all (given the semantics that I just described).

1

You spelled the command wrong. It should be cd ../.. for going two levels up, cd ../../.. for going three levels up etc.

3
  • Thankyou for your comment but it was written the smae in the book – Nilesh Aug 27 '20 at 14:02
  • 9
    It's true that cd ../../../ etc works, but the question is whether the space separated version has ever worked. OP shows the reference they are using in the question. The reference may be wrong, but the OP ("you") is not. – Zanna Aug 27 '20 at 15:48
  • 3
    Initially there was no photo in the question and I just thought that the OP read the book wrong. Now when we have the photo I can say for sure that the book is obviously wrong and I have no idea why someone wrote such a thing. As far as I know, the version with spaces never worked in any *nix-ish system. – raj Aug 27 '20 at 16:32
1

I think it depends on the shell. I'm using zsh with oh-my-zsh(as my default shell)

with example

I was in ~/miniconda3/bin and I typed cd ......(without any space) and I get into the root directory.

but

when I switch to bash I need to type cd ../../.. to go to the root directory.

1
  • On vanilla zsh I get cd: no such file or directory: ....... – Stewart Aug 28 '20 at 9:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.