LinuxFundamentals JustusKoech
LinuxFundamentals JustusKoech
Today, Linux is available in over 600 distributions, including well-known ones like
Ubuntu, Debian, and Fedora. Praised for its security, stability, and performance, Linux is
utilized across a broad spectrum of devices, from servers and desktops to embedded
systems like routers and video game consoles. Despite its strengths, Linux may present
challenges for beginners and lacks the extensive hardware driver support of Windows.
Being free and open-source, Linux allows for modification and distribution by anyone,
making it highly versatile and widely adopted. Notably, the Android operating system,
which powers smartphones and tablets, is based on the Linux kernel, contributing to
Linux's status as the most widely installed operating system. Moreover, with platforms
like Parrot OS, a Debian-based Linux distribution focused on security and privacy, Linux
continues to play a significant role in various domains, including cybersecurity and
development.
System Information
We need to learn the structure and the information about the system, its processes, network
configurations, users, directories, user settings, and the corresponding parameters. Here is a list
of the necessary tools that will help us get the above information. Most of them are installed by
default.
Questions
Find out the machine hardware name and submit it as the answer.
clAnswer: x86_64
Answer: /home/htb-student
Answer: /var/mail/htb-student
Which shell is specified for the htb-student user?
user?
Answer: /bin/bash
Answer: 4.15.0
What is the name of the network interface that MTU is set to 1500? Answer: ens192
Navigation
Navigation is essential, like working with the mouse as a standard Windows user. With it, we
move across the system and work in directories and with files, we need and want. Therefore, we
use different commands and tools to print out information about a directory or a file and can use
advanced options to optimize the output to our needs.
Questions
What is the name of the hidden “history” file in the htb-user’s home directory?
Answer: .bash_history
What is the index number of the “sudoers” file in the “/etc” directory?
Answer: 147627
The terminal in Linux is a more efficient and faster tool because you can access the files directly
with a few commands and edit and modify them selectively with regular expressions (regex).
You can also run several commands simultaneously and redirect the output to a file.
Questions
What is the name of the last modified file in the “/var/backups” directory?
Answer: apt.extended_states.0
What is the inode number of the “shadow.bak” file in the “/var/backups” directory?
Answer: 265293
Find Files and Directories
It is crucial to be able to find the files and folders we need. Once we have gained access to a
Linux based system, it will be essential to find configuration files, scripts created by users or the
administrator, and other files and folders. One of the common tools is which. This tool returns
the path to the file or link that should be executed. This allows us to determine if specific
programs, like cURL, netcat, wget, python, gcc, are available on the operating system. Let us use
it to search for Python in our interactive instance.
Questions
What is the name of the config file that has been created after 2020–03–03 and is smaller than
28k but larger than 25k?
Answer: 00-mesa-defaults.conf
How many files exist on the system that have the “.bak” extension?
Answer: 4
Answer: /usr/bin/xxd
Questions
How many files exist on the system that have the “.log” file extension?
Answer: 32
Answer: 737
Filter Contents
To read files, we do not necessarily have to use an editor for that. There are two tools called more
and less, which are very identical. These are fundamental pagers that allow us to scroll through
the file in an interactive view. After we read the content using cat and redirected it to more, the
already mentioned pager opens, and we will automatically start at the beginning of the file.If we
now take a look at the tool less, we will notice on the man page that it contains many more
features than more.
Questions
How many services are listening on the target system on all interfaces? (Not on localhost and
IPv4 only)
Answer: 7
Determine what user the ProFTPd server is running under. Submit the username as the answer.
Answer: proftpd
Use cURL from your Pwnbox (not the target machine) to obtain the source code of the
“https://www.inlanefreight.com" website and filter all unique paths of that domain. Submit the
number of these paths as the answer.
Answer: 34
User Management
User management is an essential part of Linux administration. Sometimes we need to create new users or
add other users to specific groups. Another possibility is to execute commands as a different user. After
all, it is not too rare that users of only one specific group have the permissions to view or edit specific
files or directories.
Questions
Which option needs to be set to create a home directory for a new user using “useradd”
command?
Answer: -m
Which option needs to be set to lock a user account using the “usermod” command?
Answer: --lock
Which option needs to be set to execute a command as a different user using the “su” command?
(long version of the option)
Answer: --command
Service and Process Management
Most Linux distributions have now switched to systemd. This daemon is an Init process started
first and thus has the process ID (PID) 1. This daemon monitors and takes care of the orderly
starting and stopping of other services. All processes have an assigned PID that can be viewed
under /proc/ with the corresponding number. Such a process can have a parent process ID
(PPID), and if so, it is known as the child process.
Besides systemctl we can also use update-rc.d to manage SysV init script links. Let us have a
look at some examples. We will use the OpenSSH server in these examples.
Questions
Use the “systemctl” command to list all units of services and submit the unit name with the
description “Load AppArmor profiles managed internally by snapd” as the answer.
Answer: snapd.apparmor.service
Task Scheduling
Task scheduling is a feature in Linux systems that allows users to schedule and automate tasks. It
allows administrators and users to run tasks at a specific time or within specific frequencies
without having to start them manually. It can be used in Linux systems such as Ubuntu, Redhat
Linux, and Solaris to manage a variety of tasks.
Questions
Answer: notify
Working with Web Services
There are many different ways to set up web servers on Linux operating systems. One of the
most used and widespread web servers, besides IIS and Nginx, is Apache. For an Apache web
server, we can use appropriate modules, which can encrypt the communication between browser
and web server (mod_ssl), use as a proxy server (mod_proxy), or perform complex
manipulations of HTTP header data (mod_headers) and URLs (mod_rewrite).
Questions
Find a way to start a simple HTTP server inside Pwnbox or your local VM using “npm”. Submit
the command that starts the web server on port 8080 (use the short argument to specify the port
number). ON your linux terminal, enter the following syntax to update or install npm package
and
Find a way to start a simple HTTP server inside Pwnbox or your local VM using “php”. Submit
the command that starts the web server on the localhost (127.0.0.1) on port 8080.
This command starts the PHP built-in web server on localhost (127.0.0.1) on port 8080. Any
files in the current directory will be served by the server.
File system management on Linux is a complex process that involves organizing and
maintaining the data stored on a disk or other storage device. Linux is a powerful operating
system that supports a wide range of file systems, including ext2, ext3, ext4, XFS, Btrfs, NTFS,
and more.Regular files are the most common type of file, and they are stored in the root directory
of the file system. Directories are used to store collections of files.
Questions
Answer: 3
Conclusion