-bash: /bin/cd: No such file or directory - automatically execute ls after cd
Clash Royale CLAN TAG#URR8PPP
up vote
6
down vote
favorite
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 -bash: /bin/cd: No such file or directory
and can't change directoy anymore.
linux alias cd-command
 |Â
show 4 more comments
up vote
6
down vote
favorite
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 -bash: /bin/cd: No such file or directory
and can't change directoy anymore.
linux alias cd-command
16
There is no/bin/cd
;cd
is a shell built-in.
â Andy Dalton
Jun 25 at 14:32
Enjoy unix.stackexchange.com/questions/354123 and what it hyperlinks to M. Dalton. (-:
â JdeBP
Jun 25 at 14:41
3
A POSIX compliant platform has a/bin/cd
, but that only exists for formal reasons and is not usable for anything.
â schily
Jun 25 at 14:41
1
Wow/bin/cd
must be the most useless command.
â ctrl-alt-delor
Jun 25 at 17:15
cd isn't a file on disk, It's a shell built-in command:type cd
â PersianGulf
Jun 25 at 17:26
 |Â
show 4 more comments
up vote
6
down vote
favorite
up vote
6
down vote
favorite
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 -bash: /bin/cd: No such file or directory
and can't change directoy anymore.
linux alias cd-command
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 -bash: /bin/cd: No such file or directory
and can't change directoy anymore.
linux alias cd-command
edited Jun 26 at 11:01
asked Jun 25 at 14:26
Black
4932728
4932728
16
There is no/bin/cd
;cd
is a shell built-in.
â Andy Dalton
Jun 25 at 14:32
Enjoy unix.stackexchange.com/questions/354123 and what it hyperlinks to M. Dalton. (-:
â JdeBP
Jun 25 at 14:41
3
A POSIX compliant platform has a/bin/cd
, but that only exists for formal reasons and is not usable for anything.
â schily
Jun 25 at 14:41
1
Wow/bin/cd
must be the most useless command.
â ctrl-alt-delor
Jun 25 at 17:15
cd isn't a file on disk, It's a shell built-in command:type cd
â PersianGulf
Jun 25 at 17:26
 |Â
show 4 more comments
16
There is no/bin/cd
;cd
is a shell built-in.
â Andy Dalton
Jun 25 at 14:32
Enjoy unix.stackexchange.com/questions/354123 and what it hyperlinks to M. Dalton. (-:
â JdeBP
Jun 25 at 14:41
3
A POSIX compliant platform has a/bin/cd
, but that only exists for formal reasons and is not usable for anything.
â schily
Jun 25 at 14:41
1
Wow/bin/cd
must be the most useless command.
â ctrl-alt-delor
Jun 25 at 17:15
cd isn't a file on disk, It's a shell built-in command:type cd
â PersianGulf
Jun 25 at 17:26
16
16
There is no
/bin/cd
; cd
is a shell built-in.â Andy Dalton
Jun 25 at 14:32
There is no
/bin/cd
; cd
is a shell built-in.â Andy Dalton
Jun 25 at 14:32
Enjoy unix.stackexchange.com/questions/354123 and what it hyperlinks to M. Dalton. (-:
â JdeBP
Jun 25 at 14:41
Enjoy unix.stackexchange.com/questions/354123 and what it hyperlinks to M. Dalton. (-:
â JdeBP
Jun 25 at 14:41
3
3
A POSIX compliant platform has a
/bin/cd
, but that only exists for formal reasons and is not usable for anything.â schily
Jun 25 at 14:41
A POSIX compliant platform has a
/bin/cd
, but that only exists for formal reasons and is not usable for anything.â schily
Jun 25 at 14:41
1
1
Wow
/bin/cd
must be the most useless command.â ctrl-alt-delor
Jun 25 at 17:15
Wow
/bin/cd
must be the most useless command.â ctrl-alt-delor
Jun 25 at 17:15
cd isn't a file on disk, It's a shell built-in command:
type cd
â PersianGulf
Jun 25 at 17:26
cd isn't a file on disk, It's a shell built-in command:
type cd
â PersianGulf
Jun 25 at 17:26
 |Â
show 4 more comments
3 Answers
3
active
oldest
votes
up vote
23
down vote
accepted
Your system (like many Unix systems) does not have an external cd
command (at least not at that path). Even if it had one, the ls
would give you the directory listing of the original directory. An external command can never change directory for the calling process (your shell)1.
Remove the alias from the environment with unalias cd
(and also remove its definition from any shell initialization files that you may have added it to).
With a shell function, you can get it to work as cd
ordinarily does, with an extra invocation of ls
at the end if the cd
succeeded:
cd ()
command cd "$@" && ls -lah
or,
cd () command cd "$@" && ls -lah;
This would call the cd
command built into your shell with the same command line arguments that you gave the function. If the change of directory was successful, the ls
would run.
The command
command stops the shell from executing the function recursively.
The function definition (as written above) would go into your shell's startup file. With bash
, this might be ~/.bashrc
. The function definition would then be active in the next new interactive shell session. If you want it to be active now, then execute the function definition as-is at the interactive shell prompt, which will define it within your current interactive session.
1 On systems where cd
is available as an external command, this command also does not change directory for the calling process. The only real use for such a command is to provide POSIX compliance and for acting as a test of whether changing directory to a particular one would be possible.
Where do I have to put the function?
â Black
Jun 25 at 14:37
1
@Black You may put it wherever you would have put thealias
definition. In abash
shell, that would probably be in~/.bashrc
.
â Kusalananda
Jun 25 at 14:38
I added the function to~/.bashrc
but it does not work.ls -lah
is not executed at all.
â Black
Jun 25 at 14:41
@Black No, you add it exactly the way I wrote it. Then it will be active in any new shell session.
â Kusalananda
Jun 25 at 14:41
1
Note that POSIXly, you'd usecd() command cd "$@" && ls -lah;
, though that wouldn't work withzsh
except insh
emulation. Not all shells have abuiltin
builtin. In ksh93, it does something different.
â Stéphane Chazelas
Jun 25 at 16:30
 |Â
show 5 more comments
up vote
7
down vote
I was able to solve it by removing the alias again with unalias cd
If you remove the stuck-out text, then this is the only answer that answers the question.
â ctrl-alt-delor
Jun 25 at 17:18
1
@ctrl-alt-delor Note there's no question in the question. We could only guess what the implicit question is. In this situation "why?" is as good as "how to revert?"
â Kamil Maciorowski
Jun 26 at 10:26
add a comment |Â
up vote
5
down vote
That happened because:
$ type cd
cd is a shell builtin
add a comment |Â
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
23
down vote
accepted
Your system (like many Unix systems) does not have an external cd
command (at least not at that path). Even if it had one, the ls
would give you the directory listing of the original directory. An external command can never change directory for the calling process (your shell)1.
Remove the alias from the environment with unalias cd
(and also remove its definition from any shell initialization files that you may have added it to).
With a shell function, you can get it to work as cd
ordinarily does, with an extra invocation of ls
at the end if the cd
succeeded:
cd ()
command cd "$@" && ls -lah
or,
cd () command cd "$@" && ls -lah;
This would call the cd
command built into your shell with the same command line arguments that you gave the function. If the change of directory was successful, the ls
would run.
The command
command stops the shell from executing the function recursively.
The function definition (as written above) would go into your shell's startup file. With bash
, this might be ~/.bashrc
. The function definition would then be active in the next new interactive shell session. If you want it to be active now, then execute the function definition as-is at the interactive shell prompt, which will define it within your current interactive session.
1 On systems where cd
is available as an external command, this command also does not change directory for the calling process. The only real use for such a command is to provide POSIX compliance and for acting as a test of whether changing directory to a particular one would be possible.
Where do I have to put the function?
â Black
Jun 25 at 14:37
1
@Black You may put it wherever you would have put thealias
definition. In abash
shell, that would probably be in~/.bashrc
.
â Kusalananda
Jun 25 at 14:38
I added the function to~/.bashrc
but it does not work.ls -lah
is not executed at all.
â Black
Jun 25 at 14:41
@Black No, you add it exactly the way I wrote it. Then it will be active in any new shell session.
â Kusalananda
Jun 25 at 14:41
1
Note that POSIXly, you'd usecd() command cd "$@" && ls -lah;
, though that wouldn't work withzsh
except insh
emulation. Not all shells have abuiltin
builtin. In ksh93, it does something different.
â Stéphane Chazelas
Jun 25 at 16:30
 |Â
show 5 more comments
up vote
23
down vote
accepted
Your system (like many Unix systems) does not have an external cd
command (at least not at that path). Even if it had one, the ls
would give you the directory listing of the original directory. An external command can never change directory for the calling process (your shell)1.
Remove the alias from the environment with unalias cd
(and also remove its definition from any shell initialization files that you may have added it to).
With a shell function, you can get it to work as cd
ordinarily does, with an extra invocation of ls
at the end if the cd
succeeded:
cd ()
command cd "$@" && ls -lah
or,
cd () command cd "$@" && ls -lah;
This would call the cd
command built into your shell with the same command line arguments that you gave the function. If the change of directory was successful, the ls
would run.
The command
command stops the shell from executing the function recursively.
The function definition (as written above) would go into your shell's startup file. With bash
, this might be ~/.bashrc
. The function definition would then be active in the next new interactive shell session. If you want it to be active now, then execute the function definition as-is at the interactive shell prompt, which will define it within your current interactive session.
1 On systems where cd
is available as an external command, this command also does not change directory for the calling process. The only real use for such a command is to provide POSIX compliance and for acting as a test of whether changing directory to a particular one would be possible.
Where do I have to put the function?
â Black
Jun 25 at 14:37
1
@Black You may put it wherever you would have put thealias
definition. In abash
shell, that would probably be in~/.bashrc
.
â Kusalananda
Jun 25 at 14:38
I added the function to~/.bashrc
but it does not work.ls -lah
is not executed at all.
â Black
Jun 25 at 14:41
@Black No, you add it exactly the way I wrote it. Then it will be active in any new shell session.
â Kusalananda
Jun 25 at 14:41
1
Note that POSIXly, you'd usecd() command cd "$@" && ls -lah;
, though that wouldn't work withzsh
except insh
emulation. Not all shells have abuiltin
builtin. In ksh93, it does something different.
â Stéphane Chazelas
Jun 25 at 16:30
 |Â
show 5 more comments
up vote
23
down vote
accepted
up vote
23
down vote
accepted
Your system (like many Unix systems) does not have an external cd
command (at least not at that path). Even if it had one, the ls
would give you the directory listing of the original directory. An external command can never change directory for the calling process (your shell)1.
Remove the alias from the environment with unalias cd
(and also remove its definition from any shell initialization files that you may have added it to).
With a shell function, you can get it to work as cd
ordinarily does, with an extra invocation of ls
at the end if the cd
succeeded:
cd ()
command cd "$@" && ls -lah
or,
cd () command cd "$@" && ls -lah;
This would call the cd
command built into your shell with the same command line arguments that you gave the function. If the change of directory was successful, the ls
would run.
The command
command stops the shell from executing the function recursively.
The function definition (as written above) would go into your shell's startup file. With bash
, this might be ~/.bashrc
. The function definition would then be active in the next new interactive shell session. If you want it to be active now, then execute the function definition as-is at the interactive shell prompt, which will define it within your current interactive session.
1 On systems where cd
is available as an external command, this command also does not change directory for the calling process. The only real use for such a command is to provide POSIX compliance and for acting as a test of whether changing directory to a particular one would be possible.
Your system (like many Unix systems) does not have an external cd
command (at least not at that path). Even if it had one, the ls
would give you the directory listing of the original directory. An external command can never change directory for the calling process (your shell)1.
Remove the alias from the environment with unalias cd
(and also remove its definition from any shell initialization files that you may have added it to).
With a shell function, you can get it to work as cd
ordinarily does, with an extra invocation of ls
at the end if the cd
succeeded:
cd ()
command cd "$@" && ls -lah
or,
cd () command cd "$@" && ls -lah;
This would call the cd
command built into your shell with the same command line arguments that you gave the function. If the change of directory was successful, the ls
would run.
The command
command stops the shell from executing the function recursively.
The function definition (as written above) would go into your shell's startup file. With bash
, this might be ~/.bashrc
. The function definition would then be active in the next new interactive shell session. If you want it to be active now, then execute the function definition as-is at the interactive shell prompt, which will define it within your current interactive session.
1 On systems where cd
is available as an external command, this command also does not change directory for the calling process. The only real use for such a command is to provide POSIX compliance and for acting as a test of whether changing directory to a particular one would be possible.
edited Jun 30 at 8:33
answered Jun 25 at 14:34
Kusalananda
101k13199312
101k13199312
Where do I have to put the function?
â Black
Jun 25 at 14:37
1
@Black You may put it wherever you would have put thealias
definition. In abash
shell, that would probably be in~/.bashrc
.
â Kusalananda
Jun 25 at 14:38
I added the function to~/.bashrc
but it does not work.ls -lah
is not executed at all.
â Black
Jun 25 at 14:41
@Black No, you add it exactly the way I wrote it. Then it will be active in any new shell session.
â Kusalananda
Jun 25 at 14:41
1
Note that POSIXly, you'd usecd() command cd "$@" && ls -lah;
, though that wouldn't work withzsh
except insh
emulation. Not all shells have abuiltin
builtin. In ksh93, it does something different.
â Stéphane Chazelas
Jun 25 at 16:30
 |Â
show 5 more comments
Where do I have to put the function?
â Black
Jun 25 at 14:37
1
@Black You may put it wherever you would have put thealias
definition. In abash
shell, that would probably be in~/.bashrc
.
â Kusalananda
Jun 25 at 14:38
I added the function to~/.bashrc
but it does not work.ls -lah
is not executed at all.
â Black
Jun 25 at 14:41
@Black No, you add it exactly the way I wrote it. Then it will be active in any new shell session.
â Kusalananda
Jun 25 at 14:41
1
Note that POSIXly, you'd usecd() command cd "$@" && ls -lah;
, though that wouldn't work withzsh
except insh
emulation. Not all shells have abuiltin
builtin. In ksh93, it does something different.
â Stéphane Chazelas
Jun 25 at 16:30
Where do I have to put the function?
â Black
Jun 25 at 14:37
Where do I have to put the function?
â Black
Jun 25 at 14:37
1
1
@Black You may put it wherever you would have put the
alias
definition. In a bash
shell, that would probably be in ~/.bashrc
.â Kusalananda
Jun 25 at 14:38
@Black You may put it wherever you would have put the
alias
definition. In a bash
shell, that would probably be in ~/.bashrc
.â Kusalananda
Jun 25 at 14:38
I added the function to
~/.bashrc
but it does not work. ls -lah
is not executed at all.â Black
Jun 25 at 14:41
I added the function to
~/.bashrc
but it does not work. ls -lah
is not executed at all.â Black
Jun 25 at 14:41
@Black No, you add it exactly the way I wrote it. Then it will be active in any new shell session.
â Kusalananda
Jun 25 at 14:41
@Black No, you add it exactly the way I wrote it. Then it will be active in any new shell session.
â Kusalananda
Jun 25 at 14:41
1
1
Note that POSIXly, you'd use
cd() command cd "$@" && ls -lah;
, though that wouldn't work with zsh
except in sh
emulation. Not all shells have a builtin
builtin. In ksh93, it does something different.â Stéphane Chazelas
Jun 25 at 16:30
Note that POSIXly, you'd use
cd() command cd "$@" && ls -lah;
, though that wouldn't work with zsh
except in sh
emulation. Not all shells have a builtin
builtin. In ksh93, it does something different.â Stéphane Chazelas
Jun 25 at 16:30
 |Â
show 5 more comments
up vote
7
down vote
I was able to solve it by removing the alias again with unalias cd
If you remove the stuck-out text, then this is the only answer that answers the question.
â ctrl-alt-delor
Jun 25 at 17:18
1
@ctrl-alt-delor Note there's no question in the question. We could only guess what the implicit question is. In this situation "why?" is as good as "how to revert?"
â Kamil Maciorowski
Jun 26 at 10:26
add a comment |Â
up vote
7
down vote
I was able to solve it by removing the alias again with unalias cd
If you remove the stuck-out text, then this is the only answer that answers the question.
â ctrl-alt-delor
Jun 25 at 17:18
1
@ctrl-alt-delor Note there's no question in the question. We could only guess what the implicit question is. In this situation "why?" is as good as "how to revert?"
â Kamil Maciorowski
Jun 26 at 10:26
add a comment |Â
up vote
7
down vote
up vote
7
down vote
I was able to solve it by removing the alias again with unalias cd
I was able to solve it by removing the alias again with unalias cd
edited Jun 25 at 17:18
ctrl-alt-delor
8,70331947
8,70331947
answered Jun 25 at 14:29
Black
4932728
4932728
If you remove the stuck-out text, then this is the only answer that answers the question.
â ctrl-alt-delor
Jun 25 at 17:18
1
@ctrl-alt-delor Note there's no question in the question. We could only guess what the implicit question is. In this situation "why?" is as good as "how to revert?"
â Kamil Maciorowski
Jun 26 at 10:26
add a comment |Â
If you remove the stuck-out text, then this is the only answer that answers the question.
â ctrl-alt-delor
Jun 25 at 17:18
1
@ctrl-alt-delor Note there's no question in the question. We could only guess what the implicit question is. In this situation "why?" is as good as "how to revert?"
â Kamil Maciorowski
Jun 26 at 10:26
If you remove the stuck-out text, then this is the only answer that answers the question.
â ctrl-alt-delor
Jun 25 at 17:18
If you remove the stuck-out text, then this is the only answer that answers the question.
â ctrl-alt-delor
Jun 25 at 17:18
1
1
@ctrl-alt-delor Note there's no question in the question. We could only guess what the implicit question is. In this situation "why?" is as good as "how to revert?"
â Kamil Maciorowski
Jun 26 at 10:26
@ctrl-alt-delor Note there's no question in the question. We could only guess what the implicit question is. In this situation "why?" is as good as "how to revert?"
â Kamil Maciorowski
Jun 26 at 10:26
add a comment |Â
up vote
5
down vote
That happened because:
$ type cd
cd is a shell builtin
add a comment |Â
up vote
5
down vote
That happened because:
$ type cd
cd is a shell builtin
add a comment |Â
up vote
5
down vote
up vote
5
down vote
That happened because:
$ type cd
cd is a shell builtin
That happened because:
$ type cd
cd is a shell builtin
answered Jun 25 at 14:33
Vlastimil
6,2511146115
6,2511146115
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f451778%2fbash-bin-cd-no-such-file-or-directory-automatically-execute-ls-after-cd%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
16
There is no
/bin/cd
;cd
is a shell built-in.â Andy Dalton
Jun 25 at 14:32
Enjoy unix.stackexchange.com/questions/354123 and what it hyperlinks to M. Dalton. (-:
â JdeBP
Jun 25 at 14:41
3
A POSIX compliant platform has a
/bin/cd
, but that only exists for formal reasons and is not usable for anything.â schily
Jun 25 at 14:41
1
Wow
/bin/cd
must be the most useless command.â ctrl-alt-delor
Jun 25 at 17:15
cd isn't a file on disk, It's a shell built-in command:
type cd
â PersianGulf
Jun 25 at 17:26