What differences between two below commands in CentOS7?

$ type cd
cd is a shell builtin


$ which  cd
cd is a shell builtin
cd is /usr/bin/cd
cd is /bin/cd

The cd is a shell builtin command, but why which command show another path for cd ? Is the cd command both internal command and external command ?


which shows the full path of (shell) commands.
its output is different based on different systems.
type display information about command type on Linux.
(see man page for more info)
we have 4 command types:
Built-in Shell Commands
Shell Functions
Command Alias
excutable Programs

for example:

# type ll  
ll is aliased to `ls -l --color=auto'  
# type cd  
cd is a shell builtin
# type sudo  
sudo is /usr/bin/sudo
  • In my /bin and /usr/bin/ directories, I have cd command. So, i want to know, what differences between cd builtin command and these two? – Saman Bayat Oct 22 '18 at 5:06
  • what is your OS? – BlackCrystal Oct 22 '18 at 5:10
  • Linux CentOS7 – Saman Bayat Oct 22 '18 at 5:14
  • 2
    check this out. askubuntu.com/questions/532788/… – BlackCrystal Oct 22 '18 at 5:15
  • @BlackCrystal - What is the use case for the type command? When is it used and for what purpose? – Motivated Jan 17 '19 at 1:54

Not the answer you're looking for? Browse other questions tagged or ask your own question.