Community
cancel
Showing results for 
Search instead for 
Did you mean: 
BWill15
New Contributor II
1,859 Views

Default directory after login

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/ ?

9 Replies
FTinetti
Honored Contributor I
135 Views

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.

 

Diego_V_Intel
Employee
135 Views

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

BWill15
New Contributor II
135 Views

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?

FTinetti
Honored Contributor I
135 Views

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.

BWill15
New Contributor II
135 Views

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

BWill15
New Contributor II
135 Views

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

root@galileo:/# halt

-sh: halt: command not found

FTinetti
Honored Contributor I
135 Views

BrechtW wrote:

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

  1. root@galileo:/# halt
  2. -sh: halt: command not found
root@galileo:/# halt -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.

FTinetti
Honored Contributor I
135 Views

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 .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.

Acom0
Beginner
135 Views

Thanks for the solution guys.

I've been looking for the same.

i wanted to set a new user for my client on one on our servers ( my Technical engineer is on sick leave ),i've wasted 3 hours of my life in googling this and at last i found the Linux related answer on intel forum.

Thanks a lot.

Reply