Following on from my post last night about WGet and YouTube-DL, we’ve learned how to enable Bash on Windows 10. Now, this is an extremely useful thing to do, because it empowers you to use commands that are not native on Windows (or as a Linux fanboy would say, M$).
So, just so you all get a better understanding of the improved functionality of bash, we’re going to make some comparisons and examples.
I’m not going into detail – there is far too much to cover.
Network Monitoring – netstat.
On a windows box, to see current usage per process, the easiest method is to run:
netstat -a -b
Which will return a string similar to this:
[chrome.exe] TCP 192.168.0.15:52581 22.214.171.124:https ESTABLISHED [chrome.exe] TCP 192.168.0.15:52971 126.96.36.199:https ESTABLISHED [chrome.exe] TCP 192.168.0.15:52972 188.8.131.52:https ESTABLISHED
Rather simple to do, and allows you to see what process is responsible for what traffic, and what protocol it is using.
GNU + Linux supports netstat, but has a complete different syntax for the commands. To see connections with the process, simply run the following:
root@DESKTOP-3O8E0L8:/home/nanky# netstat -p Active Internet connections (w/o servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
It returns a little more intuitive data (in my opinion). For example, we can then dictate by interface the data we wish to see by adding -i to the command:
This is an advantage over Windows. But let us get to the killer feature:
netstat -a -v -w -r
The following flags are used:
-a, --all Show both listening and non-listening sockets. With the --interfaces option, show interfaces that are not up --verbose , -v Tell the user what is going on by being verbose. Especially print some useful information about unconfigured address families. --wide , -W Do not truncate IP addresses by using output as wide as needed. This is optional for now to not break existing scripts.
Start by issuing the following command:
sudo apt-get install bmon
Once installed, you should always look at the man page:
Using bmon allows you to view the usage and statistics per interface, such as:
Of course, there are other tools to conquer these tasks out there – I would strongly suggest you read this post outlining other sysadm tools available to you.
As opposed to the clunky Windows Task Scheduler, Linux uses Cron Jobs to execute tasks.
You’ll need to have bash running for CronJobs to work on Windows.
Pretty self explanatory, create a script or command you want to execute, and add it to the scheduler. Here it the default example provided to you:
# For example, you can run a backup of all your user accounts # at 5 a.m every week with: # 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
You guessed it, the stars represent time:
# m h dom mon dow command
The tar -zcf portion is the code it executes. Pretty self explanatory. 7:30am, every week for example:
crontab -e 30 7 * * 1 /my/command/to/execute/yo.sh
You get this. Easy stuff.
Task Maintenance – task.
Okay so this one’s not so critical, I just love this application. TaskWarrior. Tasks is a super simple yet super powerful CLI driven task manager.
sudo apt-get install task
There we go, you’ve installed it. Let’s add our first task:
nanky@DESKTOP-3O8E0L8:~$ task P:H due:31 project personal add edit this css
Now let’s view our task:
ID Age P Due Description Urg 2 26s H 4w edit this css
Pretty simple method to view the task at hand. Now we want to view the task with the ID ‘2’:
task id 2
Which will return the following:
Name Value ID 2 Description change task 1 Status Pending Entered 2017-09-27 23:50:56 (1min) Last modified 2017-09-27 23:50:56 (1min) Virtual tags PENDING READY UDA UNBLOCKED LATEST PRIORITY UUID 34c4cf80-a857-4123-a463-4c4bcc44b591 Urgency 6 Priority H UDA priority.H 1 * 6 = 6 ------ 6
You can sync your tasks across multiple devices, too! Just view their usage examples, and you’ll get the feel for how complex you can make the tool.
Lastly, text editing.
I cannot live without GNU Nano. Yes, you could use Vim but the simplicity of Nano amazes me.
For example, let’s edit a file and close it, all without needed to locate it, open, manually save and confirm dialogs:
It is literally that simple, and you can interact with files stored on Windows natively.
You pretty much get the picture; CLI > GUI.
- 20 Command Line Tools to Monitor Linux Performance
- Best Linux Command-Line Tools For Network Engineers
- Top 5 Linux Utilities for Network Engineers