Undo sudo ln -sf - shell

I was having an issue pushing a git commit, so I ran sudo ln -sf /usr/bin/nodejs /usr/local/bin/node now when running node -v or nodejs -v terminal tells me -bash: node: command not found.
How can I 'undo' the sudo ln -sf

Try this:
sudo unlink /usr/bin/nodejs

Related

Building and Installing BZip2 with shared library dylib on MacOS

'Trying to build/install BZip2 on MacOS (10.13.4 - High Sierra), but all the instructions I've been able to find [including from the README] have me at the following:
wget -c https://sourceware.org/pub/bzip2/bzip2-1.0.8.tar.gz
tar -zxf bzip2-1.0.8.tar.gz
cd bzip2-1.0.8
sudo make install PREFIX=/usr/local
This installs the package without the shared library file with .dylib extension in the ./lib directory. The included instructions in the package are for Linux environment.
How do I install the shared libraries?
It turns out that doing this requires an update to the Makefile.
The package [bzip2 v1.0.8] comes with a Makefile-libbz2_so file that is for creating shared library files for Linux. To do same for MacOS a seperate Makefile is required.
Below are the updated instructions which worked. Follow the link for Makefile-libbz2_dylib for contents of the Makefile.
# Download BZip2
wget -c https://sourceware.org/pub/bzip2/bzip2-1.0.8.tar.gz
# Extract and enter directory
tar -zxf bzip2-1.0.8.tar.gz
cd bzip2-1.0.8
# create variable
export PREFIX="/usr/local"
# install - change PREFIX is required
sudo make install PREFIX=$PREFIX
# Make dynamic libraries for MACOS
wget -c https://gist.githubusercontent.com/obihill/3278c17bcee41c0c8b59a41ada8c0d35/raw/3bf890e2ad40d0af358e153395c228326f0b44d5/Makefile-libbz2_dylib
make -f Makefile-libbz2_dylib
# Do below only if your PREFIX is not /usr/local
# Create symlinks for bin
sudo ln -s $PREFIX/bin/bunzip2 /usr/local/bin/
sudo ln -s $PREFIX/bin/bzcat /usr/local/bin/
sudo ln -s $PREFIX/bin/bzcmp /usr/local/bin/
sudo ln -s $PREFIX/bin/bzdiff /usr/local/bin/
sudo ln -s $PREFIX/bin/bzegrep /usr/local/bin/
sudo ln -s $PREFIX/bin/bzfgrep /usr/local/bin/
sudo ln -s $PREFIX/bin/bzgrep /usr/local/bin/
sudo ln -s $PREFIX/bin/bzip2 /usr/local/bin/
sudo ln -s $PREFIX/bin/bzip2recover /usr/local/bin/
sudo ln -s $PREFIX/bin/bzless /usr/local/bin/
sudo ln -s $PREFIX/bin/bzmore /usr/local/bin/
# Create symlinks for lib
sudo ln -s $PREFIX/lib/libbz2.a /usr/local/lib/
sudo ln -s $PREFIX/lib/libbz2.dylib /usr/local/lib/
# Create symlinks for include
sudo ln -s $PREFIX/include/bzlib.h /usr/local/include/
If you don't have wget on your Mac, you can find instructions to set it up on this community post.
Inspiration for Makefile from here and here.

How to easily install and uninstall docker on MacOs

