
Originally Posted by
Valuehosted
Thank you Dalem, that did the trick!
I put these in /usr/bin/ is that ok or is it a NONO? This way I can type the commands from anywhere and none of them are server critical - just shorter versions of commands that I use on a daily basis.
I normally create a bin directory in my user's home directory for my homemade scripts, that are specific to my needs, and then add that to my path. Add the following to your .bashrc:
Code:
export PATH="/bin:/sbin:/home/USERNAME/bin:$PATH"
make sure you replace USERNAME with your linux username. Once that is done type:
source ~/.bashrc
to set the new path. Then you can create your bin directory:
Code:
cd ~
mkdir bin
cd bin
touch myscript
chmod 770 myscript
vim myscript
I create my scripts with:
at the top so I don't have to type sh in front of the command. For example:
Code:
#!/bin/bash
netstat -ntu | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -nr |more
You should be able to then call:
from anywhere on CLI and it will exec your commands inside. Just don't name your commands the same as other commands in /bin, /sbin etc etc.
Hope that helps.