Questions tagged [cd-command]

cd is a shell built-in to change the working directory.

Filter by
Sorted by
Tagged with
1
vote
2answers
479 views

Navigate to a directory from a favorites list [duplicate]

Like everyone, I use the cd builtin command to navigate my directory-structure. Tab-completion comes in handy. Sometimes I use pushd and popd to jump between directories. Some of those directories I ...
-1
votes
2answers
3k views

Can't access a folder with sudo

I have been using Linux for two years, but today I encountered a very strange thing. I have nginx deployed on one server, and this is its log folder: ♪ log l -d nginx drwx------ 2 nginx nginx 4.0K ...
1
vote
2answers
148 views

What happens when I try to change to a parent directory after it has been renamed?

I'm several child directories deep and I enter cd .. and receive this error: cd: ..: No such file or directory I am confused- of course there is a parent directory, I'm in it! A little digging ...
-3
votes
1answer
399 views

unable to do cd got file not found in PATH

Error: process caused \"exec: \\\"cd\\\": executable file not found in $PATH\"\n"} PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin From where cd will execute?
0
votes
3answers
314 views

What's the easiest way to cd to the deepest directory on an absolute path to a file?

For example, I may have the following on my clipboard: /Users/matt/widgets/file.txt And I want to change directory to: /Users/matt/widgets cd doesn't work: $ cd /Users/matt/widgets/file.txt bash: ...
0
votes
2answers
1k views

chroot with working directory specified

Say I want to write wrapper for chroot command with the possibility to set working directory otherwise preserving chroot semantics. Thus semantics should be: chroot.sh <chroot-dir> <working-...
25
votes
4answers
5k views

Why do I need to use cd “$@” instead of cd “$1” when writing a wrapper for cd?

Elsewhere I have seen a cd function as below: cd() { builtin cd "$@" } why is it recommended to use $@ instead of $1? I created a test directory "r st" and called the script containing this ...
3
votes
1answer
1k views

change of directory is very slow

from time to time changing to a directory (through terminal) launches git process which takes 100% of CPU time and up to 5-6 seconds during which my console is absolutely unresponsive. This doesn't ...
1
vote
1answer
1k views

Writing start script with different working directory

I installed octoprint to my raspberry pi earlier this year in order to control my 3d printers. I've been able to make the pi control 2 printers at once using octoprint. Also I've added a second ...
4
votes
2answers
401 views

Search for a specific file and change to its directory

What's the best way to go to a directory that contains a specific file? (Assuming we are starting at the root of where we wish to search). I'm using Cygwin. SOLUTION: My final solution was to put ...
-1
votes
1answer
78 views

Cannot Access Folder

I downloaded this folder using wget https://github.com/duxingkei33/orangepi_PC_gpio_pyH3 when I ls I can see the folder orangepi_PC_gpio_pyH3 however when I cd orangepi_PC_gpio_pyH3 I get error: ...
0
votes
1answer
211 views

How to put whereis result into cd? [duplicate]

My format is whereis directory | cd but I get no output (not even a warning). Where as you have other posts that require variables, my question asks how to do it without them.
0
votes
0answers
55 views

How to check if a subfolder exists and if so add it to the path automatically on cd? [duplicate]

On my Ubuntu machine, I have a lot of javascript / typescript projects. Each of npm's binary might have a global installation, like tsc at ~/.nvm/versions/node/v7.10.0/bin/tsc $ tsc -v Version 2.4.2 ...
0
votes
3answers
1k views

cd 3 times to great-grandparent dir

I have this: cd $(dirname $(dirname $(dirname "$0"))) && which will cd to project root. Is there shorthand for this somehow, where I can just be like: cd 3 && # not quite, but you ...
0
votes
1answer
2k views

sudo as user permission denied on command

Hi i'm having a real problem trying to run a script as root, the script is to use sudo to run wp-cli as the user required. The command I am using is sudo -u hstestsite1 -s "cd /home/hstestsite1/...
2
votes
2answers
180 views

Prevent or detect change directory action in a shell script

I have a library that accepts plugins. The plugins are shell scripts. I want to prevent the plugins from changing the current working directory for any command in the script. One thing I could do is ...
0
votes
2answers
186 views

