Most Useful Linux Putty Commands

In this post am going to share few most useful linux putty commands.

Unable to start MongoDB. ERROR: address already in use.

killall mongod
should kill the other process, if you have another kind of process bound to that port you could find it with netstat | grep 27017

MongoDB Config file Location:


Redis Config file Location:


Remove directory:

rm -rf foldername/

Change folder permission:

chmod -R 777 /var/www/bin

Move files from server to server

scp -r user@server1:/var/www/html/ user@server2:/var/www/html/

MYSQL Backup

mysqldump -u root -p mydb --routines mydb.sql

mysqldump -u root -p mydb | gzip > /var/www/html/mydb552015.sql.gz mysqldump -u root -p mydb --ignore-table=mydb.tableName | gzip > /var/www/html/mydbbackup.sql.gz

Permanently enable the global event scheduler:

add this line: event_scheduler=on to my.cnf inside /etc folder

Install mcrypt:

sudo yum install php-mcrypt* Restart Apache: sudo service httpd restart

View all background thread

ps -ef

Force Kill

kill -9 PID

MYSQL Create User and Grant permissions

grant all privileges on dsdocs.* to 'demanddocs'@'localhost' identified by "F$ww2371";

Run redis-server in background

Since Redis 2.6 it is possible to pass Redis configuration parameters using the command line directly. This is very useful for testing purposes.
redis-server --daemonize yes

Check if the process started or not:
ps aux | grep redis-server

PM2 Start an App:

/app/file/path/ pm2 start app.js --name="myApp" -i 4  

PM2 Start Command:

pm2 start app.js --name="mydb" -i 4

Export MongoDB:

sudo mongoexport --host= --port=27127 --db mydb -c activities --out mydb.json
Exported data will store in /root folder.
Please change your IP and Port

Search file by name in current directory including sub directory:

find . -name mydb.json

Category: Linux
About The Author