sudo/apt-get command not found in git bash - linux

I am using Windows 10 in my machine, and currently installed git bash on it.
I wanted to install node and npm for my application.
when i tried :
apt-get install nodejs
"apt-get" command not found,
I tried google and got
sudo install nodejs
"sudo" command not found.
How to use sudo and apt-get command on my git bash.

Git for Windows comes with a Windows port of Bash and a collection of few more common *nix command-line tools that have been compiled for Windows, it does not provide a complete *nix environment. Hence you cannot use tools like sudo and apt-get which modify the *nix operating system.
However, there are other tools, programs if you like, available.
Try to install node " the windows way ".

win-sudo package adds sudo to windows.
kafaior at Super User suggests:
A working sudo replacement for Cygwin's mintty terminal would be to place the following script in user's PATH:
$!/bin/bash
cygstart --action=runas mintty -e `which bash` -lc \"$#\"
Maximus mentions how to add sudo (well, csudo) via cmder.
Super User has a similar question here.
It looks like there is a command runas or elevate commands. These might be for PowerShell, rather than git bash. I'm not sure.
I found your this while looking for a way to add rsync to Git Bash. So below I included info that may or may not work for sudo or apt-get. If they do not work directly for specific commands the OP is asking about, they may inspire a solution that does work. Also this could help others who arrived here as I did.
rsync is another unix command not available in the standard installation of git bash.
However, you can download and install the Git for Windows SDK (scroll to the bottom of the page for the link). This will allow you to create a version of the Git for Windows installer that does include additional *nx commands.
Install the Git for Windows SDK according to the instructions. Part 2 is where you add the packages you want, that aren't included in the standard git bash installation. Part 3 is where you create a Git installer, which will include the additional packages. If you skipped step 2, this should produce an installer similar to the standard installer.. There is a good discussion as to why they cannot include these commands in the general distribution.
It is also possible to just grab rsync filehere or here and unpack it directly within your Git installation, and it works. I dunno if it is also possible to do something similar for sudo or apt-get.
Finally, it looks like there is a way to get *nix commands available within the Git Bash shell via cmder. Here are the instructions.

