Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
190 views

Linux Fundamentals HTB

The document provides an overview of Linux fundamentals including its history, components, file system structure, basic commands, user account management, system management tasks, and security practices. Key topics covered include the Linux kernel, daemons, shells, graphics servers, the boot process, and configuring a firewall for access control.

Uploaded by

mercyjoash5
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
190 views

Linux Fundamentals HTB

The document provides an overview of Linux fundamentals including its history, components, file system structure, basic commands, user account management, system management tasks, and security practices. Key topics covered include the Linux kernel, daemons, shells, graphics servers, the boot process, and configuring a firewall for access control.

Uploaded by

mercyjoash5
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 14

REPORT

LINUX FUNDAMENTALS

Tier 0

SOURCE OF FINDINGS:
https://academy.hackthebox.com/module/18/
section/94

1.INTRODUCTION OF LINUX
Linux was first developed in 1970s. in 1991, Linux was licensed under GNU. By now Linux has
over 600 distros around the world.
Principles of Linux
Linux has 5 principles:-
1. Everything is a file.
2. Small, single purpose programs.
3. Ability to chain programs together to perform complex tasks.
4. Avoid captive user interface.
5. Configuration data stored in text file.

1.1Components of Linux
 Bootloader - A piece of code that runs to guide the booting process to start
the operating system. Parrot Linux uses the GRUB Bootloader.
 OS Kernel - The kernel is the main component of an operating system. It
manages the resources for system's I/O devices at the hardware level.

HTB Linux Fundamentals Tier 0


 Daemons - Background services are called "daemons" in Linux. Their
purpose is to ensure that key functions such as scheduling, printing, and
multimedia are working correctly.
 OS Shell - This interface allows the user to tell the OS what to do. The most
commonly used shells are Bash, Tcsh/Csh, Ksh, Zsh, and Fish.
 Graphics server - This is subsystem that allows graphical programs to run
locally or remotely on the X-windowing system.

 Window Manager - Also known as a graphical user interface (GUI).

2. Linux Architecture

fig1: Linux architecture

3. FILE SYSTEM
The Linux file system is a hierarchical structure used to organize and store files on a Linux system. It
follows a tree-like structure with the root directory ("/") at the top, and all other directories and files
branching off from it. Here's a brief overview of the Linux file system hierarchy:

Fig2: File System Hierarchy

HTB Linux Fundamentals Tier 0


Directory in file system Description
/ All other directories and files are located under
the root directory.
/bin Contains essential binary files (programs)
required for system boot and operation.
/boot Contains boot loader files and the Linux kernel.
/dev Contains device files that represent hardware
devices connected to the system.
/etc Contains configuration files for the system and
installed applications.
/home Contains home directories for each user on the
system
/lib Contains shared libraries required by programs
in /bin and /sbin.
/mnt Used for temporarily mounting filesystems, such
as external drives or network shares.
/opt Typically used for installing third-party software
packages
/proc A virtual file system that provides information
about processes and system information.
/root Home directory for the root user (superuser).
/sbin Contains system administration binaries.
/tmp Used for storing temporary files created by
programs or users.
/usr Contains user binaries, libraries, documentation,
and other resources.
/var Contains variable data files, such as log files,
spool files, and temporary files.

4. BASIC SHELL COMMANDS USED IN TERMINAL


ls - List directory contents: rm - Remove files or directories:
cd - Change directory: cat - Concatenate and display file content:
pwd - Print working directory: head - Display the beginning of a file:
mkdir - Make directory: tail - Display the end of a file:
rmdir - Remove directory: grep - Search for a pattern in files:
touch - Create an empty file: chmod - Change file permissions:
cp - Copy files and directories: chown - Change file owner and group:
mv - Move (rename) files and directories:

HTB Linux Fundamentals Tier 0


5. Creating and managing user accounts

Creating and managing user accounts in Linux involves several steps, including creating a new user,
setting passwords, managing user groups, and assigning permissions. Here's an overview of the process,
along with some considerations for permissions and security:

5.1 Creating a User Account:


Use the adduser or useradd command to create a new user account.
Example: sudo adduser newuser (creates a new user named "newuser")
Setting Passwords:
Set a password for the new user using the passwd command.
Example: sudo passwd newuser (sets a password for the user "newuser")
Managing User Groups:
Use the usermod command to add or remove a user from a group.
Example: sudo usermod -aG groupname newuser (adds "newuser" to the group "groupname")
Viewing User Information:
Use the id command to view information about a user, including their groups.
Example: id newuser (displays information about the user "newuser")
Deleting User Accounts:
Use the userdel command to delete a user account.
Example: sudo userdel -r newuser (deletes the user "newuser" and removes their home directory)

5.2 Permissions and security considerations

File Permissions:
Linux uses a permission system to control access to files and directories.
Use the chmod command to change file permissions.
Example: chmod 755 file.txt (sets read, write, and execute permissions for the owner, and read and
execute permissions for group and others)
User Privileges:
Linux uses the sudo (superuser do) command to grant administrative privileges to users.
Add a user to the sudo group to grant them sudo access.
Example: usermod -aG sudo newuser (adds "newuser" to the sudo group)
Security Best Practices:

HTB Linux Fundamentals Tier 0


Use strong passwords for user accounts.
Limit user access to only what is necessary for their role (least privilege principle).
Regularly review user accounts and permissions to ensure they are up-to-date.
Monitoring and Logging:
Enable logging and monitoring to track user activities and detect any unauthorized access.
PAM (Pluggable Authentication Modules):
Use PAM to enforce strong authentication policies, such as password complexity requirements and
account lockout policies.

