cd is the "change directory" command offered by most shells. For CD-ROMs, please use the [cd-rom] tag.
Questions tagged [cd]
737 questions
12
votes
6 answers
In CMD / .bat I can change dir from C to D but not other way around?
Ok so here is a copy-paste of my CMD window
C:\Documents and Settings\Developer>cd /d "D:\"
D:\>cd /c "C:\"
The filename, directory name, or volume label syntax is incorrect.
D:\>
when I run cd /d "D:\" in C drive it works fine,
but when I run cd…

Andre
- 661
- 7
- 14
- 29
12
votes
5 answers
Bash script to change parent shell directory
What I'm trying to do
I've created a shell script that I've added to my $PATH that will download and get everything setup for a new Laravel project. I would like the script to end by changing my terminal directory into the new project folder.
From…

michaelespinosa
- 505
- 2
- 5
- 15
11
votes
1 answer
How to read a CD as a file?
I want to know whether it is possible in Delphi to read a CD as a raw Stream direct from the logical disk drive device "C:\".
I hope I could use a TFileStream if I have already a valid file handle.

menjaraz
- 7,551
- 4
- 41
- 81
11
votes
6 answers
How to make an html page open automatically on a CD/DVD
I need to include an html page (table of contents) on a CD/DVD. I'd like the html page to open automatically when the user puts the CD/DVD in their machine. Is there a way to do this (the MSDN cds do this) either by purchasing software or…
Sam
11
votes
2 answers
Difference between cd and function chdir
What is the difference between the cd shell command and the Perl function chdir? Please can you explain with an example?

iDev
- 2,163
- 10
- 39
- 64
10
votes
1 answer
How POSIX compliant is "/path/file/.."?
I wanted to change current directory into shell script into directory, containing specific regular file. I found that following trick works in mksh and busybox sh:
path=/path/to/regular/file
cd $path/..
but not in GNU Bash:
bash: cd:…

KAction
- 587
- 2
- 10
10
votes
6 answers
Stay in directory changed after ending of bash script
My bash script:
#!/bin/bash
cd /tmp
Before running my script:
pwd: /
After running my script:
pwd: /
After runnig my script trough sourcing it:
pwd: /tmp
How I can stay at the path from the script without sourcing it ?

astropanic
- 10,800
- 19
- 72
- 132
10
votes
1 answer
cd into a directory without knowing its name in bash
If I know there will be a single folder inside a directory, but I do not know it's name, is there a simple way in bash to go into it? If I wanted to do a check to make sure a folder exists within the current directory, can that be done?

user3475234
- 1,503
- 3
- 22
- 40
10
votes
2 answers
bash expand cd with shortcuts like zsh
Is it possible in bash to expand something like
cd /u/lo/b
to
cd /usr/local/bin
?

hasan
- 638
- 4
- 14
9
votes
2 answers
git init, add, commit from a different directory
I am writing a Lua script that creates a directory, creates some files inside of it and initializes git, adding those files to it and finally committing everything. However there's no way to use cd from inside Lua (you can, but it won't have…

user6245072
- 2,051
- 21
- 34
9
votes
4 answers
'cd' option to change to the previous directory
I remember there was a way to execute the cd command, automatically returning to the previous directory (without an explicit cd ...).
Is it possible?

Roberto Aloi
- 30,570
- 21
- 75
- 112
9
votes
3 answers
Change cd default directory (bash)
I'm looking for a way to change the default directory of cd, and I'm wondering if this is possible. I tried adding
alias "cd=cd ~/Documents/Github"
to .bashrc, but this obviously doesn't work because it breaks the cd command so that you cannot use…

Jay
- 998
- 1
- 10
- 22
8
votes
7 answers
A bash one-liner to change into the directory where some file is located
I often want to change to the directory where a particular executable is located. So I'd like something like
cd `which python`
to change into the directory where the python command is installed. However, this is obviously illegal, since cd takes…

bsdfish
- 2,434
- 1
- 21
- 20
8
votes
4 answers
How to change directory within Ubuntu WSL in Windows format?
I have installed Cygwin on Windows. To change dir in Cygwin could be done in 2 ways:
In Unix format:
cd /cygdrive/path/to/folder/
In Windows format (surrounded by double quotes):
cd "C:\Path\To\Folder\"
Is there a way to change dir in Ubuntu WSL…

Ger Cas
- 2,188
- 2
- 18
- 45
7
votes
2 answers
How to share/extend/reuse/reference GitHub Workflow?
I have two workflows. One deploys on push to master to a test environment. The other deploys on release to prod environment. They are 90% identical, code copy&paste.
Is there a concept such as extracting part of the duplicate logic and putting it…

phifa
- 856
- 7
- 11