Useful Linux / Unix Commands


Useful Unix Commands for Debugging


This is my list of commands found useful while debugging issues in logs, servers, process, etc., With regard to the list, will share the commands which I use in the real world scenarios..



Used to get the list of “open files” in linux and all the processes that opened them. I find them useful to search / find the processes that are listening on a given Port.          

            lsof -i tcp:8443

This will give the Process ID, service name which listens on the port (8443) and much more.. Particularly useful to debug different services running on the same server. 



Useful to find files on various search attributes like name & type.           

            find . -name "*.xml"

This above sample command will find all files which ends with .xml notation.



Useful to list out all the network socket connections on a system.           

            netstat -at

I find this very useful to find all the TCP port connections that are open.



Very useful in searching strings in log files           

            grep -r "<string>"

This is recursively find the string in all the files that are present in the present location.



Useful in replacing text strings in a given file.

            sed 's/localhost/' server.log

The above command will replace the word “localhost” with “” for all the matches.



This command is like a data pipe. Reads the data from input and passes it to the following command.  

           find . -name "*.xml" | xargs grep "linux"

In the above example, find utility finds all the files with .xml extension and list the files. xargs utility reads them and pass it to grep utility. Finally grep searches the given text “linux” in the list of files and only outputs the files which contains the search string in their content. 



This is one of the powerful utility and most commonly used. In the world of APIs, we would often come across cases to quickly invoke a service to examine the response or API connectivity, etc.,


Using the following command we can HTTP POST request.. Much more powerful options are available to play with HTTP header values, content types, proxy options, etc., explore…       

            curl -X POST


Want to quickly copy an artifact or a log file from one node to another, without downloading to your host system. 

            scp <file_name> <username>@<destination-host>:<folder> 

The above command will copy the local file from Server A to the remote system in the destination folder given.       

Happy Coding..!!