Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

LINUX ASSIGNMENT [] - indicates a placeholder for a command that needs to be executed either directly or using command substitution. Write a bash function

LINUX ASSIGNMENT
[] - indicates a placeholder for a command that needs to be executed either directly
or using command substitution.
Write a bash function called mystats(), which reports the following:
Print the following text or results of commands to standard output.
(HINT: Use command substitution when output for a command is on the same line
as other text.)
"[username], welcome to mystats for [your host name here]"
"Current date/time is [current date/time]"
"================================================"
"Uptime report"
[show system up time using the command uptime]
"================================================"
"Your currently running processes"
[show the running processes for the username]
"================================================"
"Disk Usage Report"
[show a human readable disk usage report using the command df -h]
"================================================"
"Have a great day!"
"================================================"
Tips:
Test the function by placing it in your .bashrc or .bash_profile.
Blackboard submission information:
After testing, create a directory called stats.
Create a file called mystats.sh which contains your function.
Create a tarball of the stats directory and upload to Blackboard
Example output when I run the function at the command line:
$ mystats
michelle, welcome to mystats for michelle-VirtualBox
Current date/time is Tue Sep 11 16:16:21 CDT 2018
================================================
Uptime report
16:16:21 up 9:44, 1 user, load average: 0.40, 0.21, 0.08
================================================
Your currently running processes
avahi 521 1 0 06:31 ? 00:00:00 avahi-daemon: running [michelle-VirtualBox.local]
michelle 1341 1 0 06:32 ? 00:00:00 /lib/systemd/systemd --user
michelle 1342 1341 0 06:32 ? 00:00:00 (sd-pam)
michelle 1355 1 0 06:32 ? 00:00:00 /usr/bin/gnome-keyring-daemon --daemonize --login
michelle 1359 1338 0 06:32 tty2 00:00:00 /usr/lib/gdm3/gdm-x-session --run-script env GNOME_SHELL_SESSION_MODE=ubuntu gnome-session --session=ubuntu
michelle 1361 1359 0 06:32 tty2 00:02:07 /usr/lib/xorg/Xorg vt2 -displayfd 3 -auth /run/user/1000/gdm/Xauthority -background none -noreset -keeptty -verbose 3
michelle 1369 1341 0 06:32 ? 00:00:00 /usr/bin/dbus-daemon --session --address=systemd: --nofork --nopidfile --systemd-activation --syslog-only
michelle 1373 1359 0 06:32 tty2 00:00:00 /usr/lib/gnome-session/gnome-session-binary --session=ubuntu
michelle 1452 1 0 06:32 ? 00:00:00 /usr/bin/VBoxClient --clipboard
michelle 1453 1452 0 06:32 ? 00:00:00 /usr/bin/VBoxClient --clipboard
michelle 1463 1 0 06:32 ? 00:00:00 /usr/bin/VBoxClient --display
michelle 1464 1463 0 06:32 ? 00:00:00 /usr/bin/VBoxClient --display
michelle 1468 1 0 06:32 ? 00:00:00 /usr/bin/VBoxClient --seamless
michelle 1469 1468 0 06:32 ? 00:00:00 /usr/bin/VBoxClient --seamless
michelle 1473 1 0 06:32 ? 00:00:00 /usr/bin/VBoxClient --draganddrop
michelle 2470 2460 0 11:02 pts/0 00:00:00 bash
michelle 16991 2470 0 16:16 pts/0 00:00:00 ps -ef
michelle 16992 2470 0 16:16 pts/0 00:00:00 grep --color=auto michelle
================================================
Disk usage report
================================================
Filesystem Size Used Avail Use% Mounted on
udev 1.9G 0 1.9G 0% /dev
tmpfs 395M 1.6M 393M 1% /run
/dev/sda1 20G 8.5G 11G 46% /
tmpfs 2.0G 0 2.0G 0% /dev/shm
/dev/loop0 144M 144M 0 100% /snap/chromium/412
/dev/loop1 35M 35M 0 100% /snap/gtk-common-themes/319
/dev/loop2 2.4M 2.4M 0 100% /snap/gnome-calculator/199
/dev/loop3 15M 15M 0 100% /snap/gnome-logs/37
/dev/loop4 3.8M 3.8M 0 100% /snap/gnome-system-monitor/45
/dev/loop5 141M 141M 0 100% /snap/gnome-3-26-1604/59
/dev/loop6 21M 21M 0 100% /snap/gnome-logs/25
/dev/loop7 13M 13M 0 100% /snap/gnome-characters/69
/dev/loop8 2.3M 2.3M 0 100% /snap/gnome-calculator/222
/dev/loop9 141M 141M 0 100% /snap/gnome-3-26-1604/70
/dev/loop10 13M 13M 0 100% /snap/gnome-characters/103
/dev/loop11 87M 87M 0 100% /snap/core/4917
/dev/loop12 13M 13M 0 100% /snap/gnome-characters/117
/dev/loop13 144M 144M 0 100% /snap/chromium/396
/dev/loop14 88M 88M 0 100% /snap/core/5328
/dev/loop15 140M 140M 0 100% /snap/gnome-3-26-1604/64
/dev/loop16 3.8M 3.8M 0 100% /snap/gnome-system-monitor/54
/dev/loop17 15M 15M 0 100% /snap/gnome-logs/40
/dev/loop18 87M 87M 0 100% /snap/core/5145
/dev/loop19 144M 144M 0 100% /snap/chromium/458
/dev/loop20 3.8M 3.8M 0 100% /snap/gnome-system-monitor/51
/dev/loop21 2.4M 2.4M 0 100% /snap/gnome-calculator/180
michelle 466G 188G 279G 41% /media/sf_michelle
tmpfs 395M 16K 395M 1% /run/user/120
tmpfs 395M 36K 395M 1% /run/user/1000
================================================
Have a great day!
================================================

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intelligent Information And Database Systems 6th Asian Conference Aciids 2014 Bangkok Thailand April 7 9 2014 Proceedings Part I 9 2014 Proceedings Part 1 Lnai 8397

Authors: Ngoc-Thanh Nguyen ,Boonwat Attachoo ,Bogdan Trawinski ,Kulwadee Somboonviwat

2014th Edition

3319054759, 978-3319054759

More Books

Students also viewed these Databases questions

Question

2. What is the business value of security and control?

Answered: 1 week ago