My question is
How to easily install docker to have it available in terminal and how to uninstall docker on osx?
To Install:
Go Here
Click the "Get Docker" or "Get Docker Desktop for Mac (Stable)" button.
Double-click the DMG
Drag Docker into Applications
Open Docker
Open Terminal after install and docker will be available. Docker should auto-launch on subsequent startups and be available on command line.
To Uninstall:
Click On Docker Icon
Select Preferences
Select Bug Icon for the Troubleshoot menu (Bomb Icon in older Docker UI)
Select Uninstall
Install
To install Docker is easy. Download the .dmg, open it, drag and drop the Docker app to Applications, then run Docker Desktop for Mac. Unfortunately, it sprawls gunk all over your Mac (see uninstall).
Uninstall
If Docker starts, you can use the Docker Desktop app to uninstall. If that doesn't work, you will have to dive into the command line. For a complete uninstall as of 27-Dec-2020, type the following into the terminal:
(Be aware, this removes any Docker virtual machines and images too!)
sudo rm -Rf /Applications/Docker.app
sudo rm -f /usr/local/bin/docker
sudo rm -f /usr/local/bin/docker-machine
sudo rm -f /usr/local/bin/com.docker.cli
sudo rm -f /usr/local/bin/docker-compose
sudo rm -f /usr/local/bin/docker-compose-v1
sudo rm -f /usr/local/bin/docker-credential-desktop
sudo rm -f /usr/local/bin/docker-credential-ecr-login
sudo rm -f /usr/local/bin/docker-credential-osxkeychain
sudo rm -f /usr/local/bin/hub-tool
sudo rm -f /usr/local/bin/hyperkit
sudo rm -f /usr/local/bin/kubectl.docker
sudo rm -f /usr/local/bin/vpnkit
sudo rm -Rf ~/.docker
sudo rm -Rf ~/Library/Containers/com.docker.docker
sudo rm -Rf ~/Library/Application\ Support/Docker\ Desktop
sudo rm -Rf ~/Library/Group\ Containers/group.com.docker
sudo rm -f ~/Library/HTTPStorages/com.docker.docker.binarycookies
sudo rm -f /Library/PrivilegedHelperTools/com.docker.vmnetd
sudo rm -f /Library/LaunchDaemons/com.docker.vmnetd.plist
sudo rm -Rf ~/Library/Logs/Docker\ Desktop
sudo rm -Rf /usr/local/lib/docker
sudo rm -f ~/Library/Preferences/com.docker.docker.plist
sudo rm -Rf ~/Library/Saved\ Application\ State/com.electron.docker-frontend.savedState
sudo rm -f ~/Library/Preferences/com.electron.docker-frontend.plist
By command line
INSTALL
Install with
brew install --cask docker
And run docker by
open /Applications/Docker.app
(or by macOs bottom menu> launchpad > docker - on first run docker will ask you about password)
Thats all :)
UNINSTALL
Type brew uninstall --cask docker
thats all :)
To clean everything (including images/containers) execute below commands:
sudo rm -Rf /Applications/Docker
sudo rm -f /usr/local/bin/docker
sudo rm -f /usr/local/bin/docker-machine
sudo rm -f /usr/local/bin/docker-compose
sudo rm -f /usr/local/bin/docker-credential-osxkeychain
sudo rm -Rf ~/.docker
sudo rm -Rf $HOME/Library/Containers/com.docker.docker # here we delete stored images
To install: brew install --cask docker
To uninstall: brew uninstall --cask docker

How do I add an updated ghostscript to AWS EC2 Instance with Amazon Linux AMI

