When sharing a git repo between wsl on windows10 and any linux, all files added/changed from wsl get the rw-rw-rw attributes, even if I explicitly do a chmod ug+x file.py before adding. If You do a ls -l in wsl all files are listed with rwxrwxrwx no matter what.
On linux I have to do a find . -name "*.py" -exec chmod ug+x {} \; on every pull/clone
What is the best way to fix this? Are there some settings in WSL? git hooks?
I assume your git repo is somewhere in the windows file system, i.e. in /mnt/c/path/to/git. In this case WSL sets all permissions in order
to best reflect the Windows permissions. (FAQ)
There is currently no way in the stable build to change this behavior. But with
the insider build 17063 the WSL team face this by implementing DrvFs support, which
allows setting the owner and mode of files using chmod/chown, and also
the creation of special files such as fifos, unix sockets and device
files. (Release Notes)
Related
I'm working on a research project in a ML lab, and running stuff on their machines virtually using ssh. The machines are Linux, and my home laptop is a Mac. The actual machine storage is really small, so I'm supposed to use these two specific directories that show up under df -I (inodes list). But how do I like redirect files to store there?
Adding it to the end of directories when I use scp -r doesn't work. My command to send directories from my local computer to the ssh is scp -r /Local directory pwd/ username#server:/home/username, and for example sticking on the anode directory to the back of it (so new command would be scp -r /Local directory pwd/ username#server:/home/username/inode directory) doesn't work.
Would appreciate help
I've this SSD drive that I bought only for work so I would like WSL2 to write on it. Found this article which I was following thru, to find out wsl --mount is working on Windows Preview Build 20211, not on my build (Win 10 1909 18363.1110).
Is there an way to do this?
Thanks!
Found out later, with a little change of terms on my research, that it could be done as in this tut here: https://www.sitepoint.com/wsl2/
To make it quick for anyone searching around here, you have to export your Linux image, unregister it from wsl and then import it again on the other drive. How it's done:
List your distros
In a Windows Powershell terminal, enter wsl --list. It should return what distros you have installed and if they're running.
Export your distro
In the same Powershell, enter mkdir D:\backup to make a dir for your backup then export it using wsl --export <distro> D:\backup\<distro>.tar. In my case, wsl --export Ubuntu D:\backup\ubuntu.tar.
Unregister the distro
You have to remove it from the C: drive with wsl --unregister Ubuntu and to make sure it worked, after the process is done list all distros again with wsl --list.
Import the distro on another drive
The syntax for this will be wsl --import <distroName> <target\directory> <origin\image>. So if you'd like to make an directory for your WSL in your new drive, just do mkdir D:\wsl or name it anyway you want. I already have a folder for that, so I went with wsl --import Ubuntu D:\wsl-dev D:\backup\ubuntu.tar.
You can verify if it's done by using the very same wsl --list.
And if you want to change your default user from root, follow below steps.
For Ubuntu 18.04, the command to change default user is
ubuntu1804 config --default-user <username>
Took me a while to figure out. Finally found it thanks to this link
I am upgrading my WSL2 instance from Debian 10 to Ubuntu 20.04 LTS, because I need some newer packages.
How do I copy files and directories from Debian to Ubuntu, preserving the permissions and owner? (uid and gid are the same in the two Linuxes.)
Copying to windows first changes the permissions and owner of files.
explorer.exe also changes permissions and owner.
Preferably, I'd also like to avoid having to create a shared disk image file that I could mount from Debian and Ubuntu in turn.
I'd like something simpler, like accessing the second WSL instance directly from the first, e.g.,
$ cp -a <Debian>/myfiles/ <Ubuntu>/myfiles
Is this possible?
See also my similar question: How to access \wsl$\othercontainer\some\file from within a WSL container? where the short answer is:
sudo mkdir /mnt/othercontainer
sudo mount -t drvfs '\\wsl$\othercontainer' /mnt/othercontainer
ls -l /mnt/othercontainer/some/file
NOTE: It looks like symbolic links aren't supported.
Use tar. It will preserve all the file metadata.
In <Debian>, create myfiles.tar.gz:
tar zcvf myfiles.tar.gz myfiles
Copy myfiles.tar.gz to your windows drive e.g. with explorer.exe or with /mnt/c, and then copy myfiles.tar.gz to <Ubuntu>. In <Ubuntu>, untar it:
tar zxvf myfiles.tar.gz myfiles
I'm behind a firewall and I have the fzf.tar.gz package which has the content of the git repo. How can I install fzf offline?
The install command ~/.fzf/install is reaching out to github.com. I'm on Redhat with no internet connection.
https://github.com/junegunn/fzf
This is just what I observed, I can't guarantee I didn't miss anything:
First, clone fzf to FZF_DIR on an online PC, then,
I'd suggest you to execute 'install' on an online PC to get necessary files
~/.fzf/bin/fzf this one is downloaded by install script
~/.fzf.bash this one is generated by install script
cp ~/.fzf/bin/fzf $FZF_DIR/bin
copy $FZF_DIR (with fzf binary in it) and .fzf.bash into your offline PC
ln -s $FZF_DIR ~/.fzf
source .fzf.bash in your .bashrc
Entire FZF_DIR is needed because it includes some other useful scripts sourced by .fzf.bash.
I have installed ApacheDS form this link
http://directory.apache.org/apacheds/download/download-linux-bin.html
It is installed in the opt folder.
How can I uninstall it?
Ok, so you must have root access then? The 32-bit .bin I've just downloaded attempted to install files to /opt/apacheds-[$VERNUM]/, /etc/init.d/, and /var/lib/apacheds-[$VERNUM]. Because all of those locations should be protected against user writes in all linux distributions by default that I'm aware of, I will assume you can escalate privileges as necessary to perform the following actions.
Another assumption I will go on is that you chose the default installation locations offered you when the .bin installer requested you provide configuration options for installation paths. When I ran it just now it asked me a question per path and I had only to press the "ENTER" key to continue using its defaults.
If you're uncertain about how to obtain root access try to prefix each command with sudo, and, failing that, try running the command su once alone before attempting to run any of the following.
### First verify install paths with root level find command
# find / -type d -name *apacheds* ; find /etc/init.d -name *apacheds*
### Review outputs of above commands and verify they match the following \
### globbing rm command before running it.
### CAUTION: If used incorrectly rm -rf could do some very annoying damage
# rm -rf /{opt,var/lib,etc/init.d}/apacheds*