6. LINUX SYSTEM MANAGEMENT


Linux system management involves a range of tasks to ensure the smooth operation, security, and
performance of a Linux-based computer system.

User and Group Management:


Creating, modifying, and deleting user accounts (adduser, usermod, userdel).
Managing user groups (addgroup, groupmod, groupdel).
Setting file and directory permissions (chmod, chown).
Package Management:
Installing, updating, and removing software packages (apt, yum, dnf, zypper).
Managing package repositories (apt- or yum-related commands).
System Monitoring and Performance Tuning:
Monitoring system resources (CPU, memory, disk usage) (top, htop, vmstat, iostat).
Tuning kernel parameters (sysctl).
Analyzing system logs (journalctl, dmesg, log files in /var/log).
File System Management:
Creating, mounting, and unmounting file systems (mount, umount).
Checking file system integrity (fsck).
Managing disk space (df, du).
Network Configuration:
Configuring network interfaces (ifconfig, ip).
Setting up network routing and DNS (route, iptables, firewalld, resolv.conf).
Monitoring network activity (netstat, ss).
Security and Access Control:
Configuring firewall rules (iptables, firewalld).

HTB Linux Fundamentals Tier 0


Enforcing access control (permissions, SELinux, AppArmor).
Managing user authentication (PAM, SSH keys).
Backup and Recovery:
Creating and restoring system backups (rsync, tar, dd).
Implementing disaster recovery plans.
System Updates and Patch Management:
Keeping the system up to date with security patches and software updates (apt, yum, dnf, zypper).
Service Management:
Starting, stopping, and restarting system services (systemctl, service).
Enabling or disabling services to start at boot (systemctl enable, chkconfig).
Remote Administration:
Managing Linux systems remotely using SSH (ssh), remote desktop protocols (VNC, RDP), or web-
based management interfaces.

7. LINUX SECURITY
Using a firewall is an essential part of Linux hardening to control incoming and outgoing network traffic
and protect the system from unauthorized access. Here's how you can harden your Linux system using a
firewall (specifically iptables):
Install iptables:
Most Linux distributions come with iptables pre-installed. If not, you can install it using your package
manager (apt, yum, etc.).
Configure iptables:
Define your firewall rules using the iptables command. For example, to allow SSH traffic (port 22) and
block all other incoming traffic:
bashCopy code
# Allow incoming SSH (port 22) traffic iptables -A INPUT -p tcp --dport 22 -j ACCEPT # Block all other
incoming traffic iptables -A INPUT -j DROP
Similarly, you can define rules for outgoing traffic using the OUTPUT chain.
Save iptables Rules:
Save your iptables rules so they persist across reboots. The exact method depends on your Linux
distribution.
For iptables-persistent on Debian/Ubuntu:
bashCopy code
sudo apt-get install iptables-persistent sudo iptables-save > /etc/iptables/rules.v4

HTB Linux Fundamentals Tier 0


For other distributions, you can use iptables-save and iptables-restore commands or add your rules to a
startup script.
Additional iptables Rules:
Consider adding additional rules to further secure your system, such as:
Limiting the rate of incoming connections to prevent DoS attacks.
Restricting access to specific IP addresses or ranges.
Logging blocked packets for later analysis.
Testing:
Test your firewall rules to ensure they are working as expected. Use tools like nmap to scan your system
from an external network.
Monitoring and Maintenance:
Regularly monitor your firewall logs for suspicious activity.
Update your firewall rules as needed to adapt to changes in your network environment.
Using Other Firewall Solutions:
While iptables is a powerful and commonly used firewall solution, you may also consider using other
firewall solutions like firewalld or ufw depending on your requirements and familiarity with the tools.

8. CONCLUSION
In conclusion, Linux is a powerful and versatile operating system that has gained popularity due to its
open-source nature, stability, and security features. Throughout this report, we have explored the basics of
Linux, including its history, file system structure, shell commands, and package management.
Package management in Linux simplifies the installation, updating, and removal of software packages,
ensuring system security and stability. We also explored basic shell commands for file and directory
manipulation, essential for day-to-day system administration tasks.

HTB Linux Fundamentals Tier 0


Fig 3 : Earned badge after completion of the module.

https://academy.hackthebox.com/achievement/badge/d408ec19-e1d6-11ee-b18d-bea50ffe6cb4

A Few Labs sessions for Linux Fundamentals

The following question are required to be answered. Under

HTB Linux Fundamentals Tier 0


Fig 3: two questions under files in linux

HTB Linux Fundamentals Tier 0


Fig: on checking the files under /var/backups, we find that the last modified file is
“apt.extended_states.0” which was modified last on November 12th 2020.

Question 2 solution.

the above image showing the inode number of the file “shadow.bak” as 265293

HTB Linux Fundamentals Tier 0


Fig: 3 questions on file Find Files and Directories
Solution is as shown below:-
Quiz 1

Answer is 00-mesa-defaults.conf

HTB Linux Fundamentals Tier 0


Quiz 2

4 files which has .bak extensions.


Quiz 3

HTB Linux Fundamentals Tier 0


Command which xxd shows the path for xxd directory. /usr/bin/xxd

Task Scheduling lab quiz

1 quiz for task scheduling.

Command Solution is as show below

HTB Linux Fundamentals Tier 0


Type is notify

HTB Linux Fundamentals Tier 0

You might also like