How can I get 9.20 - the current version?
(I'm doing the research and will answer as I finish.)
This answer is an update to the now stale answer here, with a few extra details and a reference to the current repo location.
This may be obvious to the more experienced, but this is intended to help those less experienced with CLI/make/gcc who just need gs.
First set up gcc-c++ if you haven't already [Are all packages necessary? Last two seem to be not needed.]:
sudo yum install -y gcc gcc-c++ compat-gcc-32 compat-gcc-32-c++
Then download, make and install ghostscript:
wget https://github.com/ArtifexSoftware/ghostpdl-downloads/releases/download/gs920/ghostscript-9.20.tar.gz
tar -zxvf ghostscript-9.20.tar.gz
cd ghostscript-9.20
./configure --prefix=/usr --enable-dynamic --disable-compile-inits --with-system-libtiff
make
make so
sudo make install
sudo chmod go+w /usr/include/ghostscript/
sudo make soinstall && install -v -m644 base/*.h /usr/include/ghostscript && sudo ln -v -s ghostscript /usr/include/ps
sudo ln -sfv ../ghostscript/9.20/doc /usr/share/doc/ghostscript-9.20
cd ..
wget http://sourceforge.net/projects/gs-fonts/files/latest/download?source=files --output-document=ghostscript-fonts-std-8.11.tar.gz
sudo tar -xvf ghostscript-fonts-std-8.11.tar.gz -C /usr/share/ghostscript
fc-cache -v /usr/share/ghostscript/fonts/
sudo mkdir /usr/include/ghostscript/
sudo chmod go-w /usr/include/ghostscript/
ghostscript -v
gs -v
You could put the source code on the instance and compile it.....
Met an error when ran
sudo chmod go+w /usr/include/ghostscript/
because the folder didn't exist yet.
So I did minor adjustment to the command order:
wget https://github.com/ArtifexSoftware/ghostpdl-downloads/releases/download/gs920/ghostscript-9.20.tar.gz
tar -zxvf ghostscript-9.20.tar.gz
cd ghostscript-9.20
./configure --prefix=/usr --enable-dynamic --disable-compile-inits --with-system-libtiff
make
make so
sudo make install
sudo mkdir /usr/include/ghostscript/
sudo chmod go+w /usr/include/ghostscript/
sudo make soinstall && install -v -m644 base/*.h /usr/include/ghostscript && sudo ln -v -s ghostscript /usr/include/ps
sudo ln -sfv ../ghostscript/9.20/doc /usr/share/doc/ghostscript-9.20
cd ..
wget http://sourceforge.net/projects/gs-fonts/files/latest/download?source=files --output-document=ghostscript-fonts-std-8.11.tar.gz
sudo tar -xvf ghostscript-fonts-std-8.11.tar.gz -C /usr/share/ghostscript
fc-cache -v /usr/share/ghostscript/fonts/
sudo chmod go-w /usr/include/ghostscript/
ghostscript -v
gs -v

Installing Homebrew on Macbook running El Capitan

When I run this command:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
I get the following error:
It appears Homebrew is already installed. If your intent is to reinstall you
should do the following before running this installer again:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"
The current contents of /usr/local are bin CODEOFCONDUCT.md git include lib libexec Library LICENSE.txt n share var .git .github .gitignore
However, when I run brew doctor, this error is thrown:
bash: brew: command not found
And when I try to un-install Homebrew using this script:
sudo ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"
my command prompt responds with:
Failed to locate Homebrew!
Please help.
First delete all homebrew files manually. Then reinstall Homebrew from scratch. Prefix sudo at your own discretion:
# packages
rm -rf /usr/local/Cellar
# executable
rm /usr/local/bin/brew
# meta
rm -rf /usr/local/.git
rm /usr/local/.github
rm /usr/local/.gitignore
rm /usr/local/.travis.yml
rm /usr/local/.yardopts
rm /usr/local/CODEOFCONDUCT.md
rm /usr/local/LICENSE.txt
rm /usr/local/README.md
# home
rm ~/.rvm/bin/brew
rm ~/.homebrew
rm -rf ~/Library/Caches/Homebrew
rm -rf ~/Library/Logs/Homebrew
# other
rm -rf /Library/Caches/Homebrew
# find more files to delete; delete Homebrew files only!
find / -name "*brew*"
IMPORTANT: because of permission errors upon reinstall, you may have to do one of the following steps before reinstallation; see: https://github.com/Homebrew/legacy-homebrew/issues/15138
# via: https://github.com/Homebrew/legacy-homebrew/issues/15138#issuecomment-19258042
cd /usr/local
sudo mv -v Library Library.old
# --OR--
# via: https://github.com/Homebrew/legacy-homebrew/issues/15138#issuecomment-33338868
# see: http://linuxcommand.org/man_pages/chmod1.html
cd /usr/local
chmod -R 775 Library
Reinstall Homebrew; see: http://brew.sh
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
There is a problem related to the latest version of XCode and Homebrew. Open a terminal and run:
rm -rf /usr/local/Cellar /usr/local/.git
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
If you get permission denied error use sudo. Directory /usr/local/Cellar/ is completely removed when uninstalling Homebrew, so it is safe to remove it.

Script to install Flash Player through postinst

I have created a debian package. I need to check for the Adobe Flash Player while installing this .deb. If flash player is not installed then i need to install it also. On browsing i got to know that postinst file can be used for this purpose.
The postinst file is
#!/bin/bash
echo “Stopping any Firefox that might be running”
sudo killall -9 firefox
echo “Removing any other flash plugin previously installed:”
sudo apt-get remove -y –purge flashplugin-nonfree gnash gnash-common mozilla-plugin-gnash swfdec-mozilla libflashsupport nspluginwrapper
sudo rm -f /usr/lib/mozilla/plugins/*flash*
sudo rm -f ~/.mozilla/plugins/*flash*
sudo rm -f /usr/lib/firefox/plugins/*flash*
sudo rm -f /usr/lib/firefox-addons/plugins/*flash*
sudo rm -rfd /usr/lib/nspluginwrapper
echo “Installing Flash Player 10″
#cd ~
sudo cp /home/libflashplayer.so /usr/lib/mozilla/plugins/
echo “Linking the libraries so Firefox and apps depending on XULRunner.”
sudo ln -sf /usr/lib/mozilla/plugins/libflashplayer.so /usr/lib/firefox-addons/plugins/
sudo ln -sf /usr/lib/mozilla/plugins/libflashplayer.so /usr/lib/xulrunner-addons/plugins/
# now doing some cleaning up:
sudo rm -rf libflashplayer.so
sudo rm -rf libflashplayer-10.0.32.18.linux-x86_64.so.tar.gz
But nothing is happening.
Can anyone help me to write the script to install flash player through script?
Looks like you got your $HOME path wrong:
sudo cp /home/libflashplayer.so /usr/lib/mozilla/plugins/
did you mean:
sudo cp $HOME/libflashplayer.so /usr/lib/mozilla/plugins/

Resources