Questions tagged [cd-command]

Is for questions about cd built-in bash command (e.g. how it works).

cd command change the current shell working directory.

SYNOPSIS:

cd [-L|-P] [dir]

cd change the current directory to dir (new directory). The default dir value is $HOME (HOME shell variable).

Options:

 -L force symbolic links to be followed
 -P use the physical directory structure without following symbolic

The default is to follow symbolic links, as if -L were specified.

103 questions
105
votes
8 answers

How to enter a directory with the 'cd' command if it has 700 permission and is not owned by me?

I tried to use sudo cd name_of_dir but am getting the error message: sudo: cd: command not found Is there any other way to enter a directory owned by another user which has 700 permission?
Bakhtiyor
  • 12,804
71
votes
8 answers

Why doesn't "cd" work in a shell script?

I just want to write a script which changes my directory. I put the below commands in the file /home/alex/pathABC #!/bin/sh cd /home/alex/Documents/A/B/C echo HelloWorld I did chmod +x pathABC In the Terminal, while in /home/alex, I ran…
54
votes
8 answers

How do I enter a file or directory with special characters in its name?

I want to enter the following folder in the terminal: Milano, Torino (Jan)-Compressed How should I write the command cd to enter this directory? Spaces and several other special characters like \, *, ), ( and ? cause problems when I try to use them…
Pomario
  • 2,078
26
votes
2 answers

What does cd - (cd hyphen) do?

I typed cd - in terminal by mistake today, and I got an error saying: bash: cd: OLDPWD not set And unfortunately, man cd doesn't exist. No manual entry for cd What does it actually do?
Dan
  • 14,180
22
votes
5 answers

Which package is the command 'cd' in?

I want to look into the source code behind the command cd, but cd doesn't seem to have its own package so which package is it in?
user364819
15
votes
3 answers

How do I cd into a directory in the home folder?

How do I change directories to downloads, from the home folder, in the latest version Ubuntu 12.10? I tried cd /downloads, but it gave an error saying that there is no such directory.
sam
  • 159
15
votes
3 answers

Why doesn't using two cd commands in bash script execute the second command?

I have written a bash script which creates a series of directories and clones a project to selected directories. For that, I need to cd to each directory (project 1 and project 2), but the script doesn't cd to the second directory nor executes the…
Jenny
  • 601
  • 1
  • 8
  • 19
13
votes
4 answers

How can I have mkdir cd into the newly-created directory?

Frequently, I type these commands in bash: mkdir something cd something I almost never do this: mkdir something ls # something in the current directory, not ./something/ And never this: mkdir something something2 How can I have mkdir cd into the…
user621107
12
votes
4 answers

Ubuntu 17.04 — bash: cd: too many arguments

I just upgraded my Ubuntu 16.04 to 17.04 and found a little problem with cd command. Let's say that I have two folders: album-01 & album-02 In Ubuntu 16.04, if I do cd album* it will go to the first folder found album-01 But in new Ubuntu 17.04, if…
Hidayats
  • 195
  • 1
  • 3
  • 10
12
votes
2 answers

Change directory to an external disk

I've two partitions on my windows OS and I've installed Ubuntu within windows. Partition 1 : Windows and Linux OS Partition 2 : Common storage files (called under the name New Volume) I am looking at running a shell script that is placed in…
Vamsi Emani
  • 2,575
12
votes
4 answers

How do I prevent 'cd' command from going to home directory?

The thing is that sometimes I type cd by mistake and that take me to the home directory. e.g. I'm in a directory that have a hidden directory and a visible directory, I quickly press cd+tab and that takes me to the home directory
9
votes
4 answers

cd command in terminal takes too long time to execute

When I try to navigate directories using the cd command, it takes way too a long time. And terminal suggests creating a config file to increase the timeout. Once my terminal hanged, I mean when I tried to execute the command, the cursor kept…
8
votes
2 answers

Command cd behavior

Since ubuntu 17.10, my scripts don't work the same way they used to do: cd a* would change directory to the first directory beginning with a. Now, I get this error: bash: cd: too many arguments I guess it now detects multiple arguments due to the…
Aurelien
  • 168
8
votes
2 answers

Run sudo command within directory

Possible solutions could be: Starting interactive session. sudo -s <<< "cd dir ; command" or sudo /bin/bash -c "cd dir ; command" But I don't have /bin/bash /bin/sh /bin/su or other sudoer permissions Changing directory before sudo is done. cd…
8
votes
3 answers

Error when using the commands cd.. and cd. in the terminal

I try to use the commands cd.. and cd. in the terminal to move from my current folder to a previous one, and it shows me a message that the command doesn't exist... What could the problem be? I'm using Ubuntu 18.04 LTS.
1
2 3 4 5 6 7