(Useful) Bash Commands
Command | What it does | Usage Example | Use case | References | Notes |
---|---|---|---|---|---|
find | Finds files by filename | find image.png | Looking for specific files in node libraries | ||
grep | Finds specific text in a a specific file | grep some_text index.js | search for code references inside a specific file | Reference (opens in a new tab) | |
grep to a file | Copy results of a grep search into a text file | grep some_text index.js > grep_result.txt | If the grep results are too large to properly analyze, such as grepping in a log file, dump into a text file for ease of use | Can also use the 'pipe' instead of the 'right carrot' > to 'pipe' out text to a file, it just doens't work in this markdown syntax for reasons only I know, or you can look at the code in github (opens in a new tab) and you'll get what I mean. Or peek the raw code (opens in a new tab) | |
touch | Creates a new file | touch blah.txt | While working in Bash, if you need to create a placeholder file quickly, use this command | Reference (opens in a new tab) | Typically I use this when writing a new app and need an index.js file to get started, I will type touch index.js and can write a quick hello world script using VIM and run the app. |
top | Shows list of all running services | top | If your app is running slow, type top to see if any processes are eating up too much CPU, it could even be your app. Find the PID (process id) and kill it. | See kill command below to actually kill a process | |
kill | Kills a specific process | kill 9999 | If you need to stop a specific process |