difference between ~ and cd

I am wondering what is the difference between $ ~ and $ cd Both seems to go to the same directory.
14
votes
1answer
1k views

Different behaviour of cd with multiple arguments in bash releases

Posting it here something that is puzzling me; upgrading an application server from Jessie to Stretch broke a bash script. Upon investigation, we narrowed it to a change of behaviour of the cd ...
4
votes
3answers
474 views

How to omit the character $ when entering a path stored in a variable?

I have a frequently used directory. Suppose it is: /etc/insserv.conf.d/testname I set a variable in my /root/.bashrc: mydir=/etc/insserv.conf.d/testname Now, I can open this directory by this ...
2
votes
3answers
7k views

Create alias for desktop directory

If I type in cd Desktop, no matter what folder the terminal is currently open in, I want it to navigate to /home/bob-ubuntu/Desktop In my .bashrc file I have the following lines at the bottom: alias ...
4
votes
5answers
984 views

Immediately enter the last dir you renamed

I have a directory located inside /var/www/html. I renamed this directory with mv from example1 to to example2. How could I enter the newly named dir the moment the namechange was made? How would ...
2
votes
2answers
311 views

Remove directory part from current directory in zsh

Let's say I cd to /usr/local/bin but I want to change my pwd to /usr/bin, how can I do that with zsh? I know I can do things like cd /a/b/ and then cd b c in order to change my pwd to /a/b, but I can'...
0
votes
1answer
1k views

changing current directory from child process [duplicate]

How would you arrange for a shell script to be executed in a child process, while still being able to change the current directory of the invoking shell?
0
votes
3answers
5k views

Run shell script when navigating to directory with cd [duplicate]

Is it available to set script to run in a particular directory, when you cd into it? For example if /foo is a directory with git project, is it possible, when cd /foo automatically run git status or ...
2
votes
1answer
283 views

Automate cd into an archive directory under ~/.avfs

