Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [cd-command]

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

0
votes
1answer
11 views

tcl cd/pwd command with regard to real/symbolic path

When I work under tcl environment, once I cd to a directory, even if the path I specify is its symbolic link, then no matter whether I run pwd -L or pwd -P, they all return the absolute path. This is ...
0
votes
1answer
70 views

When can a “cd” command fail in a shell script and what can I do to remedy it?

I have a shell script that failed to finish last week; it was a failed "cd" command and it exits if it fails. The script is a bash shell script for configuring new Debian installs. Here is the full ...
1
vote
1answer
39 views

Can't see a directory that's supposed to exist

So I own a device (casa node) which is basically a raspberry pi 3b+ with a hard drive and a modified OS (they call it CasaOS) and I want to edit a file. I found the location of this file by looking at ...
0
votes
3answers
139 views

In Bash, how to find with a PATH like variable

Say I have CDPATH which contains paths I want to cd to in case it is not found in . Without using cd itself how do I get the first path that would satisfy it using bash The purpose of which is to ...
3
votes
1answer
49 views

Permission denied when cd to symlink'd dir in /tmp that is 700 and owned by regular user

Question: Why am I not able to cd into a symlinked directory with 700 permissions, owned by a regular user, as root, when I am able to change into the directory itself? Example: ttucker@plato:/tmp# ...
2
votes
1answer
37 views

How does cd's “-@” parameter work?

bash's man page (and help cd) mentions that cd supports a -@ parameter ("on systems that support it") to "present a file with extended attributes as a directory containing the file attributes" Is ...
0
votes
0answers
59 views

Permission denied issue while doing CD even after having group permission

I'm getting Permission denied while doing a cd into directory /tct/foxprod_t2b_002/cilin/cust_test/testcases/level1 and user is a member of this group; other users on the group can easily accessing ...
-1
votes
2answers
311 views

bash: cd: <path> : No such file or directory [duplicate]

I upgraded to the latest version of Kali Linux and all of a sudden I can't open up files. The file manager shows the files exist and I can get in them through the file manager but cannot do so through ...
1
vote
0answers
33 views

Make bash understand I want to complete a directory name after “cd”

How to get bash to auto-complete cd commands only with directory names and ignore filenames (just as CMD on Windows) Example: I'm in /some/folder/ I have -rwxr-xr-x filesharp -rwxr-xr-x ...
-1
votes
1answer
48 views

How to switch to the last added folder in that particular folder in S3 bucket

I have a **S3 bucket in which starting of every month ... will be added. And in the month lder daily **new files will be added .
0
votes
3answers
64 views

Shortcut to `cd` into the 2nd folder in a directory

CONTEXT I am in a directory with 3 folders. After executing ls -1 they are ordered like so: folder1 folder2 folder3 I want to quickly cd into folder2. I was able to write a function to quickly cd ...
0
votes
2answers
43 views

How do I return to admin mode in fedora?

I am using fedora. When I logged in to the terminal my name ended with "~]$" but after I did these two operations "cd /tmp" and "cd .." my name now ends with "/]$" and I can't do much anymore. Can't ...
0
votes
1answer
73 views

Why would calling cd (builtin) from cd (shell function) without “command” cause an endless loop?

I once read in a Bash book by O'Reilly the following (my summary): command and enable cd () { echo "Improved CD !" # Improvement one; command cd # Improvement two; # Do cool ...
101
votes
11answers
22k views

Does cd . have use?

One of the tutorials I've been following briefly stated that cd . has no use. When trying to replicate issue shown by OP in Symbolic link recursion - what makes it “reset”?, I also tried cd ., which ...
-4
votes
1answer
63 views

What is the result of cd * [closed]

I tried cd * in my terminal (ubuntu), it changes my directory to the first directory listing
17
votes
2answers
2k views

What is the difference between the commands builtin cd and cd?

I encountered a Linux command, builtin cd. What is the difference between the commands builtin cd and cd? In fact, I made some researches about the difference, but I could not find a remarkable and ...
1
vote
1answer
42 views

