cd is a command-line utility to change the working directory.
-3
votes
1answer
33 views
Not able to Run cd command with restricted user!
I have restricted a normal user to limited commands using rbash, now am not able to cd (change directory) to other directory,can someone help me how can i run cd command with restricted user, please ...
0
votes
0answers
32 views
Why cd command is not working? [duplicate]
I wrote a basic script to mkdir and then cd to the directory. The directory is creating but cd is not working.
Details::
[root@a ~]# cat somefile
mkdir $1
cd $1
[root@a ~]#
Shell result::
[root@a ~...
1
vote
3answers
37 views
Run git fetch after any cd command
I need to run git fetch after any cd command in the background and only if I'm in a git directory.
I'm horrible at zsh/bash scripting and could use some help with this
2
votes
1answer
17 views
Create shorcuts in a terminal to navigate between folders [duplicate]
I am looking a way to create shortcuts for the cd command. My goal is to go quickly to distant folders. I have a new (big) drive which is not in my /home folder (but in /media/user/xxX/yyy/) and I ...
3
votes
1answer
33 views
How to define alias only for some directory?
I want to define some alias iex="iex -S mix" only for one directory - this alias should work only when I cd'ed to this directory. Another requirement - this functionality should be placed inside this ...
0
votes
1answer
19 views
alias to make a new directory and go to it [duplicate]
So here I've created, or at least tried to create an alias for a command that accepts a command-line argument, makes a new directory with that name, and goes to it.
alias newfolder='mkdir $2 ; cd "$(...
15
votes
3answers
1k views
How to run one command with a directory as argument, then cd to the same? I get “no such file or directory”
I would like to construct a short function to do the following. Let's say that I move file 'file.tex' to my documents directory:
mv file.tex ~/Documents
Then, I'd like to cd to that directory:
cd ~/...
0
votes
1answer
72 views
How to change directory to desktop on german ubuntu?
I fail to change to the desktop via command line. I tried it like this.
cd ~/Desktop
But then I get "File or Path not found"
3
votes
1answer
306 views
How do I access a folder which I can't sudo cd into?
I'm trying to change my directory to /boot/efi, but running sudo cd /boot/efi does nothing. I'm on fedora 23. Is there a more powerful command for this?
0
votes
1answer
125 views
Cannot change directory at /home as root user (Permission denied) [closed]
I am using GNUroot debian ( an android app ) and after many attempts to connect with ssh to my server I now have no access with cd at my /home folder as a root user. I can run ls /home but I cannot ...
2
votes
3answers
588 views
Pass output of “whereis” command to “cd” to change directory in one step
It should be simple no-doubt, but I can't find a way to pass output of whereis command to cd command in same line so I don't have to do cd in the second step.
I have tried passing like below:
cd $(...
3
votes
1answer
45 views
Use a symbolic link to redirect?
Is it possible to set up a symbolic link such that cd called on the link redirects to the linked path? Kind of like this:
$ ln /A/B /B/C
$ cd /A/B
$ pwd
/B/C
$
2
votes
1answer
26 views
how to have a custom zsh auto_cd command
Instead of the normal cd I've created my own function
function cd {
builtin cd "$@" && ls -F
}
This works great for when I use commands like cd someDir/subDir but not when I change ...
-3
votes
1answer
81 views
I cant cd hidden files/dir
I have been working on git a little bit and i tried to cd into /home/pi/Desktop/python_git/.git But it complained there was no directory called /.git. I know that this is because it begins with a . ...
2
votes
0answers
70 views
cd with double slash hangs forever on Mac OS X Terminal
If I type cd // on the Mac OS X Terminal (Version 2.6.1 (361.1)), the prompt hangs forever. Why?
Curiously that doesn't happen if I do cd / or cd ///.
I am using El Captain with the bash that comes ...
1
vote
1answer
260 views
Bash script SFTPing into remote server and downloading files, cd into proper directory on local machine
I have a cron on my Ubuntu server that runs this bash script daily:
#!/usr/bin/expect -f
spawn sftp user@ip
expect "password:"
send "password\n"
expect "sftp>"
send "cd remote_directory\n"
expect "...
13
votes
0answers
200 views
Completion for the first argument of cd OLD NEW
In zsh, the cd command has a two-argument form: cd OLD NEW changes to ${PWD/OLD/NEW}. With the new-style completion system, zsh is capable of completing NEW: the second argument is completed based on ...
1
vote
2answers
37 views
How to work with symbolic links to directories
I am experimenting with symbolic links and I'm encountering a couple issues. The first is how after following a symbolic link to a directory to display the actual working directory instead of the ...
2
votes
1answer
100 views
Tab to show directory contents
I use the terminal app on OSX. Whenever I cd into a deep directory I find it useful to display the successive directory contents as I go. By tapping tab when typing the filepath, it lets me see the ...
1
vote
1answer
36 views
cd: permission denied: binutils-2.21.1
I'm following Tools Used in 6.828 to configure.
$ sudo tar xjf binutils-2.21.1.tar.bz2
generate folder binutils-2.21.1
$ cd binutils-2.21.1
cd: permission denied: binutils-2.21.1
$ sudo cd binutils-...
3
votes
3answers
221 views
POSIX compliance of the cd program?
Is globbing and shell expansion same thing? I'm learning C by writing a custom shell and I'm also learning POSIX. Now I wonder if it is POSIX compliance that cd - takes you back and that ~ means home ...
2
votes
1answer
49 views
Change to a directory containing a space
I'm using a MacBook with OS X installed.
I'm on Terminal trying to go to a directory. So I'm in Home and I use the command ls and there is a VirtualBox VMs directory.
But when I try to do cd ...
1
vote
1answer
56 views
How can I get a persistent dirstack with unique entries in zsh?
The Arch Wiki has this interesting bit of zsh configuration:
DIRSTACKFILE="$HOME/.cache/zsh/dirs"
if [[ -f $DIRSTACKFILE ]] && [[ $#dirstack -eq 0 ]]; then
dirstack=( ${(f)"$(< $...
2
votes
1answer
26 views
Change color when changing directory
I have two folders called Documents and Downloads. In zsh, when I type
cdSpaceDoTabc
the color of Documents change from white to (hard to read) gray. How can I turn off this color change or control ...
3
votes
1answer
521 views
pushd, popd vs cd, cd- in bash and zsh
Is there a difference between the behavior of pushd/popd in bash vs zsh? It seems in zsh cd, cd- behaves exactly the same as pushd/popd (which adds/pops directory automatically when cd) while in bash ...
-9
votes
2answers
1k views
What does the cd /etc command do?
I was asked the question "what does the cd /etc command do?". This is my answer:
This command cd /etc changes directory to the directory specified after the slash /. The /etc refers to a folder in ...
2
votes
2answers
64 views
cd out of deleted folder
Is there a way to cd out of a directory which has just been deleted (go up one level into the upper folder which still exists?
It often happens to me that I have a console opened for a folder, and ...
0
votes
0answers
19 views
Is this correct folder name `//` achieved via `cd //` [duplicate]
I never saw this before, nor I can track this via Google, and I thought interesting to share.
If I set cd // and I pwd I get the output //.
If I touch a.txt I checked this file belongs to /
If I set ...
1
vote
2answers
269 views
Change Directory and execute command automatically then change directory back out
I'm attempting to write a script that will be run in a given directory with many single level sub directories. The script will cd into each of the sub directories, execute a command on the files in ...
0
votes
1answer
69 views
Why is cd appending dirs like pushd?
I am using zsh in Babun (Cygwin with oh-my-zsh and some extras).
I noticed some odd behavior, it looks like cd is behaving like pushd?
{ ~ } » mkdir foo
{ ~ } » pushd foo
~/foo ~
{ foo } » popd
~
...
0
votes
2answers
96 views
How to use cd command in su command?
In the below script the cases aserver and bserver work fine. But in case "cserver" above, after su - gsxuserp, I need to perform the following three options with the same user.
cd ..
cd ...
0
votes
2answers
64 views
Where does cd command is configured to cd $HOME when no path is specified?
The following commands does the same thing
$ cd
$ cd $HOME
$ cd ~
$ cd /home/user
In three of them, the path is relatively specified. But how or why in the earth the simple cd opens the user's home ...
0
votes
1answer
56 views
What is the safest (or most elegant or shortest) way to change to the directory from where a script is called?
I wondered what might be a safe or the Unix compatible way to change to the directory from which a script is called.
These two methods even work in a directory with spaces and special characters in ...
-1
votes
2answers
130 views
How to change to home directory without using only “cd”
I am doing an assignment that requires me to change in to my home directory from my currenty directory which is ~/sample_dir1/sample_dir/cambridge.
It asks me to change to my home directory using a ...
0
votes
1answer
25 views
why does /var/mail/{username} = /Users/{username}?
My basic question is why do both of these paths point to home (i.e., ~)? Is it pointing to the same home or is it duplicated?
I doubt it's duplicated, so if not, how does cd .. decide which directory ...
1
vote
1answer
102 views
Bash script won't change directory
First of all, I've got no background in programming and do this as a hobby in my spare time.
And by that i mean: It's a "hobby", i do it for fun. I began like 6 weeks ago, everything script-like here ...
2
votes
1answer
82 views
Automatically add slash when navigating through symlink
I use symlinks a lot and pretty much linked my whole home directory into a folder .other or .dotfiles. When I'm im my home directory and try to got into the folder .config/, its actually a symbolic ...
2
votes
4answers
135 views
cd into last alphanumeric directory
I have this directory contents:
As you can see, the directory names are just timestamps - in general when I am the top level directory I usually want to open the most recent directory which is the ...
3
votes
4answers
175 views
Change dir from script without a “shell procedure” or “sourcing the script”
I know what I can make a shell procedure or source the script instead of running it to cd the shell I am using. What I want to know is there any way to cd the "parent shell" (not sure if that is the ...
0
votes
1answer
474 views
using cd command with a variable [closed]
Edit : actually as @thrig says both ways do work.
Mods feel free to delete this question (I can't because it has answers)
I have a folder that I want to cd into.
for example, suppose I am in /home/...
1
vote
2answers
236 views
cd in bash script without alias, function, source [duplicate]
I have a little problem, and hope that anyone can help me. I've written a bash script which should cd me to a directory.
My problem is that only the directory in the subshell changes.
I've read of ...
0
votes
1answer
115 views
Bash script not working, doesn't change directory
First off, I only just started learning how to use Linux yesterday so my abilities are very limited.
I am essentially creating a script that I can run everytime I turn on my VPS and the script then ...
2
votes
2answers
123 views
How to navigate the filesystem efficiently? [closed]
This question is on the "do everything through the terminal" mindset. I find navigating through the file system very inefficient. My typical workflow is:
I want to go to ~/foo/bar/boo/far/my/project/...
16
votes
6answers
808 views
Equivalent of alias for a symbolic link?
I find myself needing to jump around a few directories in my home folder often and get tired of writing them. I would like a quicker approach, which would traditionally be a symbolic link.
However, I ...
3
votes
3answers
24 views
jump to current day's directory in a date based directory hierachy?
I have a pretty standard directory higherachy, year, month, date, for log files. If I want to go to todays logs I have to type cd logs/2015/12/16/
By itself this wouldn't be bad, but since I ...
1
vote
1answer
171 views
How to declare some aliases dynamically in zsh?
I would like to declare a few shortcut commands to switch between my various coding projects, so I have come up with the following script.
projects=$(ls -d ~/Workspace/*/)
prefix="/Users/myuser/...
2
votes
1answer
181 views
How to not show path after cd command with CDPATH set?
Setting the CDPATH variable is very useful, but it results in some not very nice result: each time I use the cd command, the full path of directory I want to move is printed.
For example, if I am in ...
1
vote
2answers
53 views
'cd //; pwd' # What's happening here? [duplicate]
A coworker just pointed out something odd, and I'm curious what the explanation might be.
On the systems I've tried, cd /', 'cd //', and 'cd ///' all have the effect of changing directory to the file ...
2
votes
1answer
247 views
ls after cd in tcsh?
I cannot seem to find an answer to this question. In my .bash_profile I have this line:
cd() { builtin cd "$@"; ll; }
which executes ll every time I change directories. I would like this ...
3
votes
4answers
231 views
Why does the wildcard * not work when changing directories?
For example I'm in my directory:
/home/myname
and then I want to CD into a different directory.
/home/pulsar/...
Since I need to go pretty deep into the other directory, how can I go about this ...