Linux operation, the difference between the "-" and "-" in the SU Switch User command

Source: Internet
Author: User
Tags postgresql commands

When working with such problems, the server needs to switch from root to PostgreSQL to install the user to start the PostgreSQL service.

The switch user and start PostgreSQL commands are as follows:

# Switch to Pgsql user su postgres# starting Pg_ctl start -bash:pg_ctl:command not found

Hint that the PG_CTL command does not exist, but it is certain that the previous installation of PostgreSQL is so started, how can not this time.

Later learned that the original is the question of the SU command, there is no horizontal bar "-" There is a difference.

su - Postgres

There are bars login shell: User switch, change working directory, load all user environment configuration.

No bar interactive shell: The user switches, but the working directory does not switch to the user's working directory, and the environment variables set by the user are not loaded.

"When Bash starts executes the commands in a variety of different scripts.
(1) When started as an interactive login Shell:bash reads and executes The/etc/profile (if it exists). After reading. File, it looks for
~/.bash_profile, ~/.bash_login, and ~/.profile in this order, and reads and executes the first one (that's exists and is Rea  dable). When a login shell
Exits:bash reads and executes ~/.bash_logout (if it exists).

(2) When the started as an interactive shell (but not a login shell): Bash reads and executes ~/.BASHRC (if it exists). "

Linux operation, the difference between the "-" and "-" in the SU Switch User command

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.