{"id":80676,"date":"2017-05-24T10:20:11","date_gmt":"2017-05-24T14:20:11","guid":{"rendered":"https:\/\/www.templatemonster.com\/help\/?p=80676"},"modified":"2017-10-20T08:57:02","modified_gmt":"2017-10-20T12:57:02","slug":"magento-2-working-command-line-interfacecli-essential-commands-store-management-application","status":"publish","type":"post","link":"https:\/\/www.templatemonster.com\/help\/magento-2-working-command-line-interfacecli-essential-commands-store-management-application.html","title":{"rendered":"Magento 2. Working with command-line interface(CLI). Essential commands for store management and their application"},"content":{"rendered":"<p><strong>Magento 2<\/strong> has introduced a built-in command-line interface tool based on <em>Symfony Console Component<\/em>. The feature allows you to perform a wide range of recurring tasks, e.g. <em>indexing<\/em>, <em>cache management<\/em>,\u00a0<em>deployment of static view files<\/em>, etc.  The instructions below will brief you on basic frequently-used <strong>Magento 2&#47;Unix<\/strong> commands and provide an insight into their application.<p>\r\n\r\n <div class=\"video-container\">\r\n\t<iframe src=\"https:\/\/www.youtube.com\/embed\/kuvyFMYIiuM\"><\/iframe>\r\n<\/div>\r\n <p><strong>Magento 2<\/strong> has introduced a built-in command-line interface tool based on <em>Symfony Console Component<\/em>. <\/p>\r\n<p>The feature allows you to perform a wide range of recurring tasks, e.g. <em>indexing<\/em>, <em>cache management<\/em>,\u00a0<em>deployment of static view files<\/em>, etc. \r\nThe instructions below will brief you on basic frequently-used <strong>Magento 2&#47;Unix<\/strong> commands and provide an insight into their application.<p>\r\n<p class=\"attention\">Note&#33; This tutorial assumes your environment has been configured to meet <em>Magento system requirements<\/em> and recognize <em>Magento<\/em> commands.<\/p>\r\n<h3 class=\"custom\">Unix commands<\/h3>\r\n<ul class=\"list\">\r\n\t<li>\r\n       <p>Log into your server via <strong>Secure Shell<\/strong>&#40; <strong>SSH<\/strong>&#41;. Determine your current location&#59;<\/p>\r\n\r\n       <h4>pwd<\/h4>\r\n \r\n       <p>Stands for <em>print working directory<\/em>. The command will output the pathname of the directory in which you are located. In most cases, the pathname will be your system <em>docroot<\/em> in a hierarchy of directories.<\/p>\r\n       <p><em>Examples&#58;<\/em><\/p>\r\n       <pre>[~]$ pwd<\/pre>\r\n       <pre>\/home\/user\/public_html<\/pre>\r\n       <p>In this example, the user is located in <em>public_html<\/em> directory, where <em>&#47;home&#47;user<\/em> is document root directory.<\/p>\r\n       <p class=\"attention\">Note&#33; <em>public_html<\/em>, <em>htdocs<\/em> are the names typically given to server home&#40;<em>root<\/em>&#41; subdirectories. If you are having trouble locating your <em>docroot<\/em>, contact your hosting provider directly&#33;<\/p>\r\n<li><p>Change your working directory&#59;<\/p>\r\n\r\n\t<h4>cd<\/h4>\r\n\r\n\t<p>The <em>cd<\/em> command which stands for <em>change directory<\/em> will allow you to move around within your filesystem hierarchy.<\/p>\r\n\t<p><em>Examples&#58;<\/em><\/p>\r\n\t<pre>[~]$ cd public_html\/magento\/var <\/pre>\r\n\t<p>By executing the above command, you will jump from your current working directory which is the parent directory of <em>public_html<\/em> to <em>var<\/em> directory. Note, <em>public_html&#47;magento&#47;var<\/em> means a directory named <strong>var<\/strong> which is located in a directory named <strong>magento<\/strong> which is located in its turn in <em>public_html<\/em> directory which is a child directory of <em>current working directory<\/em>.<\/p>\r\n  <pre>[~]$ cd \/home\/user\/public_html<\/pre>\r\n  <p> You might have noticed a <em>forward slash<\/em> at the beginning of the path in the second example, unlike the first. A single forward slash &#40;<strong>&#47;<\/strong>&#41; represents system root directory which means that the command is initiated in <em>document root<\/em>.\r\n  <p>This command will take you one level down.<\/p>\r\n  <pre>[~]$ cd .. <\/pre>\r\n  <p>Jump to your home directory using this command.<\/p>\r\n  <pre>[~]$ cd ~ <\/pre>\r\n  <p>\r\n<\/li>\r\n<li><p>Show directory contents&#59;<\/p>\r\n  \r\n  <h4>ls<\/h4>\r\n\r\n  <p>Stands for <em>list<\/em>. This command will display the contents of directory. \r\n  Syntax&#58;<\/p>\r\n  <pre>ls [OPTION]... [FILE]...<\/pre>\r\n  <p><em>Examples&#58;<\/em><\/p>\r\n  <pre>[~]$ ls var <\/pre>\r\n  <pre>.\/  ..\/  cache\/  composer_home\/  generation\/  log\/  page_cache\/  session\/<\/pre>\r\n\r\n  <p>The above example  will show the contents of <em>var<\/em> directory.<\/p>\r\n  <pre>[~]$ ls -l var <\/pre>\r\n  <p><em>-l<\/em> flag with <em>ls<\/em> command lists the total of objects within directories and their subdirectories, names of the files in specified directory, size of the files, their permissions and the date of last modification.<\/p>\r\n<\/li>\r\n<li><p>Find a file&#59;<\/p>\r\n\r\n  <h4>find<\/h4>\r\n\r\n  <p><em>find<\/em> is a powerful command used to search for objects within filesystem based on various search criteria, e.g. extension, permissions, size, modification date, etc. The command lists files and directories based on conditions specified for files that match the arguments in the command expression.\r\n  Syntax&#58;<\/p>\r\n  <pre> find [OPTION] path... [expression]<\/pre>\r\n   <p><em>Examples&#58;<\/em><\/p>\r\n   <pre>[~]$ find var -type d -name Cache<\/pre>\r\n   <p>The above command will find all directories &#40;<strong>-type d<\/strong> argument&#41;, named <em>Cache<\/em>&#40;<strong>-name<\/strong> argument&#41;, in <strong>var<\/strong> directory.<\/p>\r\n   <pre>[~]$ find app\/design -type f -name \"*.xml\"<\/pre>\r\n   <p>This command will surf <em>design<\/em> directory to locate all files matching the arguments specified in expression, e.g. <strong>-type f<\/strong> only files, <strong>-name &#8220;*.xml&#8221;<\/strong> with <em>.xml<\/em> extension.<\/p>\r\n <\/li>\r\n <li><p>Change&#47;assign access permissions&#59;<\/p>\r\n\r\n  <h4>chmod<\/h4>\r\n\r\n  <p>Stands for <em>change file mode bits<\/em>.  <em>chmod<\/em> is a unix-based system call which can modify access permissions to filesystem objects. It defines who can access specific file&#47;directory and the way that file&#47;directory can be accessed. Syntax&#58;<\/p>\r\n  <pre>chmod [OPTION]... Mode [,Mode]... file...<\/pre>\r\n  <p><em>Options&#58;<\/em><\/p>\r\n  <ul class=\"list\">\r\n     <li><p><strong>-R<\/strong> affects files and diretories recursively&#59;<\/p><\/li>\r\n     <li><p><strong>-f<\/strong> force, suppresses errors and forges ahead&#59;<\/p><\/li>\r\n     <li><p><strong>-v<\/strong> verbose, outputs the objects which have been processed&#59;<\/p><\/li>\r\n   <\/ul>\r\n   <p><em>Examples&#58;<\/em><\/p>\r\n   <pre>[~]$ chmod -Rfv 0777 var<\/pre>\r\n   <p>The above command executed from <em>&#91;magento&#95;install&#95;dir&#93;<\/em> changes permissions of <strong>var<\/strong> directory and all other objects within to <em>0777<\/em> or <em>rwxrwxrwx<\/em>.<\/p>\r\n   <pre>[~]$ chmod -v 0644 composer.json<\/pre>\r\n   <pre>mode of 'composer.json' changed from 0777 (rwxrwxrwx) to 0644 (rw-r--r--)<\/pre>\r\n   <p>This command applies changes to specific file. You might be wondering if there is a way to  assign different permissions to directories and files globally. This is where the power of <strong>find<\/strong> command might come in handy \r\n   since <em>chmod<\/em> by default does not have options to sort objects by any criteria.<\/p>\r\n   <p>Run the following command from <em>&#91;magento&#95;install&#95;dir&#93;<\/em> to assign <strong>0755<\/strong> permissions to all sub-directories within magento application directory&#58;<\/p>\r\n   \r\n   <pre>[~]$ find -type d -exec chmod -fv 0755 {} \\;<\/pre>\r\n\r\n   <p>Run the following command from <em>&#91;magento&#95;install&#95;dir&#93;<\/em> to assign <strong>0644<\/strong> permissions to all files within magento application directory&#58;<\/p>\r\n\r\n   <pre>[~]$ find -type f -exec chmod -fv 0644 {} \\;<\/pre>\r\n   \r\n   <p>Run the following command from <em>&#91;magento&#95;install&#95;dir&#93;<\/em> to locate sub-directories with <strong>0775<\/strong> permissions and change them to <strong>0755<\/strong>&#58;<\/p>\r\n   <pre>[~]$ find -type d -perm 0775 -exec chmod -fv 0755 {} \\;<\/pre>\r\n\r\n    <p>Run the following command from <em>&#91;magento&#95;install&#95;dir&#93;<\/em> to locate sub-directories without <strong>0755<\/strong> permissions and change them to <strong>0755<\/strong>&#58;<\/p>\r\n    <pre>[~]$ find -type d ! -perm 0755 -exec chmod -fv 0755 {} \\;<\/pre>\r\n\r\n   <p class=\"attention\">Note&#33; <strong>-R<\/strong> flag should not be used here. It ignores arguments of <em>find<\/em> command thus apply permissions globally to both files and directories within specified sub-directory.<\/p>\r\n <\/li>\r\n<li><p>Remove an object&#59;<\/p>\r\n  <h4>rm<\/h4>\r\n  <p>The <em>rm<\/em> command is used to delete objects such as files, directories from Unix-like operating systems.\r\n    Syntax&#58;<\/p>\r\n    <pre>rm [OPTION]... FILE...<\/pre>\r\n      <p><em>Options&#58;<\/em><\/p>\r\n  <ul class=\"list\">\r\n     <li><p><strong>-r<\/strong> affects files and directories recursively, so as not to leave files without directories to reside in&#59;<\/p><\/li>\r\n     <li><p><strong>-f<\/strong> overrides confirmation prompts, never prompts before removing files. It will not remove directories which are <strong>write-protected<\/strong>&#59;<\/p><\/li>\r\n     <li><p><strong>-v<\/strong> explains what is being done, which objects have been removed&#59;<\/p><\/li>\r\n     <li><p><strong>-i<\/strong> asks for confirmation before every deletion&#59;<\/p><\/li>\r\n   <\/ul>\r\n   <p><em>Examples&#58;<\/em><\/p>\r\n   <pre>[~]$ rm -rfv var\/generation<\/pre>\r\n   <p>The command recursively deletes <em>generation<\/em> directory with all its contents.<\/p>\r\n   <p>Remove the contents of <strong>var<\/strong> dir&#58;<\/p>\r\n   <pre>[~]$ rm -rfv var\/*<\/pre>\r\n   <p>Another way to remove subdirectories of specific folder, <em>pub&#47;static<\/em> in this case, without removing parent directory is to use <strong>rm<\/strong> in conjunction with <strong>find<\/strong> command&#58;<\/p>\r\n   <pre>[~]$ find pub\/static -mindepth 1 -maxdepth 1 | xargs rm -rfv<\/pre>\r\n\r\n   <p class=\"attention\">WARNING&#33; Ensure that you verify current working directory, command options and files to be removed before executing <em>rm -rf<\/em>. The command cannot be reversed.<\/p>\r\n  <\/li>\r\n <li><p>To sum up&#59;<\/p>\r\n  <h4>man<\/h4>\r\n  <p><em>man<\/em> is an online reference &#34;manual&#34;. They are manual pages which provide detailed documentation about <em>Unix commands<\/em>, <em>configuration files<\/em>, <em>system calls<\/em>, etc.<\/p>\r\n  <p><em>Examples&#58;<\/em><\/p>\r\n  <pre>[~]$ man xargs<\/pre>\r\n  <pre>[~]$ man chmod<\/pre>\r\n  <pre>[~]$ man wget<\/pre>\r\n  <p>The above commands once executed open manual page of the specified command within <em>command-line<\/em> console.<\/p>\r\n<\/ul>\r\n\r\n<h3 class=\"custom\">Magento 2 commands summary<\/h3>\r\n\r\n  <p>Log into your server via <strong>Secure Shell<\/strong>&#40;<strong>SSH<\/strong>&#41;. <strong>cd<\/strong> to &#47;<em>&#91;magento&#95;install&#95;dir&#93;&#47;bin<\/em> directory from which the commands must be executed. Examples&#58;<\/p>\r\n    <pre>[~]$ cd \/home\/user\/public_html\/bin<\/pre>\r\n    <pre>[~]$ php magento<\/pre>\r\n    <p>This command displays installed application version as well as the list of available commands.<\/p>\r\n    \r\n\t\r\n<a class=\"darkbox\" href=\"\/help\/wp-content\/uploads\/2017\/05\/magento2_working_with_command_line_interface.jpg\"><img loading=\"lazy\" src=\"\/help\/wp-content\/uploads\/2017\/05\/magento2_working_with_command_line_interface.jpg\" alt=\"\" width=\"963\" height=\"521\" class=\"alignnone size-full wp-image-80677\" srcset=\"https:\/\/www.templatemonster.com\/help\/wp-content\/uploads\/2017\/05\/magento2_working_with_command_line_interface.jpg 963w, https:\/\/www.templatemonster.com\/help\/wp-content\/uploads\/2017\/05\/magento2_working_with_command_line_interface-150x81.jpg 150w, https:\/\/www.templatemonster.com\/help\/wp-content\/uploads\/2017\/05\/magento2_working_with_command_line_interface-300x162.jpg 300w, https:\/\/www.templatemonster.com\/help\/wp-content\/uploads\/2017\/05\/magento2_working_with_command_line_interface-768x416.jpg 768w\" sizes=\"(max-width: 963px) 100vw, 963px\" \/><\/a>\r\n    \r\n\t\r\n\t<p>The commands can also be run in the following ways&#58;<\/p>\r\n    <pre>[~]$ php \/[magento_install_dir]\/bin\/magento [command]<\/pre>\r\n    <pre>[~]$ cd \/[magento_install_dir]\/<\/pre>\r\n    <pre>[~]$ php bin\/magento [command]<\/pre>\r\n  <ul class=\"list\">\r\n  <li><p><strong>Help commands<\/strong><\/p>\r\n    <ol>\r\n        <li><pre>[~]$ php magento --list<\/pre>\r\n          <p>This command will display the list of all available <em>Magento 2<\/em> commands and their short summary&#59;<\/p><\/li>\r\n          <li><pre>[~]$ php magento [command] -h<\/pre>\r\n              <pre>[~]$ php magento setup:upgrade -h<\/pre>\r\n              <p>Use <em>-h<\/em> flag at the end of the <em>magento command<\/em> to receive detailed description of a particular command.<\/p>\r\n              \r\n\t\t\t  \r\n<a class=\"darkbox\" href=\"\/help\/wp-content\/uploads\/2017\/05\/magento2_working_with_command_line_interface7.jpg\"><img loading=\"lazy\" src=\"\/help\/wp-content\/uploads\/2017\/05\/magento2_working_with_command_line_interface7.jpg\" alt=\"\" width=\"967\" height=\"283\" class=\"alignnone size-full wp-image-80683\" srcset=\"https:\/\/www.templatemonster.com\/help\/wp-content\/uploads\/2017\/05\/magento2_working_with_command_line_interface7.jpg 967w, https:\/\/www.templatemonster.com\/help\/wp-content\/uploads\/2017\/05\/magento2_working_with_command_line_interface7-150x44.jpg 150w, https:\/\/www.templatemonster.com\/help\/wp-content\/uploads\/2017\/05\/magento2_working_with_command_line_interface7-300x88.jpg 300w, https:\/\/www.templatemonster.com\/help\/wp-content\/uploads\/2017\/05\/magento2_working_with_command_line_interface7-768x225.jpg 768w\" sizes=\"(max-width: 967px) 100vw, 967px\" \/><\/a>\r\n\t\t\t  \r\n\t\t\t  <\/li>\r\n      <\/ol>\r\n  <\/li>\r\n<li><strong>Cache<\/strong>\r\n  <p>Display the status of cache types&#58;<\/p>\r\n  <pre>[~]$ php magento cache:status<\/pre>\r\n  <p>Disable&#47;enable cache&#47;cache types&#58;<\/p>\r\n  <pre>[~]$ php magento cache:disable full_page eav<\/pre>\r\n  <pre>[~]$ php magento cache:enable<\/pre>\r\n  <p>Clean <em>magento <\/em> cache. The command removes items from <em>enabled cache types<\/em> only&#58;<\/p>\r\n  <pre>[~]$ php magento cache:clean<\/pre>\r\n  <p><em>Flush<\/em> magento cache. Unlike <em>cache&#58;clean<\/em>, <em>cache&#58;flush<\/em> purges the entire cache storage, including that of <em>disabled cache types<\/em>&#58;<\/p>\r\n  <pre>[~]$ php magento cache:flush<\/pre>\r\n  \r\n  \r\n<a class=\"darkbox\" href=\"\/help\/wp-content\/uploads\/2017\/05\/magento2_working_with_command_line_interface2.jpg\"><img loading=\"lazy\" src=\"\/help\/wp-content\/uploads\/2017\/05\/magento2_working_with_command_line_interface2.jpg\" alt=\"\" width=\"963\" height=\"496\" class=\"alignnone size-full wp-image-80678\" srcset=\"https:\/\/www.templatemonster.com\/help\/wp-content\/uploads\/2017\/05\/magento2_working_with_command_line_interface2.jpg 963w, https:\/\/www.templatemonster.com\/help\/wp-content\/uploads\/2017\/05\/magento2_working_with_command_line_interface2-150x77.jpg 150w, https:\/\/www.templatemonster.com\/help\/wp-content\/uploads\/2017\/05\/magento2_working_with_command_line_interface2-300x155.jpg 300w, https:\/\/www.templatemonster.com\/help\/wp-content\/uploads\/2017\/05\/magento2_working_with_command_line_interface2-768x396.jpg 768w\" sizes=\"(max-width: 963px) 100vw, 963px\" \/><\/a>  \r\n  \r\n<\/li>\r\n<li><strong>Indexers<\/strong>\r\n  <p>Show indexer status&#58;<\/p>\r\n  <pre>[~]$ php magento indexer:status<\/pre>\r\n  <p>Re-index all <em>indexers<\/em> or any <em>selected indexer<\/em>&#58;<\/p>\r\n  <pre>[~]$ php magento indexer:reindex<\/pre>\r\n  <pre>[~]$ php magento indexer:reindex catalog_product_attribute<\/pre>\r\n  <p>Change <em>indexer<\/em> modes via <strong>CLI<\/strong>, i.e. <em>Update on Save<\/em>, <em>Update by Schedule<\/em>&#58;<\/p>\r\n  <pre>[~]$ php magento indexer:set-mode realtime<\/pre>\r\n  <pre>[~]$ php magento indexer:set-mode schedule<\/pre>\r\n  \r\n  \r\n<a class=\"darkbox\" href=\"\/help\/wp-content\/uploads\/2017\/05\/magento2_working_with_command_line_interface3.jpg\"><img loading=\"lazy\" src=\"\/help\/wp-content\/uploads\/2017\/05\/magento2_working_with_command_line_interface3.jpg\" alt=\"\" width=\"968\" height=\"353\" class=\"alignnone size-full wp-image-80679\" srcset=\"https:\/\/www.templatemonster.com\/help\/wp-content\/uploads\/2017\/05\/magento2_working_with_command_line_interface3.jpg 968w, https:\/\/www.templatemonster.com\/help\/wp-content\/uploads\/2017\/05\/magento2_working_with_command_line_interface3-150x55.jpg 150w, https:\/\/www.templatemonster.com\/help\/wp-content\/uploads\/2017\/05\/magento2_working_with_command_line_interface3-300x109.jpg 300w, https:\/\/www.templatemonster.com\/help\/wp-content\/uploads\/2017\/05\/magento2_working_with_command_line_interface3-768x280.jpg 768w\" sizes=\"(max-width: 968px) 100vw, 968px\" \/><\/a>  \r\n  \r\n<\/li>\r\n<li><strong>Admin<\/strong>\r\n  <p>In case you have lost your admin password, the backend access can be regained by creating a new admin user. \r\n  Example command creates a user named <em>John Doe<\/em> with username <strong>john<\/strong> and password <strong>johndoe123<\/strong>&#58;<\/p>\r\n  <pre>[~]$ php magento admin:user:create --admin-user john --admin-password johndoe123 <br>--admin-email johndoe@email.com --admin-firstname john --admin-lastname doe\r\n  <\/pre>\r\n  <p>The options specified in the above command are <strong>mandatory<\/strong>.<\/p>\r\n  \r\n  \r\n<a class=\"darkbox\" href=\"\/help\/wp-content\/uploads\/2017\/05\/magento2_working_with_command_line_interface4.jpg\"><img loading=\"lazy\" src=\"\/help\/wp-content\/uploads\/2017\/05\/magento2_working_with_command_line_interface4.jpg\" alt=\"\" width=\"931\" height=\"380\" class=\"alignnone size-full wp-image-80680\" srcset=\"https:\/\/www.templatemonster.com\/help\/wp-content\/uploads\/2017\/05\/magento2_working_with_command_line_interface4.jpg 931w, https:\/\/www.templatemonster.com\/help\/wp-content\/uploads\/2017\/05\/magento2_working_with_command_line_interface4-150x61.jpg 150w, https:\/\/www.templatemonster.com\/help\/wp-content\/uploads\/2017\/05\/magento2_working_with_command_line_interface4-300x122.jpg 300w, https:\/\/www.templatemonster.com\/help\/wp-content\/uploads\/2017\/05\/magento2_working_with_command_line_interface4-768x313.jpg 768w\" sizes=\"(max-width: 931px) 100vw, 931px\" \/><\/a>\r\n  \r\n  \r\n<\/li>\r\n<li><strong>Setup<\/strong>\r\n  <ol>\r\n  <li><p>Magento frontend is served through <em>pub&#47;static<\/em> directory. This directory can be cached for browsers, so to speak, not dynamically served. If a new extension, or theme is installed, modified, you might need to remove existing <em>pub&#47;static<\/em> contents and re-deploy <em>static view files<\/em>&#58;<\/p>\r\n  <pre>[~]$ php magento setup:static-content:deploy<\/pre>\r\n  <p><em>Language packages<\/em> are regular extensions which are to be deployed once installed. Find the language locale by running the following command&#58;<\/p>\r\n  <pre>[~]$ php magento info:language:list<\/pre>\r\n  <p>Deploy <em>static view files<\/em> of the language pack by adding its locale to the end of command&#58;<\/p>\r\n  <pre>[~]$ php magento setup:static-content:deploy es_ES<\/pre>\r\n  <p>Deploy <em>static view files<\/em> of specific theme<\/p>\r\n  <pre>[~]$ php magento setup:static-content:deploy --theme Magento\/luma<\/pre>\r\n  \r\n  \r\n<a class=\"darkbox\" href=\"\/help\/wp-content\/uploads\/2017\/05\/magento2_working_with_command_line_interface5.jpg\"><img loading=\"lazy\" src=\"\/help\/wp-content\/uploads\/2017\/05\/magento2_working_with_command_line_interface5.jpg\" alt=\"\" width=\"927\" height=\"431\" class=\"alignnone size-full wp-image-80681\" srcset=\"https:\/\/www.templatemonster.com\/help\/wp-content\/uploads\/2017\/05\/magento2_working_with_command_line_interface5.jpg 927w, https:\/\/www.templatemonster.com\/help\/wp-content\/uploads\/2017\/05\/magento2_working_with_command_line_interface5-150x70.jpg 150w, https:\/\/www.templatemonster.com\/help\/wp-content\/uploads\/2017\/05\/magento2_working_with_command_line_interface5-300x139.jpg 300w, https:\/\/www.templatemonster.com\/help\/wp-content\/uploads\/2017\/05\/magento2_working_with_command_line_interface5-768x357.jpg 768w\" sizes=\"(max-width: 927px) 100vw, 927px\" \/><\/a>  \r\n  \r\n  <\/li>\r\n  <li><p>By executing <em>setup&#58;upgrade<\/em>, you will update Magento database components as well as truncate <em>var&#47;di<\/em> &#40;if compiled&#41; <em>var&#47;view_preprocessed<\/em> and <em>var&#47;generation<\/em> directories. The command is to be executed once particular extension has been installed or activated&#58;<\/p>\r\n    <pre>[~]$ php magento setup:upgrade<\/pre>\r\n   \r\n   \r\n<a class=\"darkbox\" href=\"\/help\/wp-content\/uploads\/2017\/05\/magento2_working_with_command_line_interface6.jpg\"><img loading=\"lazy\" src=\"\/help\/wp-content\/uploads\/2017\/05\/magento2_working_with_command_line_interface6.jpg\" alt=\"\" width=\"932\" height=\"561\" class=\"alignnone size-full wp-image-80682\" srcset=\"https:\/\/www.templatemonster.com\/help\/wp-content\/uploads\/2017\/05\/magento2_working_with_command_line_interface6.jpg 932w, https:\/\/www.templatemonster.com\/help\/wp-content\/uploads\/2017\/05\/magento2_working_with_command_line_interface6-150x90.jpg 150w, https:\/\/www.templatemonster.com\/help\/wp-content\/uploads\/2017\/05\/magento2_working_with_command_line_interface6-300x181.jpg 300w, https:\/\/www.templatemonster.com\/help\/wp-content\/uploads\/2017\/05\/magento2_working_with_command_line_interface6-768x462.jpg 768w\" sizes=\"(max-width: 932px) 100vw, 932px\" \/><\/a>   \r\n   \r\n   <\/li>\r\n  <li><p>Trigger code generation and compilation by applying <em>setup&#58;di&#58;compile<\/em>&#40;built-in code compiler&#41;. The command will generate <em>var&#47;di<\/em> directory and compile <em>factories, proxies, interceptors<\/em> classes.  The command is not mandatory to execute if your application is running in <strong>default<\/strong> or <strong>developer mode<\/strong> . The application code must be recompiled after certain code changes when in <strong>production<\/strong> mode&#58;<\/p>\r\n    <pre>[~]$ php magento setup:di:compile<\/pre><\/li>\r\n  <\/ol>\r\n  <li><strong>Module<\/strong>\r\n    <p>Display the list of available <em>enabled&#47;disabled<\/em> modules by using <em>module&#58;status<\/em> command&#58;<\/p>\r\n    <pre>[~]$ php magento module:status<\/pre>\r\n    <p>Enable&#47;disable modules via <strong>CLI<\/strong>&#58;<\/p>\r\n    <pre>[~]$ php magento module:disable Namespace_Module<\/pre>\r\n    <p>Disable <em>Blog<\/em> extension and clear all its static view files&#58;<\/p>\r\n    <pre>[~]$ php magento module:disable TemplateMonster_blog --clear-static-content<\/pre>\r\n    <p>Uninstall <em>Magento<\/em> module&#58;<\/p>\r\n    <pre>[~]$ php magento module:uninstall TemplateMonster_blog<\/pre>\r\n\t\r\n\t\r\n<a class=\"darkbox\" href=\"\/help\/wp-content\/uploads\/2017\/05\/magento2_working_with_command_line_interface8.jpg\"><img loading=\"lazy\" src=\"\/help\/wp-content\/uploads\/2017\/05\/magento2_working_with_command_line_interface8.jpg\" alt=\"\" width=\"938\" height=\"237\" class=\"alignnone size-full wp-image-80684\" srcset=\"https:\/\/www.templatemonster.com\/help\/wp-content\/uploads\/2017\/05\/magento2_working_with_command_line_interface8.jpg 938w, https:\/\/www.templatemonster.com\/help\/wp-content\/uploads\/2017\/05\/magento2_working_with_command_line_interface8-150x38.jpg 150w, https:\/\/www.templatemonster.com\/help\/wp-content\/uploads\/2017\/05\/magento2_working_with_command_line_interface8-300x76.jpg 300w, https:\/\/www.templatemonster.com\/help\/wp-content\/uploads\/2017\/05\/magento2_working_with_command_line_interface8-768x194.jpg 768w\" sizes=\"(max-width: 938px) 100vw, 938px\" \/><\/a>\t\r\n\t\r\n  <\/li>\r\n  <li><strong>Maintenance<\/strong>\r\n    <p><em>Magento<\/em> comes with the option to enable&#47;disable <em>maintenance<\/em> mode while configuring&#47;maintaining the website&#58;<\/p>\r\n    <pre>[~]$ php magento maintenance:enable<\/pre>\r\n    <p>The command creates <em>var&#47;.maintenance.flag<\/em> file which is used by <em>Magento<\/em> to detect status.<\/p>\r\n    <p>Enable <em>maintenance mode<\/em> for everyone except <em>192.10.0.0, 192.192.2.11<\/em>&#58;<\/p>\r\n    <pre>[~]$ php magento maintenance:enable --ip=192.10.0.0 --ip=192.192.2.11<\/pre>\r\n    <p>The command creates <em>var&#47;.maintenance.ip<\/em> file. Disable <em>maintenance<\/em>&#58;<\/p>\r\n    <pre>[~]$ php magento maintenance:disable<\/pre>\r\n\t\r\n\t\r\n<a class=\"darkbox\" href=\"\/help\/wp-content\/uploads\/2017\/05\/magento2_working_with_command_line_interface9.jpg\"><img loading=\"lazy\" src=\"\/help\/wp-content\/uploads\/2017\/05\/magento2_working_with_command_line_interface9.jpg\" alt=\"\" width=\"945\" height=\"118\" class=\"alignnone size-full wp-image-80685\" srcset=\"https:\/\/www.templatemonster.com\/help\/wp-content\/uploads\/2017\/05\/magento2_working_with_command_line_interface9.jpg 945w, https:\/\/www.templatemonster.com\/help\/wp-content\/uploads\/2017\/05\/magento2_working_with_command_line_interface9-150x19.jpg 150w, https:\/\/www.templatemonster.com\/help\/wp-content\/uploads\/2017\/05\/magento2_working_with_command_line_interface9-300x37.jpg 300w, https:\/\/www.templatemonster.com\/help\/wp-content\/uploads\/2017\/05\/magento2_working_with_command_line_interface9-768x96.jpg 768w\" sizes=\"(max-width: 945px) 100vw, 945px\" \/><\/a>\t\r\n\t\r\n  <\/li>\r\n<\/ul>\r\n<div class=\"inline-banner\">\r\n<a href=\"https:\/\/www.templatemonster.com\/service-center\/ \">\r\n<img src=\"\/help\/files\/banners\/inline\/Banner-2-(835-x100).jpg\"\/>\r\n<\/a>\r\n<\/div>\r\n<h4><em>Tips<\/em><\/h4>\r\n<p>Instead of typing full command name, <em>abbreviations or acronyms<\/em> can be used. It will know which command you are trying to execute unless it is ambiguous. Example&#58;<\/p>\r\n<pre>[~]$ php magento i:rein<\/pre>\r\n<p>For <em>indexer&#58;reindex.<\/em><\/p>\r\n<pre>[~]$ php magento c:f<\/pre>\r\n<p>For <em>cache&#58;flush<\/em><\/p>\r\n<p>Feel free to check the detailed video tutorial below:<\/p>\r\n <a href=\"http:\/\/www.youtube.com\/watch?v=kuvyFMYIiuM?width=1280&amp;height=720\" rel=\"prettyPhoto\">Magento 2. Working with command-line interface(CLI). Essential commands for store management and their application<\/a>\r\n<p>Take a closer look at the collection of <a href=\"https:\/\/www.templatemonster.com\/magento-themes.php\" target=\"_blank\">Magento themes<\/a> and select the best for your project.<\/p>","protected":false},"excerpt":{"rendered":"<p><strong>Magento 2<\/strong> has introduced a built-in command-line interface tool based on <em>Symfony Console Component<\/em>.  The instructions below will brief you on basic frequently-used <strong>Magento 2&#47;Unix<\/strong> commands.<\/p>\n<p>\n","protected":false},"author":111,"featured_media":80688,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[729],"tags":[2588,2585,2587,2315,2586],"_links":{"self":[{"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/posts\/80676"}],"collection":[{"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/users\/111"}],"replies":[{"embeddable":true,"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/comments?post=80676"}],"version-history":[{"count":17,"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/posts\/80676\/revisions"}],"predecessor-version":[{"id":83205,"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/posts\/80676\/revisions\/83205"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/media\/80688"}],"wp:attachment":[{"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/media?parent=80676"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/categories?post=80676"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/tags?post=80676"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}