The php command in conjunction with the -m flag will output all modules used in the current PHP installation.

$ php -m

Adding a pipe with the grep command will filter the results. So, if you wanted to see if the imagick module is currently installed, you could use the following command

$ php -m | grep imagick