CINXE.COM
Working efficiently with the command line | Development tools | Drupal Wiki guide on Drupal.org
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" version="XHTML+RDFa 1.0" dir="ltr" xmlns:fb="http://ogp.me/ns/fb#" xmlns:og="http://ogp.me/ns#"> <head profile="http://www.w3.org/1999/xhtml/vocab"> <meta name="HandheldFriendly" content="true" /> <meta name="viewport" content="width=device-width" /> <meta name="MobileOptimized" content="width" /> <!--[if IE]><![endif]--> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="description" content="How to work efficiently using tab completion, aliases and other shell tricks" /> <meta name="generator" content="Drupal 7 (https://www.drupal.org)" /> <link rel="image_src" href="https://www.drupal.org/sites/all/themes/bluecheese/images/og.jpg" /> <link rel="canonical" href="https://www.drupal.org/docs/develop/development-tools/working-efficiently-with-the-command-line" /> <link rel="shortlink" href="https://www.drupal.org/node/3358604" /> <meta property="og:site_name" content="Drupal.org" /> <meta property="og:type" content="article" /> <meta property="og:url" content="https://www.drupal.org/docs/develop/development-tools/working-efficiently-with-the-command-line" /> <meta property="og:title" content="Working efficiently with the command line" /> <meta property="og:description" content="Working with the command line (CLI) can be tedious and difficult, but also extremely efficient if you remember the commands and / or can find them again quickly. What can take numerous clicks in a GUI, can be replace with a long one-liner with the command line. Your CLI (or really your shell) can help you in many ways. Command history To repeat previous commands you can use up and down arrow. But the most powerful tool is history search - Ctrl+R in most shells. To automatically autocomplete commands from the history pressing up or down arrow, add this in your ~/.bashrc file." /> <meta property="og:updated_time" content="2023-12-21T11:43:32+00:00" /> <meta property="article:published_time" content="2023-05-06T09:39:35+00:00" /> <meta property="article:modified_time" content="2023-12-21T11:43:32+00:00" /> <title>Working efficiently with the command line | Development tools | Drupal Wiki guide on Drupal.org</title> <link type="text/css" rel="stylesheet" href="/files/advagg_css/css__vwdslBVX8xVWQ4hx4mWxIC59-lKGPldWkMIm435ispk__msT4O19F5udTbXsVQpyNk2EFYlbaoLwufqq_ZcdDcB0__YaNGWokqa69Wq8hHbkE322PVJ8I-GmpfBsT8LGsMpcI.css" media="all" /> <link type="text/css" rel="stylesheet" href="/files/advagg_css/css__Xi-PZpvKTY78w7l1WNsqwUA52MIupHJebCMiX34Ugt0__D_EUHDAfEQdxcLiSDY7hREUWkG1Ge56_h2z3Er8V188__YaNGWokqa69Wq8hHbkE322PVJ8I-GmpfBsT8LGsMpcI.css" media="all" /> <link type="text/css" rel="stylesheet" href="/files/advagg_css/css__WF0PRotZAhCcl0aJjY5W2LYj8UwiYuB2dZEFluOh3Tc__FviX13FUB-Ppa2XB29BUIJQZ1Wg-F5XiDE7XD5y7mjQ__YaNGWokqa69Wq8hHbkE322PVJ8I-GmpfBsT8LGsMpcI.css" media="all" /> <link type="text/css" rel="stylesheet" href="/files/advagg_css/css__Fx0_w1L9q3nwzXnALG7UfjLF34FGYgJTz636-GWbM6k__0jWLTEHP3h5U5RcXuZcFhf0DdvRdzP3_wzCVNT015Ls__YaNGWokqa69Wq8hHbkE322PVJ8I-GmpfBsT8LGsMpcI.css" media="all" /> <link type="text/css" rel="stylesheet" href="/files/advagg_css/css__pWCOPcaPe71p3QyGrAeqEd6dwL_n27prYOjnWQj4jVI__fR6RV6fh70jWL18FMzdVQpGUyYT8iL9Vw8wnms1DdQA__YaNGWokqa69Wq8hHbkE322PVJ8I-GmpfBsT8LGsMpcI.css" media="all" /> <link type="text/css" rel="stylesheet" href="/files/advagg_css/css__mlCLWKqAJJ-E-mMVCEmFp-7SE_XsgAxpf7HS-FcVqB0__7Tgy6u_PBeTp3b4s5UumhQPx9mJ_jhs1Z-WvSrqxAHk__YaNGWokqa69Wq8hHbkE322PVJ8I-GmpfBsT8LGsMpcI.css" media="all" /> <link type="text/css" rel="stylesheet" href="/files/advagg_css/css__QPp1snPjYt_xYr0c_V0IORcEElkIUBBBrvOB4ZE0Gnw__8jkPtXCYcQv4spuNwtiMBMbZXgCS-2GouDqwnCBDPRE__YaNGWokqa69Wq8hHbkE322PVJ8I-GmpfBsT8LGsMpcI.css" media="all" /> </head> <body class="html not-front not-logged-in no-sidebars page-node page-node- page-node-3358604 node-type-documentation drupalorg-site-main panels-layout og-context og-context-node og-context-node-2809279" > <div id="skip-link" tabindex="-1"> <a class="element-invisible element-focusable" href="#content">Skip to main content</a> <a class="element-invisible element-focusable skip-link-search" href="#search-block-form">Skip to search</a> </div> <div class="region region-page-top"> <noscript aria-hidden="true"><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-W36H8DW" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript> <div id="drupalorg-crosssite-gdpr">Can we use first and third party cookies and web beacons to <a href="https://www.drupal.org/terms">understand our audience, and to tailor promotions you see</a>?<br><button class="yes">Yes, please</button><button class="no">No, do not track me</button></div> </div> <div id="nav-header"> <div class="menu-nav"> <a class="nav-btn" id="nav-open-btn" href="#block-system-main-menu"><img src="/sites/all/themes/bluecheese/images/icon-w-menu.svg" alt="Main menu"></a> </div> <nav id="navigation-inner" class="container-12" role="navigation"> <div class="region region-navigation"> <div id="block-system-main-menu" class="block block-system block-menu"> <div class="block-inner"> <div class="content"> <div class="menu-block"><ul class="menu button"><li class="first leaf"><a href="/home" title="Drupal.org home page">Drupal.org home</a></li> <li class="expanded"><a href="/about" title="">Why Drupal?</a><div class="menu-block"><ul class="menu button"><li class="first leaf"><a href="/about" title="Learn about Drupal">About Drupal</a></li> <li class="leaf"><a href="/docs/getting-started/understanding-drupal/overview-of-drupal" title="">Platform overview</a></li> <li class="leaf"><a href="/about/11" title="">Drupal 11</a></li> <li class="leaf"><a href="/features/content-authoring" title="">Content Authoring</a></li> <li class="leaf"><a href="/features/content-as-a-service" title="">Content as a Service</a></li> <li class="leaf"><a href="/features/decoupled" title="">Decoupled</a></li> <li class="leaf"><a href="/features/accessibility" title="">Accessibility</a></li> <li class="leaf"><a href="/features/marketing-automation" title="">Marketing Automation</a></li> <li class="leaf"><a href="/features/multilingual" title="">Multilingual</a></li> <li class="leaf"><a href="/features/security" title="">Security</a></li> <li class="leaf"><a href="/features/personalization" title="">Personalization</a></li> <li class="leaf"><a href="/case-studies" title="View case studies to see how your peers have built success on Drupal">Case studies</a></li> <li class="leaf"><a href="https://www.drupal.org/association/beyond-the-build" title="">Video series</a></li> <li class="last leaf"><a href="/about/in-the-news" title="">News</a></li> </ul></div></li> <li class="expanded"><a href="/industries" title="Examples of solutions built on Drupal">Use cases</a><div class="menu-block"><ul class="menu button"><li class="first leaf"><a href="/developers" title="">For Developers</a></li> <li class="leaf"><a href="/marketers" title="Why marketers should choose Drupal for their ambitious digital experiences">For Marketers</a></li> <li class="leaf"><a href="/industries/ecommerce" title="">E-commerce</a></li> <li class="leaf"><a href="/industries/education" title="">Education</a></li> <li class="leaf"><a href="/industries/fintech" title="">FinTech</a></li> <li class="leaf"><a href="/industries/government" title="">Government</a></li> <li class="leaf"><a href="/industries/healthcare" title="">Healthcare</a></li> <li class="leaf"><a href="/industries/hightech" title="">High Tech</a></li> <li class="leaf"><a href="/industries/nonprofit" title="">Nonprofit</a></li> <li class="leaf"><a href="/industries/retail" title="">Retail</a></li> <li class="last leaf"><a href="/industries/travel" title="">Travel</a></li> </ul></div></li> <li class="expanded"><a href="/documentation" title="Resources to help you on your Drupal journey">Resources</a><div class="menu-block"><ul class="menu button"><li class="first leaf"><a href="/docs/getting-started/installing-drupal" title="">Installing Drupal</a></li> <li class="leaf"><a href="/documentation" title="Drupal Documentation">Documentation</a></li> <li class="leaf"><a href="/docs/user_guide/en/index.html" title="The Drupal 8 user guide will get you up to speed in no time">User guide</a></li> <li class="leaf"><a href="/docs/official_docs/local-development-guide" title="">Local Development Guide</a></li> <li class="leaf"><a href="/security" title="Find information about security releases for Drupal">Security</a></li> <li class="leaf"><a href="/news" title="News about the Drupal ecosystem">News</a></li> <li class="leaf"><a href="/planet" title="">Blog</a></li> <li class="last leaf"><a href="/about/drupal-7/d7eol/partners" title="Find help for your Drupal 7 migration">Migrate from D7</a></li> </ul></div></li> <li class="expanded"><a href="/drupal-services" title="Buy Drupal Products and Services">Services</a><div class="menu-block"><ul class="menu button"><li class="first leaf"><a href="/drupal-services" title="View the Drupal service provider marketplace">Find an Agency Partner</a></li> <li class="leaf"><a href="/hosting" title="Find trusted Drupal hosting providers">Find Integrations & Hosting</a></li> <li class="leaf"><a href="/training" title="Find expert Drupal training">Find Drupal Training</a></li> <li class="leaf"><a href="/association/become-a-drupal-certified-partner" title="">Become a Certified Partner</a></li> <li class="last leaf"><a href="/about/drupal-7/d7eol/migration-resource-center/enterprise" title="">Find a D7 migration partner</a></li> </ul></div></li> <li class="expanded"><a href="/community" title="Drupal Community">Community</a><div class="menu-block"><ul class="menu button"><li class="first leaf"><a href="/community/contributor-guide" title="">How to Contribute</a></li> <li class="leaf"><a href="/community" title="View the community portal and find all the ways you can contribute to Drupal">About the Community</a></li> <li class="leaf"><a href="/support" title="">Support</a></li> <li class="leaf"><a href="/project/governance" title="">Community Governance</a></li> <li class="last leaf"><a href="https://jobs.drupal.org" title="">Jobs/Careers</a></li> </ul></div></li> <li class="expanded"><a href="/community/events" title="Find Drupal Events around the world, from the official DrupalCons, to community Camps and Meet-Ups">Events</a><div class="menu-block"><ul class="menu button"><li class="first leaf"><a href="https://events.drupal.org/barcelona2024" title="">DrupalCon Barcelona 2024</a></li> <li class="leaf"><a href="https://events.drupal.org/singapore2024" title="">DrupalCon Singapore 2024</a></li> <li class="leaf"><a href="https://events.drupal.org/atlanta2025" title="">DrupalCon Atlanta 2025</a></li> <li class="last leaf"><a href="/community/events" title="">Community Events</a></li> </ul></div></li> <li class="expanded"><a href="/download" title="Download and Extend Drupal">Download</a><div class="menu-block"><ul class="menu button"><li class="first collapsed"><a href="/download" title="Build your solution on Drupal">Download</a></li> <li class="leaf"><a href="/project/modules" title="Find modules to extend Drupal to meet any need">Modules</a></li> <li class="leaf"><a href="/project/themes" title="Browse themes as a starting point for making your Drupal site your own">Themes</a></li> <li class="leaf"><a href="/project/distributions" title="Use a distribution to start with a version of Drupal customized to purpose">Distributions</a></li> <li class="leaf"><a href="/project/issues" title="Dive into the issues queues and contribute back to Drupal">Issue queues</a></li> <li class="last leaf"><a href="https://git.drupalcode.org/project/drupal" title="">Browse Repository</a></li> </ul></div></li> <li class="expanded"><a href="/association" title="About the Drupal Association - the non-profit that supports the Drupal project">Give</a><div class="menu-block"><ul class="menu button"><li class="first leaf"><a href="/association" title="Learn about the Drupal Association - the nonprofit that supports the Drupal project">Drupal Association</a></li> <li class="leaf"><a href="/association/organization-membership" title="Learn more about the organizations that support the Drupal Association and our mission">Become an Organization Member</a></li> <li class="leaf"><a href="/association/become-a-drupal-certified-partner" title="">Become a Certified Partner</a></li> <li class="leaf"><a href="/association/RippleMakers" title="">Become a Ripple Maker</a></li> <li class="leaf"><a href="/association/donate" title="">Make a Donation</a></li> <li class="leaf"><a href="/association/discover-drupal" title="">Discover Drupal</a></li> <li class="last leaf"><a href="https://www.drupal.org/swag?utm_source=drupalorg&utm_medium=banner&utm_campaign=drupal_swag_shop_2020_09_17" title="Purchase Drupal merchandise and be the coolest kid on the block">Drupal Swag Shop</a></li> </ul></div></li> <li class="last expanded"><a href="/try-drupal" title="Try Drupal">Demo</a><div class="menu-block"><ul class="menu button"><li class="first leaf"><a href="/try-drupal" title="Demo Drupal online with a Drupal platform partner">Demo online</a></li> <li class="last leaf"><a href="/download" title="">Download</a></li> </ul></div></li> </ul></div><a class="close-btn" href="#top">Return to content</a> </div> </div> </div> <div id="block-search-form" class="block block-search"> <div class="block-inner"> <div class="content"> <form action="/docs/develop/development-tools/working-efficiently-with-the-command-line" method="post" id="search-block-form" accept-charset="UTF-8"><div><div class="container-inline"> <h2 class="element-invisible">Search form</h2> <div class="form-item form-type-textfield form-item-search-block-form"> <label class="element-invisible" for="edit-search-block-form--2">Search </label> <input placeholder="Search…" type="text" id="edit-search-block-form--2" name="search_block_form" value="" size="15" maxlength="128" class="form-text" /> </div> <div class="form-actions form-wrapper" id="edit-actions"><input alt="Search" type="image" id="edit-submit" name="submit" value="Search" src="/sites/all/themes/bluecheese/images/icon-w-search.svg" class="form-submit" /></div><input type="hidden" name="form_build_id" value="form-kz79Qs1SUtM79fR7Qk3_oKokHGfrqjjseQI_F1bGrOg" /> <input type="hidden" name="form_id" value="search_block_form" /> </div> </div></form> </div> </div> </div> <div id="block-system-user-menu" class="block block-system block-menu"> <div class="block-inner"> <div class="content"> <div class="menu-block"><ul class="menu"><li class="button default"><a href="#block-system-user-menu"><img src="https://www.drupal.org/sites/all/themes/bluecheese/images/icon-w-user.svg" alt="Log in, view profile, and more"></a><ul><li class="first leaf"><a href="/user/login?destination=node/3358604" title="">Log in</a></li> <li class="last leaf"><a href="/user/register?destination=node/3358604" title="">Create account</a></li> </ul></li></ul></div> </div> </div> </div> </div> </nav> </div> <div id="header" class="clearfix"> <div id="header-inner" class="container-12 clearfix"> <div id="header-left"> <div id="site-name"><a href="/documentation">Documentation</a></div> </div> <div id="header-right"> <div class="region region-header"> <div id="block-drupalorg-search-documentation" class="block block-drupalorg"> <div class="block-inner"> <div class="content"> <form class="container-inline" action="/docs/develop/development-tools/working-efficiently-with-the-command-line" method="post" id="drupalorg-documentation-search-form" accept-charset="UTF-8"><div><input type="hidden" name="form_build_id" value="form-MEJ5QnCvx-VPFcDj-WCdQpUcLvdAmGET-wBnwxxrXkc" /> <input type="hidden" name="form_id" value="drupalorg_documentation_search_form" /> <div class="form-item form-type-textfield form-item-drupalorg-documentation-search-form"> <label class="element-invisible" for="edit-drupalorg-documentation-search-form--2">Search </label> <input placeholder="Search documentation…" type="text" id="edit-drupalorg-documentation-search-form--2" name="drupalorg_documentation_search_form" value="" size="15" maxlength="128" class="form-text" /> </div> <div class="form-actions form-wrapper" id="edit-actions--2"><input alt="Search" type="image" id="edit-submit--2" name="submit" value="Search" src="/sites/all/themes/bluecheese/images/icon-w-search.svg" class="form-submit" /></div></div></form> </div> </div> </div> </div> </div> </div> </div> <div id="banner" data-nosnippet> <div class="region region-banner"> <div id="block-drupalorg-announcements" class="block block-drupalorg"> <div class="block-inner"> <div class="content"> <div class="announcement"><img class="photo" src="https://www.drupal.org/files/styles/grid-2-2x-square/public/announcements/drupalcon-hexagon-icon-280X280px_2_0.png?itok=uzoGg7T8" width="280" height="280" alt="Announcement icon" title="Announcement icon" />Join us at DrupalCon Singapore from 9-11 December 2024, for three exciting days of Drupal content, training, contributions, networking, and the inaugural DrupalCon Splash Awards! Be part of this landmark event as we celebrate and expand Drupal's impact across Asia.</div> <div class="cta"><a href="https://events.humanitix.com/drupalcon-singapore-2024" class="global-announce-banner dc-singapore-registration">Get your tickets now</a></div> </div> </div> </div> </div> </div> <div id="page" class="clearfix"> <div class="breadbox"><nav class="breadcrumb container-12"><span><a href="/docs/develop">Develop</a></span><span><a href="/docs/develop/development-tools">Development tools</a></span></nav></div> <div id="main" role="main"> <div id="content" class="clearfix"> <div id="content-inner" class="clearfix"> <div class="region region-content"> <div id="block-system-main" class="block block-system"> <div class="block-inner"> <div class="content"> <div class="panelizer-view-mode node node-full node-documentation node-3358604"> <div class="panel-display hydra panel-layout clearfix " > <div class="container preface clearfix panel-panel"> <div class="container-inner preface-inner panel-panel-inner"> </div> </div> <div class="container content clearfix"> <div class="container-inner content-inner panel-panel-inner"> <div class="column-content-region top-right-content column panel-panel"> <div class="column-content-region-inner top-right-content-inner column-inner panel-panel-inner"> <div class="panel-pane pane-block pane-drupalorg-carbon-ad-sidebar" > <div class="pane-content"> <script async type="text/javascript" src="//cdn.carbonads.com/carbon.js?serve=CKYIEKJI&placement=drupalorg" id="_carbonads_js"></script><div class="ad-explanation description">Advertising sustains the DA. Ads are hidden for members. <a href="/association/individual-membership">Join today</a></div> </div> </div> <div class="panel-separator"></div><div class="panel-pane pane-block pane-table-of-contents-toc-w-3y7froeoqmgrpcmgnphqwt4pi3" id="on-this-page" > <h3 class="pane-title"> On this page </h3> <div class="pane-content"> <div class="item-list"><ul class="anchor-list"><li class="anchor-list__item h2-tag first"><a href="/docs/develop/development-tools/working-efficiently-with-the-command-line#s-command-history" class="toc-link toc-link-invalid-id active">Command history</a></li> <li class="anchor-list__item h2-tag"><a href="/docs/develop/development-tools/working-efficiently-with-the-command-line#s-tab-completion" class="toc-link toc-link-invalid-id active">Tab completion</a></li> <li class="anchor-list__item h2-tag"><a href="/docs/develop/development-tools/working-efficiently-with-the-command-line#s-aliases" class="toc-link toc-link-invalid-id active">Aliases</a></li> <li class="anchor-list__item h3-tag"><a href="/docs/develop/development-tools/working-efficiently-with-the-command-line#s-ddev-drush-and-composer-aliases" class="toc-link toc-link-invalid-id active">DDEV, Drush, and Composer aliases</a></li> <li class="anchor-list__item h3-tag"><a href="/docs/develop/development-tools/working-efficiently-with-the-command-line#s-open-web-site-logged-in-as-admin" class="toc-link toc-link-invalid-id active">Open web site logged in as admin</a></li> <li class="anchor-list__item h2-tag"><a href="/docs/develop/development-tools/working-efficiently-with-the-command-line#s-run-commands-via-composerjson" class="toc-link toc-link-invalid-id active">Run commands via composer.json</a></li> <li class="anchor-list__item h2-tag last"><a href="/docs/develop/development-tools/working-efficiently-with-the-command-line#s-report-with-custom-ddev-command" class="toc-link toc-link-invalid-id active">Report with custom DDEV command</a></li> </ul></div> </div> </div> <div class="panel-separator"></div><div class="panel-pane pane-block pane-og-menu-og-single-menu-block" id="development-tools" > <h2 class="pane-title"> <a href="/docs/develop/development-tools">Development tools</a> </h2> <div class="pane-content"> <ul class="menu"><li class="first leaf"><a href="/docs/develop/development-tools/development-tools-overview">Development tools overview</a></li> <li class="leaf"><a href="/docs/develop/development-tools/drush">Drush</a></li> <li class="leaf"><a href="/docs/develop/development-tools/editors-and-ides" title="">Editors and IDEs</a></li> <li class="leaf"><a href="/docs/develop/development-tools/drupalpod">DrupalPod</a></li> <li class="leaf"><a href="/docs/develop/development-tools/develop-on-windows">Develop on Windows</a></li> <li class="leaf"><a href="/docs/develop/development-tools/set-up-your-browser-to-make-your-work-easy">Set up your browser to make your work easy</a></li> <li class="leaf"><a href="/docs/develop/development-tools/xhprof-code-profiler">XHProf Code Profiler</a></li> <li class="leaf"><a href="/docs/develop/development-tools/xdebug-debugger">Xdebug debugger</a></li> <li class="leaf"><a href="/docs/develop/development-tools/disabling-and-debugging-caching">Disable caching</a></li> <li class="leaf"><a href="/docs/develop/development-tools/enable-verbose-error-logging-for-better-backtracing-and-debugging">Enable verbose error logging for better backtracing and debugging</a></li> <li class="leaf"><a href="/docs/develop/development-tools/phpstan" title="">PHPStan</a></li> <li class="leaf active-trail"><a href="/docs/develop/development-tools/working-efficiently-with-the-command-line" class="active-trail active">Working efficiently with the command line</a></li> <li class="last leaf"><a href="/docs/develop/development-tools/cspell" title="Automated code spell checking via cspell">cspell</a></li> </ul> </div> </div> <div class="panel-separator"></div><div class="panel-pane pane-node-links" > <div class="pane-content"> </div> </div> </div> </div> <div class="column-content-region left-content column panel-panel "> <div class="column-content-region-inner left-content-inner column-inner panel-panel-inner"> <div class="panel-pane pane-node-title" > <div class="pane-content"> <h1>Working efficiently with the command line</h1> </div> </div> <div class="panel-separator"></div><div class="panel-pane pane-node-updated" id="last-updated-on" > <span class="pane-title"> Last <a href="/node/3358604/discuss">updated</a> on </span> <div class="pane-content"> 21 December 2023 </div> </div> <div class="panel-separator"></div><div class="panel-pane pane-entity-field pane-node-field-documentation-status" > <div class="pane-content"> <div class="field field-name-field-documentation-status field-type-list-text field-label-hidden"><div class="field-items"><div class="field-item even"><p class="deprecated">This documentation <strong>needs review</strong>. See "Help improve this page" in the sidebar.</p></div></div></div> </div> </div> <div class="panel-separator"></div><div class="panel-pane pane-entity-field pane-node-body" > <div class="pane-content"> <div class="field field-name-body field-type-text-with-summary field-label-hidden"><div class="field-items"><div class="field-item even"><p>Working with the command line (CLI) can be tedious and difficult, but also extremely efficient if you remember the commands and / or can find them again quickly. What can take numerous clicks in a GUI, can be replace with a long one-liner with the command line. Your CLI (or really your <a href="https://en.wikipedia.org/wiki/Shell_(computing)" rel="nofollow">shell</a>) can help you in many ways.</p> <h2 id="s-command-history"><a class="toc-anchor" title="Permalink to this headline" href="#s-command-history"></a>Command history</h2> <p>To repeat previous commands you can use up and down arrow. But the most powerful tool is history search - <code class="language-php">Ctrl+R</code> in most shells. </p> <p>To automatically autocomplete commands from the history pressing up or down arrow, add this in your <code class="language-php">~/.bashrc</code> file. Type for example "drush" and press up for suggestions:</p> <pre> <code class="language-php"># Bind up/down arrow to history search bind '"\e[A":history-search-backward' bind '"\e[B":history-search-forward' # Settings for history function export HISTCONTROL=ignoreboth:erasedups export HISTIGNORE='&:e:c:l:ca:cd:cd -'</code></pre><h2 id="s-tab-completion"><a class="toc-anchor" title="Permalink to this headline" href="#s-tab-completion"></a>Tab completion</h2> <p>To not have to type or remember long commands, most commands offer tab completion. You type part of an option or an argument, and then hit tab to complete it. (You can also type part of the command name to complete it.) You can also use completion to list all options or arguments if you have forgotten them.</p> <p>Both Drush and Composer supports tab completion - read the <a href="https://www.drush.org/12.x/commands/completion/" rel="nofollow">Drush</a> or <a href="https://getcomposer.org/doc/03-cli.md#bash-completions" rel="nofollow">Composer</a> documentation. </p> <h2 id="s-aliases"><a class="toc-anchor" title="Permalink to this headline" href="#s-aliases"></a>Aliases</h2> <p>To not have to repeatedly type long commands, you can create aliases in Unix (Linux and macOS) functioning as shortcuts. You can also string together several commands in an alias, automating tedious tasks. You can call your aliases anything you want, as long as another command with that name doesn't already exist.</p> <p>In these examples DDEV is used, but it works just the same way with other programs.</p> <h3 id="s-ddev-drush-and-composer-aliases"><a class="toc-anchor" title="Permalink to this headline" href="#s-ddev-drush-and-composer-aliases"></a>DDEV, Drush, and Composer aliases</h3> <p>Here is an example of a few aliases. Add it in your <code class="language-php"> ~/.bash_aliases</code> file:</p> <pre> <code class="language-php"># DDEV, Drush, and Composer aliases alias dstart='ddev start' alias dstop='ddev stop' alias drush='ddev drush' alias din='ddev drush install' alias dun='ddev drush pm:uninstall' alias duli='ddev drush uli' alias creq='ddev composer require' alias crem='ddev composer remove'</code></pre><p>Now run this command to make it take effect:</p> <p><code class="language-php">source ~/.bash_aliases</code></p> <p>You should now be able to enter a DDEV installation, type <code class="language-php">dstart</code> and hit Return after which DDEV should start.</p> <p>Most docker based dev environments provide build-in aliases and allow you to create your owns, there usually based on bash scripts or gnu-make:</p> <ul> <li>DDEV: <a href="https://ddev.readthedocs.io/en/latest/users/extend/custom-commands/" rel="nofollow">https://ddev.readthedocs.io/en/latest/users/extend/custom-commands/</a></li> <li>Docker4Drupal: <a href="https://wodby.com/docs/1.0/stacks/laravel/local/#make-commands" rel="nofollow">https://wodby.com/docs/1.0/stacks/laravel/local/#make-commands</a></li> <li>Docskal: <a href="https://docs.docksal.io/fin/custom-commands/" rel="nofollow">https://docs.docksal.io/fin/custom-commands/</a></li> <li>Lando : <a href="https://docs.lando.dev/core/v3/tooling.html" rel="nofollow">https://docs.lando.dev/core/v3/tooling.html</a></li> </ul> <h3 id="s-open-web-site-logged-in-as-admin"><a class="toc-anchor" title="Permalink to this headline" href="#s-open-web-site-logged-in-as-admin"></a>Open web site logged in as admin</h3> <p>This one-liner will generate a one-time-login, and open up the web site in your browser, logged in as admin:</p> <p><code class="language-php">xdg-open $(ddev drush uli)</code></p> <p>You can define a destination URL like this:</p> <p><code class="language-php">xdg-open $(ddev drush uli)?destination=/upgrade</code></p> <h2 id="s-run-commands-via-composerjson"><a class="toc-anchor" title="Permalink to this headline" href="#s-run-commands-via-composerjson"></a>Run commands via <code class="language-php">composer.json</code></h2> <p>You can run commands with Composer. Just add something like this in your <code class="language-php">composer.json</code>:</p> <pre> <code class="language-php"> "scripts": { "project:reinstall": [ "[ ! -z $(ddev drush core:status --field=db-status) ] && ddev drush cache:rebuild || true", "ddev drush site:install -v --yes", "ddev drush cache:rebuild", "ddev drush user:login" ] },</code></pre><p>Run it with this command:</p> <p><code class="language-php">composer project:reinstall</code></p> <p>For details, see <a href="https://cyberschorsch.dev/drupal/effortless-drupal-reinstallations-quick-guide-using-composer" rel="nofollow">Effortless Drupal Reinstallations: A Quick Guide Using Composer</a>.</p> <h2 id="s-report-with-custom-ddev-command"><a class="toc-anchor" title="Permalink to this headline" href="#s-report-with-custom-ddev-command"></a>Report with custom DDEV command</h2> <p>You can extend DDEV with <a href="https://ddev.readthedocs.io/en/stable/users/extend/custom-commands/" rel="nofollow">Custom Commands</a> to trigger a series of Drush commands, as well as run Unix commands. It works really well, and it's easy to write your own custom command files.</p> <p>Add this in a new <code class="language-php">.ddev/commands/web/report</code> file in your project:</p> <pre> <code class="language-php">#!/bin/bash ## Description: Get a report of Drupal version, updates, etc. ## Usage: report ## Example: 'ddev report' echo '** Check config status, get versions and important log messages, etc.' echo '' echo '* Configuration status' drush config:status echo '' echo '* Versions, db and webserver' drush core:status | grep 'version' # see webcommands.example for all available web script variables echo 'Database :' $DDEV_DATABASE echo 'Webserver :' $DDEV_WEBSERVER_TYPE echo '' echo '* Last 3 log entries with severity minimum Warning' drush watchdog:show --count=3 --severity-min=Warning echo '' echo '** Check for Drupal core and module updates' composer outdated "drupal/*" echo '' echo '** Check for security vulnerabilities' composer audit echo '' </code></pre><p>Run the command, to get a report about your system:</p> <pre> <code class="language-php">$ ddev report ** Check config status, get versions and important log messages, etc. * Configuration status [notice] No differences between DB and sync directory. * Versions, db and webserver Drupal version : 10.1.5 PHP version : 8.1.23 Drush version : 12.1.2.0 Database : mariadb:10.4 Webserver : nginx-fpm * Last 3 log entries with severity minimum Warning ----- -------------- ------ ---------- ----------------------------------- ID Date Type Severity Message ----- -------------- ------ ---------- ----------------------------------- 101 03/Nov 19:16 php Error Error: Call to undefined function chart_info_default_settings 94 03/Nov 18:06 cron Warning Attempting to re-run cron while it is already running. 93 03/Nov 18:06 cron Warning Attempting to re-run cron while it is already running. ----- -------------- ------ ---------- ----------------------------------- ** Check for Drupal core and module updates Color legend: - patch or minor release available - update recommended - major release available - update possible Direct dependencies required in composer.json: drupal/core-composer-scaffold 10.1.5 10.1.6 A flexible Composer projec... drupal/core-project-message 10.1.5 10.1.6 Adds a message after Compo... drupal/core-recommended 10.1.5 10.1.6 Core and its dependencies ... drupal/metatag 1.26.0 2.0.0 Manage meta tags for all e... drupal/search_api_solr 4.3.0 4.3.1 Offers an implementation o... drupal/security_review 2.0.1 2.0.2 The Security Review module... drupal/site_audit 4.0.0-rc3 4.0.0-rc4 This extension provides Si... drupal/webprofiler 10.1.1 10.1.3 Extract, collect, store an... ** Check for security vulnerabilities No security vulnerability advisories found.</code></pre></div></div></div> </div> </div> </div> </div> <div class="column-content-region bottom-right-content column panel-panel"> <div class="column-content-region-inner bottom-right-content-inner column-inner panel-panel-inner"> <div class="panel-pane pane-views-panes pane-documentation-help-improve-pane" id="help-improve-this-page" > <h2 class="pane-title"> Help improve this page </h2> <div class="pane-content"> <div class="view view-documentation-help view-id-documentation_help view-display-id-improve_pane view-dom-id-c8e9e452a6145679e7c7928c10b15487"> <div class="view-content"> <div class="views-row views-row-1 views-row-odd views-row-first views-row-last"> <span class="views-field views-field-field-documentation-status"> <strong class="views-label views-label-field-documentation-status">Page status: </strong> <span class="field-content">Needs review</span> </span> <div class="views-field views-field-nothing"> <span class="field-content"><br /><strong>You can:</strong><br /> <ul> <li>Log in, click <a href="/node/3358604/edit">Edit</a>, and edit this page</li> <li>Log in, click <a href="/node/3358604/discuss">Discuss</a>, update the Page status value, and suggest an improvement</li> <li>Log in and <a href="/node/add/project-issue/documentation?title=Suggestion%20for%3A%20%283358604%29%20Working%20efficiently%20with%20the%20command%20line">create a Documentation issue</a> with your suggestion</li> </ul></span> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> <div class="container footer clearfix panel-panel"> <div class="container-inner footer-inner panel-panel-inner"> </div> </div> </div><!-- /.sutro --> </div> </div> </div> </div> </div> </div> </div> <!-- /#content --> </div> <!-- /#column-left --> </div> <!-- /#page --> <div id="footer" role="contentinfo"> <div class="region region-footer"> <div id="block-drupalorg-documentation-license" class="block block-drupalorg"> <div class="block-inner"> <div class="content"> Drupal’s online documentation is © 2000-2024 by the individual contributors and can be used in accordance with the <a href="/terms">Creative Commons License, Attribution-ShareAlike 2.0</a>. PHP code is distributed under the <a href="https://www.gnu.org/licenses/old-licenses/gpl-2.0.html">GNU General Public License</a>. </div> </div> </div> <div id="block-drupalorg-crosssite-infra-partner" class="block block-drupalorg-crosssite"> <div class="block-inner"> <div class="content"> <a href="https://tag1consulting.com" >Infrastructure management for Drupal.org provided by <img src="/files/cta/graphic/tag1_wht.svg" alt="Tag1 logo" ></a> <br /> <span style="font-size: .65em;"><a href="https://d7es.tag1.com/">Need a Drupal 7 extended support partner? Consider Tag1.</a></span> </div> </div> </div> <div id="block-drupalorg-crosssite-drupalorg-footer" class="block block-drupalorg-crosssite"> <div class="block-inner"> <div class="content"> <h4 class="element-invisible">News items</h4><ul class="drupal-news"><li class="0 first"><a href="https://www.drupal.org/news">News</a></li> <li class="1"><a href="https://www.drupal.org/planet" title="News from Drupal community members">Planet Drupal</a></li> <li class="2"><a href="https://www.drupal.org/about/media-kit/social-media" title="Drupal on social media">Social media</a></li> <li class="3"><a href="https://www.drupal.org/subscribe">Sign up for Drupal news</a></li> <li class="4"><a href="https://www.drupal.org/security" title="Announcements from the Drupal Security Team">Security advisories</a></li> <li class="5 last"><a href="https://jobs.drupal.org/" title="Drupal Jobs">Jobs</a></li> </ul><h4 class="element-invisible">Our community</h4><ul class="community"><li class="0 first"><a href="https://www.drupal.org/community">Community</a></li> <li class="1"><span><a href="https://www.drupal.org/drupal-services" title="People and organizations offering Drupal services">Services</a>, <a href="https://www.drupal.org/training" title="People and organizations offering Drupal training">Training</a> & <a href="https://www.drupal.org/hosting" title="Organizations offering Drupal hosting">Hosting</a></span></li> <li class="2"><a href="https://www.drupal.org/community/contributor-guide">Contributor guide</a></li> <li class="3"><a href="https://groups.drupal.org/groups" title="groups.drupal.org">Groups & meetups</a></li> <li class="4"><a href="https://events.drupal.org" title="Upcoming and past DrupalCons">DrupalCon</a></li> <li class="5 last"><a href="https://www.drupal.org/dcoc" title="Drupal code of conduct">Code of conduct</a></li> </ul><h4 class="element-invisible">Documentation</h4><ul class="get-started"><li class="0 first"><a href="https://www.drupal.org/documentation" title="Documentation for working with Drupal">Documentation</a></li> <li class="1"><a href="https://www.drupal.org/docs">Drupal Guide</a></li> <li class="2"><a href="https://www.drupal.org/docs/user_guide/en/index.html">Drupal User Guide</a></li> <li class="3"><a href="https://www.drupal.org/documentation/develop">Developer docs</a></li> <li class="4 last"><a href="https://api.drupal.org/" title="Drupal API reference">API.Drupal.org</a></li> </ul><h4 class="element-invisible">Drupal code base</h4><ul class="download-extend"><li class="0 first"><a href="https://www.drupal.org/download">Download & Extend</a></li> <li class="1"><a href="https://www.drupal.org/project/drupal" title="Download the latest version of the Drupal software">Drupal core</a></li> <li class="2"><a href="https://www.drupal.org/project/project_module" title="Download add-on features and functionality">Modules</a></li> <li class="3"><a href="https://www.drupal.org/project/project_theme" title="Download pre-designed styles for Drupal">Themes</a></li> <li class="4 last"><a href="https://www.drupal.org/project/project_distribution" title="Download a pre-packaged Drupal site">Distributions</a></li> </ul><h4 class="element-invisible">Governance of community</h4><ul class="about"><li class="0 first"><a href="https://www.drupal.org/about">About</a></li> <li class="1"><a href="https://www.drupal.org/about/features/accessibility" title="Our committment to accessibility">Web accessibility</a></li> <li class="2"><a href="https://www.drupal.org/association" title="About the Drupal Association">Drupal Association</a></li> <li class="3"><a href="https://www.drupal.org/drupalorg" title="About Drupal.org">About Drupal.org</a></li> <li class="4"><a href="https://www.drupal.org/terms" title="Drupal.org terms of service">Terms of service</a></li> <li class="5 last"><a href="https://www.drupal.org/privacy" title="Drupal.org privacy policy">Privacy policy</a></li> </ul> </div> </div> </div> <div id="block-block-77" class="block block-block"> <div class="block-inner"> <div class="content"> <p>Drupal is a <a href="/about/trademark">registered trademark</a> of <a href="https://dri.es">Dries Buytaert</a>.</p> </div> </div> </div> </div> </div> <div class="region region-page-bottom"> <script type="text/javascript"> (function(){ window._pxAppId = 'PXVnPBBfwe'; window._pxParam2 = ''; window._pxParam3 = '0'; var p = document.getElementsByTagName('script')[0], s = document.createElement('script'); s.async = 1; s.src = '/VnPBBfwe/init.js'; p.parentNode.insertBefore(s,p); }()); </script> <noscript> <div style="position:fixed; top:0; left:0; display:none" width="1" height="1"> <img src="/VnPBBfwe/xhr/api/v1/collector/noScript.gif?appId=PXVnPBBfwe"> </div> </noscript> </div> <script type="text/javascript" src="/files/advagg_js/js__B0FBwiP97ZnD38IFraZus4upS4KVkMXI3ou0fJ2ZXGA__pPDESRJz9GHsxqQIwQ_V8xnFYEH5jipG2eicsfrdWCs__YaNGWokqa69Wq8hHbkE322PVJ8I-GmpfBsT8LGsMpcI.js" defer="defer"></script> <!--[if lte IE 9]> <script type="text/javascript" src="/files/advagg_js/js__79M6UrZjAw3oNGnUjsWip12JsvnUZmJGA3h9LI0kuzE__J0sbXAJNry2-C_ZL2xd0RdVuzwTLvwN-UisIv5RNCvU__YaNGWokqa69Wq8hHbkE322PVJ8I-GmpfBsT8LGsMpcI.js#ie9-" onload="if(jQuery.isFunction(jQuery.holdReady)){jQuery.holdReady(true);}"></script> <![endif]--> <!--[if gt IE 9]> <script type="text/javascript" src="/files/advagg_js/js__79M6UrZjAw3oNGnUjsWip12JsvnUZmJGA3h9LI0kuzE__J0sbXAJNry2-C_ZL2xd0RdVuzwTLvwN-UisIv5RNCvU__YaNGWokqa69Wq8hHbkE322PVJ8I-GmpfBsT8LGsMpcI.js#ie10+" defer="defer" onload="if(jQuery.isFunction(jQuery.holdReady)){jQuery.holdReady(true);}"></script> <![endif]--> <!--[if !IE]><!--> <script type="text/javascript" src="/files/advagg_js/js__79M6UrZjAw3oNGnUjsWip12JsvnUZmJGA3h9LI0kuzE__J0sbXAJNry2-C_ZL2xd0RdVuzwTLvwN-UisIv5RNCvU__YaNGWokqa69Wq8hHbkE322PVJ8I-GmpfBsT8LGsMpcI.js" defer="defer" onload="if(jQuery.isFunction(jQuery.holdReady)){jQuery.holdReady(true);}"></script> <!--<![endif]--> <script type="text/javascript" src="/files/advagg_js/js__pqoYaVR8NVhof-vNXe50j2TKhFv__IihVag_h4G6kus__B4mbn4wICLQjWm1m3-z1kw8F1FtP0cDAHKp00Xy_-88__YaNGWokqa69Wq8hHbkE322PVJ8I-GmpfBsT8LGsMpcI.js" defer="defer"></script> <script type="text/javascript" src="/files/advagg_js/js__H5AFmq1RrXKsrazzPq_xPQPy4K0wUKqecPjczzRiTgQ__wor4r9P8YTtQ7p6fbywTetZ47Z_orumIfrrhgxrpLus__YaNGWokqa69Wq8hHbkE322PVJ8I-GmpfBsT8LGsMpcI.js" defer="defer" onload=" function advagg_mod_1() { // Count how many times this function is called. advagg_mod_1.count = ++advagg_mod_1.count || 1; try { if (advagg_mod_1.count <= 40) { init_drupal_core_settings(); // Set this to 100 so that this function only runs once. advagg_mod_1.count = 100; } } catch(e) { if (advagg_mod_1.count >= 40) { // Throw the exception if this still fails after running 40 times. throw e; } else { // Try again in 1 ms. window.setTimeout(advagg_mod_1, 1); } } } function advagg_mod_1_check() { if (window.init_drupal_core_settings && window.jQuery && window.Drupal) { advagg_mod_1(); } else { window.setTimeout(advagg_mod_1_check, 1); } } advagg_mod_1_check();"></script> <script type="text/javascript" src="/files/advagg_js/js__Oc0wwB7MVRfxtYw6EQM7d9sXj9PAQePoWSzQJ0uTk6c__iXqOGoaPhZHCPEspUr5BC8BwOx5P8B11xv7VOhoUii8__YaNGWokqa69Wq8hHbkE322PVJ8I-GmpfBsT8LGsMpcI.js" defer="defer"></script> <script type="text/javascript" src="/files/advagg_js/js__FabcJ6qluktliDejymsuV-FqaN_HyMKGe93c2rO9Ky0__el1ZLGkKneOoCS6OWa01WHuIEsTsXZ46MRLCF390Fbw__YaNGWokqa69Wq8hHbkE322PVJ8I-GmpfBsT8LGsMpcI.js" defer="defer"></script> <script type="text/javascript" src="/files/advagg_js/js__YT6D1B_BKxvm6JCH_t9sZNI5L6yITa_DlU5QcSlOkAU__OXobH7d1IP1o3WABlniIrU_-pcJacVSIPUv9bpD-6pQ__YaNGWokqa69Wq8hHbkE322PVJ8I-GmpfBsT8LGsMpcI.js" defer="defer"></script> <script type="text/javascript" src="/files/advagg_js/js__xNXZEl6CREO_N4cX50nXAG3o3PPW1f2SzBBHY8rEKV8__vTuPvw9kFyhvW1mq6Cl_PG3exxZo1gi4hMxmKe9QZUI__YaNGWokqa69Wq8hHbkE322PVJ8I-GmpfBsT8LGsMpcI.js" defer="defer"></script> <script type="text/javascript" src="/files/advagg_js/js__pLKQd4r7OrHglE7Qkqw53K2UXCqQdhqQ9v0cz7hMCQY__OErfYuQdGbFHcCoLoUW_ESSvaumApNojzjJit8-2xcw__YaNGWokqa69Wq8hHbkE322PVJ8I-GmpfBsT8LGsMpcI.js" defer="defer"></script> <script type="text/javascript" src="/files/advagg_js/js__hHUWFbMAa11eJtx5V0ym9o0YBsB1udk34qUT5wr1ihI__ntICfIdx3SsBpfvYB8AF0VuFk7gZjQgBaS1C9CyMj6o__YaNGWokqa69Wq8hHbkE322PVJ8I-GmpfBsT8LGsMpcI.js" defer="defer"></script> <script type="text/javascript"> <!--//--><![CDATA[//><!-- function init_drupal_core_settings() {jQuery.extend(Drupal.settings,{"basePath":"\/","pathPrefix":"","setHasJsCookie":0,"ajaxPageState":{"theme":"bluecheese","theme_token":"a1VQoRfjih2XhfFpyucJXz8mPesvYO6UTlT4gXUXABg"},"drupalorgGitlab":{"gitlab_base_url":"https:\/\/git.drupalcode.org","base_url":"https:\/\/www.drupal.org"},"better_exposed_filters":{"views":{"documentation_help":{"displays":{"improve_pane":{"filters":[]}}},"documentation_related_content":{"displays":{"related_content_pane":{"filters":[]}}}}},"urlIsAjaxTrusted":{"\/docs\/develop\/development-tools\/working-efficiently-with-the-command-line":true},"drupalorgCrosssiteConsentNeeded":true,"ogContext":{"groupType":"node","gid":"2809279"}}); if(jQuery.isFunction(jQuery.holdReady)){jQuery.holdReady(false);}} if(window.jQuery && window.Drupal){init_drupal_core_settings();} //--><!]]> </script> <script type="text/javascript" src="/files/advagg_js/js__2k0CJ3KAQNFTFab3y6ZvNtxs3HLons0Brq7VwvPSkKo__RYlZCliQTuN7U7I5I1Xhn1dAop17g2hAft1wVGgKHGA__YaNGWokqa69Wq8hHbkE322PVJ8I-GmpfBsT8LGsMpcI.js" defer="defer"></script> <script type="text/javascript" src="/files/advagg_js/js__vj0LjvNwl-3K1P9LGT4BGuXCZcAovYsVlVmoJN3TMRg__KW8SiGceRY3sjIKVrffDjf2MK4A5Vp3EDDxVO-4pegI__YaNGWokqa69Wq8hHbkE322PVJ8I-GmpfBsT8LGsMpcI.js" defer="defer"></script> </body> </html>