Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Safely change home directory

I'm trying to safely update the home directory as specified in /etc/passwd, but the standard Linux utils - usermod and vipw - for doing so aren't provided by Cygwin.

Could anyone tell me how they changed this in Cygwin?

like image 606
sblundy Avatar asked Oct 22 '08 13:10

sblundy


People also ask

Can you change home directory Mac?

Open the Users folder on the startup disk. It contains the home folder for each user. To get there, you can choose Go > Go to Folder from the menu bar, then enter /Users . Rename the user's home folder without using any spaces in the new name.

How do I change the home directory name in Linux?

To rename a directory on Linux, use the “mv” command and specify the directory to be renamed as well as the destination for your directory. To rename this directory, you would use the “mv” command and specify the two directory names.

How do I change my home directory on Mac terminal?

In Terminal. app's preferences, in the "Settings" tab, select the style of your terminal (probably Basic: the default), then go to the "Shell" pane and put cd /any/directory/you/want in the run command box. This will automatically change directory when you open a new terminal.

Why can't I change my Mac username?

You can't change the name of an account while logged into the account you're changing. So you will also need to log in to a different (administrator) account to do this – you may need to create that first.


2 Answers

EDIT: For recent versions of Cygwin (1.7.34 and beyond), see this newer question.

Like sblundy's answer, you can always edit by-hand.

But if you want to do it the "official" way, use the cygwin-specific mkpasswd command. Below is a snippet from the official docs on mkpasswd :

For example, this command:

Example 3.11. Using an alternate home root

$ mkpasswd -l -p "$(cygpath -H)" > /etc/passwd 

would put local users' home directories in the Windows 'Profiles' directory.

There's a bunch of other really useful commands described on the Cygwin Utilities documentation page (which includes mkpasswd). The use of cygpath in the example above is another of these cygwin-specific tools.

While you're at it, you probably also want to read the Using Cygwin Effectively with Windows documentation. There's a bunch of really good advice.

like image 95
netjeff Avatar answered Oct 03 '22 14:10

netjeff


I ended up exiting all my cygwin shells and editing it by hand in a text editor. So far, so good.

Note: don't escape the spaces in the "Documents and Settings" directory. The entry will look like

user:...:/cygdrive/c/Documents and Settings/user:/bin/bash 

The line is tokenized on the : character.

like image 36
sblundy Avatar answered Oct 03 '22 14:10

sblundy