Is there a difference between pwd and cd?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP












-1















Is there a difference between pwd and cd (no arguments)? They both print the current directory's path but is there a subtle difference that I'm missing, and if so, when should I use which?










share|improve this question




























    -1















    Is there a difference between pwd and cd (no arguments)? They both print the current directory's path but is there a subtle difference that I'm missing, and if so, when should I use which?










    share|improve this question


























      -1












      -1








      -1








      Is there a difference between pwd and cd (no arguments)? They both print the current directory's path but is there a subtle difference that I'm missing, and if so, when should I use which?










      share|improve this question
















      Is there a difference between pwd and cd (no arguments)? They both print the current directory's path but is there a subtle difference that I'm missing, and if so, when should I use which?







      cd-command pwd






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Feb 13 at 11:14









      iBug

      956928




      956928










      asked Apr 9 '17 at 5:29









      retniktretnikt

      114




      114




















          4 Answers
          4






          active

          oldest

          votes


















          5














          Yes, they are completely different commands that do different things.



          pwd prints the directory you are currently in. It does nothing else.pwd does not take any arguments.



          cd without arguments changes your working directory to your home directory. It does not print anything by default.



          cd with an argument will change your working directory to whatever directory you supplied as an argument.






          share|improve this answer























          • Thanks. I must have misremembered about cd with no arguments. Sorry.

            – retnikt
            Apr 9 '17 at 6:40






          • 2





            pwd does take a couple of arguments, the options -L and -P (for "logical" and "physical"). These flags happen to be supported (with the same meanings) by the cd command too.

            – Kusalananda
            Apr 9 '17 at 7:12


















          3














          cd changes to your home directory, I think this is a more than subtle difference.



          I suggest reading the man page before asking in a forum.






          share|improve this answer






























            1














            The command



            pwd


            shows the current directory, while the command



            cd


            will change directory to your home directory.






            share|improve this answer






























              0














              You can also use the below command to find out where the previous command was executed and get on the folder.



              cd - 


              In contrast, pwd only gives you the path of the current working directory.






              share|improve this answer






















                Your Answer








                StackExchange.ready(function()
                var channelOptions =
                tags: "".split(" "),
                id: "106"
                ;
                initTagRenderer("".split(" "), "".split(" "), channelOptions);

                StackExchange.using("externalEditor", function()
                // Have to fire editor after snippets, if snippets enabled
                if (StackExchange.settings.snippets.snippetsEnabled)
                StackExchange.using("snippets", function()
                createEditor();
                );

                else
                createEditor();

                );

                function createEditor()
                StackExchange.prepareEditor(
                heartbeatType: 'answer',
                autoActivateHeartbeat: false,
                convertImagesToLinks: false,
                noModals: true,
                showLowRepImageUploadWarning: true,
                reputationToPostImages: null,
                bindNavPrevention: true,
                postfix: "",
                imageUploader:
                brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
                contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
                allowUrls: true
                ,
                onDemand: true,
                discardSelector: ".discard-answer"
                ,immediatelyShowMarkdownHelp:true
                );



                );













                draft saved

                draft discarded


















                StackExchange.ready(
                function ()
                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f357893%2fis-there-a-difference-between-pwd-and-cd%23new-answer', 'question_page');

                );

                Post as a guest















                Required, but never shown

























                4 Answers
                4






                active

                oldest

                votes








                4 Answers
                4






                active

                oldest

                votes









                active

                oldest

                votes






                active

                oldest

                votes









                5














                Yes, they are completely different commands that do different things.



                pwd prints the directory you are currently in. It does nothing else.pwd does not take any arguments.



                cd without arguments changes your working directory to your home directory. It does not print anything by default.



                cd with an argument will change your working directory to whatever directory you supplied as an argument.






                share|improve this answer























                • Thanks. I must have misremembered about cd with no arguments. Sorry.

                  – retnikt
                  Apr 9 '17 at 6:40






                • 2





                  pwd does take a couple of arguments, the options -L and -P (for "logical" and "physical"). These flags happen to be supported (with the same meanings) by the cd command too.

                  – Kusalananda
                  Apr 9 '17 at 7:12















                5














                Yes, they are completely different commands that do different things.



                pwd prints the directory you are currently in. It does nothing else.pwd does not take any arguments.



                cd without arguments changes your working directory to your home directory. It does not print anything by default.



                cd with an argument will change your working directory to whatever directory you supplied as an argument.






                share|improve this answer























                • Thanks. I must have misremembered about cd with no arguments. Sorry.

                  – retnikt
                  Apr 9 '17 at 6:40






                • 2





                  pwd does take a couple of arguments, the options -L and -P (for "logical" and "physical"). These flags happen to be supported (with the same meanings) by the cd command too.

                  – Kusalananda
                  Apr 9 '17 at 7:12













                5












                5








                5







                Yes, they are completely different commands that do different things.



                pwd prints the directory you are currently in. It does nothing else.pwd does not take any arguments.



                cd without arguments changes your working directory to your home directory. It does not print anything by default.



                cd with an argument will change your working directory to whatever directory you supplied as an argument.






                share|improve this answer













                Yes, they are completely different commands that do different things.



                pwd prints the directory you are currently in. It does nothing else.pwd does not take any arguments.



                cd without arguments changes your working directory to your home directory. It does not print anything by default.



                cd with an argument will change your working directory to whatever directory you supplied as an argument.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Apr 9 '17 at 5:50









                user91656user91656

                741




                741












                • Thanks. I must have misremembered about cd with no arguments. Sorry.

                  – retnikt
                  Apr 9 '17 at 6:40






                • 2





                  pwd does take a couple of arguments, the options -L and -P (for "logical" and "physical"). These flags happen to be supported (with the same meanings) by the cd command too.

                  – Kusalananda
                  Apr 9 '17 at 7:12

















                • Thanks. I must have misremembered about cd with no arguments. Sorry.

                  – retnikt
                  Apr 9 '17 at 6:40






                • 2





                  pwd does take a couple of arguments, the options -L and -P (for "logical" and "physical"). These flags happen to be supported (with the same meanings) by the cd command too.

                  – Kusalananda
                  Apr 9 '17 at 7:12
















                Thanks. I must have misremembered about cd with no arguments. Sorry.

                – retnikt
                Apr 9 '17 at 6:40





                Thanks. I must have misremembered about cd with no arguments. Sorry.

                – retnikt
                Apr 9 '17 at 6:40




                2




                2





                pwd does take a couple of arguments, the options -L and -P (for "logical" and "physical"). These flags happen to be supported (with the same meanings) by the cd command too.

                – Kusalananda
                Apr 9 '17 at 7:12





                pwd does take a couple of arguments, the options -L and -P (for "logical" and "physical"). These flags happen to be supported (with the same meanings) by the cd command too.

                – Kusalananda
                Apr 9 '17 at 7:12













                3














                cd changes to your home directory, I think this is a more than subtle difference.



                I suggest reading the man page before asking in a forum.






                share|improve this answer



























                  3














                  cd changes to your home directory, I think this is a more than subtle difference.



                  I suggest reading the man page before asking in a forum.






                  share|improve this answer

























                    3












                    3








                    3







                    cd changes to your home directory, I think this is a more than subtle difference.



                    I suggest reading the man page before asking in a forum.






                    share|improve this answer













                    cd changes to your home directory, I think this is a more than subtle difference.



                    I suggest reading the man page before asking in a forum.







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Apr 9 '17 at 5:46









                    PhilipposPhilippos

                    6,06711647




                    6,06711647





















                        1














                        The command



                        pwd


                        shows the current directory, while the command



                        cd


                        will change directory to your home directory.






                        share|improve this answer



























                          1














                          The command



                          pwd


                          shows the current directory, while the command



                          cd


                          will change directory to your home directory.






                          share|improve this answer

























                            1












                            1








                            1







                            The command



                            pwd


                            shows the current directory, while the command



                            cd


                            will change directory to your home directory.






                            share|improve this answer













                            The command



                            pwd


                            shows the current directory, while the command



                            cd


                            will change directory to your home directory.







                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Apr 9 '17 at 5:45









                            Stephen RauchStephen Rauch

                            3,344101428




                            3,344101428





















                                0














                                You can also use the below command to find out where the previous command was executed and get on the folder.



                                cd - 


                                In contrast, pwd only gives you the path of the current working directory.






                                share|improve this answer



























                                  0














                                  You can also use the below command to find out where the previous command was executed and get on the folder.



                                  cd - 


                                  In contrast, pwd only gives you the path of the current working directory.






                                  share|improve this answer

























                                    0












                                    0








                                    0







                                    You can also use the below command to find out where the previous command was executed and get on the folder.



                                    cd - 


                                    In contrast, pwd only gives you the path of the current working directory.






                                    share|improve this answer













                                    You can also use the below command to find out where the previous command was executed and get on the folder.



                                    cd - 


                                    In contrast, pwd only gives you the path of the current working directory.







                                    share|improve this answer












                                    share|improve this answer



                                    share|improve this answer










                                    answered Jul 31 '18 at 5:25









                                    Kartik ChopraKartik Chopra

                                    1




                                    1



























                                        draft saved

                                        draft discarded
















































                                        Thanks for contributing an answer to Unix & Linux Stack Exchange!


                                        • Please be sure to answer the question. Provide details and share your research!

                                        But avoid


                                        • Asking for help, clarification, or responding to other answers.

                                        • Making statements based on opinion; back them up with references or personal experience.

                                        To learn more, see our tips on writing great answers.




                                        draft saved


                                        draft discarded














                                        StackExchange.ready(
                                        function ()
                                        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f357893%2fis-there-a-difference-between-pwd-and-cd%23new-answer', 'question_page');

                                        );

                                        Post as a guest















                                        Required, but never shown





















































                                        Required, but never shown














                                        Required, but never shown












                                        Required, but never shown







                                        Required, but never shown

































                                        Required, but never shown














                                        Required, but never shown












                                        Required, but never shown







                                        Required, but never shown






                                        Popular posts from this blog

                                        How to check contact read email or not when send email to Individual?

                                        Bahrain

                                        Postfix configuration issue with fips on centos 7; mailgun relay