Automate your work with simple Shell Script

Shell Script to run root with password in one small script line?

Please check this script, it will help you to run commands directly.
Sometime it becomes every important to run commands direclty with root user.

#!/bin/sh
passwd="enter your password here"
echo "enter command to run with root"
read command
echo $passwd | sudo -S $command

=======================

Install Mongodb in to your server using this script in 5mins

#!/bin/sh

#import key
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 0C49F3730359A14518585931BC711F9BA15703C6
#Adding Repo
echo "deb [ arch=amd64,arm64 ] http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.4 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-3.4.list`
#Database update for new repo
apt-get update
#command to install mongodb
apt-get install -y mongodb-org
#start service
service mongod start
#restart
service mongod restart

Important commands for mongodb

How to access mongodb remotely

vim /etc/mongo.conf

Comment

# bindIp: 127.0.0.1

service mongod restart

## Create User

mongo
use admin

db.createUser( { user: Important commands for mongodb"advancetracker", pwd: "B6g3940huwMB1Vp", roles: [ { role: "userAdminAnyDatabase", db: "admin" } ] })

## connect mongodb remotely using this comment

mongo --host 192.168.10.18 --port 27017 -u advancetracker -p --verbose --authenticationDatabase admin

techouse

I love helping beautiful people like you. I love hanging out with my dogs.

You may also like...

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

× How can I help you?