Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Typically I would create a user account and in the home folder, place the cd command in the ~/.bashrc file. For system users, however, with on home folders, the /etc/bash.bashrc file is used instead and with multiple system users I need a more conditional approach.

Can the /etc/bash.bashrc file know which user is executing it, and change directories on login based on which user I've logged in as?

These system users are never logged in as remotely, only using su.

share|improve this question

You can set the home folder for a user in /etc/passwd. Find the line with that user name and change the sixth entry which represents the absolute path to the directory where the user will be in when he log in.

See also: Understanding /etc/passwd File Format

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.