Linux - Linux Kernel
The kernel is the heart of the Linux operating system. It manages the resources of Linux such as:
• File management
• Multitasking
• Memory management
• I/O management
• Process management
• Device management
• Networking support including IPv4 and IPv6
• Advanced features such as virtual memory, shared libraries, demand loading, shared copy-on-write executables etc
The kernel decides who will use these resources and for how long and when. It runs your programs or sets up to execute binary files. The kernel acts as an intermediary between the computer hardware and various applications.
Linux Shell
- The shell is a user program or it is an environment provided for user interaction.
- It is a command language interpreter that executes commands read from the standard input device such as keyboard or from a file.
- The shell gets started when you log in or open a console (terminal).
- Quick and dirty way to execute utilities.
- The shell is not part of system kernel, but uses the system kernel to execute programs, create files etc.
- Several shells are available for Linux including:
- BASH ( Bourne-Again SHell ) - Most common shell in Linux. It's Open Source.
- CSH (C SHell) - The C shell's syntax and usage are very similar to the C programming language.
- KSH (Korn SHell) - Created by David Korn at AT & T Bell Labs. The Korn Shell also was the base for the POSIX Shell standard specifications.
- TCSH - It is an enhanced but completely compatible version of the Berkeley UNIX C shell (CSH).
Please note that each shell does the same job, but each understands different command syntax and provides different built-in functions. Under MS-DOS, the shell name is COMMAND.COM which is also used for the same purpose, but it is by far not as powerful as our Linux Shells are!
Shell Prompt
There are various ways to get shell access:
- Terminal - Linux desktop provide a GUI based login system. Once logged in you can gain access to a shell by running X Terminal (XTerm), Gnome Terminal (GTerm), or KDE Terminal (KTerm) application.
- Connect via secure shell (SSH) - You will get a shell prompt as soon as you log in into remote server or workstation.
- Use the console - A few Linux system also provides a text-based login system. Generally you get a shell prompt as soon as you log in to the system.
How do I find out my current shell name?
To find all of the available shells in your system, type the following command:
cat /etc/shells
In case the /etc/shells file has more than one shell listed under it, then it means that more than one shell is supported by your platform.
Command Line Interface (CLI)
The shell provides an interface to Linux where you can type or enter commands using the keyboard. It is known as the command line interface (CLI). To find out your current shell type following command[1].:
echo $SHELL
ps $$
ps -p $$
The following sample output indicate that I am using bash shell:
PID TTY TIME CMD 13931 pts/4 00:00:00 bash
Basic Command Line Editing
You can use the following key combinations to edit and recall commands:
- CTRL + L : Clear the screen.
- CTRL + W : Delete the word starting at cursor.
- CTRL + U : Clear the line i.e. Delete all words from command line.
- Up and Down arrow keys : Recall commands (see command history).
- Tab : Auto-complete files, directory, command names and much more.
- CTRL + R : Search through previously used commands (see command history)
- CTRL + C : Cancel currently running commands.
- CTRL + T : Swap the last two characters before the cursor.
- ESC + T : Swap the last two words before the cursor.
- CTRL + H : Delete the letter starting at cursor.
Executing A Command
Type your command, and press enter key. Try this the date command which will display current date and time:
date
Sample outputs:
Tue Apr 27 05:20:35 IST 2010
Command And File Completion
The Bash shell will auto complete file and command names, when possible and/or when you tell them to. For example, if you type sle and pressing Tab key will make the shell automatically complete your command name. Another example, if you type ls /e and pressing Tab key will make the shell automatically complete your word to /etc as it sees that /etc/ is a directory which starts with /e.
Getting Help In Linux
- Most commands under Linux will come with documentation.
- You can view documentation with the man command or info command. In this example, open the manpage for date command:
man date
- You can read info documentation as follows for the ls command:
info ls
- Many commands accepts --help or -h command line option. In this example, display help options for the date command:
date --help
- In short use any one of the following option to get more information about Linux commands:
man commandName
info commandName
commandName -h
commandName