Questions tagged [cd-command]

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

Filter by
Sorted by
Tagged with
2
votes
1answer
68 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
3answers
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 ...
2
votes
1answer
37 views

How to get recent places in terminal/shell?

Is there any way to get a list of the most recent 'places' (directories) have been navigated in terminal (osx)? I mean, I'd like to open my terminal, tipe some command, get the last 2 or 3 places I've ...
10
votes
5answers
598 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
1answer
45 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
0answers
21 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” ...
0
votes
4answers
39 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 ...
-3
votes
2answers
45 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.
1
vote
1answer
30 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
1answer
26 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
64 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
146 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
98 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
31 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
57 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
898 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
3k 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 |-- ...
1
vote
1answer
226 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
19 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
48 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
486 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
68 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
136 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
70 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
2answers
44 views

issues Debugging cd on custom shell [closed]

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
195 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
64 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
122 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
316 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
32 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
60 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
301 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
283 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
131 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
741 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
220 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
94 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
73 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
1k 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 / = .......
2
votes
3answers
977 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
313 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
1k 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
81 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
133 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
45 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
37 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
316 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
2k 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
2 3 4 5
8