Homework 11: Further Practice

Due Thursday, April 26, by 10:30 AM


As usual, place the commands you used to solve each of the 5 problems into a file called homework11. This is intended as practice, since this week's lecture topic is not really well-suited to a matching homework assignment.
  1. Write a command that prints out the number of directories listed in the PATH variable. Directories are separated by colons, but there is not a leading or trailing colon.
  2. Create a command that prints out the names of the 10 largest files in the current directory, in order from largest to smallest, with human-readable sizes.
  3. Make 100 files, numbered 1-100, each containing a single word. You might want to test this in a directory other than your home directory (make one for the purpose). A loop will work here, but mkdir and {} ranges will also work.
  4. Running "service --status-all" will show the status of all services on isoptera. Are more service running (+) or stopped (-)? Have your command print the number of each. It does not need to determine which number is greater.
  5. /proc/interrupts will show what each interrupt on the system is used for, and the number of interrupts handled by each processor. On a computer without many processors, it looks like this:
               CPU0       CPU1       
      0:    7449584    5652603   IO-APIC-edge      timer
      1:      18591      16694   IO-APIC-edge      i8042
      8:          1          0   IO-APIC-edge      rtc0
      9:     102720     102820   IO-APIC-fasteoi   acpi
     12:     220865     200951   IO-APIC-edge      i8042
     14:     113535     110905   IO-APIC-edge      ata_piix
     15:          0          0   IO-APIC-edge      ata_piix
     16:          0          0   IO-APIC-fasteoi   uhci_hcd:usb3, yenta
     17:          1          1   IO-APIC-fasteoi   firewire_ohci, uhci_hcd:usb4
     18:          0          0   IO-APIC-fasteoi   mmc0, uhci_hcd:usb7, r592, r852
     19:          0          0   IO-APIC-fasteoi   ehci_hcd:usb6
     20:         72         66   IO-APIC-fasteoi   uhci_hcd:usb1
     21:          0          0   IO-APIC-fasteoi   uhci_hcd:usb2
     22:          1          2   IO-APIC-fasteoi   ehci_hcd:usb5
     23:          0          0   IO-APIC-fasteoi   i801_smbus
     40:          0          0   PCI-MSI-edge      PCIe PME
     41:          0          0   PCI-MSI-edge      PCIe PME
     42:          0          0   PCI-MSI-edge      PCIe PME
     43:          0          0   PCI-MSI-edge      PCIe PME
     44:          0          0   PCI-MSI-edge      PCIe PME, pciehp
     45:          0          0   PCI-MSI-edge      PCIe PME
     46:         30          2   PCI-MSI-edge    
     47:     431806     422206   PCI-MSI-edge      ahci
     48:     590550     480638   PCI-MSI-edge      snd_hda_intel
     49:       2126    8808762   PCI-MSI-edge      iwl3945
     50:      64579      48729   PCI-MSI-edge      nvidia
    NMI:       8278       8520   Non-maskable interrupts
    LOC:    5684955    6683330   Local timer interrupts
    SPU:          0          0   Spurious interrupts
    PMI:       8278       8520   Performance monitoring interrupts
    IWI:          2          0   IRQ work interrupts
    RTR:          0          0   APIC ICR read retries
    RES:    2932614    2979736   Rescheduling interrupts
    CAL:       1542       1783   Function call interrupts
    TLB:     620032     613178   TLB shootdowns
    TRM:          0          0   Thermal event interrupts
    THR:          0          0   Threshold APIC interrupts
    MCE:          0          0   Machine check exceptions
    MCP:        766        766   Machine check polls
    HYP:          0          0   Hypervisor callback interrupts
    ERR:          0
    MIS:          0
                    
    On isoptera, this file is made nearly unreadable by the large number of CPUs on the system. Print out the file, without any of the CPU columns, but with the interrupt number (number before the colon), and the interrupt use (the text at the end) still intact and lined up correctly.
Turn in your homework by creating a file named "homework11" with no extension in your home directory, with permissions set so that only you can view the file. This assignment is worth 35 points, 5 from correct naming, 5 from correct permissions, and 5 from each of the problems above. As a reminder, you can set the permissions correctly with this line:
chmod 600 homework11