I use avfs to conveniently look inside archives from a shell prompt. This creates a view of the whole directory tree under ~/.avfs (so if a file /path/to/foo exists then it's also visible as ~/.avfs/...
25
votes
4answers
38k views

Alias to CD in a directory and call a command

I have a .bash_profile and in that I have a set of aliases. Those aliases at the moment execute only a single command and it was fairly easy. I would however like to do two things with a new alias ...
2
votes
2answers
290 views

I have a command that outputs a directory and I want to cd into that directory

I was hoping I could just do cd | [my command] but it seems cd doesn't work from a pipe. I want to simply cd into the output of [my command] without writing a bash script of sorts I'm hoping there is ...
0
votes
1answer
1k views

Unable to move to an existing directory

Put simply, I have a file on my desktop that I'm attempting to access using cd /file name and I'm returned with: No such file or directory. I resorted to copying and pasting the directory (being ...
0
votes
1answer
548 views

how to cd to directory OR directory file is in? [duplicate]

If I do cd "user/Dropbox/foo.txt", I get -bash: cd: user/Dropbox/foo.txt: Not a directory. But my intention in this case is always the same: I want to cd to the directory the file is in. I tried this:...
-1
votes
4answers
4k views

Is there a difference between pwd and cd?

Is there a difference between pwd and cd (no arguments)? They both print the current directory's path but is there a subtle difference that I'm missing, and if so, when should I use which?
6
votes
1answer
3k views

Examples of options to bash cd, eg: cd -Pe@ $directory

In bash 4.4.12, help cd says: Options: -L force symbolic links to be followed: resolve symbolic links in DIR after processing instances of `..' -P use the physical ...
-2
votes
1answer
2k views

Not able to cd into folder in Linux machine. Says file/folder does not exist

I have written a test ksh file to cd into a folder and do a listing. Following is written: `cd "their_file/"`; `pwd`; `ls -l`; Gives me following output: ./test.ksh: line 2: /home/user/final: Is ...
2
votes
3answers
913 views

Asking Bash to cd into each directory under some path and run a command when it is inside?

Take this path for example: /var/www/html. Inside the dir html, there are a few subdirectories. I need the system to go into each one of these sub-directories via cd (it must be cd), and then running ...
6
votes
11answers
2k views

Ability to easily switch between directories in different areas [duplicate]

I'm doing something where I'm frequently changing between two directories far away from each other in the system's file tree. Is there anyway I can assign some kind of short name to each one for use ...
1
vote
2answers
633 views

Bash script to replace two steps: cd ./some_dir, ls -al?

I'd like to write a bash scipt that would change to target directory and list the contents of new directory, all in one step. It would replace the two commands I constantly use consecutively: cd ./...
3
votes
1answer
305 views

how to add a custom option to the mkdir command

I have created lots of directories and I would to make my life lazy and to auto cd into the directory that I made with the option of -g with the result of mkdir -g foo The terminal would be like this:...
3
votes
1answer
576 views

Bash 'cd' with cdable_vars: how to suppress CWD echo?

I have used the Bash shopt cdable_vars option for years. When I cd to a destination that requires cdable_vars to resolve, the shell echoes my CWD before returning me to the prompt. When I cd to a ...
3
votes
1answer
5k views

Cannot cd to .ssh

After adding new ssh key to .ssh/authorized_hosts I can no longer ssh to the machine without entering password. What is even more funny is that the .ssh directory is suddenly inaccessible when I'm ...
0
votes
2answers
72 views

Key I can hold down to only tab complete a folder

Say I have a directory like so: foo/ bar.js bar/ if I cd into foo and then type "ba" and then hit tab, I won't get completion because a file name overlaps with a folder. Is there a key I can ...
4
votes
2answers
233 views

Execute cd in two windows with one command

I used iTerm2. I often split the pane into two windows. When I want to change the directory in one, I want to also change the directory in the other automatically. Is this possible? A Tmux solution ...
1
vote
1answer
363 views

service status keyword “service” is not needed

Could somebody help me understand why the following is happening? $ cd /etc/init.d; sudo service hadoop-hdfs-namenode status Hadoop namenode is running [ OK ] $ sudo /etc/init.d/hadoop-hdfs-namenode ...
1
vote
2answers
1k views

Execute command from specific folder

I have a screenshot tool that only works if I start it from the same directory where the file is in. Now I want to make a shortcut to just press print, the command is: bash -c '~/Documents/...
-4
votes
1answer
5k views

About bash : cd: too many arguments in my vmware kali linux

Having problems with this, it is not working.
5
votes
2answers
2k views

Symbolic link to change directory only works from home dir

Using this answer, I have created a symbolic link in my .bashrc file to make changing to a frequently used directory easier. E.g. ln -s ~/a/b/c/d/development dev I can change directory from my home ...
12
votes
5answers
6k views

How do I use `find` to go to directory of that file

I want to find a file and then enter the directory containing it. I tried find /media/storage -name "Fedora" | xargs cd but of course, I the is not a directory error. How do I enter its parent ...
2
votes
0answers
3k views

Navigating the file system: Difference between CD and PUSHD [duplicate]

Being very novice in navigating the file system, I always use the CD command line to change directories. I just find out that there is another command called: PUSHD I am having hard time to ...
2
votes
2answers
225 views

Get zsh not to complete users

I have a directory with a single subdirectory named src. I'd expect when typing in cd s and hitting TAB for the directory to be completed. Instead, zsh tries to complete all users on the system ...
0
votes
3answers
16k views

bash script to cd into directory

This bash file running on Mac terminal failed to change the directory. Rather reporting it does not exist when it actually does. Any thing I did wrong? #!/usr/bin/env bash set -e read name ...
16
votes
1answer
4k views

What exactly is dot dot (..)? Why is its behavior different with symlinks?

I am trying to understand the nature of .. (double dot). It seems to point to different targets depending on how you access it. Example:- /outer/ middle/ inner/ inner ...
33
votes
4answers
5k views

How to tell if I'm actually in a symlink location from command line?

Suppose I have a folder: cd /home/cpm135/public_html and make a symbolic link ln -s /var/lib/class . Later, I'm in that directory: cd /home/cpm135/public_html/class The pwd is going to tell me I'...

1 2
3
4 5
8