Questions tagged [cd]

cd is the "change directory" command offered by most shells. For CD-ROMs, please use the [cd-rom] tag.

737 questions
845
votes
15 answers

Equivalent of shell 'cd' command to change the working directory?

cd is the shell command to change the working directory. How do I change the current working directory in Python?
too much php
  • 88,666
  • 34
  • 128
  • 138
397
votes
6 answers

Change directory command in Docker?

In docker I want to do this: git clone XYZ cd XYZ make XYZ However because there is no cd command, I have to pass in the full path everytime (make XYZ /fullpath). Any good solutions for this?
RParadox
  • 6,393
  • 4
  • 23
  • 33
147
votes
7 answers

Change working directory in my current shell context when running Node script

I am trying to change the working directory of my Node.js script when it is run from a bin script. I have something like the following: #!/usr/bin/env node process.chdir('/Users') When I then run this file with ./bin/nodefile, it exits, but the…
Jonovono
  • 1,979
  • 7
  • 30
  • 53
110
votes
7 answers

bash - how to pipe result from the which command to cd

How could I pipe the result from a which command to cd? This is what I am trying to do: which oracle | cd cd < which oracle But none of them works. Is there a way to achieve this (rather than copy/paste of course)? Edit : on second thought, this…
Michael Mao
  • 9,878
  • 23
  • 75
  • 91
90
votes
7 answers

How to run 'cd' in shell script and stay there after script finishes?

I used 'change directory' in my shell script (bash) #!/bin/bash alias mycd='cd some_place' mycd pwd pwd prints some_place correctly, but after the script finished my current working directory doesn't change. Is it possible to change my path by…
qrtt1
  • 7,746
  • 8
  • 42
  • 62
90
votes
5 answers

docker-exec failed: "cd": executable file not found in $PATH

I used this command: docker exec compassionate_mclean cd /root/python The error returned is docker-exec: failed to exec: exec: "cd": executable file not found in $PATH Kindly help me out
sabarish
  • 1,059
  • 1
  • 11
  • 14
79
votes
18 answers

How to cd into a directory with space in the name?

I'm attempting to get into the directory /cygdrive/c/Users/my dir/Documents: $ DOCS="/cygdrive/c/Users/my\ dir/Documents" $ echo $DOCS /cygdrive/c/Users/my\ dir/Documents $ cd $DOCS -bash: cd: /cygdrive/c/Users/my\: No such file or directory $ cd…
user2316667
  • 5,444
  • 13
  • 49
  • 71
79
votes
15 answers

Run cmd commands through Java

I found several code snippets for running cmd commands through a Java class, but I wasn't able to understand it. This is code for opening the cmd public void excCommand(String new_dir){ Runtime rt = Runtime.getRuntime(); try { …
Reham
  • 1,916
  • 6
  • 21
  • 45
72
votes
4 answers

How do I find the current directory of a batch file, and then use it for the path?

I have a batch file that I intend to distribute to our customers to run a software task. We distribute them as a folder or .zip with the files inside. Inside, there is the batch files and another folder with the files needed to run the…
Ryan Barber
  • 735
  • 1
  • 6
  • 7
61
votes
8 answers

How to use "cd" command using Java runtime?

I've created a standalone java application in which I'm trying to change the directory using the "cd" command in Ubuntu 10.04 terminal. I've used the following code. String[] command = new String[]{"cd",path}; Process child =…
Antrromet
  • 15,294
  • 10
  • 60
  • 75
59
votes
14 answers

Go up several directories in linux

When I want to go one directory up I use cd .. But when I want to go 7 directories up is there any way to do this other than just typing seven (7) times cd .. ?
56
votes
2 answers

What does double slash // in `cd //` mean in Linux?

I've entered a command cd // instead of cd / by mistake and instead of getting an error as I'd expect the shell (Bash) showed a prompt as if I'm in the // directory:- @://$ @://$ pwd // Listing the content of…
vitaut
  • 49,672
  • 25
  • 199
  • 336
46
votes
11 answers

"cd" does not work in shell script

I am wondering why cd does not work in shell script. It is as follows, #!/bin/sh cd test mkdir $(date +%d-%mm-%Y) When I run this, I get can't cd to test cd: 2: can't cd to /test Why is it like this?
Abhishek
  • 6,862
  • 22
  • 62
  • 79
42
votes
9 answers

One command to create and change directory

I'm searching for just one command — nothing with && or | — that creates a directory and then immediately changes your current directory to the newly-created directory. (This is a question someone got for his exams of "linux-usage", he made a new…
Autom3
  • 443
  • 1
  • 4
  • 8
38
votes
1 answer

bash : cd : too many arguments

if i need to go to my directory named as"exception handling" then i write (cd exception handling) but it gives error too many arguments
Veerabala J
  • 553
  • 1
  • 5
  • 14
1
2 3
49 50