Write a function named getComputerinfo that displays disk usage, memory usage, the uptime, currently logged users, and password information. (Hint, you can use free (free memory), df (free disk), uptime, w, and cat /etc/shadow) commands to complete your task
Keep answer in file1.sh
chmod file1.sh #this is to give executable permission to file
./filename.sh #this is to run the file
The answer is below:
#!/bin/sh
# Function
function getComputerinfo()
{
# Here I have used many empty echos to print some empty line between different outputs.
echo "Disk usage statistics..."
echo ""
# Displays free disk space of many drives in human readable format(with -H option)
df -H
echo ""
echo ""
echo "Free memory statistics..."
echo ""
# Displays free memory in human readable format(using -h option)
free -h
echo ""
echo ""
echo "System uptime..."
echo ""
# Displays uptime(with p option you get only uptime stats)
uptime -p
echo ""
echo ""
echo "Users logged in to system..."
echo ""
# w command to display logged in users and their info
w
echo ""
echo ""
echo "Password information(You need to enter password)"
echo ""
# All sensitive details of users are stored in /etc/shadow file which can only be accessed with super user mode
sudo cat /etc/shadow
}
getComputerinfo
Write a function named getComputerinfo that displays disk usage, memory usage, the uptime, currently logged users,...
Exercise 1: Write a shell script that loops through the /etc/passwd file one line at a time. Prepend each line with a line number followed by a colon and then a space. Example output: 1: root:x:0:0:root:/root:/bin/bash 2: daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin 3: bin:x:2:2:bin:/bin:/usr/sbin/nologin 4: sys:x:3:3:sys:/dev:/usr/sbin/nologin Exercise 2: Write a shell script that asks the user for the number of lines they would like to display from the /etc/passwd file and display those lines. Example output: How many lines of /etc/passwd would you like...
Can someone post Screenshots for this Assignment? CPT 247 Assignment Module 7-8 Complete each of the items listed below. When you have a completed item displayed on your screen, use “screen capture” or a “snipping tool” to take a picture of the item. If you are unfamiliar with “screen capture” contact your instructor ASAP Paste the picture of the item into a Word document Above each picture include the item number and give the name of the item and a...
In C++ Programming Write a program in a file named SeedFinder.cpp that finds and displays all the seeds of a integer given by the user. Let’s define a seed of an integer, n, to be a positive value that equals n when multiplied by its individual digits. For example, 23 is a seed of 138 because 23 × 2 × 3 = 138. 111 is an example of a seed of itself because 111 × 1 × 1 × 1...
Most system administrators would like to know the utilization of their systems by their users. On a Linux system, each user's login records are normally stored in the binary file /var/log/wtmp. The login records in this binary file can not be viewed or edited directly using normal Linux text commands like 'less', 'cat', etc. The 'last' command is often used to display the login records stored in this file in a human readable form. Please check the man page of...
Hello, please help with the following, you're tasked with writing a shell script named “rpsm.sh”. The script reports and prints (to stdout) selected storage management information. Think of it as “RePort Storage Management”. The easy way to describe what the script needs to do is to look at what it should display in the case where you provide incorrect parameters, or in the case where you provide “-h” for help: Usage: ./rpsm.sh <options>< directory> Reports selected information about specified directory...
1. Print out information of PHP use phpinfo() function. 2. Write a program that check and print odd / even numbers (from number 1 to 100 using for/while loop). Display the results within an HTML table with 2 columns as shown below: NUMBERS RESULTS 1 ODD 2 EVEN 3 ODD HINT: use <table> tags to create a table, <th> tags for ‘Numbers’ and ‘Results’. Wrap code PHP inside HTML code. For example: <html> <title>CHECK ODD or EVEN</title> <body> <table> <?php...
Write the following program in C++. Review structures, pointers and dynamic memory allocation from CSIT 839. Also, review pointers and dynamic memory allocation posted here under Pages. For sorting, you can refer to the textbook for Co Sci 839 or google "C++ sort functions". I've also included under files, a sample C++ source file named sort_binsearch.cpp which gives an example of both sorting and binary search. The Bubble sort is the simplest. For binary search too, you can refer to...
Most system administrators would like to know the utilization of their systems by their users. On a Linux system, each user's login records are normally stored in the binary file /var/log/wtmp. The login records in this binary file can not be viewed or edited directly using normal Linux text commands like 'less', 'cat', etc. The 'last' command is often used to display the login records stored in this file in a human readable form. Please check the man page of...
C++ Programming Assignment S Mammal Lab This lab's goal is to give you some practice using inheritance, virtual functions, pointers, dynamic memory allocation, random numbers, and polymorphism. To complete the lab implement the following steps: Create a class called Mammal. All mammals have a weight and a name, so its data should be the mammal's weight and name. Provide a default constructor that sets the mammal's weight to 0 and name to null, and another constructor that allows the weight...
***NEED SOLUTION IN PYTHON *** 1. Create a main function which only gets executed when the file is directly executed Hint: def main(): pass if __name__ == '__main__': main() 2. Your programs will use a file called scores.txt to store a bunch of user-provided numbers. These can be int or float but their values must be between 0 and 100. Inside the main function, display the current list of numbers to the user and ask if they want to update...