8 Replies Latest reply on Mar 11, 2016 9:22 AM by FGT

    Default directory after login

    BrechtW

      When I log in via Serial or SSH I start in this folder.

      galileo login: root

      root@galileo:~#

      How do I set the default directory after login to /media/card/ ?

        • 1. Re: Default directory after login
          FGT

          I don't have a Galileo at hand to verify before posting, but you can try with the standard usermod command (take a look at man usermod):

           

          usermod -m -d /media/card root


          HTH,


          Fernando.


          • 2. Re: Default directory after login
            DiegoV_Intel

            Hi BrechtW,

             

            I tested the suggestion provided by FGT and it worked, however I had to change it a little bit. First, I tried to run the command usermod -m -d /media/card root, but I got a message that states that the user root is currently used by a process. I had to create another user, then I ran the command again and it worked. The following are the steps I followed:

            1. Run the following command to create a new user: useradd test-user. "test-user" is the new username, you can change it.
            2. Run the following command to set a password to the new user: passwd test-user
            3. Run the command suggested by FGT with the new user created: usermod -m -d /media/card test-user
            4. Access the Galileo's console through SSH. Use the new user to login, and then type the password.
            5. If you run the command pwd, you will check that you are in the /media/card directory

             

            Hope that helps you.

             

            Regards,

            Diego

            1 of 1 people found this helpful
            • 3. Re: Default directory after login
              BrechtW

              I you are now "test-user", can you than avoid the error that user root is used by a process, and still make /media/card default folder for root user?

              • 4. Re: Default directory after login
                FGT

                That's right.

                 

                Now I have a Galileo at hand...

                 

                If you are still interested in having the root account with another home directory, just edit the

                 

                /etc/passwd

                 

                file, and change the line

                 

                root::0:0:root:/home/root:/bin/sh

                 

                to

                 

                root:x:0:0:root:/media/card:/bin/sh

                 

                 

                HTH,

                 

                Fernando.

                • 5. Re: Default directory after login
                  BrechtW

                  Thank you very much @FGT. This is a real time saver.

                   

                  I changed

                  root::0:0:root:/home/root:/bin/sh

                  to

                  root:x:0:0:root:/media/card:/bin/sh

                  in /etc/passwd, edited it with vi, pressed insert, changed the path, exited with :wq and it worked!

                   

                  galileo login: root

                  Password:

                  root@galileo:~# pwd

                  /media/card

                  • 6. Re: Default directory after login
                    BrechtW

                    I have a problem now, it doesn't recognize shell commands:

                     

                    root@galileo:/# halt
                    -sh: halt: command not found
                    
                    • 7. Re: Default directory after login
                      FGT

                      BrechtW wrote:

                       

                      I have a problem now, it doesn't recognize shell commands:

                       

                      1. root@galileo:/# halt 
                      2. -sh: halt: command not found 

                      Yes, you are right... I realized after my previous post, sorry.

                       

                      I'm looking at some turn-around, since it seems to be some path problem... but I don't understand why...

                       

                      Let me try some experiments,

                       

                      Fernando.

                      • 8. Re: Default directory after login
                        FGT

                        FGT wrote:

                         

                        BrechtW wrote:

                         

                        I have a problem now, it doesn't recognize shell commands:

                         

                        1. root@galileo:/# halt 
                        2. -sh: halt: command not found 

                        Yes, you are right... I realized after my previous post, sorry.

                         

                        I'm looking at some turn-around, since it seems to be some path problem... but I don't understand why...

                         

                        Let me try some experiments,

                         

                        Fernando.

                        Here it is... just a reminder first: all of this is at least "strange"... make sure you make backups of files you change. I usually make

                         

                        cp <filename> <filename>.original

                         

                        just to be able to (hopefully) return to the/some original state...

                         

                        I do not recall how "standard" linux identifies root user login, but it appears that yocto uses... the home directory! Anyhow, to "recover" the paths root have (and maybe some other environment), edit

                         

                        if [ "$HOME" = "/home/root" ]; then

                         

                        to

                         

                        if [ "$HOME" = "/media/card" ]; then

                         

                        Furthermore, when I have to change more than one system configuration file I start thinking there should be something more elegant to do... but I usually end way out of elegance... ...

                         

                        HTH,

                         

                        Fernando.

                        1 of 1 people found this helpful