B.Sc Computer Science
Linux and Shell Programming - Lab
Bharathiar University
Program 2. Write a shell script to show the following system configuration :
a. currently logged user and his log name
b. current shell , home directory , Operating System type , current Path setting , current
working directory
c. show currently logged number of users, show all available shells
d. show CPU information like processor type , speed
e. show memory information
Source Code
echo "Currently logged user and his log name:"echo " Username: $(whoami)"echo " Login name: $(logname)"echo
echo " Current shell: $SHELL"echo " Home directory: $HOME"echo " Operating System type: $(uname -s)"echo " Current Path setting: $PATH"echo " Current working directory: $(pwd)"echo
echo " Currently logged users: $(who | wc -l)"echo " Available shells: $(cat /etc/shells)"echo
echo " Processor type: $(uname -p)"echo " Processor speed:"echo " $(cat /proc/cpuinfo | grep "MHz")"echoecho "Memory information:"echo "$(free -h)"
SAMPLE OUTPUT:
echo "Currently logged user and his log name:"
echo " Username: $(whoami)"
echo " Login name: $(logname)"
echo
echo " Current shell: $SHELL"
echo " Home directory: $HOME"
echo " Operating System type: $(uname -s)"
echo " Current Path setting: $PATH"
echo " Current working directory: $(pwd)"
echo
echo " Currently logged users: $(who | wc -l)"
echo " Available shells: $(cat /etc/shells)"
echo
echo " Processor type: $(uname -p)"
echo " Processor speed:"
echo " $(cat /proc/cpuinfo | grep "MHz")"
echo
echo "Memory information:"
echo "$(free -h)"
SAMPLE OUTPUT:
No comments:
Post a Comment