What is sh?
sh
(or the Shell Command Language) is a programming language described by the POSIX standard. It has many implementations (ksh88
, Dash, ...). Bash can also be considered an implementation of sh
(see below).
Because sh
is a specification, not an implementation, /bin/sh
is a symlink (or a hard link) to an actual implementation on most POSIX systems.
What is Bash?
Bash started as an sh
-compatible implementation (although it predates the POSIX standard by a few years), but as time passed it has acquired many extensions. Many of these extensions may change the behavior of valid POSIX shell scripts, so by itself Bash is not a valid POSIX shell. Rather, it is a dialect of the POSIX shell language.
Bash supports a --posix
switch, which makes it more POSIX-compliant. It also tries to mimic POSIX if invoked as sh
.
sh = bash?
For a long time, /bin/sh
used to point to /bin/bash
on most GNU/Linux systems. As a result, it had almost become safe to ignore the difference between the two. But that started to change recently.
Some popular examples of systems where /bin/sh
does not point to /bin/bash
(and on some of which /bin/bash
may not even exist) are:
- Modern Debian and Ubuntu systems, which symlink
sh
todash
by default; - Busybox, which is usually run during the Linux system boot time as part of
initramfs
. It uses the ash shell implementation. - BSD systems, and in general any non-Linux systems. OpenBSD uses
pdksh
, a descendant of the KornShell. FreeBSD'ssh
is a descendant of the original Unix Bourne shell. Solaris has its ownsh
which for a long time was not POSIX-compliant; a free implementation is available from the Heirloom project.
Determine the shell type:
echo "-----------------------"
echo "System Health Snapshot"
echo "-----------------------"
# Check CPU Usage
echo -e "\n1. CPU Usage:"
top -b -n 1 | grep '%Cpu'
# Check Memory Usage
echo -e "\n2. Memory Usage:"
free -m
# Check Disk Space
echo -e "\n3. Disk Space:"
df -h
# Check Network Activity
echo -e "\n4. Network Activity:"
iftop -t -s 2
# Check Running Processes
echo -e "\n5. Running Processes:"
ps aux
# Check System Uptime
echo -e "\n6. System Uptime:"
uptime
# Check System Load Average
echo -e "\n7. System Load Average:"
w
# Check Kernel Messages
echo -e "\n8. Kernel Messages:"
dmesg | tail -n 5
# Check System Logs
echo -e "\n9. System Logs (last 10 lines):"
tail -n 10 /var/log/syslog
# Check Users Currently Logged In
echo -e "\n10. Users Currently Logged In:"
who
# Check CPU/RAM count like 2gb or 4gb
echo "-----------------------"
0 Comments