Installing applications in git bash does not sound right to me. I would suggest you either use the native Windows installer (https://nodejs.org/) or, if you prefer a package manager, use Chocolatey (https://chocolatey.org/) to install nodejs with:
choco install nodejs

Related

wget command not found on linux server

I have a linux server (completely new, web hosting, nothing is installed into it), and want to use a "wget" command. Currently, it is not found. Kernel version 2.6.32-896.16.1.lve1.4.54.el6.x86_64
I am completely new to linux, tried to solve this issue by myself, but couldn't do it. I log in into this linux server via PuTTY via my Windows OS laptop.
wget https://www.python.org/ftp/python/3.6.6/Python-3.6.6.tgz
To get "wget" to work, I will need to install it. I guess I will need to install first "sudo" and/or "apt" and/or "apt-get". But couldn't do it. Please give me a short list of steps in which order to install them.
Given your kernel version, it looks like your Linux distribution is CentOS 6 or RHEL 6. Try installing wget with this command:
yum install wget
You must be root when you run this command.
Incase you using Debian version of Linux, use the following:
sudo apt-get install wget
From kernel version, it looks like you are using RHEL/Centos 6.
Please check -
https://centos.pkgs.org/6/centos-x86_64/wget-1.12-10.el6.x86_64.rpm.html
If the mentioned dependencies exist in your system, you can directly fire the rpm command
rpm command guide -
https://docs.fedoraproject.org/ro/Fedora_Draft_Documentation/0.1/html/RPM_Guide/ch02s03.html
If it doesn't work, you need to use yum command. (You need to configure yum command first, if not configured already)
yum install wget
To configure yum command in centos6 -
https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/6/html/deployment_guide/sec-configuring_yum_and_yum_repositories
Note - you need to be root user for above activities.

How to install packages in Linux (CentOS) without root user with automatic dependency handling?

Is it possible to use RPM or YUM or any other package manager in Linux, specifically CentOS, to install a package either already downloaded or from repo to a custom location without admin/root access?
I tried building from sources, using cmake, configure, make, make install etc, but, it ended up having so many dependencies one after other.
Or are there any better alternatives?
It is possible to use yum and rpm to install any package in the repository of the distribution. Here is the recipe:
Find the package name
Use yum search.
Download
Download the package and all of its dependencies using yumdownloader (which is available on CentOS by default). You'll need to pass it --resolve to get dependency resolution. yumdownloader downloads to the current directory unless you specify a --destdir.
mkdir -p ~/rpm
yumdownloader --destdir ~/rpm --resolve vim-common
Choose a prefix location
It might be ~, ~/centos, or ~/y. If your home is slow because it is on a network file system, you can put it in /var/tmp/....
mkdir ~/centos
Extract all .rpm packages
Extract all .rpm packages to your chosen prefix location.
cd ~/centos && rpm2cpio ~/rpm/x.rpm | cpio -id
rpm2cpio outputs the .rpm file as a .cpio archive on stdout.
cpio reads it from from stdin
-i means extract (to the current directory)
-d means create missing directory
You can optionally use -v: verbose
Configure the environment
You will need to configure the environment variable PATH and LD_LIBRARY_PATH for the installed packages to work correctly. Here is the corresponding sample from my ~/.bashrc:
export PATH="$HOME/centos/usr/sbin:$HOME/centos/usr/bin:$HOME/centos/bin:$PATH"
export MANPATH="$HOME/centos/usr/share/man:$MANPATH"
L='/lib:/lib64:/usr/lib:/usr/lib64'
export LD_LIBRARY_PATH="$HOME/centos/usr/lib:$HOME/centos/usr/lib64:$L"
Edited note (thanks to #AmitNaidu for pointing out my mistake):
According to bash documentation about startup files, when connecting to a server via ssh, only .bashrc is sourced:
Invoked by remote shell daemon
Bash attempts to determine when it is being run with its standard input connected to a network connection, as when executed by the remote shell daemon, usually rshd, or the secure shell daemon sshd. If Bash determines it is being run in this fashion, it reads and executes commands from ~/.bashrc, if that file exists and is readable.
Now if you want to install a lot of packages that way, you might want to automate the process. If so, have a look at this repository.
Extra note: if you are trying to install any of gcc, zlib, make, cmake, git, fish, zsh or tmux , you should really consider using conda, see my other answer.
TL;DR Use Miniconda, conda-forge is amazing.
curl "https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh" | sh
Or, alternatively:
curl https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh > Miniconda.sh
bash Miniconda.sh -b -p ~/conda
# -b is used to specify that this is done "in batch", so skip the EULA prompt
# -p lets you specify where you want conda installed
Commonly wanted packages:
gcc conda install gcc
zlib conda install zlib
make conda install make
cmake conda install cmake
git conda install git
fish conda install -c conda-forge fish
zsh conda install -c ActivisionGameScience zsh
tmux conda install -c conda-forge tmux
This tmux has a bug with the name of the ncurse library it uses. You can work around it by going to your da/lib folder and symlinking ln -sT libtinfow.so.6.1 libtinfo.so.6
For the rest, you can try https://anaconda.org/search?q=.
I've tried for a long time to get a package manager to work well on CentOS/RedHat but without success. The best I could do was to install a Gentoo Prefix at the correct location on another CentOS with root access, then scp a .tar.xz of the whole installation to the target server (only way to get a proper gcc for Gentoo Prefix). I could emerge (build & install) packages on the target server but kept hitting problems with locals and permissions.
I recently achieved a user installation of some interesting packages using conda. Here is how to install it from the command line:
curl "https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh" | sh
If like me, your home folder is hosted on a remote drive (a network file system), you might not want to install it in your home folder, so you might want to use something like mkdir /var/tmp/lo then specify an installation folder like /var/tmp/lo/da during the installation.
You'll then be able to install quite a lot of packages, though maybe not all those you wanted. Most of the time, if it is not in the default channel, it will be in conda-forge. You can check for existing packages at https://anaconda.org/search?q=
Other package managers I've tried to use after conda:
Linuxbrew
I thought that with that it would be easy to install homebrew (linuxbrew) but their sources are messy and use hard-coded absolute path to ruby interpreter, which fails because it isn't the last version and so on and so on and I gave up.
Nix
Nix still requires you to use the /nix folder. They hard-coded it too and it's hard to sed it correctly from every download it has to do during the installation (let alone updates).
Gentoo Prefix
I expect Gentoo Prefix to be easier to install directly now that we gcc can be used on the target server. -- Ok, I tried but met permissions bugs during installation (2018-09-28):
portage.exception.OperationNotPermitted: chown(b'~/gentoo/tmp/var/tmp/portage/sys-apps/gentoo-functions-0.12/image/var', 2000, 2000)
PkgSrc
I'm going to try pkgsrc now. -- Use (older) version 64-bit EL 6.x if on CentOS 6 or if encountering (G)LibC version issues with the 7.x one. -- No luck, pkgsrc hard codes /usr/pkg/sbin and /usr/pkg/bin. So it can't be used as user, unless maybe setting up a fakechroot environment. But I've never done that and I expect usability issues.
Please comment/answer if you succeed in installing any other package manager.
Download the packages, and indicate to include dependencies with the --resolve flag.
yumdownloader --resolve openslide-tools
Iterate over all downloaded rpm files.
for i in *.rpm; do rpm2cpio $i | cpio -idv; done
the output will be stored in your present working directory $PWD/usr/*
This answer by goldilocks sounds like what you are looking for.
https://unix.stackexchange.com/a/61295
It's still not a pretty process, but seems easier than building from source.
Otherwise you might want to look into non-root package managers as an alternative to yum.
Yes it is. If the software is packaged in repos. And admin installed
PackageKit-command-not-found package.
See:
https://fedoraproject.org/wiki/Features/PackageKitCommandNotFound

how to update make 3.81 linux

I am new to Linux (new as in installed it yesterday), I need it for my programming course in the university and I've been told to install specific versions of specific programs, but though I've used apt-get install to install them (having previously done apt-get update) they aren't in the correct version.
The programs that I need are make 4.0 and valgrind 3.10.1.
apt-get installs make 3.81 and valgrind 3.10.0.SVN.
I have tried typing "apt-get install make4.0" and "apt-get install valgrind10.3.1" to no avail. I have downloaded them from the internet and followed what instructions I could understand to install the newer versions but it keeps saying that I have the older ones. (I'm not sure if I can post direct links here, if I can let me know and I'll post where I got them from).
What have I been doing wrong? How can I fix this?
I am currently running Linux Mint.
Thanks for any answer in advance.
Due to a long-standing unresolved Debian bug report, GNU Make remained the age-old 3.81 in Debian for a very long time, and as a consequence, in Debian-based distributions such as Ubuntu and Mint.
The latest Debian release, Jessie, has upgraded to 4.0, so Debian-based distributions will have that upgrade. However, it is better to use 4.1.
This has been discussed many times on the GNU Make mailing list and elsewhere.
So to get a newer version, you must compile it from scratch.
This is easy:
Install the required packages (gcc, make and such).
Open up a shell (if you're using the GUI, a terminal window).
Type the following commands (or something equivalent, e.g. you can use curl instead of wget):
cd /tmp
wget http://ftp.gnu.org/gnu/make/make-4.1.tar.gz
tar xvf make-4.1.tar.gz
cd make-4.1/
./configure
make
sudo make install
cd ..
rm -rf make-4.1.tar.gz make-4.1
Now, make 4.1 is in /usr/local/bin/make.
You can verify it is there with whereis make.
You can make it your default make by prefixing /usr/local/bin to your $PATH variable in your shell startup file; for instance, in .profile or .bashrc if you use the bash shell.
Don't try to install a self-compiled make (or anything else that doesn't come from the distribution's package manager) into /bin or /usr/bin; doing that will confuse your package manager.

apt-get for Cygwin?

Is there any apt-get-like program for use with Cygwin?
I already tried cyg-apt but when I try I get this error:
cyg-apt: downloading: http://cygwin.mirrors.pair.com/setup-2.bz2
cyg-apt: downloading: http://cygwin.mirrors.pair.com/setup-2.ini
cyg-apt: bad URL http://cygwin.mirrors.pair.com/setup-2.ini, exiting.
Best I have ever used:
apt-cyg package manager
You can do this using Cygwin’s setup.exe from Windows command line. Example:
cd C:\cygwin64
setup-x86_64 -q -P wget,tar,gawk,bzip2,subversion,vim
For a more convenient installer, you may want to use the
apt-cyg package manager. Its syntax is
similar to apt-get, which is a plus. For this, follow the above steps and then
use Cygwin Bash for the following steps:
wget rawgit.com/transcode-open/apt-cyg/master/apt-cyg
install apt-cyg /bin
Now that apt-cyg is installed. Here are a few examples of installing some
packages:
apt-cyg install nano
apt-cyg install git
apt-cyg install ca-certificates
Update: you can read the more complex answer, which contains more methods and information.
There exists a couple of scripts, which can be used as simple package managers. But as far as I know, none of them allows you to upgrade packages, because it’s not an easy task on Windows since there is not possible to overwrite files in use. So you have to close all Cygwin instances first and then you can use Cygwin’s native setup.exe (which itself does the upgrade via “replace after reboot” method, when files are in use).
apt-cyg
The best one for me. Simply because it’s one of the most recent. It works correctly for both platforms - x86 and x86_64. There exists a lot of forks with some additional features. For example the kou1okada fork is one of improved versions.
Cygwin’s setup.exe
It has also command line mode. Moreover it allows you to upgrade all installed packages at once.
setup.exe-x86_64.exe -q --packages=bash,vim
Example use:
setup.exe-x86_64.exe -q --packages="bash,vim"
You can create an alias for easier use, for example:
alias cyg-get="/cygdrive/d/path/to/cygwin/setup-x86_64.exe -q -P"
Then you can for example install the Vim package with:
cyg-get vim
you can always make a bash alias to setup*.exe files in $home/.bashrc
cygwin 32bit
alias cyg-get="/cygdrive/c/cygwin/setup-x86.exe -q -P"
cygwin 64bit
alias cyg-get="/cygdrive/c/cygwin64/setup-x86_64.exe -q -P"
now you can install packages with
cyg-get <package>
This got it working for me:
curl https://raw.githubusercontent.com/transcode-open/apt-cyg/master/apt-cyg > \
apt-cyg && install apt-cyg /bin
No. The only officially supported tool for downloading and updating Cygwin packages is the setup.exe file you used for the initial install, although that can be invoked with command line arguments to help the process.
From that same page:
The basic reason for not having a more full-featured package manager is that such a program would need full access to all of Cygwin's POSIX functionality. That is, however, difficult to provide in a Cygwin-free environment, such as exists on first installation. Additionally, Windows does not easily allow overwriting of in-use executables so installing a new version of the Cygwin DLL while a package manager is using the DLL is problematic.
You can use Chocolatey to install cyg-get and then install your packages with it.
For example:
choco install cyg-get
Then:
cyg-get install my-package

when using CPAN in linux ubuntu should I run it using sudo / as root or as my default user

I get errors like this
Running make install
Prepending blib/arch and blib/lib of 17 build dirs to PERL5LIB; for 'install'
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
ERROR: Can't create '/usr/local/man/man3'
Do not have write permissions on '/usr/local/man/man3'
You may have to su to root to install the package
(Or you may want to run something like
o conf make_install_make_command 'sudo make'
Will I still be able to run the software / library's that perl / CPAN installs as a my default user.
What is the best practice when working with CPAN / Perl on Debian like systems.
You should run the cpan command as your normal user. You have two choices:
Install modules into a directory under your home dir. local::lib will help you set that up.
Configure cpan to use sudo during the install phase. You do that by starting the cpan shell and typing:
o conf make_install_make_command 'sudo make'
o conf mbuild_install_build_command 'sudo ./Build'
o conf commit
The first line configures MakeMaker to use sudo. The second line does the same for Module::Build. The third line saves the changes.
If you want to install your modules for your own use, then you should be running it as yourself. Use local::lib to set up your environment variables so that this works nicely. You may wish to look at cpan minus as an alternative to the default cpan installer.
You may also wish to consider using perlbrew to install a newer version of perl that is completely independent from the system perl.
If you want to install them system wide, then I recommend (since you have tagged this ubuntu) looking at dh-make-perl to produce .deb files that you can install and uninstall with dpkg.
If you want to install modules as a non-root user, you can configure your cpan to use an install base:
makepl_arg [INSTALL_BASE=/home/nelaar/perl]
mbuildpl_arg [--install_base=/home/nelaar/perl]
And set PERL5LIB accordingly to /home/nelaar/perl/lib/perl5.

Resources