Checking the number of files in a specific folder

I have 100 folders (called "Folder_1", "Folder_2", "Folder_3", ...) containing several files. From a loop over each folder, I would like to run commands (i.e., display the folder name) depending on ...
0
votes
1answer
93 views

How do you go back to the previous directory in Ranger?

In Ranger you can go to a directory with g. When you type g it gives you a list of places you can very easily go. For example g, and then p takes me to /tmp. How do I get back to the directory I was ...
5
votes
0answers
202 views

cifs: Cannot cd into a directory

For some reason I cannot cd into a particular remote directory for which I have access, it fails with: $ cd Data\ Services/ -bash: cd: Data Services/: Invalid argument This is how I mounted it: $ ...
1
vote
1answer
80 views

How do I cd and then ls in my cshrc

I want to be able to cd into a path and have it ls automatically. I have tried doing a function such as cs() { cd "@a" ; ls} but this results in an error saying "badly placed ()" so I do not think I ...
1
vote
1answer
28 views

Dirstack: index starts with 0

Zsh: 5.6.2 I use dirstack from archwiki: https://wiki.archlinux.org/index.php/zsh#Dirstack All setopts in script are on, script is sourced in ~/.zshrc, It works before and somehow change index to 0,...
1
vote
1answer
28 views

How to Start a Service in a Specific Directory via Daemontools?

I am using daemontools to start my application. In the run script, I have something like exec taskset -c 2 [absolute path to my application] But the problem is that one of the black box library my ...
10
votes
2answers
2k views

Can you explain these three things in this bash code for me?

