{"id":27307,"date":"2018-06-28T04:33:49","date_gmt":"2018-06-28T09:33:49","guid":{"rendered":"https:\/\/www.rosehosting.com\/blog\/?p=27307"},"modified":"2023-04-05T04:12:47","modified_gmt":"2023-04-05T09:12:47","slug":"create-custom-commands-in-linux","status":"publish","type":"post","link":"https:\/\/www.rosehosting.com\/blog\/create-custom-commands-in-linux\/","title":{"rendered":"How to Create Custom Commands in Linux"},"content":{"rendered":"<div id=\"bsf_rt_marker\"><\/div><p><img decoding=\"async\" class=\"alignnone size-full wp-image-27328\" src=\"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2018\/06\/How-to-Create-Custom-Commands-in-Linux.jpg\" alt=\"How to Create Custom Commands in Linux\" width=\"742\" height=\"371\" srcset=\"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2018\/06\/How-to-Create-Custom-Commands-in-Linux.jpg 742w, https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2018\/06\/How-to-Create-Custom-Commands-in-Linux-150x75.jpg 150w, https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2018\/06\/How-to-Create-Custom-Commands-in-Linux-300x150.jpg 300w\" sizes=\"(max-width: 742px) 100vw, 742px\" \/><\/p>\n<p>In this tutorial, We&#8217;ll show you how to create custom commands in Linux which will allow you to create &#8220;shortcut&#8221; commands using a simple name of your choosing. Even better, you can chain multiple commands like this together and run them all with a single word. Useful, right? As you get more and more acquainted with Linux, you&#8217;ll come across commands in forums and tutorials that can be really complex (and weird). Consider the following example to print the list of files in a single column:<\/p>\n<pre>ls -l --color | awk '{ print $9 }'<\/pre>\n<p>This gives us the following output:<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-27308\" src=\"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2018\/06\/Output-of-awk-command.jpg\" alt=\"Output of awk command\" width=\"686\" height=\"237\" srcset=\"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2018\/06\/Output-of-awk-command.jpg 686w, https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2018\/06\/Output-of-awk-command-150x52.jpg 150w, https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2018\/06\/Output-of-awk-command-300x104.jpg 300w\" sizes=\"(max-width: 686px) 100vw, 686px\" \/><\/p>\n<p>So far so good. But what if you want to use this command frequently? It&#8217;s difficult to remember this letter for letter, it&#8217;s not easy to type out, and it takes way too long. Now add dozens of other commands with similar (or greater) levels of complexity, and it&#8217;s easy to see that we need a new solution.<\/p>\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_82_2 counter-hierarchy ez-toc-counter ez-toc-transparent ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-69fbf93e8c8a3\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"ez-toc-cssicon\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-69fbf93e8c8a3\"  aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.rosehosting.com\/blog\/create-custom-commands-in-linux\/#Step-1-Open-a-File-in-the-Text-Editor-with-your-Command-Name\" >Step 1: Open a File in the Text Editor with your Command Name<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.rosehosting.com\/blog\/create-custom-commands-in-linux\/#Step-2-Assign-the-Right-Permissions-to-our-Script\" >Step 2: Assign the Right Permissions to our Script<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.rosehosting.com\/blog\/create-custom-commands-in-linux\/#Step-3-Specifying-Paths-to-Our-Script\" >Step 3: Specifying Paths to Our Script<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"western\"><span class=\"ez-toc-section\" id=\"Step-1-Open-a-File-in-the-Text-Editor-with-your-Command-Name\"><\/span>Step 1: Open a File in the Text Editor with your Command Name<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Let&#8217;s say we want to call our new command &#8220;files&#8221;. We create a new file with the name &#8220;files&#8221; using the text editor &#8220;vi&#8221; by issuing this command:<\/p>\n<pre>vi files<\/pre>\n<p>This will open up a basic editor where you can type your text. By default, it&#8217;ll be in &#8220;read&#8221; mode and you can&#8217;t add new text. Change this to insert mode by pressing the &#8220;Insert&#8221; key on your keyboard.<\/p>\n<p>Now copy and paste the following text. You can quickly paste into the terminal by right-clicking inside it.<\/p>\n<pre>#!\/bin\/bash\r\n<b># Print list of files in one column\r\nls -l --color | awk '{ print $9 }'<\/b><\/pre>\n<p>As you can see, this is pasted into vi when the &#8220;INSERT&#8221; mode is on:<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-27309\" src=\"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2018\/06\/Copy-and-Paste-the-script-into-vi.jpg\" alt=\"Copy and Paste the script into vi\" width=\"647\" height=\"466\" srcset=\"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2018\/06\/Copy-and-Paste-the-script-into-vi.jpg 647w, https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2018\/06\/Copy-and-Paste-the-script-into-vi-150x108.jpg 150w, https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2018\/06\/Copy-and-Paste-the-script-into-vi-300x216.jpg 300w\" sizes=\"(max-width: 647px) 100vw, 647px\" \/><\/p>\n<p>This is called a &#8220;script&#8221;, and it&#8217;s made up of three parts:<\/p>\n<ol>\n<li>It starts with the words &#8220;#!\/bin\/bash&#8221;<\/li>\n<li>Lines starting with a hashtag (#) are comments<\/li>\n<li>The rest are commands. Replace the 3rd line with your complicated command that you want to simplify<\/li>\n<\/ol>\n<p>Now exit &#8220;Insert&#8221; mode by pressing the &#8220;Esc&#8221; key. Save the file by pressing Shift+Z+Z (Hold the shift key down and press &#8220;z&#8221; two times&#8221;.<\/p>\n<p>The file is now saved in your current folder. You can display its contents by typing:<\/p>\n<pre>cat files<\/pre>\n<p>This gives the following output:<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-27310\" src=\"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2018\/06\/Display-the-contents-of-our-file.jpg\" alt=\"Display the contents of our file\" width=\"690\" height=\"278\" srcset=\"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2018\/06\/Display-the-contents-of-our-file.jpg 690w, https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2018\/06\/Display-the-contents-of-our-file-150x60.jpg 150w, https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2018\/06\/Display-the-contents-of-our-file-300x121.jpg 300w\" sizes=\"(max-width: 690px) 100vw, 690px\" \/><\/p>\n<h2 class=\"western\"><span class=\"ez-toc-section\" id=\"Step-2-Assign-the-Right-Permissions-to-our-Script\"><\/span>Step 2: Assign the Right Permissions to our Script<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>If we just list the files in the directory, you will see that our new file is one of them.<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-27311\" src=\"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2018\/06\/Just-a-regular-file.jpg\" alt=\"Just a regular file\" width=\"669\" height=\"311\" srcset=\"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2018\/06\/Just-a-regular-file.jpg 669w, https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2018\/06\/Just-a-regular-file-150x70.jpg 150w, https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2018\/06\/Just-a-regular-file-300x139.jpg 300w\" sizes=\"(max-width: 669px) 100vw, 669px\" \/><\/p>\n<p>However, it&#8217;s just a regular file and not something that can be executed. The &#8220;ls&#8221; command displays executable files in green. So we need to tell Linux that our new file is executable. We do this by typing the following:<\/p>\n<pre>chmod 755 files<\/pre>\n<p>This changes the file permissions and makes it executable. Now &#8220;ls&#8221; shows the file as green:<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-27315\" src=\"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2018\/06\/Change-script-file-permissions.jpg\" alt=\"Change script file permissions\" width=\"693\" height=\"320\" srcset=\"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2018\/06\/Change-script-file-permissions.jpg 693w, https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2018\/06\/Change-script-file-permissions-150x69.jpg 150w, https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2018\/06\/Change-script-file-permissions-300x139.jpg 300w\" sizes=\"(max-width: 693px) 100vw, 693px\" \/><\/p>\n<p>It&#8217;s time to run our command!<\/p>\n<h2 class=\"western\"><span class=\"ez-toc-section\" id=\"Step-3-Specifying-Paths-to-Our-Script\"><\/span>Step 3: Specifying Paths to Our Script<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Unfortunately, we can&#8217;t just type &#8220;files&#8221; into the current directory to run our new script. We get an error message that says, &#8220;command not found&#8221;:<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-27316\" src=\"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2018\/06\/Command-not-found.jpg\" alt=\"Command not found\" width=\"690\" height=\"196\" srcset=\"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2018\/06\/Command-not-found.jpg 690w, https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2018\/06\/Command-not-found-150x43.jpg 150w, https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2018\/06\/Command-not-found-300x85.jpg 300w\" sizes=\"(max-width: 690px) 100vw, 690px\" \/><\/p>\n<p>This is because Linux searches for regular commands in a specific set of directories referenced by the $PATH variable. And our current directory isn&#8217;t on that list.<\/p>\n<p>So we have three choices:<\/p>\n<ol>\n<li>Manually specify the full location of our script file each time<\/li>\n<li>Add the &#8220;current directory&#8221; to the $PATH variable<\/li>\n<li>Move our script file into an existing folder referenced by $PATH<\/li>\n<\/ol>\n<p>Let&#8217;s see how to do all three:<\/p>\n<h3 class=\"western\">Method 1: Manually Specify the Full Location<\/h3>\n<p>When we tried to just type &#8220;files&#8221; earlier, we got an error. But we can specify the current directory for our script file like this:<\/p>\n<pre>.\/files<\/pre>\n<p>And this works as you can see below:<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-27317\" src=\"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2018\/06\/Manually-specify-the-current-directory.jpg\" alt=\"Manually specify the current directory\" width=\"689\" height=\"281\" srcset=\"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2018\/06\/Manually-specify-the-current-directory.jpg 689w, https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2018\/06\/Manually-specify-the-current-directory-150x61.jpg 150w, https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2018\/06\/Manually-specify-the-current-directory-300x122.jpg 300w\" sizes=\"(max-width: 689px) 100vw, 689px\" \/><\/p>\n<p>Unfortunately, this won&#8217;t work if we&#8217;re in some other folder. We&#8217;d have to specify the fully qualified path, which is a pain.<\/p>\n<h3 class=\"western\">Method 2: Add the &#8220;Current Directory&#8221; to the PATH Variable<\/h3>\n<p>This method suffers from the same problem as the first one. We can tell Linux to always search the &#8220;current directory&#8221; for scripts and commands. That way, we won&#8217;t have to use &#8220;.\/&#8221;. We can temporarily add the current directory to $PATH like this:<\/p>\n<pre>PATH=\"$PATH:.\"<\/pre>\n<p>Now just typing &#8220;files&#8221; works as shown here:<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-27318\" src=\"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2018\/06\/Adding-the-current-directory-to-PATH.jpg\" alt=\"Adding the current directory-to-PATH\" width=\"663\" height=\"352\" srcset=\"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2018\/06\/Adding-the-current-directory-to-PATH.jpg 663w, https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2018\/06\/Adding-the-current-directory-to-PATH-150x80.jpg 150w, https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2018\/06\/Adding-the-current-directory-to-PATH-300x159.jpg 300w\" sizes=\"(max-width: 663px) 100vw, 663px\" \/><\/p>\n<p>However, this approach has two problems:<\/p>\n<ol>\n<li>As mentioned, you can&#8217;t access the script from any other directory other than its own<\/li>\n<li>The change in $PATH is temporary. It&#8217;ll be reset when the user&#8217;s session is over!<\/li>\n<\/ol>\n<p>To make the changes to $PATH permanent, we need to edit this file:<\/p>\n<pre>~\/.bash_profile<\/pre>\n<p>As before, we can use the vi editor:<\/p>\n<pre>vi ~\/.bash_profile<\/pre>\n<p>Again, press &#8220;Insert&#8221; to go into INSERT mode, and navigate to the line specifying the PATH variable as shown here:<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-27319\" src=\"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2018\/06\/Navigate-to-the-PATH-variable-declaration.jpg\" alt=\"Navigate to the PATH variable declaration\" width=\"659\" height=\"317\" srcset=\"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2018\/06\/Navigate-to-the-PATH-variable-declaration.jpg 659w, https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2018\/06\/Navigate-to-the-PATH-variable-declaration-150x72.jpg 150w, https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2018\/06\/Navigate-to-the-PATH-variable-declaration-300x144.jpg 300w\" sizes=\"(max-width: 659px) 100vw, 659px\" \/><\/p>\n<p>Now add the following to the end of the PATH line:<\/p>\n<pre>:.<\/pre>\n<p>That&#8217;s a colon (:) followed by a dot (.). Save the file in vi by pressing &#8220;Esc&#8221; and Shift+z+z like before. However, the changes won&#8217;t take effect until you reload ~\/.bash_profile . Do this using the following command:<\/p>\n<pre>source ~\/.bash_profile<\/pre>\n<p>You can check if the changes have taken place by echo&#8217;ing the $PATH variable. You should see the addition at the end of the line like this:<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-27320\" src=\"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2018\/06\/Add-Current-Path-to-PATH.jpg\" alt=\"Add Current Path to PATH\" width=\"700\" height=\"323\" srcset=\"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2018\/06\/Add-Current-Path-to-PATH.jpg 700w, https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2018\/06\/Add-Current-Path-to-PATH-150x69.jpg 150w, https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2018\/06\/Add-Current-Path-to-PATH-300x138.jpg 300w\" sizes=\"(max-width: 700px) 100vw, 700px\" \/><\/p>\n<p>Now the change will persist even when your user session ends. However, you still can&#8217;t execute the command from any folder. For that, we need Method 3.<\/p>\n<h3 class=\"western\">Method 3: Add the File to an Existing $PATH Destination (Recommended)<\/h3>\n<p>In my opinion, this is the best way to add your custom command so that you can access it from anywhere.<\/p>\n<p>First, get a list of $PATH locations by echo&#8217;ing PATH as shown in Method 2.<\/p>\n<p>Each folder location is separated by a colon (:) You can see in the above screenshot, that the folder \/usr\/local\/bin is one of the paths.<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-27327\" src=\"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2018\/06\/usr-local-bin-is-one-of-the-paths-.jpg\" alt=\"usr local bin is one of the paths\" width=\"700\" height=\"256\" srcset=\"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2018\/06\/usr-local-bin-is-one-of-the-paths-.jpg 700w, https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2018\/06\/usr-local-bin-is-one-of-the-paths--150x55.jpg 150w, https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2018\/06\/usr-local-bin-is-one-of-the-paths--300x110.jpg 300w\" sizes=\"(max-width: 700px) 100vw, 700px\" \/><\/p>\n<p>So we just move our custom command to this location (or any other folder in $PATH) via this command:<\/p>\n<pre>mv files \/usr\/local\/bin<\/pre>\n<p>And now we can change our working folder and access the script from wherever we want!<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-27321\" src=\"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2018\/06\/Custom-Command-Working-from-New-Location.jpg\" alt=\"Custom Command Working from New Location\" width=\"708\" height=\"317\" srcset=\"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2018\/06\/Custom-Command-Working-from-New-Location.jpg 708w, https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2018\/06\/Custom-Command-Working-from-New-Location-150x67.jpg 150w, https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2018\/06\/Custom-Command-Working-from-New-Location-300x134.jpg 300w\" sizes=\"(max-width: 708px) 100vw, 708px\" \/><\/p>\n<p>In this screenshot, I&#8217;ve moved the script to \/usr\/local\/bin and gone one folder up by &#8220;cd..&#8221;. And the command still works!<\/p>\n<p>This is the right way to create custom commands in Linux. It&#8217;s just the tip of the iceberg when it comes to scripting in Linux. You can write complex logic loops and execute conditional statements. You can also use this to create aliases for existing commands, or chain a bunch of them together for automatic execution! If this is your first foray into Linux scripting, be prepared to access a wealth of power and functionality in the future.<\/p>\n<p>Happy scripting!<\/p>\n<hr \/>\n<p>You don&#8217;t have to create custom commands in Linux, if you use one of our fully managed web hosting solutions, you can always ask our technical support to create a custom command line in Linux. They are available 24\/7 and will help you any aspect of managing your server.<\/p>\n<p>If you liked this post on how to\u00a0Create Custom Commands in Linux, please share it with you friends on social media on the buttons below, or if you have any question regarding this blog post, please leave a comment and one of our system administrators will reply to it. Thanks!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this tutorial, We&#8217;ll show you how to create custom commands in Linux which will allow you to create &#8220;shortcut&#8221; &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"How to Create Custom Commands in Linux\" class=\"read-more button\" href=\"https:\/\/www.rosehosting.com\/blog\/create-custom-commands-in-linux\/#more-27307\" aria-label=\"Read more about How to Create Custom Commands in Linux\">Read More<\/a><\/p>\n","protected":false},"author":4,"featured_media":27328,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1236,13],"tags":[1725,27],"class_list":["post-27307","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-guides","category-tutorials","tag-custom-commands","tag-linux","generate-columns","tablet-grid-50","mobile-grid-100","grid-parent","grid-33"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.5 (Yoast SEO v27.5) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>How to Create Custom Commands in Linux | RoseHosting<\/title>\n<meta name=\"description\" content=\"How to Create Custom Commands in Linux | RoseHosting\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.rosehosting.com\/blog\/create-custom-commands-in-linux\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Create Custom Commands in Linux\" \/>\n<meta property=\"og:description\" content=\"How to Create Custom Commands in Linux | RoseHosting\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.rosehosting.com\/blog\/create-custom-commands-in-linux\/\" \/>\n<meta property=\"og:site_name\" content=\"RoseHosting\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/RoseHosting\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/rosehosting.helpdesk\" \/>\n<meta property=\"article:published_time\" content=\"2018-06-28T09:33:49+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-04-05T09:12:47+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2018\/06\/How-to-Create-Custom-Commands-in-Linux.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"742\" \/>\n\t<meta property=\"og:image:height\" content=\"371\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Jeff Wilson\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@rosehosting\" \/>\n<meta name=\"twitter:site\" content=\"@rosehosting\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Jeff Wilson\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/create-custom-commands-in-linux\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/create-custom-commands-in-linux\\\/\"},\"author\":{\"name\":\"Jeff Wilson\",\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/#\\\/schema\\\/person\\\/7ce77a842fa6a9a7f8efa186f2353713\"},\"headline\":\"How to Create Custom Commands in Linux\",\"datePublished\":\"2018-06-28T09:33:49+00:00\",\"dateModified\":\"2023-04-05T09:12:47+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/create-custom-commands-in-linux\\\/\"},\"wordCount\":1187,\"commentCount\":2,\"publisher\":{\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/create-custom-commands-in-linux\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/wp-content\\\/uploads\\\/2018\\\/06\\\/How-to-Create-Custom-Commands-in-Linux.jpg\",\"keywords\":[\"CUSTOM COMMANDS\",\"Linux\"],\"articleSection\":[\"Guides\",\"Tutorials\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/create-custom-commands-in-linux\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/create-custom-commands-in-linux\\\/\",\"url\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/create-custom-commands-in-linux\\\/\",\"name\":\"How to Create Custom Commands in Linux | RoseHosting\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/create-custom-commands-in-linux\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/create-custom-commands-in-linux\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/wp-content\\\/uploads\\\/2018\\\/06\\\/How-to-Create-Custom-Commands-in-Linux.jpg\",\"datePublished\":\"2018-06-28T09:33:49+00:00\",\"dateModified\":\"2023-04-05T09:12:47+00:00\",\"description\":\"How to Create Custom Commands in Linux | RoseHosting\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/create-custom-commands-in-linux\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/create-custom-commands-in-linux\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/create-custom-commands-in-linux\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/wp-content\\\/uploads\\\/2018\\\/06\\\/How-to-Create-Custom-Commands-in-Linux.jpg\",\"contentUrl\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/wp-content\\\/uploads\\\/2018\\\/06\\\/How-to-Create-Custom-Commands-in-Linux.jpg\",\"width\":742,\"height\":371,\"caption\":\"How to Create Custom Commands in Linux\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/create-custom-commands-in-linux\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Create Custom Commands in Linux\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/\",\"name\":\"RoseHosting.com\",\"description\":\"Premium Linux Tutorials Since 2001\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/#organization\",\"name\":\"RoseHosting\",\"url\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/03\\\/android-chrome-192x192-1.png\",\"contentUrl\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/03\\\/android-chrome-192x192-1.png\",\"width\":192,\"height\":192,\"caption\":\"RoseHosting\"},\"image\":{\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/RoseHosting\",\"https:\\\/\\\/x.com\\\/rosehosting\",\"https:\\\/\\\/www.linkedin.com\\\/in\\\/rosehosting\\\/\"],\"description\":\"RoseHosting is a leading Linux hosting provider, serving thousands of clients world-wide since 2001.\",\"email\":\"info@rosehosting.com\",\"telephone\":\"(314) 275-0414\",\"legalName\":\"Rose Web Services LLC\",\"foundingDate\":\"2001-04-02\",\"numberOfEmployees\":{\"@type\":\"QuantitativeValue\",\"minValue\":\"11\",\"maxValue\":\"50\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/#\\\/schema\\\/person\\\/7ce77a842fa6a9a7f8efa186f2353713\",\"name\":\"Jeff Wilson\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/0985fed6af04cc60703d2ecf27c65dfa373e0ca00eb21c0b03477e099ea3f99f?s=96&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/0985fed6af04cc60703d2ecf27c65dfa373e0ca00eb21c0b03477e099ea3f99f?s=96&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/0985fed6af04cc60703d2ecf27c65dfa373e0ca00eb21c0b03477e099ea3f99f?s=96&r=g\",\"caption\":\"Jeff Wilson\"},\"description\":\"An experienced Linux veteran with many years of experience. Helping other Linux admins with frequent Linux and business-related blog posts on the RoseHosting blog. Techie by choice. Loving nature and travel. Happily married and father of two lovely children.\",\"sameAs\":[\"https:\\\/\\\/www.rosehosting.com\",\"https:\\\/\\\/www.facebook.com\\\/rosehosting.helpdesk\"],\"url\":\"https:\\\/\\\/www.rosehosting.com\\\/blog\\\/author\\\/jwilson\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"How to Create Custom Commands in Linux | RoseHosting","description":"How to Create Custom Commands in Linux | RoseHosting","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.rosehosting.com\/blog\/create-custom-commands-in-linux\/","og_locale":"en_US","og_type":"article","og_title":"How to Create Custom Commands in Linux","og_description":"How to Create Custom Commands in Linux | RoseHosting","og_url":"https:\/\/www.rosehosting.com\/blog\/create-custom-commands-in-linux\/","og_site_name":"RoseHosting","article_publisher":"https:\/\/www.facebook.com\/RoseHosting","article_author":"https:\/\/www.facebook.com\/rosehosting.helpdesk","article_published_time":"2018-06-28T09:33:49+00:00","article_modified_time":"2023-04-05T09:12:47+00:00","og_image":[{"width":742,"height":371,"url":"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2018\/06\/How-to-Create-Custom-Commands-in-Linux.jpg","type":"image\/jpeg"}],"author":"Jeff Wilson","twitter_card":"summary_large_image","twitter_creator":"@rosehosting","twitter_site":"@rosehosting","twitter_misc":{"Written by":"Jeff Wilson","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.rosehosting.com\/blog\/create-custom-commands-in-linux\/#article","isPartOf":{"@id":"https:\/\/www.rosehosting.com\/blog\/create-custom-commands-in-linux\/"},"author":{"name":"Jeff Wilson","@id":"https:\/\/www.rosehosting.com\/blog\/#\/schema\/person\/7ce77a842fa6a9a7f8efa186f2353713"},"headline":"How to Create Custom Commands in Linux","datePublished":"2018-06-28T09:33:49+00:00","dateModified":"2023-04-05T09:12:47+00:00","mainEntityOfPage":{"@id":"https:\/\/www.rosehosting.com\/blog\/create-custom-commands-in-linux\/"},"wordCount":1187,"commentCount":2,"publisher":{"@id":"https:\/\/www.rosehosting.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.rosehosting.com\/blog\/create-custom-commands-in-linux\/#primaryimage"},"thumbnailUrl":"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2018\/06\/How-to-Create-Custom-Commands-in-Linux.jpg","keywords":["CUSTOM COMMANDS","Linux"],"articleSection":["Guides","Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.rosehosting.com\/blog\/create-custom-commands-in-linux\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.rosehosting.com\/blog\/create-custom-commands-in-linux\/","url":"https:\/\/www.rosehosting.com\/blog\/create-custom-commands-in-linux\/","name":"How to Create Custom Commands in Linux | RoseHosting","isPartOf":{"@id":"https:\/\/www.rosehosting.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.rosehosting.com\/blog\/create-custom-commands-in-linux\/#primaryimage"},"image":{"@id":"https:\/\/www.rosehosting.com\/blog\/create-custom-commands-in-linux\/#primaryimage"},"thumbnailUrl":"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2018\/06\/How-to-Create-Custom-Commands-in-Linux.jpg","datePublished":"2018-06-28T09:33:49+00:00","dateModified":"2023-04-05T09:12:47+00:00","description":"How to Create Custom Commands in Linux | RoseHosting","breadcrumb":{"@id":"https:\/\/www.rosehosting.com\/blog\/create-custom-commands-in-linux\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.rosehosting.com\/blog\/create-custom-commands-in-linux\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.rosehosting.com\/blog\/create-custom-commands-in-linux\/#primaryimage","url":"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2018\/06\/How-to-Create-Custom-Commands-in-Linux.jpg","contentUrl":"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2018\/06\/How-to-Create-Custom-Commands-in-Linux.jpg","width":742,"height":371,"caption":"How to Create Custom Commands in Linux"},{"@type":"BreadcrumbList","@id":"https:\/\/www.rosehosting.com\/blog\/create-custom-commands-in-linux\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.rosehosting.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How to Create Custom Commands in Linux"}]},{"@type":"WebSite","@id":"https:\/\/www.rosehosting.com\/blog\/#website","url":"https:\/\/www.rosehosting.com\/blog\/","name":"RoseHosting.com","description":"Premium Linux Tutorials Since 2001","publisher":{"@id":"https:\/\/www.rosehosting.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.rosehosting.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.rosehosting.com\/blog\/#organization","name":"RoseHosting","url":"https:\/\/www.rosehosting.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.rosehosting.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2022\/03\/android-chrome-192x192-1.png","contentUrl":"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2022\/03\/android-chrome-192x192-1.png","width":192,"height":192,"caption":"RoseHosting"},"image":{"@id":"https:\/\/www.rosehosting.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/RoseHosting","https:\/\/x.com\/rosehosting","https:\/\/www.linkedin.com\/in\/rosehosting\/"],"description":"RoseHosting is a leading Linux hosting provider, serving thousands of clients world-wide since 2001.","email":"info@rosehosting.com","telephone":"(314) 275-0414","legalName":"Rose Web Services LLC","foundingDate":"2001-04-02","numberOfEmployees":{"@type":"QuantitativeValue","minValue":"11","maxValue":"50"}},{"@type":"Person","@id":"https:\/\/www.rosehosting.com\/blog\/#\/schema\/person\/7ce77a842fa6a9a7f8efa186f2353713","name":"Jeff Wilson","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/0985fed6af04cc60703d2ecf27c65dfa373e0ca00eb21c0b03477e099ea3f99f?s=96&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/0985fed6af04cc60703d2ecf27c65dfa373e0ca00eb21c0b03477e099ea3f99f?s=96&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/0985fed6af04cc60703d2ecf27c65dfa373e0ca00eb21c0b03477e099ea3f99f?s=96&r=g","caption":"Jeff Wilson"},"description":"An experienced Linux veteran with many years of experience. Helping other Linux admins with frequent Linux and business-related blog posts on the RoseHosting blog. Techie by choice. Loving nature and travel. Happily married and father of two lovely children.","sameAs":["https:\/\/www.rosehosting.com","https:\/\/www.facebook.com\/rosehosting.helpdesk"],"url":"https:\/\/www.rosehosting.com\/blog\/author\/jwilson\/"}]}},"_links":{"self":[{"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/posts\/27307","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/comments?post=27307"}],"version-history":[{"count":1,"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/posts\/27307\/revisions"}],"predecessor-version":[{"id":41788,"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/posts\/27307\/revisions\/41788"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/media\/27328"}],"wp:attachment":[{"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/media?parent=27307"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/categories?post=27307"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/tags?post=27307"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}