Questions tagged [cd-command]

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

Filter by
Sorted by
Tagged with
-1
votes
4answers
87 views

Where is cd ~ located on Ubuntu?

What is the absolute path of cd ~ on Ubuntu? Trying to find out where this dir is located? For example: /home
0
votes
1answer
45 views

How to use external command cd in bash?

I'm trying to use external cd (/usr/bin/cd) to jump to parent directory /usr/bin/cd .. but it doesn't work (no error message, current directory remains as was). I know this is a builtin bash command ...
0
votes
1answer
40 views

Passing a Directory to cd

I have a function, which I would hope would get me a fuzzy search on the latest directories I have been looking at and save me time, a simple 1 liner: dirs | sed 'y/ /\n/' | fzf | xargs cd 2 hours ...
0
votes
2answers
103 views

How to execute a bash script, with it's arguments, on multiple directories? [duplicate]

I have a shell script app1.sh and a tree of folders, but I don't know how to execute this shell inside each folder. Here is This script recieves an string, an integer and a file as arguments to work....
1
vote
0answers
26 views

Oh My Zsh - execute ls after auto cd [duplicate]

Oh My Zsh has this lovely feature where you can just type dir-name instead of cd dir-name to access the directory called dir-name. In my old .bashrc I had a function that overwrites the builtin cd ...
0
votes
0answers
18 views

Does zsh support tab completion when changing directories using path replacement? [duplicate]

I just started using zsh after being a bash user for over two years and out of the many great enhancements it offers, I am ecstatic over the path replacement capability when changing directories. But ...
3
votes
1answer
50 views

Change directories verbosely?

I am logging every action performed in a bash script to a logfile. I would like to have cd verbosely change directories so I can record the output to the log. Kind of like this: iMac:~ leetbacoon$ ...
2
votes
3answers
112 views

Faster way to cd into a directory after listing the directory in a previous command?

I was looking for a file in a directory and so I used the find command which then showed the directory path of where the file is. ex. $find . -name file.txt /folder/path/file-contents/file.txt Now ...
2
votes
2answers
91 views

How can I combine the ssh and cd commands?

I am trying to write a bash-script to update a remote git repo. The script looks something like: #!/bin/bash ssh user@remote.de 'cd /home/h/usr/praktikum | git pull | sbatch run.sh' However, the ...
0
votes
1answer
83 views

How to disallow 'cd ..' for a chroot user

I wanted to restrict a user from accessing files (just outside his directory), so I used chroot, and made the restricted directory as his landing directory upon logging in. But, If I do cd .. that ...
7
votes
1answer
566 views

Can I create a one way symlink?

I want to create a one way symlink i.e. I can use it to go to the destination directory but I cannot go back. Let's say there is a directory called D with two subdirectories S1 and S2. I want to ...
1
vote
2answers
53 views

Symlinked directories and output redirect

When I run the following command, where symlinked-dir is just that - a symlink to another directory, cat complains that there is no such file. There is, indeed, no such file - it's created in the ...
10
votes
1answer
1k views

“cd” into /sys/kernel/debug/tracing causes permission change

I've faced a really strange issue today, and am totally helpless about it. Some of the servers I manage are monitored with Nagios. Recently I saw a disk usage probe failing with this error: DISK ...
0
votes
3answers
67 views

How to copy a file to a destination folder and cd to the destination folder in one command

To explain my question, here is the dumb way of how I'm doing things: cp fileFromMyFriend.txt ~/my_first_subfolder/my_second_subfolder/more_subfolders cd ~/my_first_subfolder/my_second_subfolder/...
0
votes
0answers
55 views

Xargs and cd command [duplicate]

Can someone can explain me why the code below: echo "dir1" | xargs cd doesn't actually change working dir to dir1? It just return an error:xargs: cd: No such file or directory. Shouldn't the xargs ...
2
votes
1answer
53 views

User Function to cd to nearest directory with given name

Would anyone have a user-defined function to put in my .basrc to do this. The following example should explain what I have in mind. Given the following file system: Level1 Level2 Level3 / ...
15
votes
3answers
4k views

Why did my folder names end up like this, and how can I fix this using a script?

Sorry if this has an answer elsewhere, I've no idea how to search for my problem. I was running some simulations on a redhat linux HPC server, and my code for handling the folder structure to save ...
0
votes
1answer
258 views

The root directory and slash in cd command

I'm new to Linux and I want to understand this simple Linux command: cd /boot/../dev cd = change directory The first / = go to the root directory boot = is the name of a directory The second / = .......
1
vote
3answers
308 views

How to create bash alias on Ubunth WSL when username has space and apostrophe

I'm trying to create the following alias in Ubuntu WSL: alias windocs='cd /mnt/c/Users/Firstname L'astname/Documents/' My username is unfortunately Firstname L'astname, including the space and ...
1
vote
1answer
232 views

Not able to use cd Getting fatal: Not a git repository (or any of the parent directories): .git

I am using zsh on an Ubuntu 16.04 Since today I have not been able to use the cd command. Whenever I try to change my directory from the terminal I get this error fatal: Not a git repository (or any ...
0
votes
2answers
384 views

Change directory of remote machine through ssh after ~./bashrc execution

I am trying to run a script on a remote machine via ssh. For this I want to change the directory and run the script from there. I found that the standard method on how to do this is: ssh -Y -t user@...
1
vote
2answers
67 views

sh: is there a command to interactively edit the PWD?

I'm looking for a command that invokes readline or similar, primed with the current $PWD, to let the user edit the current directory, then cd to the edited value. E.g. > cd ~/a/b/c/d > pwd > ...
2
votes
1answer
96 views

Complete a command fully relative to a different directory

I have a function to run a single command in a different category. cd1 SOMEDIR MYCOMMAND ARG… is equivalent to (cd SOMEDIR && MYCOMMAND ARG…), with two advantages. It's slightly easier to type ...
0
votes
2answers
34 views

Convenient way to cd into a frequently-used dir? [duplicate]

A dir I cd into a lot has a really long path. I'd like to reduce keystrokes. I have tried this... sudo ln -s /mnt/c/Users/me/ho/hum/bin /mybin It works, but something about it seems wrong. Is ...
2
votes
0answers
33 views

Add file to PATH only when in specific directory [duplicate]

Is it possible to make executable appear in the global search path when I am entering to the some specific directory and get it removed once directory changed again?
0
votes
1answer
223 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
492 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
44 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 ...
1
vote
3answers
174 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
579 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
58 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
386 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 ...
0
votes
2answers
9k 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
52 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
54 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
203 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
55 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 ...
-1
votes
1answer
124 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 ...
102
votes
11answers
23k 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
83 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 ...
0
votes
1answer
48 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 ...
1
vote
1answer
374 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 ...
6
votes
1answer
854 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
574 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
41 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
83 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
248 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
140 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, ...

1
2 3 4 5
7