Bash Script devopsroles.com

Useful shell commands

In this tutorial, I will write about Useful shell commands. Tips and trick about kill process, How to remove ssh host and SCP command. Bash script the essential for DevOps Roles.

Useful shell commands

Kill Process

ps aux | grep <keyword> | grep -v grep | awk '{ print "kill -9", $2 }' | sh

For example, How to kill running Tilix process as the picture below

Kill the process Tilix

[huupv@huupv devopsroles]$ ps aux | grep tilix | grep -v grep | awk '{ print "kill -9", $2 }' | sh

How to remove ssh host

ssh-keygen -R <IP address/host_name>

SCP command

Upload to server

scp -i <ssh key private file> -r <local directory/file> <user>@<remote server>:<remote directory/file>

Download from server

scp -i <ssh key private file> -r <user>@<remote server>:<remote directory/file> <local directory/file>

Conclusion

Thought the article, How to use “Useful shell commands” as above. I hope will this your helpful. Thank you for reading the DevopsRoles page!

Leave a Reply

Your email address will not be published. Required fields are marked *

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