Shell How to change EDITOR to default parameter

Something appears to be weird about the way you changed the root shell. When you log in as "root" your home directory should be /root but it shows up in your $PATH and in your pwd as /home/ihor (or as /usr/home/ihor, which is effectively the same directory, because /home is a link to /usr/home). Yet, id and $USER both show that you are logged in as "root".

Next, presumably in /home/ihor/.profile you reset the HOME environment variable to /root. Therefore, you then probably executing /root/.shrc (instead of /home/ihor/.shrc), because in your .profile file, the statement ENV=$HOME/.shrc; export ENV will expand to ENV=/root/.shrc instead of to ENV=/home/ihor/.shrc.

It appears that you have made some of your changes manually instead of by using the chsh command, which is the recommended way of changing the root shell.

At this point you should proceed very cautiously before making any more changes. Have you manually edited your /etc/passwd file?
yep I've done It before, but it did not take any effect, i thought it should been. Then i've changed the shell through chsh and it works perfectly after this step. Maybe it's because I'm loggining in with sudo su, or it's not the case at all?
 
sudo su is not the same as logging in as root. sudo su - (or sudo su -l) is the way (or another way) to simulate a login shell.

Please review the manual entry su(1) before proceeding further. It will help to explain why your $HOME environment variable is wrong, and why other environment variables are wrong.

Also, you should execute the command PS1="\u@\h:\w \\$ " from the command line, right away-- this will allow you to see what your present working directory is.

Edited to add: Following SirDice's advice, you should probably review the manual entry for sudo(8) instead of su(1)-- I don't use sudo so I don't understand it so well.

Once you can see what your present working directory is, you should try to sort out which .profile and .shrc files you've been editing. You should restore /home/ihor/.profile and /home/ihor/.shrc to their original contents, and put your changes in /root/.profile and /root/.shrc instead.

Any time you're uncertain about what your present working directory is, you can just run pwd to see. If you have any questions about this, please ask.

Also, please read pwd_mkdb(8) to learn how to fix your /etc/passwd file. You should never manually edit your passwd file. I also recommend reading the following two threads:

Thread having-trouble-changing-shell-with-chsh.78914

Thread unable-to-change-shell.24720
 
sudo su is not the same as logging in as root. sudo su - (or sudo su -l) is the way (or another way) to simulate a login shell.

Please review the manual entry su(1) before proceeding further. It will help to explain why your $HOME environment variable is wrong, and why other environment variables are wrong.

Also, you should execute the command PS1="\u@\h:\w \\$ " from the command line, right away-- this will allow you to see what your present working directory is.

Edited to add: Following SirDice's advice, you should probably review the manual entry for sudo(8) instead of su(1)-- I don't use sudo so I don't understand it so well.

Once you can see what your present working directory is, you should try to sort out which .profile and .shrc files you've been editing. You should restore /home/ihor/.profile and /home/ihor/.shrc to their original contents, and put your changes in /root/.profile and /root/.shrc instead.

Any time you're uncertain about what your present working directory is, you can just run pwd to see. If you have any questions about this, please ask.

Also, please read pwd_mkdb(8) to learn how to fix your /etc/passwd file. You should never manually edit your passwd file. I also recommend reading the following two threads:

Thread having-trouble-changing-shell-with-chsh.78914

Thread unable-to-change-shell.24720
Thanks a lot for an explanaitions, reading man of su was really surprised, thought tthat it was just tool for changing user, now the mistifications around not changed variables became more clear. So it's like virtual environment. Will read its man page more in depth. But I'm still wondering how to login as root after I sshed on machine.

One more question is about this /etc/passwd. why can't just use this file, what is history and purpose of this redundancy of data. Where is the actually used data that dublicates the /etc/passwd and which is used by chsh util?

/etc/pwd.db The insecure password database file.
/etc/pwd.db.tmp A temporary file.
/etc/spwd.db The secure password database file.
/etc/spwd.db.tmp A temporary file.
/etc/master.passwd The current password file.
/etc/passwd A Version 7 format password file.

what is the purpose of such a lot of stuff? Thought that the only place is /etc/passwd, it sounds logical for me
 
But I'm still wondering how to login as root after I sshed on machine.
Simplest solution, sudo -i (if you want to use sudo(8)) or su - (you will need to be a member of the wheel group).

One more question is about this /etc/passwd. why can't just use this file, what is history and purpose of this redundancy of data.
Back in the early days this is where the user accounts and passwords were stored. But letting everyone have access to the password hashes is kind of dangerous and the fact that a flat text file doesn't scale very well with a large number of accounts, this was changed to a database structure. The actual passwords (their hashes to be exact) was split off from the other information (/etc/pwd.db and /etc/spwd.db) because not all applications that need access to the information also need access to the passwords (that's only needed for authentication purposes). The 'old' /etc/passwd file is still in place because there are still some tools around that depend on the information in it. It's basically a relic from the past that's still around.
 
Is there a simple GUI for FreeBSD to view (not edit) Berkeley database file content?

I see this for Linux: Ubuntu Manpage: bdbvu - simple GUI tool to browse Berkeley DB databases but can't find anything comparable in FreshPorts.
I would like to start gui some day later, but I would rather use cli for editing purposes. The problem is that I can't install kde or something else, it's only xfce working from pkgs and ports for me.

Yep, the sudo -i method works perfectly, nano is now loading wihtout anny reconfiguring.
Thak you all
 
Back
Top