Questions tagged [cd-command]
cd is a shell built-in to change the working directory.
410
questions
0
votes
1
answer
35
views
How to explain a weird cd behavior on macOS?
My system is macOS 13.2.1, the shell is oh-my-zsh (same behavior on bash). I found a weird behavior on cd command. It changes the current directory to a wrong one. This is not caused by the soft link, ...
-4
votes
3
answers
86
views
hello I am very confused what does cd-- do?
I accidentally typed an extra dash and now I am in a weird directory that I cannot leave! Please help is there a way to undo it?
0
votes
1
answer
26
views
What does "resolve symlink" mean?
Im confused about this bash option:
-P
If set, do not resolve symbolic links when performing commands such as cd which change the current directory. The physical directory
is used instead. By default,...
0
votes
1
answer
69
views
sudoers syntax error near line 1 while adding cmnd alias
I am attempting to modify the sudoers files located within the sudoers.d directory to allow a group named "swts" to perform a cp and chown as part of an automation job. To accomplish this, I ...
32
votes
1
answer
3k
views
How to get the cd shell-builtin to stop guessing?
For example:
$ ls -aF
./ ../ bin/
$ cd tin # with a tee, not bee
bin
$ pwd
/home/user/bin
In other words, cd guesses that what I really meant was cd bin, and successfully (huh?) changes the current ...
0
votes
1
answer
45
views
How to change to a directory with a leading - [duplicate]
I don't know why someone would make a directory with a leading hyphen, e.g. named "-1". When I try to change to that directory, it says invalid option.
I tried putting "-1" in ...
0
votes
1
answer
151
views
ZSH -- cd into directory without full path name
https://stackoverflow.com/questions/25802017/bash-shell-search-for-subfolder-in-current-dir-and-cd-into-it
would like to implement this, as I don't want to tabcomplete.
when I type the command:
cd `...
0
votes
1
answer
80
views
Change to a new directory in Linux, while remembering the current, and cd back to it
The pushd and popd are very useful and often needed when working on the command line, but I'm not enjoying them to the extent they can. It is subjective but I find the naming of the pair to be ...
0
votes
1
answer
48
views
Automatically list the contents of a directory when i cd into it only if it's a sub-directory of $HOME
From a reddit thread I found this short snippet you can add to your .bashrc that automatically shows the list of contents of a dir you've cd'd into:
cd() {
builtin cd "$@" && ls
}...
0
votes
1
answer
40
views
Why shouldn't a user cd to a directory using absolute path without rx to all its ancestors?
On Windows, it seems that if the user has read/write permission to the lev5 directory, but no permission at all for all its ancestors, cd c:\lev1\lev2\lev3\lev4\lev5 still works.
On Linux, even if I ...
0
votes
0
answers
41
views
No such file using thunar
This is really frustrating.
The directory exists.
andy@7 /media/andy/5b4b2ae5-9aaa-4559-9f41-afb313998c75/home/andy/bin>
How do I fix this?
cd: /media/andy/5b4b2ae5-9aaa-4559-9f41-afb313998c75/...
0
votes
4
answers
104
views
Re-cd into current directory
I am in a directory which is a symlink
me@hostname:/home/me$ ls -al
the_link -> actual_a
actual_a
actual_b
actual_c
me@hostname:/home/me$ cd the_link
me@hostname:/home/me/the_link$
Now while I've ...
1
vote
2
answers
199
views
Xterm cd command not working in launch option
When I launch xterm with the following command:
xterm -e 'cd ~' -hold
A new xterm window pops up saying: xterm: Can't execvp cd ~: No such file or directory
After which the xterm window is still in my ...
0
votes
0
answers
1k
views
Ubuntu on Windows: why is cd /mnt/c/Users/username/Desktop not working?
I'm running Ubuntu 20.04 on Windows 10. I have been able to access the directories in my desktop directly by using the cd /mnt/c/Users/username/Desktop command until yesterday, but today I tried ...
1
vote
1
answer
63
views
Safe place to `cd`?
Perhaps a pedantic question, but is there a convention on where to cd if I want to move the current directory to somewhere else. (It can't be moved while being inside it)
I guess / (root) would do as ...
0
votes
2
answers
120
views
"cd" in a function works, except when it doesn't
The first thing I do after cd'ing to a directory is to use "ls", as I imagine is the case for a lot of people. So I decided to define a function in my .bashrc to do both together. This is ...
0
votes
1
answer
112
views
"xargs" not sending argument to "cd" via stdio
I am seeing "xargs" behaviour that seems to be quite unexpected, in my experience. I use "ls" to find a matching folder name and sending it to "cd" using "xargs&...
4
votes
1
answer
610
views
Use the parent directory from the symlink instead of where the directory actually resides on the filesystem
So let's set up the context. Two paths:
/some/very/convoluted/path/name/the-wanted-directory
/myhome
I create a symbolic link in /myhome and then cd into it:
/myhome $ ln -s /some/very/convoluted/path/...
-3
votes
1
answer
97
views
What does 'cd ../..' mean in linux?
I am aware that cd is used to navigate between files in linux commandline. However, I am not sure what the following, that I came across while trying to replicate something, means:
cd ../..
It was ...
1
vote
2
answers
748
views
Use parent directory base name for making a new directories in a for loop
I am attempting to use a for loop to move files (e.g. .txt) into a new directory, where the original directory name as part of the name, but add an extra "with-new-files" onto the name so I ...
1
vote
0
answers
95
views
ls displays no files even though folder contains files
This question is actually derived from a problem I have with a python library which deletes a file tree and then recreates the content, but on attempt of execution of a file inside the directory, the ...
2
votes
2
answers
32
views
Is there a way to quickly change dir to one from where one of the jobs is running?
The output of jobs looks something like this
[1] Stopped TERM=xterm-256color vim --servername vim ~/.gitconfig
[2]- Stopped TERM=xterm-256color vim --servername vim ~...
-1
votes
2
answers
57
views
How to define a new command that is a wrapper of an existing command and accepts all original flags?
What I want to do is to make a command that prints some related info if the command is successful. As an example, if I define an alias as
alias cd='cd /path/to/destination/ && echo "...
-4
votes
1
answer
2k
views
Can't find /etc/passwd [closed]
For some reason, every time I need to go to passwd or even shadow, It does not allow me.
For example:
cd /etc/passwd
Output: cd: not a directory: /etc/passwd
Same thing with shadow. Because of this, ...
0
votes
1
answer
260
views
how to cd into previous directory
I am using Ubuntu and sometimes when I use cd - I don't go into the previous directory. And every time I get the directory which it cded to. example:-
$cd -
/home/[usrname]/Downloads
$cd -
/home/[...
0
votes
0
answers
18
views
cd command to a variable containing a path with spaces gives different output than actually giving the path as an input [duplicate]
I have a directory named "test 1" and I create a variable
dest="test\ 1"
I want to navigate to the directory using the cd command, so I type
cd $dest
which gives the output as
-...
2
votes
2
answers
227
views
What is the zsh equivalent of "pushd -n" in bash?
I want to push a directory onto the directory stack in order to refer to it using "tilde shorthand" (eg. ~1 refers to the second entry in the directory list), but I don't want to actually ...
-2
votes
1
answer
1k
views
Permissions denied in Kali Linux
I cannot get into /root and even when i use "sudo ls /root" it asks me for the password then nothing happens. Im new to linux and when I was testing out Kali linux i tried using permission ...
0
votes
1
answer
807
views
Changing directory with if else condition
Below is a small extract of my code for you to have a better visibilty on my problem. As each file in the directory enters the loop, the value of em is extracted from the filename and compared with ...
1
vote
1
answer
43
views
Sourcing a script to change pwd, ignore piping at end of command?
I have a little script I wrote that lets me change to the directory of a script that's on the path, which helps me quickly get to other scripts I tend to want to edit, in the same folder as the ...
-2
votes
1
answer
515
views
why couldnt I cd /etc/group but return not a directory in ubuntu?
I switch user to root used su. but i still couldnt cd /etc/group but the group folder is in my /etc folder.
root@Desktop:/etc# cd group
bash: cd: group: Not a directory
0
votes
3
answers
223
views
How to use substitute with cd command in Linux
We recently migrated from HP-UX B.11.31 to Linux 3.10.0-1160.15.2.el7.x86_64.
I am trying to achieve the below (which worked in the earlier HP-UX system):
$ pwd
/global/app/opt/prod/ee/01/custo/src/
$ ...
0
votes
1
answer
165
views
How to tell 'find' command to jump to a position and search? [duplicate]
I'm preparing headers for a C++ project and I decided to use find to get include option to other header files. To list the right path, I need to use cd with it, like:
cd 'PATH/TO/HEADER/FILE'
find ../....
1
vote
0
answers
77
views
bash: run command from script, but affect the shell where it´s called from
There is a script that should change the path of the shell where it was run from. I used this code:
#!/bin/bash
TTY=$(tty)
echo -e "cd /tmp/ \r" > $TTY
exit
But that does not work. Is ...
0
votes
0
answers
110
views
The cd command on macOS performs an ls after dc. Why?
On MacOS terminal with bash, I get an ls after a cd. When the directory contains many files, I can't see the effect of the cd since it scrolls away due to the ls.
This is what I see
$ which cd
cd is a ...
-6
votes
2
answers
672
views
in what language is bashrc written
I came across a cool way to go up more than 1 directory level by adding a function to the .bashrc file.
It is done by just opening the .bashrc file and inserting the function:
#user defined functions
...
2
votes
2
answers
575
views
Why do I have to use this command twice to execute it?
I made an alias alias goto="cd $@ && source ~/.zshrc" and it works, but only if I execute it twice. Even after I execute it twice in one shell, and if I want to move to another dir, ...
3
votes
1
answer
424
views
Are there any caveats in using shopt -s autocd?
I have recently discovered the feature shopt -s autocd:
autocd If set, a command name that is the name
of a directory is executed as if it were
the ...
2
votes
1
answer
68
views
Why do I get an error when using cd as env's utility argument? [duplicate]
I'm studying the env command and trying to understand how it works. Here's the command synopsis:
env [-iv] [-P altpath] [-S string] [-u name] [name=value ...] [utility [argument ...]]
I decided to ...
2
votes
1
answer
397
views
change directory based on file shell script
Firstly come background I am trying to write an executable shell script I can easily map as the default for .tgz files to auto-extract.
so far so simple
tar -xzvf $1
which works to drag/drop but not ...
8
votes
3
answers
2k
views
is there a way to cd into a directory based on the last characters?
I have directories that begin with 164 but they differ based on the last few digits. I would like to cd into a directory based on the last few digits if not the last digit itself, say 9 vs 8. The ...
5
votes
1
answer
537
views
How to get recent places in terminal/shell?
Is there any way to get a list of the most recent 'places' (directories) that have been navigated in terminal (osx)? I mean, I'd like to open my terminal, type some command, get the last 2 or 3 places ...
10
votes
5
answers
631
views
Changing directory by changing one early word in a pathname
How do I change to a near-identical path with a different low-level parent? If you’re working in for instance ~/foobar/foo/data/images/2020/01/14/0001/ and need to get to the same path in bar instead ...
0
votes
1
answer
230
views
Unix Executable to the directory it is housed in Mac
I am trying to make an executable script on Mac where it makes the directory it is housed in the current directory (cd) and then runs some more commands. I started with a find command however in the ...
1
vote
0
answers
23
views
Is it possible to directly access files out of a symlink-directory? [duplicate]
Say I have this directory structure:
foo
│ ╲
bar baz
│ ╲
wun ← wunl
│
blarg
Here, wunl is a symlink pointing to ../bar/wun. Now I can
$ cd foo/baz/wunl/blarg
At this point, I'm not “actually” ...
1
vote
7
answers
284
views
Changing to a frequently used directory easily
Every time I need to go to a new directory I give the command cd and the name of the directory and ls to see the contents inside it. Is there any method or command to directly go the directory of my ...
-2
votes
2
answers
193
views
Add a directory to path
I would like to know how to add a directory to path (such as my Downloads folder) so that whenever I type cd Downloads from whatever directory, I go to ~/Downloads.
2
votes
1
answer
365
views
How to navigate to a filesystem
I am using a cloud linux desktop and when I typed in df -h I get a list of filesystems as so:
Filesystem Size Used Avail Use% Mounted on
/dev/xvda1 9.8G 4.5G 5.3G 47% /
tmpfs ...
0
votes
1
answer
141
views
Accidently use "mv" command on home directory
I was in my home directory and then I typed
cd .icons/a_folder/
For a weird moment, I typed
mv ../..
instead of
cd ../..
I do not know why I made that mistake, but since ../.. was my home directory
...
0
votes
1
answer
157
views
How to find a file and make that the current working directory (cd)
I am trying to make an executable script on Mac where it searches for a file and makes that the current directory (cd) and then runs some more commands. I started with
find . -type d -name "...