{"id":619,"date":"2013-03-07T20:09:03","date_gmt":"2013-03-08T01:09:03","guid":{"rendered":"https:\/\/www.inmotionhosting.com\/support\/2013\/03\/07\/using-the-linux-cd-command\/"},"modified":"2021-08-16T23:19:49","modified_gmt":"2021-08-17T03:19:49","slug":"using-the-linux-cd-command","status":"publish","type":"post","link":"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/using-the-linux-cd-command\/","title":{"rendered":"Using the Linux cd command"},"content":{"rendered":"<p>In this article I&#8217;m going to show you how to use the Linux <strong>cd<\/strong> command in order to change directories while you are connected to your server via SSH.<\/p>\n<p class=\"alert\">Please note in order to follow along with any of these examples, you need to have a VPS (Vitual Private Server) or dedicated server with SSH access. You can read about <a href=\"\/support\/server\/ssh\/how-to-login-ssh\/\" target=\"_blank\" rel=\"noopener\">how to login to your server via SSH<\/a> for more details.<\/p>\n<h2>What is cd?<\/h2>\n<p>The <strong>cd<\/strong> command stands for <strong>c<\/strong>hange <strong>d<\/strong>irectory, and it&#8217;s been around for a very long time. Back before computers had nice GUIs (Graphical User Interfaces) to allow us to easily navigate around our file systems, you would need to give the computer commands via command line to let it know where you&#8217;re trying to go.<\/p>\n<p>A lot of times you might need to connect to your server and move around to different directories in order to locate logs, run a script, or perform various other actions. So becoming very familiar with the capabilites of the <strong>cd<\/strong> command can go a long way in making your server management easier.<\/p>\n<h2>What can I do with the cd command?<\/h2>\n<p>Below I&#8217;m going to show the several different ways in which you can use the <strong>cd<\/strong> command in order to navigate around your server&#8217;s file system.<\/p>\n<h3>cd<\/h3>\n<p>First up is just the <strong>cd<\/strong> command all by itself:<\/p>\n<p class=\"cli\" style=\"width: 500px; white-space: nowrap;\">userna5@vpsXXXX [\/home\/userna5\/public_html\/wordpress]# <strong style=\"color: red;\">cd<\/strong><\/p>\n<p>This will just change directories to the current user&#8217;s home directory, so this is the output we get:<\/p>\n<p class=\"cli\" style=\"width: 500px; white-space: nowrap;\">userna5@vpsXXXX [\/home\/userna5]#<\/p>\n<h3>cd &#8211;<\/h3>\n<p>Next if we use <strong>cd &#8211;<\/strong>(tick, or minus symbol), this will take us back to the most recently changed from directory.<\/p>\n<p class=\"cli\" style=\"width: 500px; white-space: nowrap;\">userna5@vpsXXXX [\/home\/userna5]# <strong style=\"color: red;\">cd &#8211;<\/strong><\/p>\n<p>So we end up back where we originally started:<\/p>\n<p class=\"cli\" style=\"width: 500px; white-space: nowrap;\">userna5@vpsXXXX [\/home\/userna5\/public_html\/wordpress]#<\/p>\n<h3>cd ~username<\/h3>\n<p>If we use <strong>cd ~<\/strong> it will change to the current logged in user&#8217;s home directory, or if we use <strong>cd ~username<\/strong> it will automatically drop us in that specified user&#8217;s home directory:<\/p>\n<p class=\"cli\" style=\"width: 500px; white-space: nowrap;\">userna5@vpsXXXX [\/home\/userna5\/public_html\/wordpress]# <strong style=\"color: red;\">cd ~userna5<\/strong><\/p>\n<p>We end up again in our specified user&#8217;s home directory:<\/p>\n<p class=\"cli\" style=\"width: 500px; white-space: nowrap;\">userna5@vpsXXXX [\/home\/userna5]#<\/p>\n<h3>cd directory<\/h3>\n<p>When using <strong>cd directory<\/strong> this will take us to a sub-directory of the current directory we are in:<\/p>\n<p class=\"cli\" style=\"width: 500px; white-space: nowrap;\">userna5@vpsXXXX [\/home\/userna5\/public_html\/]# <strong style=\"color: red;\">cd wordpress<\/strong><\/p>\n<p>We end up in the sub-directory <strong>wordpress<\/strong>:<\/p>\n<p class=\"cli\" style=\"width: 500px; white-space: nowrap;\">userna5@vpsXXXX [\/home\/userna5\/public_html\/wordpress]#<\/p>\n<h3>cd \/directory<\/h3>\n<p>When using <strong>cd \/directory<\/strong> this specifies the absolute directory we are trying to navigate to:<\/p>\n<p class=\"cli\" style=\"width: 500px; white-space: nowrap;\">userna5@vpsXXXX [\/home\/]# <strong style=\"color: red;\">cd \/home\/userna5\/public_html\/wordpress<\/strong><\/p>\n<p>We end up back in our <strong>wordpress<\/strong> directory, but using a <strong>\/<\/strong> forward slash this time in front of the directory allows us to jump there from any other directory on the server:<\/p>\n<p class=\"cli\" style=\"width: 500px; white-space: nowrap;\">userna5@vpsXXXX [\/home\/userna5\/public_html\/wordpress]#<\/p>\n<h3>cd ..\/..\/<\/h3>\n<p>You can use any number of <strong>cd ..\/<\/strong>commands in order to traverse up the directory tree. For example if we use two here:<\/p>\n<p class=\"cli\" style=\"width: 500px; white-space: nowrap;\">userna5@vpsXXXX [\/home\/userna5\/public_html\/wordpress]# <strong style=\"color: red;\">cd ..\/..\/<\/strong><\/p>\n<p>We end up 2 directories up from the directory we were in:<\/p>\n<p class=\"cli\" style=\"width: 500px; white-space: nowrap;\">userna5@vpsXXXX [\/home\/userna5]#<\/p>\n<h2>Conclusion<\/h2>\n<p>You should now better understand what all you can do with the Linux <strong>cd<\/strong> command, as you&#8217;re trying to navigate around the file system of your server.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this article I&#8217;m going to show you how to use the Linux cd command in order to change directories while you are connected to your server via SSH. Please note in order to follow along with any of these examples, you need to have a VPS (Vitual Private Server) or dedicated server with SSH<a class=\"moretag\" href=\"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/using-the-linux-cd-command\/\"> Read More ><\/a><\/p>\n","protected":false},"author":57014,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[4308],"tags":[],"class_list":["post-619","post","type-post","status-publish","format-standard","hentry","category-linux"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.1.1 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Using the Linux cd command | InMotion Hosting<\/title>\n<meta name=\"description\" content=\"In this article I&#039;m going to show you how to use the Linux cd command in order to change directories while you are connected to your server via SSH.\" \/>\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.inmotionhosting.com\/support\/server\/linux\/using-the-linux-cd-command\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Using the Linux cd command | InMotion Hosting\" \/>\n<meta property=\"og:description\" content=\"In this article I&#039;m going to show you how to use the Linux cd command in order to change directories while you are connected to your server via SSH.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/using-the-linux-cd-command\/\" \/>\n<meta property=\"og:site_name\" content=\"InMotion Hosting Support Center\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/inmotionhosting\/\" \/>\n<meta property=\"article:published_time\" content=\"2013-03-08T01:09:03+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-08-17T03:19:49+00:00\" \/>\n<meta name=\"author\" content=\"InMotion Hosting Contributor\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@https:\/\/twitter.com\/InMotionHosting\" \/>\n<meta name=\"twitter:site\" content=\"@InMotionHosting\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"InMotion Hosting Contributor\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/using-the-linux-cd-command\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/using-the-linux-cd-command\/\"},\"author\":{\"name\":\"InMotion Hosting Contributor\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/f9a4fc454cd1df128ee8e898d30d4644\"},\"headline\":\"Using the Linux cd command\",\"datePublished\":\"2013-03-08T01:09:03+00:00\",\"dateModified\":\"2021-08-17T03:19:49+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/using-the-linux-cd-command\/\"},\"wordCount\":557,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#organization\"},\"articleSection\":[\"Linux\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/using-the-linux-cd-command\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/using-the-linux-cd-command\/\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/using-the-linux-cd-command\/\",\"name\":\"Using the Linux cd command | InMotion Hosting\",\"isPartOf\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#website\"},\"datePublished\":\"2013-03-08T01:09:03+00:00\",\"dateModified\":\"2021-08-17T03:19:49+00:00\",\"description\":\"In this article I'm going to show you how to use the Linux cd command in order to change directories while you are connected to your server via SSH.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/using-the-linux-cd-command\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/using-the-linux-cd-command\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/using-the-linux-cd-command\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.inmotionhosting.com\/support\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Using the Linux cd command\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#website\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/\",\"name\":\"InMotion Hosting Support Center\",\"description\":\"Web Hosting Support &amp; Tutorials\",\"publisher\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.inmotionhosting.com\/support\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#organization\",\"name\":\"InMotion Hosting\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2023\/02\/inmotion-hosting-logo-yoast.jpg\",\"contentUrl\":\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2023\/02\/inmotion-hosting-logo-yoast.jpg\",\"width\":696,\"height\":696,\"caption\":\"InMotion Hosting\"},\"image\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/inmotionhosting\/\",\"https:\/\/x.com\/InMotionHosting\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/f9a4fc454cd1df128ee8e898d30d4644\",\"name\":\"InMotion Hosting Contributor\",\"description\":\"InMotion Hosting contributors are highly knowledgeable individuals who create relevant content on new trends and troubleshooting techniques to help you achieve your online goals!\",\"sameAs\":[\"https:\/\/www.linkedin.com\/company\/inmotion-hosting\/\",\"https:\/\/x.com\/https:\/\/twitter.com\/InMotionHosting\"],\"url\":\"https:\/\/www.inmotionhosting.com\/support\/author\/inmotion-hosting-contributor\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Using the Linux cd command | InMotion Hosting","description":"In this article I'm going to show you how to use the Linux cd command in order to change directories while you are connected to your server via SSH.","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.inmotionhosting.com\/support\/server\/linux\/using-the-linux-cd-command\/","og_locale":"en_US","og_type":"article","og_title":"Using the Linux cd command | InMotion Hosting","og_description":"In this article I'm going to show you how to use the Linux cd command in order to change directories while you are connected to your server via SSH.","og_url":"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/using-the-linux-cd-command\/","og_site_name":"InMotion Hosting Support Center","article_publisher":"https:\/\/www.facebook.com\/inmotionhosting\/","article_published_time":"2013-03-08T01:09:03+00:00","article_modified_time":"2021-08-17T03:19:49+00:00","author":"InMotion Hosting Contributor","twitter_card":"summary_large_image","twitter_creator":"@https:\/\/twitter.com\/InMotionHosting","twitter_site":"@InMotionHosting","twitter_misc":{"Written by":"InMotion Hosting Contributor","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/using-the-linux-cd-command\/#article","isPartOf":{"@id":"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/using-the-linux-cd-command\/"},"author":{"name":"InMotion Hosting Contributor","@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/f9a4fc454cd1df128ee8e898d30d4644"},"headline":"Using the Linux cd command","datePublished":"2013-03-08T01:09:03+00:00","dateModified":"2021-08-17T03:19:49+00:00","mainEntityOfPage":{"@id":"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/using-the-linux-cd-command\/"},"wordCount":557,"commentCount":0,"publisher":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#organization"},"articleSection":["Linux"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.inmotionhosting.com\/support\/server\/linux\/using-the-linux-cd-command\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/using-the-linux-cd-command\/","url":"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/using-the-linux-cd-command\/","name":"Using the Linux cd command | InMotion Hosting","isPartOf":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#website"},"datePublished":"2013-03-08T01:09:03+00:00","dateModified":"2021-08-17T03:19:49+00:00","description":"In this article I'm going to show you how to use the Linux cd command in order to change directories while you are connected to your server via SSH.","breadcrumb":{"@id":"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/using-the-linux-cd-command\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.inmotionhosting.com\/support\/server\/linux\/using-the-linux-cd-command\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.inmotionhosting.com\/support\/server\/linux\/using-the-linux-cd-command\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.inmotionhosting.com\/support\/"},{"@type":"ListItem","position":2,"name":"Using the Linux cd command"}]},{"@type":"WebSite","@id":"https:\/\/www.inmotionhosting.com\/support\/#website","url":"https:\/\/www.inmotionhosting.com\/support\/","name":"InMotion Hosting Support Center","description":"Web Hosting Support &amp; Tutorials","publisher":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.inmotionhosting.com\/support\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.inmotionhosting.com\/support\/#organization","name":"InMotion Hosting","url":"https:\/\/www.inmotionhosting.com\/support\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/logo\/image\/","url":"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2023\/02\/inmotion-hosting-logo-yoast.jpg","contentUrl":"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2023\/02\/inmotion-hosting-logo-yoast.jpg","width":696,"height":696,"caption":"InMotion Hosting"},"image":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/inmotionhosting\/","https:\/\/x.com\/InMotionHosting"]},{"@type":"Person","@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/f9a4fc454cd1df128ee8e898d30d4644","name":"InMotion Hosting Contributor","description":"InMotion Hosting contributors are highly knowledgeable individuals who create relevant content on new trends and troubleshooting techniques to help you achieve your online goals!","sameAs":["https:\/\/www.linkedin.com\/company\/inmotion-hosting\/","https:\/\/x.com\/https:\/\/twitter.com\/InMotionHosting"],"url":"https:\/\/www.inmotionhosting.com\/support\/author\/inmotion-hosting-contributor\/"}]}},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"primary_category":null,"_links":{"self":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts\/619","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/users\/57014"}],"replies":[{"embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/comments?post=619"}],"version-history":[{"count":3,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts\/619\/revisions"}],"predecessor-version":[{"id":84866,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts\/619\/revisions\/84866"}],"wp:attachment":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/media?parent=619"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/categories?post=619"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/tags?post=619"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}