0

For some preliminary information, I am using WSL2. This is my first time using Linux.

I would like to install Typst which is similar to LaTeX.

I have used wget to download the file for my computer architecture, but when I tried to put it in a directory I know is in the path (ex: /usr/local/bin) I am not allowed to do so.

Is there a fix or a workaround?

3
  • 1
    Please do not post text as images and if you post images, at least make so they are readable. Anyway… you normally need to be root for creating a file into /usr/local/bin. You possibly should use sudo. Commented Dec 20, 2023 at 0:31
  • Sorry about that. I've deleted the image. By being root, do you mean having administrator privileges. Additionally, could you elaborate on what you mean by using sudo or how I would go about doing so. Thank you. Edit: Figured it out. Thank you. Commented Dec 20, 2023 at 0:44
  • Yes you require administrator privileges. In Linux the administrator has user id zero, and is almost always called root. You can use the commands su or sudo to change yor privilidge level. To use su you need to know root\'s password. sudo requires that the system is configured to get the elivated access, which should be the case for WSL. wget does not preserve execute permissions. Use chmod +x /usr/local/bin/typest to mark the file as executable. Linux doesn't use file extensions like .exe to say if a file is executable. Commented Dec 20, 2023 at 2:02

1 Answer 1

5

As explained in the comments, if you know the root password, then you can open a root shell or if your account has sudoer rights, which it usually does in WSL, you can also open a root shell or use sudo before the command to place the file in /usr/local/bin which is usually only writable by root and as you've correctly gathered, is nearly always already in the PATH for everyone.

Another option which doesn't require sudoer rights and is to place the file in a directory in your home directory, say for example ~/bin or ~/.local/bin. They may already exist but you can create them if necessary. They are usually in the PATH by default. Verify this with the following command:

echo $PATH

If the directory that you created and in which you placed the file doesn't appear in the output, you can add the directory to your PATH. The following will do this for most shells including the commonly used bash, zsh, and ksh.

export PATH=~/.local/bin:$PATH

That will prepend it so that the instance typetest in that directory is the first one that is found and used. This is viable in the case that only your user account needs it. You can add that line to your shell init file such as ~/.bashrc so that it adds it to your environment at login.

You'll need to make sure that the file is executable by using chmod +x /path/to/typetest which can be done before or after placing it the directory that you choose.

You must log in to answer this question.