Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

How to use cd command in Windows


  • Please log in to reply
5 replies to this topic

#1 Dotan Cohen

Dotan Cohen

  • Members
  • 10 posts
  • OFFLINE
  •  
  • Local time:05:23 PM

Posted 21 July 2011 - 10:52 AM

Hi all, I'm a Linux user just starting to get the hang of Windows 7. How can one perform these functions with the Windows cd command:
1) Go back to the previous directory (cd - in Bash)
2) Go to the user's home directory (cd ~ in Bash)
3) Bookmark a directory (not built into bash, but cdargs or DerB can be added)

Thanks

BC AdBot (Login to Remove)

 


#2 whoabuddy

whoabuddy

    Bleepin' Verbose


  • Malware Response Instructor
  • 2,053 posts
  • ONLINE
  •  
  • Gender:Male
  • Location:Cottonwood, AZ
  • Local time:07:23 AM

Posted 21 July 2011 - 11:11 AM

Previous Directory: cd ..\
Current Directory: cd .\
Root Directory: cd \

After some research, the home directory should be accessible with an environment variable.

cd %homepath%

As for bookmarking, I can't think of a way to do it outside of creating your own environment variables with SETX, but I wasn't able to get it working in the few minutes I spent on it.
Meditate. Elevate. Appreciate. | "Life is a journey, love is the destination, happiness is the path!"
If I am helping you and have not responded within 48 hours, please send me a PM.
Vi Veri Universum Vivus Vici (VVVVV)
Excellent Security Advice
Proud member of UNITE

#3 Dotan Cohen

Dotan Cohen
  • Topic Starter

  • Members
  • 10 posts
  • OFFLINE
  •  
  • Local time:05:23 PM

Posted 21 July 2011 - 11:17 AM

Previous Directory: cd ..\
Current Directory: cd .\
Root Directory: cd \


Thanks, but that goes up a directory, but not to the last directory that I was in. For instance:
C:\Users\dotancohen\some\long\filepath>cd C:\Windows
Now how would I get back to C:\Users\dotancohen\some\long\filepath

After some research, the home directory should be accessible with an environment variable.

cd %homepath%


Thank you! Where did you research that, I should certainly be reading whatever other info is in there.

As for bookmarking, I can't think of a way to do it outside of creating your own environment variables with SETX, but I wasn't able to get it working in the few minutes I spent on it.


Thanks, that is interesting. I've also discovered pushd and popd, but I cannot get pushd to automatically use the current directory.

#4 whoabuddy

whoabuddy

    Bleepin' Verbose


  • Malware Response Instructor
  • 2,053 posts
  • ONLINE
  •  
  • Gender:Male
  • Location:Cottonwood, AZ
  • Local time:07:23 AM

Posted 21 July 2011 - 11:39 AM

Thanks, but that goes up a directory, but not to the last directory that I was in. For instance:
C:\Users\dotancohen\some\long\filepath>cd C:\Windows
Now how would I get back to C:\Users\dotancohen\some\long\filepath


Looking through the reference on CD from SS64 I don't see any options to get to the previous directory, but there still may be a way to do it with variables, that's a tricky one!

Thank you! Where did you research that, I should certainly be reading whatever other info is in there.


I found it in a MS KB article, and here is a Technet reference about recognized environment variables.

Thanks, that is interesting. I've also discovered pushd and popd, but I cannot get pushd to automatically use the current directory.


I've never used these commands until you mentioned them, but I think they can help with what you're looking for, here's what I get in my tests:

C:\Users\whoabuddy>pushd c:\users
C:\Users>popd
C:\Users\whoabuddy>

and

C:\Users\whoabuddy>pushd ..\public
C:\Users\Public>popd
C:\Users\whoabuddy>

What are you trying to accomplish with the current directory? You should be able to use .\ like I referenced in the CD commands.
Meditate. Elevate. Appreciate. | "Life is a journey, love is the destination, happiness is the path!"
If I am helping you and have not responded within 48 hours, please send me a PM.
Vi Veri Universum Vivus Vici (VVVVV)
Excellent Security Advice
Proud member of UNITE

#5 Dotan Cohen

Dotan Cohen
  • Topic Starter

  • Members
  • 10 posts
  • OFFLINE
  •  
  • Local time:05:23 PM

Posted 21 July 2011 - 11:50 AM

Looking through the reference on CD from SS64 I don't see any options to get to the previous directory, but there still may be a way to do it with variables, that's a tricky one!


Yes, tricky indeed. That is a good site, I'll poke around there a bit.

I found it in a MS KB article, and here is a Technet reference about recognized environment variables.


More good reading material, thanks.

I've never used these commands until you mentioned them, but I think they can help with what you're looking for, here's what I get in my tests:
C:\Users\whoabuddy>pushd c:\users
C:\Users>popd
C:\Users\whoabuddy>

and

C:\Users\whoabuddy>pushd ..\public
C:\Users\Public>popd
C:\Users\whoabuddy>

What are you trying to accomplish with the current directory? You should be able to use .\ like I referenced in the CD commands.


I was doing it all wrong, I thought that pushd would save the current directory and then I could change directories:
C:\Users\dotancohen>pushd
C:\Users\dotancohen>cd C:\Windows
C:\Windows>popd
C:\Windows>

I now see my mistake. Thank you!

#6 whoabuddy

whoabuddy

    Bleepin' Verbose


  • Malware Response Instructor
  • 2,053 posts
  • ONLINE
  •  
  • Gender:Male
  • Location:Cottonwood, AZ
  • Local time:07:23 AM

Posted 21 July 2011 - 08:17 PM

Glad I could help! I'm not an expert on all of this stuff but I try to make it work, let me know if I can provide you with any more info!
Meditate. Elevate. Appreciate. | "Life is a journey, love is the destination, happiness is the path!"
If I am helping you and have not responded within 48 hours, please send me a PM.
Vi Veri Universum Vivus Vici (VVVVV)
Excellent Security Advice
Proud member of UNITE




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users