What is Operating system?
The interface between the computer hardware and the user. The are different kinds of OS of which the few most well known are:
Windows
Linux
MacOS
Andriod and IOS
About Linux
Linux is an open source operating system that has transformed the way we think about computing.
The story of Linux started when Linus Torvald who worked on UNIX wanted to improve the UNIX and make it free open source. But he was missing the key component. He then worked with Richard Stallman founder of the GNU Project, an OS based on UNIX, together made the element called Kernel. The kernel acts as the core of an operating system, managing hardware and software interactions.. This made the introduction of Linux possible.
Linux Architecture
The Linux is made based on the following key elements:
User
User is the person interacting with the computer
Linux has Multi User System
Application
- A program that performs a specific task
Shell
- Command Line Interpreter
Filesystem Hierarchy Standard(FHS)
- The component of the Linux OS that organizes data
Kernel
The component of the Linux OS that manages process and memory
Communicates with the hardware to execute command from the shell
Use drivers to enable applications to execute tasks
Ensures that the system allocates resource more efficiently and makes the system work faster
Hardware
- Physical Components of a computer
Linux Distributions
There are many different versions of Linux each with their own parent distributions.
Few notable are:
Redhat - CentOS
Slackwar - SUSE
Debian - Ubuntu and Kali Linux
Kali Linux
Kali Linux is the trademark of offensive security which is derived from Debian.
Primary use of Kali Linux:
Penetration Testing
Penetration Testing is a simulated attack that helps identify vulnerability in system, network, websites, applications and process
Notable tools for Pen Test:
Metasploit: Used to look for and exploit vulnerability on machine
Burp Suite: Test weakness in web applications
John The Ripper: Tool to guess passoword
Digital Forensics
The practice of collecting and analyzing data to determine what has happened after an attack
Notable tools for Digital Forensics:
tcpdump: CLI packet analyzer used to capture traffic which can identify SYN flood attack, ICMP flood attack and port vulnerabilities
wireshark: GUI that can analyze live and capture network traffic
Autospy: Used to analyze hard drives and smart phones
Ubuntu
Ubuntu is a popular Linux distribution based on Debian, widely used for cloud computing.
Primary Uses of Ubuntu:
Server Management
Ubuntu Server is optimized for hosting applications, websites, and services in a stable, secure, and scalable environment
Notable Features:
LAMP Stack: Supports Linux, Apache, MySQL, and PHP for web development
Cloud Integration: Compatible with AWS, Azure, and OpenStack
Long-Term Support (LTS): Provides five years of security updates for reliable server management
Development and Testing
Ubuntu is favored by developers for its compatibility with various programming languages and tools
Popular Tools:
Snapcraft: Package management system for deploying applications
Docker: For containerized application development
Package Manager
Brief description:
A package is a piece of software that can be combined with other packages to form an application
Package contains files necessary for an application to install, which includes dependencies
It resolves the issue related to dependencies
Types of Packet Managers:
For Red Hat - Red Hat Package Manager(RPM) with extension .rpm
For Debian - dpkg with extension .deb
Package Manager tools:
Advanced Package Tool(APT) - Debian based
Yellowdog Updater Modifier(YUM) - Red Hat based
Shell
Brief description:
Shell is a command line interpreter which instructs the computer to do a task
Communicates with kernel to execute command
Types of Shell:
Bourne-Again Shell - bash($)
C Shell - csh
Korn Shell - ksh($)
Enhanced C Shell - tcsh
Z Shell - zsh(%)
Bash is the default shell in most Linux distributions. Bash is user friendly.
Shell Communications
Standard Input - Information received by the OS via the command line
Standard Output - Information returned to OS by the shell
Standard Erro - Error messages returned by the OS through the Shell
Linux Bashing
Before we move on to Bash commands let us learn few terms and their use:
Argument - Specific information needed by a command
FHS - Component of Linux OS that organizes data
Root Directory is the highest level directory of Linux with all permissions
“/” indicates the branch directories
“/home” - Each user have their own home directory
“/bin“ - Contains the binary executable files required to run the system
“/etc“ - Stores the system configuration files
“/temp“ - Stores the temporary files and usually used by the attackers
“/mnt“ - Mount and Stores Media for USB and Hard Drives
Absolute File Path - Full file path from the Root
Relative File Path - The file path that starts from users current directory, indicated with “.“ or “..“
Permission - The type of access granted for a file or directory
Read - Contents on the file can be read
Write - Allows modifications of contents of the file
Execute - File can be executed if it’s an executable file or opened if directory
Type Of Owner Based On Permission
User - The owner of the file who created it
Group - Multi-user environment
Other - All other users who have access to the system
File Permission Representation
drwxrwxrwx
- Missing value are replaced with “-“
Here, d indicates its a directory else if it has “-“ it indicates file
rwx rwx rwx is three owners based on permission
Missing value represented with “-“ indicate that the specific permission is missing
r - read, w - write, x - execute
1st rwx indicate the permissions of User
2nd rwx indicate the permissions of Group
3rd rwx indicate the permissions of Others
- Files with full access are called world writable file
Authorization - The concept of granting access to specific resource in a system
Authentication - Process of verifying who someone is
Principle Of Least Privilege - Concept of granting only the minimal access and authorization required to complete a task or function
Now, let us move on to the commands:
Manage File Content and Filtering
grep - Searches a specific file and returns all lines in the file containing a specified string
| (Piping) - Sends the standard output of one command as standard input to another command for further processing
find - The command searches for directories and files that meets specified criteria:
Search with specific string in name
Search with file size
Search when last modified
Create and Modify Directories
mkdir - Creates a new directory
rmdir - Removes or Deletes directory
touch - Creates new file
rm - Removes or deletes a file
mv - Moves a file/directory to new location
cp - Copies a file to new location
nano - A text file editor in CLI
Standard Output Redirection
“>“ - Overwrites the existing file
“>>“ - Adds the content at the end of the file
File Permissions
“ls - l“ - Displays the permission for files/directories
“ls -a“ - Displays the hidden files
“ls -la“ - Displays both file/dir permissions and hidden files
chmod - Changes permissions on files and directory
Adding and Deleting Users
Sudo - Grants elevated permissions temporarily to specific user. Used so that each time root user can be avoided because its vulnerable to attacker
useradd - Adds a user to the system
userdel - Deletes user from the system
usermod - Modify the existing account
chown - Changes ownership of a file or directory
Help in Linux
man - Displays informations on other commands and how they work
whatis - Displays a description of a command on a single line
apropos - Searches the manual page distributions for a specified string
Find more details on bashing here