2

What differences between two below commands in CentOS7?

$ type cd
cd is a shell builtin

and

$ 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 ?

1 Answers1

4

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