I am unable to find the etc/passwd file in cygwin - cygwin

I recently installed cygwin, and have been unable to find my passwd/etc file in order set to HOME. Is there any way to force cygwin to generate the file?

The /etc/passwd and group files are no longer generated by default, starting with Cygwin 1.7.34.
You can still generate them. Cygwin will use these files preferentially if present, by default, but only to cater to existing installs and special situations.
When these files are not present, Cygwin now uses the native Windows user management mechanisms: Active Directory where present, or SAM where not.
It is therefore recommended that you use this new mechanism to change your home directory. The easiest way I know of to do this is to add a line like this to your /etc/nsswitch.conf file:
db_home: /%H
That will change your Cygwin home directory to be equal to your Windows user profile directory. There are many other legal % tokens you can use here to achieve different results. See the previous link for details.

In my case, I set db_home: /%H in /etc/nsswitch.conf file, and change permission of my .ssh dirctory to "full control".

Related

Can't change Cygwin Home Directory from /SPB_Data

I recently installed Cygwin. Its default home directory is
/cygdrive/c/Users/<username>/AppData/Roaming/SPB_Data
[Editor's note: this also applies when the directory is /cygdrive/c/SPB_Data.]
I have tried changing the db_home setting in /etc/nsswitch.conf according to this post, but that doesn't make any difference.
How do I change the home directory to /cygdrive/c/Cygwin64/home?
With high likelyhood you have installed some software from Allegro (now owned by cadence) after installing cygwin.
Allegro overwrites the windows system variable 'HOME' and sets it to 'C:\SPB_Data'
To fix this delete the enviroment variable, then the home folder can be set according to the linked stackoverflow question.
Alternatively you could set the correct home folder path in the enviroment variable, but this is not reccomnended according to cygwin documentation.
cygwin documentation: https://cygwin.com/cygwin-ug-net/setup-env.html
Also see this old forum post
https://community.cadence.com/general_topics/f/feedback-suggestions-and-questions/17969/orcad-install-killed-oracle-virtualbox
I registered to reply to this old question since it is the top result on google (for me at least) when searching for 'cygwin SPB_data'. And this question sendt me in the right direction, but did not contain the correct answer.
see https://cygwin.com/cygwin-ug-net/ntsec.html#ntsec-mapping-nsswitch
and set on /etc/nsswitch.conf
db_home: /home/%U
Don't use notepad as it will set the line end to windows default CRLF
After changing the file, close all cygwin processes, as its value is read at
cygwin start.

Debian Package Creation postinst as non-root

I have created quite a few deb files, i have no problems doing that and they all run beautifully. However, if i want to replace a file in users home directory I am unsure on how to do that.
I have tried making a postinst to rsync the files from a predefined location to home directory, but since the postinst file is being run as root ( due to the debian installer running as root ) it is being sent to the root home directory and not the user's home directory....
Here's an example of the deb file contents :
Debian Directory ---> Control File ----> Postint File
usr/share/desktop (directory with files inside)
The postinst file has the sync command to send those files to users home:
#!/bin/sh
rsync -av /usr/share/desktop/ ~/.config/desktop/
The problem is it is sending the files to Root/home... not the default users home :(
I don't have the username of the user since this will be used on many computers with different users, therefore I can't use sudo -u username.
So what do I do? how do i replace files in users home directory from deb install? Any help is much appreciated.
In a Bash script, ~ refers to the current user's home directory. The package installation scripts are always run as root, so that's what "current user" means in this context.
(You could argue that the package installation is probably initiated by a user running su or sudo, but in the general case, you cannot assume this to be the case.)
Modifying user files from a system package appears extremely suspicious in any event. If the need is genuine, this should probably not be approached as a system package installation question in the first place. What are you actually trying to accomplish?
Not only are you violating the basic principle that package management should not meddle with user files; a consequence of this arrangement is that the operation can only be performed once: If the user has installed the package, attempting to install it again does nothing (at least until you uninstall).
A more manageable and predictable approach would seem to be making the package provide this functionality, but leave it to the user to invoke the actual sync (overwriting) script as needed. Perhaps you want to hook it into the desktop startup scripts somehow.
Having said that, sudo exposes the invoking user's identity in $SUDO_USER so you could look for that, and simply fail if it is not set.
As an aside, package scripts should work with dash so you need to avoid bashisms - prefer $HOME over ~, for example.
I managed to find a workaround, although it is not exactly what I was looking for, but here is my solution, at least for now.
#!/bin/sh
#This will move the desktop settings to required folder.
szAnswer=$(zenity --entry --text "Enter your login username\nThis must be entered correctly\n" --entry-text "Enter name of profile to use:")
xfce4-terminal -e "sudo rsync -av /usr/share/Desktop/ /home/$szAnswer/.config/xfce4/"
exit 0
In other words, the user gets asked to enter his username, and the files get copied to that user's home directory. The advantage is that if he does have multiple users, it will use the correct user. The disadvantage is if he enters username wrong, even a spelling mistake, the install will fail.
But it does work, I have tested. If anyone has a better solution I eagerly await your suggestions.

Is there a way to enable auto-complete for files in user PATH under Windows cmd?

The tab-autocomplete feature in Windows is mostly like what is under Linux, but as far as I tried, it will not search my user PATH, so the files can be auto-completed has to be in the current directory.
Is there a way to enable Windows cmd to search not just the current directory but all user or system PATH?
Thanks!

Setting Working Directory to Desktop in Cygwin

The current directory on cygwin is home/myuser. I navigated to cygwin and found it has a directory called home/myuser and could not figure out how I would navigate to the desktop. I did not want to add a desktop directory there and I could not navigate above the root folder (cygwin). Any idea on how I could do this?
This is essentially covered in the Cygwin FAQ under "How can I access other drives?". No, you're not trying to access another drive, but you are trying to access a folder outside of the Cygwin tree. As the FAQ item says, Cygwin maps your Windows drives as /cygdrive/<drive-letter>, so your desktop is likely something like /cygdrive/c/Users/<username>/Desktop. Note that the path has changed over the years with various versions of Windows and you didn't specify what version you're running, so it may not be exactly that.
Anyway, what I would do, would be to create a symbolic link to that from my Cygwin home folder. Something like this:
ln -s "/cygdrive/c/Users/<username>/Desktop" Desktop
I put the quotes in because depending on what version of windows you have, this path may include spaces.
You'll probably notice from the FAQ that the Cygwin version of bash accepts DOS-style pathnames, so you can actually do the following:
cd "C:/Users/<username>/Desktop"
But I recommend avoiding such syntax. Not all Cygwin apps understand DOS-style paths, and you'll only end up confusing yourself if you have to try to figure out whether what you're doing will work with a DOS-style path or not. It's best to just use the Unix-style paths for everything when in the Cygwin environment, unless you have a very good reason not to.
Add
cd "/cygdrive/c/Users/<username>/Desktop"
to .bashrc file located in <cygwin install directory>/home/<username>. This will change working directory to desktop every time you open Cygwin terminal.

Custom InstallAnywhere location for .com.zerog.registry.xml file on linux

I'm running into an issue where I do not have write access to the /var directory on a UNIX environment, and InstallAnywhere doesn't provide me the option of writing the .com.zerog.registry.xml to any other location for a product installation. Is there a parameter out there that allows for this file to be written to a different directory?
According to the IA docs:
If logged in as root, the global registry is located in \var.
If logged in as a user, it is located in the user’s home directory.
So, if you're running as root and can't write to /var, it sounds like a permissions problem with the /var directory, independent of IA. Check the permissions on /var.
If you're running as a non-root user, then the registry shouldn't be going to /var, but to $HOME/.com.zerog.registry.xml (FWIW, I just checked one of our test Linux boxes and found .com.zerog.registry.xml under both /var and under test-user $HOME directories. The docs appear to be correct).
I've also seen some very strange behavior if IA is low on space in $TMP. Make sure you have plenty of space there.
Also, have you considered running the installer with sudo, or the graphical equivalents kdesudo (KDE) and gksu (Gnome)? Those might get you where you want to go.

Resources