Basic LINUX Elements 1.
Kernel - The core of the Linux system is the Kernel - the operating system program. The kernel controls the resources of the computer, allotting them to different users and tasks. It interacts directly with the hardware, thus making the programs easy to write and portable across different platforms of hardware. It also maintaining the time and date and launching applications. Since the kernel communicates directly with the hardware, the parts of the kernel must be customized to the hardware features of each system.
2.
Shell - The kernel does not deal directly with a user. Instead, the login process starts up a separate, interactive program, called the SHELL that has the power to provide the services that a user wants. It protects the user from having to know the intricate hardware details. The shell runs like any other program under Linux system. There are various shells available for Unix/Linux Systems: Unix Shells: 1. Bourne Shell - Basic Shell of Unix 2. C Shell - Resembles the C Language. 3. Korn Shell - Combination of Bourne and C Shell. 4. Restricted Shell - Typically used for guest logins. Linux Shells 1. Bash - Just as Bourne Shell of Unix 2. Pdksh - Public Domain Korn Shell 3. Tcsh - Tom's C Shell 4. ASH - Kenneth Almquist developed it for limited memory computer and it is lightweight of Bourne Shell Clone. 5. zah - It has best features of Tcsh shell and also it can emulate all the features of Korn Shell. Some other shells are - flash, bsh, esh, fsh, Gsh, Gush, Kshell, lsh etc.
3.
Device Drivers - Device drivers are software packages that form a major part of the Kernel. They control the interaction between the hardware devices and the operating system.
4.
Utilities - Utilities are software tools included with the LINUX operating system that lets you do miscellaneous jobs such as text editing, programming and communications.
5.
Commands - A LINUX command is a series of characters that you supply at the prompt in Linux Shell. Linux command is case sensitive. The first word is the command itself and the rest are the command's arguments.
File System Linux treats everything as files. Even a directory is treated as a file that contains entries for several other files. All the hardware devices, such as I/O devices, storage devices etc. are all treated as files. The Linux file system is organized in hierarchy, which starts with the root directory, which is represented by a forward slash (/). Generally we get following folders in the root folder: 1. /bin - This folder contains all the binary executable files of Linux. 2. /dev - This folder contains device drivers for all the hardware devices, such as printer, hard disk etc. 3. /etc - This directory contains the system-related data which users and the system need to refer to, such as the passwd file. These are generally essential miscellaneous system programs and configuration files. 4. /lib - This folder contains all the library function such as c, c++ etc. which is very useful for programmers to develop their programs. 5. /usr or /home - This folder contains generally home directory of users. 6. /tmp - All the temporary files get place here which will automatically created and deleted by Linux. 7. /kernel - This directory contains all the kernel specific code. Kernel is the heart of the Linux system. It is responsible for resource allocation, security and low-level hardware interfaces. 8. /mnt - In this folder other hardware devices like CD-ROM or floopy's related data contained. 9. /var - This folder has information specific to different utilities of Linux.
Types of Files In Linux, all information is treated as File, whether it is file, folder or any hardware device, Linux treated all of it same. There are three categories of files: 1. Ordinary Files – All the files created by a user come under this category of files. These include all the data files, program files,
2.
3.
object files and executables files. A user can make changes to such files. Directory Files – Linux automatically creates a directory file when a directory is created. This file has the same name as the directory, and contains information about the files under the directory. A directory file cannot be modified by a user but is, instead, modified automatically by the system when a new file or a sub-directory is added to the directory. Special Files – Most of the system files in Linux are special files. Special files are typically associated with Input/Output devices and are found in the standard Linux directories, such as /dev and /etc. Users cannot alter special files. Linux supports the following types of Special files: * Character device files – This type of files read and writes data one character at a time. A modem is an example of a character device file. Character devices are also called sequentially accessed devices. * Block device files – It can access a block of data a time. Generally, a block of data can be either 512 or 1024 bytes. Here, the kernel reads or writes minimum one block of data at a time. The kernel collects the data in the memory for the amount of block memory and then makes it available to a user. Such devices allow random access. This makes input/output operations faster. Eg. Harddisk. * Hard links – These are special files that allow a single file to have multiple names. You can have a hard link file only for a file and not for a directory. These links are known as hard links because they create a direct link to an inode. Since each filesystem has its own inode information database, you can hard-link files only when they are on the same filesystem; symbolic links don’t have this restriction. * Symbolic Links – It also known as soft links, are similar to hard links except that they can work across different filesystems.
Types of Users in Linux 1.
2. 3.
System Administrator – In Linux the System Administrator is known as root user. Root is primarily responsible for the smooth operation of the system. It is the root’s job to switch on the system console (the machine on which the operating system resides, also known as the Server Machine). The root also creates users and groups of users for the system, and takes backups to prevent loss of data due to system breakdown. File Owner – The user who creates a file is said to be the owner of that file. The owner of a file can perform any operation on that file – coping, deleting, editing etc. Group Owner – In Linux it is possible to create groups and then keep all those users having the same task of same nature under
4.
same group. This feature enables the users to see or show their files to their group members and keep safe from other users. Other Users – All the users of the system who are not members of the group are reffered to as Other Users for the files of that group. Other Users are users who do not belong to the particular group.
Linux Commands 1.
pwd (Print Working Directory) - This command if used then returns the absolute path of the current working directory. $ pwd /usr/rinki/india $
2.
mkdir (Make Directory) - This command is used to create new directory. We can also create more than one directory at a time through separating them with spaces between them. $ mkdir Rajeev $ mkdir Rajeev/Ranjan Rajeev/Twinkle Rajeev/Gaurav Note : Linux used "/" symbol instead of "\" for indicating path.
3.
cd (Change Directory) - This command is used to change path from one folder to another. We can use cd command in following way :$ cd Rajeev /* Get changed into folder Rajeev $ cd .. /* Come back at parent folder $ cd / /* Come back at root directory, i.e. "/" $ cd /* Come back at user's parent directory
4.
clear (Clear Screen) - This command is used to clear the screen. $ clear
5.
man (Manual of Command) - This command is used to get help about any Linux command. $ man cd
6.
ls - List Files - This command is used to see the directory and files of specified path. Syntax: ls <switches> Switches: -a Lists all the files, including hidden files -F Shows the file type along with the name (‘/’ for a directory, ‘*’ for an executable) -R Does a recursive listing, that is, displays the contents of the specified directory and all the subdirectories. -r Displays files and sub-directories in the reverse order -s Sorts by file size
-A
Displays the files of almost all directories
except the . and .. directories Note: A hidden file is one whose name starts with a period. $ ls /* Shows directory width wise $ ls -l /* Shows directory with full details, i.e. Owner, Group Owner, file type, file size etc. in 9 columns having each column following features: 1 File type and File Access Permission (FAPs) Ordinary Files d Directory b Block special file c Character Special file l Symbolic Link s Symbolic link 2 Number of Links 3 File Owner 4 Group Owner (Group Name) 5 File Size 6, 7 and 8 Day and time of last modification to the file 9 Name of the file $ ls -la $ 7.
/* Show hidden files too
cat - This command is used to Create or see the content of one or more files. For creating file we have to use ">" symbol and after completing file Press "^+D". $ cat > Rajeev He is a boy. He can do his talk efficiently. ^D /* A file created. $ cat Rajeev /* Show content. He is a boy. He can do his talk efficiently. ^D $ cat Rajeev Raman /* Shows content of both files
8.
cp - Copy - This command is used to copy one or more file or folder with new name or at new place. $ cp Rajeev Rakesh /* Make Rakesh just duplicate of Rajeev $ cp -r India Bharat /* Copies folder India with all its files and sub-directories with a new name Bharat. 9.
rm - This command is used to remove file(s) or folder(s) from disk. $ rm zz /* Delete the file "zz".
$ rm -r Ranjan and files. $ rmdir Rani
/* Delete the folder Ranjan with all its sub-folder /* Delete the folder Rani if it is blank folder.
10.
mv - This command is used to move a file or folder to another location as well as it is also used to rename a file or folder. $ mv Rajeev Ranjan /* Rename the folder Rajeev with Ranjan $ mv B.txt Rajeev/A.txt /* Move the file B.Txt into Folder Rajeev
11.
more or less - This command is used to show the content of a file screen wise if the content is too large. Both command shows one screenful message at a time but while we use "more" then at next page we can't go to previous page but in case of "less" command we can also go back. To quit from here we have to press "q".