I have a function in my .bashrc file. I know what it does, it steps up X many directories with cd Here it is: up() { local d="" limit=$1 for ((i=1 ; i <= limit ; i++)) do ...
-1
votes
2answers
60 views

CD vs Full Path per command

What is faster or considered better practice in shell scripts to first Cd into a directory then carry out commands or to write the full path? For example: Is it better to write cd /directory1/ and ...
0
votes
2answers
74 views

How do I make a cd command take effect outside of the bash script subshell? [duplicate]

I made this script: #!/bin/bash if [[ $# -ne 1 ]]; then echo "only use one argument" exit 1 fi mkdir $1 sleep 0.5 cd $1 exit 0 I wanted to make a script that I would later put into /usr/bin, ...
0
votes
1answer
440 views

How to access USB disk from terminal

I have few files in a USB disk named F:. I The files inside it are large. I do not want to move them to my harddisk. I want to make some comparison, e.g. diff between files from inside the USB and in ...
0
votes
2answers
54 views

Unable to go inside directory on Debian 9

I am logged in as sudo user on Debian 9. When I do ls then it shows me there is a directory called vars If I do cd /vars then I get error bash: cd: /vars: No such file or directory If I do sudo ...
0
votes
1answer
52 views

Shell Script To CD and Run a Python Script

OK, I know that there is a lot like this question but I literally get nothing. The thing i need is a script that cd's to /home/project then runs python3 pyscript.py I created an alias to cd alias name=...
1
vote
1answer
75 views

How can I suppress printing the full path to subdirectories when using CDPATH=“.:/some/path”?

I want to use bash's CDPATH to point to a directory of symlinks to directories that I access frequently. However, doing: export CDPATH="~/symlinks" causes cd SUBDIR to stop working if ./SUBDIR and ~...
2
votes
2answers
66 views

How do I create a symbol to represent a path to easily cd into a directory?

In the same way that cd ~ directs you to your home directory, is it possible to create another symbol, @ for example, such that cd @ would take me to /my/working/directory?
6
votes
3answers
3k views

-bash: /bin/cd: No such file or directory - automatically execute ls after cd

I accidentially destroyed my cd command. I tried to automatically execute ls after cd is called. I found a post saying that I have to execute alias cd='/bin/cd && /bin/ls', but now I get -...
3
votes
1answer
133 views

Why does `cd` have no effect if output is piped?

I accidentally typed cd /tmp | tail which is of course not what I meant. But to my surprise, I then did not change directory. Why is this? For comparison cd /tmp > /tmp/foo does result in a ...
7
votes
5answers
2k views

$ find -exec cd => gives error: => find: ‘cd’: No such file or directory

When I run this command it works: $ find . -inum 888696 -exec ls '{}' \; Conversation.pst Outlook Data File Outlook Data File.sbd Trash Unsent Messages Inbox.pst Outlook Data File.msf ...
5
votes
3answers
121 views

Is there any case in which the `cd .` (single dot) command could be useful?

This should theoretically just be redundant since it changes into the current working directory. Anyway, is there any scenario in practice, where this command could be useful?
1
vote
1answer
724 views

Getting random “cd: Too many arguments.” error messages when using different commands

I am getting random "cd: Too many arguments." when using different commands, for example newgrp or when logging in. Here is a console log showing the issue along with the Linux version and shell type. ...
1
vote
1answer
54 views

cd to a path containing spaces using a path variable [duplicate]

I have a file containing a list of commands which I run from my .bash_profile as source my_cmds For eg: $cat my_cmds scripts=~/scripts assuming my $HOME is /Users/knayak, when I run cd $scripts ...
0
votes
3answers
58 views

Solution to change directory passing a directory pattern as the parameter

I'd like to get any script or Linux solution to implement changing directory passing not exactly a directory but a pattern as the parameter. Something like this: # Ex: I'd like to execute a "cd" to a ...
0
votes
1answer
113 views

Why does cd need execution permission of a directory? [duplicate]

From https://unix.stackexchange.com/a/350629/674 For directories, the execute permission is a little different; it means you can do things to files within that directory (e. g. read or execute them)...
1
vote
2answers
48 views

cd's '-e' option

According to the Bash manual page the -e option of cd leads to an unsuccessful return status after a successful directory change. If the -e option is supplied with -P and the current working ...
1
vote
1answer
116 views

Inconsistent behavior of Bash's `cd` with symbolic links [duplicate]

I am currently trying understand the behavior of Bash's cd when it comes to symbolic links. By default, cd should follow the logical directory structure and should not resolve symbolic links. cd ...
0
votes
3answers
165 views

Change directory working directory for previous directory in Shell Script

Is there any way to achieve below.. I am stuck to perform my task. I have written shell script which gives me correct output only when the script is getting executed on same month below is the ...
0
votes
1answer
27 views

Alias CD to a directory that's name is included in current directory

I've been using cmake and creating a build folder for my cmake code and I want to easily cd to the build directory. I've been naming my build directory in this format: /parent/codeandsuch /parent/...
0
votes
5answers
626 views

Change directory using ls | tail -1

I want to go in the directory on the basis of highest directory number. Path: /home/cg/root/2018/01. Inside this path I have multiple directories as below 15 16 17 So on.. In this case highest ...
-1
votes
4answers
193 views

Need to change directory in bash script

I am trying to change a directory in a bash script in order to delete a file after it has been transferred. Here is my script and what I would like to do: Please see line 5: 1 #!/bin/bash 2 name=...
1
vote
2answers
2k views

curl -O : Why it's not possible to download file specific directory? [closed]

The man curl entry for curl -O says: If you want the file saved in a different directory, make sure you change cur‐ rent working directory before you invoke curl with the -O, --...
0
votes
1answer
28 views

cd fails when trying to enter maldetect version-agnostic directory

I'm installing Maldet on Debian 9.3: cd /usr/local/src wget http://www.rfxn.com/downloads/maldetect-current.tar.gz tar -xzvf maldetect-current.tar.gz cd maldetect-* bash ./install.sh While doing cd ...
1
vote
1answer
47 views

is there a way to `ls` midway through the path of a `cp` or `mv` command (i.e. without cd-ing to the directory in order to perform an `ls`)?

I'm looking for a more efficient way to check what directories and files exist midway through typing the path for a cp or mv command without having to cd to the folder and running ls, then returning ...
1
vote
2answers
216 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
923 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
78 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 ...