Unit - 3
Unit - 3
Bash stands for Bourne Again Shell and it is the default shell on many Linux
distributions today. It is also a sh-compatible shell and offers practical
improvements over sh for programming and interactive use which includes:
2. TENEX C Shell
Tcsh is enhanced C shell, it can be used as an interactive login shell and shell
script command processor.
C like syntax
Command-line editor
Programmable word and filename completion
Spelling correction
Job control
3. Korn Shell
Ksh stands for Korn shell and was designed and developed by David G. Korn.
It is a complete, powerful, high-level programming language and also an
interactive command language just like many other Unix/GNU Linux shells.
The Korn shell includes features from other shells and provides several more
advanced features found in modern scripting languages such as;
associative arrays
floating point arithmetic
job control
command aliasing
command history
supports POSIX standards
backward compatibility with bash
It is also a powerful scripting language just like the other shells available. Though
it has some unique features that include:
Filename generation
Startup files
Login/Logout watching
Closing comments
Concept index
Variable index
Functions index
Key index and many more that you can find out in man pages
5. Scheme Shell
The Scheme shell (scsh) is an exotic shell that offers a scripting environment
using Scheme, which is a derivative of the Lisp language. The Pyshell is an
attempt to create a similar script that uses the Python language.
cat /etc/shells
# /etc/shells: valid login shells
/bin/sh
/bin/dash
/bin/bash
/bin/rbash
To check current shell use echo $SHELL
3. Double ampersand (&&) operator: The double ampersand operator allows you
to execute the second command only if the first command succeeds. For
example, to compile and run a C program, you can use the following
command:
gcc -o myprog myprog.c && ./myprog
4. Double vertical bar (||) : The double vertical bar operator allows you to execute
the second command only if the first command fails. For example, to check if
a file exists and create it if it does not, you can use the following command:
[ -e myfile ] || touch myfile
6. Braces: Braces can be used to group commands and execute them in the
current shell environment. For example, to create a variable and set its value,
you can use the following command:
{ var ="hello world" ; echo $var; }
By using these commands, users can easily manage the directory stack and
navigate through their directory history.
1. ps: The ps command is used to list all the processes running on the system. It
displays information such as the PID, process status, CPU usage, and memory usage.
2. top: The top command is used to monitor the system in real-time. It displays the
processes that are using the most CPU and memory.
3. kill: The kill command is used to send a signal to a process to terminate it. The
default signal sent by the kill command is SIGTERM, which allows the process to
perform cleanup operations before it terminates. The SIGKILL signal can also be
used to terminate a process immediately.
4. pkill: The pkill command is used to kill processes based on their name or other
attributes. It is useful when you want to kill all the processes associated with a
particular program.
5. killall: The killall command is similar to pkill, but it matches the name of the process
exactly.
6. nice: The nice command is used to set the priority of a process. A higher nice value
means lower priority, and a lower nice value means higher priority.
7. renice: The renice command is used to change the priority of a running process.
8. htop: The htop command is similar to top, but it provides a more user-friendly
interface.
9. pstree: The pstree command is used to display the processes in a tree-like format,
showing the parent-child relationships between processes.
10. jobs: The jobs command is used to display the jobs running in the current shell
session.
11. bg: This command moves a currently suspended job to the background, allowing
other jobs to run in the foreground.
12. fg: This command brings a background job back to the foreground, allowing you to
interact with it again.
13. strace: This command allows you to trace system calls and signals made by a
running process, helping you to debug problems or understand how a program is
working.