hash -r command is used to refresh path environment variable in linux systems. On FreeBSD, the command is rehash.
I have a file create-vm in both /usr/bin and /usr/local/bin folders. This i actually copied by accident, now i run create-vm command, it actually run old version of the script. To find which create-vm you run, use which command.
root@server2:~# which create-vm /usr/local/bin/create-vm root@server2:~#
I deleted the file as i don’t want same file exists in 2 different locations. Now when i run create-vm command again, it did not work as Linux did not look at /usr/bin for this file.
root@server2:~# rm /usr/local/bin/create-vm root@server2:~# create-vm -r ubuntuvm -bash: /usr/local/bin/create-vm: No such file or directory root@server2:~# ls -l /usr/bin | grep create-vm -rwxr-xr-x 1 root root 11191 Sep 7 05:12 create-vm root@server2:~#
To refresh the path hash, we need to use command hash -r or restart the terminal session.
root@server2:~# hash -r root@server2:~# create-vm -r ubuntuvm Thu, 07 Sep 2017 05:15:37 -0400 Destroying ubuntuvm domain... Thu, 07 Sep 2017 05:15:37 -0400 Destroying ubuntuvm storage pool... Thu, 07 Sep 2017 05:15:37 -0400 Undefining ubuntuvm storage pool... Thu, 07 Sep 2017 05:15:37 -0400 Undefining ubuntuvm domain... Thu, 07 Sep 2017 05:15:37 -0400 Deleting ubuntuvm files... root@server2:~#