Introduction
Index
- What is Linux?
- Linux Distributions
- Different Between Linux and Windows
- GUI vs CLI
- Components of Linux System
- The Architecture of a Linux System
- Understanding Linux Kernel
- Installing Linux OS
- Booting Process
- Shutting Down Process
- Concept of Root
- Basic Commands
- Working with vi Editor
What is Linux?
Linux is an open-source operating system like another operating system such as windows. An operating system such as a window. An operating system is software that enables the communication between computer Hardware and Software. The kernel is a program at the heart of the Linux operating system that takes care of fundamental stuff, like letting hardware communicate with software.
Linux operating system is one of the popular versions of the UNIX operating system, which is designed to offer a free or low-cost operating system for personal computer users. It gained a reputation as a fast performing and very efficient system.
Linux is a freely distributed implementation of a UNIX-like kernel, the low-level core of an operating system.
Because Linux takes the UNIX system as its inspiration, Linux and UNIX programs are very similar. In fact, almost all programs written for UNIX can be compiled and run on Linux.3.
Some commercial applications sold for commercial versions of UNIX can run unchanged in binary form on Linux systems.
Basic Features of the Linux Operating System:
- Portable: - Portability means software can work on different types of hardware in the same way. Linux kernel and application programs support their installation on any kind of hardware platform
- Open Source: - Linux source code is freely available and it is a community-based development project. Multiple teams work in collaboration to enhance the capability of the Linux operating system and it is continuously evolving.
- Multi-User: - Linux is a multiuser system which means multiple users can access system resources like memory / RAM/application programs at the same time.
- Multiprogramming: - Linux is a multiprogramming system which means multiple applications can run at the same time.
- Hierarchical File System: - Linux provides a standard file structure in which system files/ user files are arranged.
- Shell: - Linux provides a special interpreter program that can be used to execute commands of the operating system. It can be used to do various types of operations such as call application programming etc.
- Security: - Linux provides user security by using authentication features like password protection/ controlled access to specific files/ encryption of data
Linux Distribution
There are hundreds of Linux operating systems or Distributions available these days. Many of them are designed with a specific purpose in mind.
- Arch: - This Linux Distro is popular amongst developers. It is an independently developed system. It is designed for users who go for a do-it-yourself approach.
- Cent OS: - It is one of the most used Linux Distribution for enterprise and web Server. It is a free enterprise-class operating system and is based heavily on Red Hat Enterprise Distro.
- Debian: - Debian is a stable and popular non-commercial Linux distribution. It is widely used as a desktop Linux Distro and is user-oriented. It strictly acts within the Linux protocols.
- Fedora: - Another Linux kernel-based Distro Fedora is supported by the Fedora Project, an endeavor by Red Hat. It is popular among desktop users. It versions are known for their short life cycle.
- Gentoo: - It is a source-based distribution which means that you need to configure the code on your system before you can install it. It is not for Linux beginners, but it is sure fun for experienced users.
- Open SUSE: - It is an easy to use and a good alternative to MS windows. It can be easily set up and can also run on small computers with obsolete configurations.
- Red Hat: - Another popular enterprise-based Linux Distribution is Red Hat Enterprise.
- Ubuntu: - This is the third most popular desktop operating system after Microsoft Windows and Apple Mac OS. It is based on the Debian Linux Distribution, and it is known as its desktop environment.
Difference Between Linux and Windows
| Linux | Windows |
|---|---|
| Unix/Linux uses a tree-like hierarchical file system. | Windows uses different data drives like C: D: E to stored files and folders. |
| There are no drives in Linux | Windows has different drives like C: D: E |
| Peripherals like hard drives, CD-ROMs, printers are also considered files in Linux/Unix | Hard drives, CD-ROMs, printers are considered devices |
| There are 3 types of user account types 1) Regular, 2) Root, and 3) Service Account | There are 4 types of user account types 1) Administrator, 2) Standard, 3) Child, 4) Guest |
| The root user is the superuser and has all administrative privileges. | Administrator user has all administrative privileges of computers. |
| Linux file naming convention is case-sensitive. Thus, sample and SAMPLE are 2 different files in Linux/Unix operating system. | In Windows, you cannot have 2 files with the same name in the same folder |
| For every user /home/username directory is created which is called his home directory. | In windows, My Documents is the default home directory. |
Difference Between Graphical User Interface and Command Line Interface
| Basis of comparison | GUI | CLI |
|---|---|---|
| Basic | This user interface enables the user to interact with electronic devices with the help of graphical icons and visual indicators. | This user interface enables a user to give a command to interact with an electronic device. |
| Ease of understating | The graphical user interface is visually intuitive. It is easy to understand for beginners. | Due to the need for remembering commands, it is difficult to handle and requires expertise. |
| Memory Requirement | It requires more memory as it consists of a lot of graphical components. | It requires less memory as compared to GUI. |
| Speed | It generally uses a mouse to execute commands. The speed of GUI is Slower than CLI. | Because the keyboard is used to execute the commands, the speed of the CLI is Faster than GUI. |
| Appearance | One can change the appearance with a customizable option. | It is not possible to change the appearance. |
| Flexibility | More flexible than CLI | Less flexible than GUI |
| Device used | Keyboard and mouse | Keyboard |
| Precision | Low as compared to the CLI | High as compared to the GUI |
Components of Linux system
- Kernel: - Linux Kernel is the core part of the operating system. It establishes communication between devices and software. Moreover, it manages system resources.
- System Library: - It is one of the most used Linux Distribution for enterprise and web Server. It is a free enterprise-class operating system and is based heavily on Red Hat Enterprise Distro.
- System Utility: - Debian is a stable and popular non-commercial Linux distribution. It is widely used as a desktop Linux Distro and is user-oriented. It strictly acts within the Linux protocols.
The architecture of a Linux System
- Kernel: - The kernel is the core part of the operating system, which is responsible for all the major activities of the LINUX operating system. This operating system consists of different modules and interacts directly with the underlying hardware. The kernel offers the required abstraction to hide application programs or low-level hardware details to the system.
- HARDWARE: - physical parts of a computer, such as central processing unit (CPU), monitor, mouse, keyboard, hard disk, and other connected devices to CPU
- SHELL: - Shell is an environment in which we can run our commands, programs, and shell scripts. It is a user interface for access to an operating system's services. (User interface program execution, file system manipulation, input/output operations, communication, resource allocation, error detection, security, and protection)
- Utilities: - Utility programs that provide the user most of the functionalities of an operating system.
Understanding Linux Kernel
The kernel is the core part of the operating system, which is responsible for all the major activities of the LINUX operating system. This operating system consists of different modules and interacts directly with the underlying hardware. The kernel offers the required abstraction to hide application programs or low-level hardware details to the system. The types of Kernels are as follows:
- Monolithic Kernel
- Microkernels
- Exo kernels
- Hybrid kernels
Responsibilities:
- Device Management: - A system has many devices connected to it like a CPU, a memory device, Sound cards, graphic cards, etc. A kernel stores all the data related to all the devices in the device driver.
- Memory Management: - Another function that the kernel has to manage is memory management. The Kernel keeps track of used and unused memory and makes sure that processes shouldn’t manipulate data of each other using virtual memory addresses.
- Process management: - In the process, the management kernel assigns enough time and gives priorities to processes before handling the CPU to other processes. It also deals with security and ownership information.
- Handling system calls: - Handling system calls means a programmer can write a query or ask the kernel to perform a task.
Installing Linux System
System Requirements for Red Hat Enterprise Linux Versions:
- Operating System: - Red Hat Enterprise Linux 4 or 5 with the latest patches and upgrades
- CPU Type: - Pentium 4 or higher; 2 GHz or higher
- Memory/RAM: - 1 GB minimum
- Hard Disk: - 4 GB minimum
Partitioning the Hard Drive in Linux:
For a proper Linux installation in a single-user desktop system, three partitions are recommended: swap, root, and home:
- Swap: - This is a partition that will be used as a Linux swap space. This is the space on the hard drive that can be used as virtual memory. Virtual memory allows the computer to run large programs and perform complex tasks even if it does not have enough physical RAM to do the job
- root (/): - The root file system is represented by a forward slash (/). It is the top of the directory tree and contains Linux and everything that you install with Linux. You must create a partition for the root directory.
- /home: - The third and final partition you should create will hold your / home directory. This is the place where all the user-specific files are stored. On a multi-user system, each user will have their own directory under /home.
(Steps of Linux Installation)--Click on this
Booting Process
- Reading of the boot loader from the MBR (Master Boot Record)
- Loading and initialization of the kernel.
- Device Detection and configuration.
- Creation of kernel processes.
- Administrator intervention (single-user-mode only).
- Execution of system startup scripts.
Shutdown Process
- Shutdown the gentle way to halt the system.
- Shutdown sends messages to logged-in users at progressively shorter intervals, warning them of the impending downtime.
- Warning simply say that the system is being shut down and give the time remaining until the event. [Shutdown time R H S F]
- R = Reboot
- H = Halt
- S = Enter single-user mode
- F = Skip fsck
Concept of Root/ Super User
- It is created by default and has user & group ID as 0.
- It doesn’t have a password by default. One can assign it by [# Sudo Password root]
- Give a strong password for root
- One should only use this privilege for the small intervals for specific tasks and then go back to a normal user.
- Inexperienced users can cause serious harm to OS and may also leave security vulnerability.
Basic Commands
| File Commands | ||
|---|---|---|
| S.No. | command | Description |
| 1. | ls | Directory listing |
| 2. | ls -al | Formatted listing with hidden files |
| 3. | ls -lt | Sorting the Formatted listing by time modification |
| 4. | cd dir | Change directory to dir |
| 5. | cd | Change to home directory |
| 6. | pwd | Show current working directory |
| 7. | mkdir dir | Creating a directory dir |
| 8. | cat >file | Places the standard input into the file |
| 9. | more file | Output the contents of the file |
| 10. | head file | Output the first 10 lines of the file |
| 11. | tail file | Output the last 10 lines of the file |
| 12. | tail -f file | Output the contents of file as it grows,starting with the last 10 lines |
| 13. | touch file | Create or update file |
| 14. | rm file | Deleting the file |
| 15. | rm -r dir | Deleting the directory |
| 16. | rm -f file | Force to remove the file |
| 17. | rm -rf dir | Force to remove the directory dir |
| 18. | cp file1 file2 | Copy the contents of file1 to file2 |
| 19. | cp -r dir1 dir2 | Copy dir1 to dir2;create dir2 if not present |
| 20. | mv file1 file2 | Rename or move file1 to file2,if file2 is an existing directory |
| 21. | ln -s file link | Create symbolic link link to file |
| Process management | ||
| S.No. | command | Description |
| 1. | ps | To display the currently working processes |
| 2. | top | Display all running process |
| 3. | kill pid | Kill the process with given pid |
| 4. | killall proc | Kill all the process named proc |
| 5. | pkill pattern | Will kill all processes matching the pattern |
| 6. | bg | List stopped or background jobs,resume a stopped job in the background |
| 7. | fg | Brings the most recent job to foreground |
| 8. | fg n | Brings job n to the foreground |
| File permission | ||
| S.No. | command | Description |
| 1. | chmod octal file | Change the permission of file to octal,which can be found separately for user,group,world by adding, 4-read(r), 2-write(w), 1-execute(x) |
| Searching | ||
| S.No. | command | Description |
| 1. | grep pattern file | Search for pattern in file |
| 2. | grep -r pattern dir | Search recursively for pattern in dir |
| 3. | command | grep pattern | Search pattern in the output of a command |
| 4. | locate file | Find all instances of file |
| 5. | find . -name filename | Searches in the current directory (represented by a period) and below it, for files and directories with names starting with filename |
| 6. | pgrep pattern | Searches for all the named processes , that matches with the pattern and, by default, returns their ID |
| System Info | ||
| S.No. | command | Description |
| 1. | date | Show the current date and time |
| 2. | cal | Show this month's calender |
| 3. | uptime | Show current uptime |
| 4. | w | Display who is on line |
| 5. | whoami | Who you are logged in as |
| 6. | finger user | Display information about user |
| 7. | uname -a | Show kernel information |
| 8. | cat /proc/cpuinfo | Cpu information |
| 9. | cat proc/meminfo | Memory information |
| 10. | man command | Show the manual for command |
| 11. | df | Show the disk usage |
| 12. | du | Show directory space usage |
| 13. | free | Show memory and swap usage |
| 14. | whereis app | Show possible locations of app |
| 15. | which app | Show which applications will be run by default |
| Compression | ||
| S.No. | command | Description |
| 1. | tar cf file.tar file | Create tar named file.tar containing file |
| 2. | tar xf file.tar | Extract the files from file.tar |
| 3. | tar czf file.tar.gz files | Create a tar with Gzip compression |
| 4. | tar xzf file.tar.gz | Extract a tar using Gzip |
| 5. | tar cjf file.tar.bz2 | Create tar with Bzip2 compression |
| 6. | tar xjf file.tar.bz2 | Extract a tar using Bzip2 |
| 7. | gzip file | Compresses file and renames it to file.gz |
| 8. | gzip -d file.gz | Decompresses file.gz back to file |
| Network | ||
| S.No. | command | Description |
| 1. | ping host | Ping host and output results |
| 2. | whois domain | Get whois information for domains |
| 3. | dig domain | Get DNS information for domain |
| 4. | dig -x host | Reverse lookup host |
| 5. | wget file | Download file |
| 6. | wget -c file | Continue a stopped download |
| Shortcuts | ||
| S.No. | command | Description |
| 1. | ctrl+c | Halts the current command |
| 2. | ctrl+z | Stops the current command, resume with fg in the foreground or bg in the background |
| 3. | ctrl+d | Logout the current session, similar to exit |
| 4. | ctrl+w | Erases one word in the current line |
| 5. | ctrl+u | Erases the whole line |
| 6. | ctrl+r | Type to bring up a recent command |
| 7. | !! | Repeats the last command |
| 8. | exit | Logout the current session |
vi Editor
The VI editor is the most popular and classic text editor in the Linux family. Below, are some reasons which make it a widely used editor –
- It is available in almost all Linux Distributions
- It works the same across different platforms and Distributions
- It is user-friendly. Hence, millions of Linux users love it and use it for their editing needs
- To work on VI editor, you need to understand its operation modes. They can be divided into two main parts.
vi Command mode:
- The vi editor opens in this mode, and it only understands commands
- In this mode, you can, move the cursor and cut, copy, paste the text
- This mode also saves the changes you have made to the file
- Commands are case-sensitive. You should use the right letter case.
vi Editor Insert mode:
- This mode is for inserting text in the file.
- You can switch to the Insert mode from the command mode by pressing ‘i’ on the keyboard
- Once you are in Insert mode, any key would be taken as an input for the file on which you are currently working.
- To return to the command mode and save the changes you have made you need to press the Esc key
vi Editing commands:
- i: - Insert at cursor (goes into insert mode)
- a: - Write after the cursor (goes into insert mode)
- A: - Write at the end of the line (goes into insert mode)
- ESC: - Terminate insert mode
- u: - Undo last change
- U: - Undo all changes to the entire line
- o: - Open a new line (goes into insert mode)
- dd: - Delete line
- 3dd: - Delete 3 lines
- D: - Delete contents of the line after the cursor
- C: - Delete the contents of a line after the cursor and insert new text. Press the ESC key to end insertion.
- dw: - Delete word
- 4dw: - Delete 4 words
- cw: - Change word
- x: - Delete the character at the cursor
- r: - Replace character
- R: - Overwrite characters from cursor onward
- s: - Substitute one character under cursor continue to insert
- S: - Substitute the entire line and begin to insert at the beginning of the line
- ~: - Change case of individual character
Saving and Closing the file:
- Shift+zz: - Save the file and quit
- :w: - Save the file but keep it open
- :q: - Quit without saving
- :wq: - Save the file and quit
How to use vi editor:
To launch the VI Editor -Open the Terminal (CLI) and type
vi <filename_NEW> or <filename_EXISTING>
And if you specify an existing file, then the editor would open it for you to edit. Else, you can create a new file.
Comments
Post a Comment