Linux command exercise: Disk Management related Exercises

Source: Internet
Author: User

Practice A

1. Write a script

1) display a menu to the user

d| D) show disk usages.

m| M) show memory usages.

s| S) show swap usages.

*) quit.

2) Display the appropriate content when the user has given the option:

Extended:

When the user chooses to complete, displays the corresponding information, does not exit, but lets the user select again, again

Displays the appropriate content, except that the user uses quit.

#!/bin/bash

#program:

#练习磁盘管理相关脚本编写

#history Donggen 2016-11-03-10:19

Path=http://www.11.qixoo.com/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bash

Export PATH

Cat << EOF

d| D) show disk usages.

m| M) show memory usages.

s| S) show swap usages.

*) quit.

Eof

Read-p "Your Choice:" Choice

while [$CHOICE! = "Quit"]; Do

Case $CHOICE in

d| D

DF-PH;;

m| M

Free-m;;

s| S

free-m | grep ' Swap ';;

*)

echo "Unknown ...";;

Esac

Read-p "Again,your Choice:" Choice

Done

[test]#./showsystem.sh

d| D) show disk usages.

m| M) show memory usages.

s| S) show swap usages.

*) quit.

Your choice:d

Filesystem Size used Avail use% mounted on

/dev/sda2 4.9G 1.5G 3.1G 33%/

Tmpfs 947M 0 947M 0%/dev/shm

/DEV/SDA1 2.0G 61M 1.8G 4%/boot

/dev/sda3 3.9G 73M 3.6G 2%/Home

/dev/sda7 2.0G 35M 1.8G 2%/tmp

/dev/sda5 2.9G 1.7G 1.2G 59%/usr

Again,your choice:d

Filesystem Size used Avail use% mounted on

/dev/sda2 4.9G 1.5G 3.1G 33%/

Tmpfs 947M 0 947M 0%/dev/shm

/DEV/SDA1 2.0G 61M 1.8G 4%/boot

/dev/sda3 3.9G 73M 3.6G 2%/Home

/dev/sda7 2.0G 35M 1.8G 2%/tmp

/dev/sda5 2.9G 1.7G 1.2G 59%/usr

Again,your choice:s

swap:1999 0 1999

Again,your choice:n

Unknown.

Again,your choice:m

Total used free shared buffers Cached

mem:1893 181 1711 0 42 62

-/+ buffers/cache:76 1816

swap:1999 0 1999

Again,your Choice:quit

[test]#

Linux command exercise: Disk Management related Exercises

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.