Questions tagged [cd-command]

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

Filter by
Sorted by
Tagged with
0
votes
1answer
24 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
1answer
52 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 "...
2
votes
3answers
139 views

Has “cd .. .. ..” ever worked for going up 3 directories?

I was reading a book published in 2018 titled "Linux Basics for Hackers: Getting Started with Networking, Scripting, and Security in Kali" from no starch press. And this was written there ...
-1
votes
1answer
74 views

Add variable to cd directory path

I know these questions might have been asked somewhere but their solutions don't really work. I need help. I want to add a variable to a directory name then change directory to it. The approach below ...
0
votes
2answers
30 views

I copied a file into my VM, but the folder is a regular file

I'm new to Linux, and I'm trying to untar the following file, so I moved from GCS to the Virtual Machine with the following command gsutil cp gs://ghtorrent_datadump/mysql-2020-07-17.tar home/...
1
vote
4answers
50 views

Taking a File Argument and Moving to That Directory? [duplicate]

Is there a Unix command or shell script that takes a file argument and moves to the containing directory, ignoring the file part of the argument altogether?
13
votes
3answers
820 views

What is an “alternative directory name” in CDPATH for the cd command?

In the cd, bash help page: The variable CDPATH defines the search path for the directory containing DIR. Alternative directory names in CDPATH are separated by a colon (:). A null directory name is ...
9
votes
4answers
2k views

How to `cd` with word in the middle of a folder?

I have workspace with many folders which all are consisted of long paths. For example: |- workspace |-- this.is.very.long.name.context |-- this.is.another.long.path.authors |-- // 20 more folders |-- ...
0
votes
1answer
66 views

why cant I sudo cd into /root [duplicate]

when I run sudo cd /root it says sudo: cd: command not found but it works perfectly fine if I first sudo su and then do cd /root. Isn't sudo supposed to give me root privileges?
0
votes
0answers
17 views

How to use cdir in multiple tmux panes?

I use cdir python package to navigate between folders and it works very fine. Documentation here. But I have an issue in using it with tmux I am explaining the situation below: I have started a ...
0
votes
0answers
32 views

How to change directory from environment variable in tcsh?

I have captured a linux path into an environment variable. Now I want to change the directory to the path in that environment variable. Lets say the environment variable is named: gr I can see the ...
8
votes
1answer
408 views

libtool error cd: ../..: Not a directory

Getting this very bizarre error from libtool when trying to install a package I built. It happens when running in a subdirectory (src/api) of the source tree: make[5]: Leaving directory '/users/...
0
votes
1answer
56 views

What will this do? “ cd /; ls -al > $HOME/outputfile.log ”

This was an exercise proposed to us in class' but I didn't get it. What exactly will these commands do? cd / ls -al > $HOME/outputfile.log I did try it (in Linux) but (apparently) nothing ...
3
votes
2answers
102 views

what is the purpose of “cd .” command?

We know that the cd command is used to change directories. For example cd dirname valid dirnames include . and .. as well. The purpose of cd .. is clear. From the manpage: A null directory name ...
1
vote
1answer
54 views

Is there a way to change the directory where cd without argument change to?

cd without argument change to the home directory. I'd like it to change to another one. Is there another way than writing a function to do that?
1
vote
3answers
30 views

issues Debugging cd on custom shell

I am having issues with my custom shell cd command I created. Right now I am testing the base case where cd is the only argument, when that is the case its suppose to change the default directory to ...
-1
votes
4answers
112 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
50 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
68 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
154 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
31 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 ...
3
votes
1answer
53 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
4answers
180 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
174 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
107 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
673 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
119 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
2k 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
71 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/...
2
votes
1answer
63 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
673 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
660 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
283 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
788 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
77 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 > ...
3
votes
1answer
117 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
37 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
34 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
272 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
1k 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
224 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
626 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
83 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
1k 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
17k 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
58 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
325 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 ...

1
2 3 4 5
8