Day 1

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 8

DAY 1

TASK 1: Virtual Box Installation

TASK 2: Setting up CentOS

TASK 3: Core Commands


To create a file
→ touch filename.txt (just creates the file to write the contents use nano command)
→ cat > filename.txt (create and ca
→ nano filename.txt (write the contents and save it using ctrl+o and press enter to save, and exit using
ctrl+x)

To display the contents of the file


→ cat filename.txt (used to concatenate and output the contents).
→ less filename.txt (used to view the contents of a file one screen at a time. Use ‘spacebar’ to see the next
page and ‘q’ to exit)
→ more filename.txt (same features as less)
→ head -n 10 filename.txt (displays first 10 lines…default is 10 lines)
→ tail -n 10 filename.txt (displays the last 10 lines )

Cat command:
→ Cat filename.txt → displays the content of the file.
→ Cat file1.txt file2.txt → concatenates both files
→ Cat file1.txt file2.txt > newfile.txt → concatenates and copies the content into newfile.
→ Cat -n file1.txt → gives the number of lines used.
After creating the contents using cat and viewing the contents using nano press’q’ to exit.

Grep command:
→ grep “pattern” filename (find out pattern in the file)
→ grep -i “pattern” filename (case insensitive)
→ grep -n “pattern” filename (displays the line that matches the pattern)
→ grep -v “pattern” filename (invert match – displays the lines that don't match the pattern)

TASK 4: Users and Groups


UID – User ID
GID – Group ID
UID 0 – the root user (has high privileges on the system.
Wheel group: Have special(higher) privileges on the system, such as the ability to become root
or the ability to bypass certain security restrictions.
Linux has GUI tools to manage users and groups.

To add user → useradd username (At first while creating the account, it is created without the
password)
To add password → passwd username
To create a new group → groupadd groupname
To set group password → gpasswd -a groupname

/etc/passwd → Stores basic information about user accounts.


Example: username : password : UID : GID : GECOS : home_dir : shell (one line per user
separated by : )

/etc/shadow → Stores encrypted password hashes and additional password-related information.


→ Each line represents a user account and contains details like
● password hash,
● password expiration,
● and other security-related settings.
Example: john:$6$ABC123$...:18732:0:99999:7:::

/etc/group → Contains a list of groups on the system


● Group name,
● Optional group password,
● Numeric GID,
● Comma separated list of users in the group.
Example: webdev:x:502:user1, user2, user4

Su and sudo: (su→ substitute user user to switch user)

The sudo command allows authorized users to perform administrative tasks without logging in
as the root user.

TASK 5: Applications and Services

Two categories of software:


Applications
Services (Daemons)

Boot process:
BIOS (basic input output system)
Boot loader (loads the kernel into the memory)
Kernel Loading
Mounting Partitions
Init system (systemd)

Services configured using systemct1


Commands:
Systemct1 enable/disable servicename
Systemct1 start/stop/restart/reload servicename
Systemct1 status servicename
Attackers create backdoor service in /etc/systemd/system/
By creating their own service and configuring it to start at boot, the attacker's service will start
every time the machine boots.

TASK 6: File system, Ownership, and Permissions


FIles or directories starting with ‘.’ are hidden by default.
Can view them using by adding “-a” option to ls

FIle permissions:
Read
Write
Execute
It is defined separately by User, Group and other

r=4, w=2, x=1


Chmod 754 filename.txt → rwx r-x r–

Important DIrectories:
1. /bin & /usr/bin
→ Contains executable programs
→ bin stands for “binary”
→ Contains essential commands that are required for the system to boot and repair itself (ex: ls,cp,mv)
→ /usr directory stands for ”Unix System Resources” containing user binaries (executable files ) that are
not necessary for the system’s basic functionality.

2. /sbin & /usr/sbin (system binary & system binaries for user commands)
→ contains executable programs that root users generally need.

3. /lib & /usr/lib


→ Contains kernel modules

DLL → Dynamic Link Libraries play a role similar to shared libraries. Contains compiled code and data
that multiple programs can use simultaneously

SUID bit:
→ Set User ID (SUID) bit
→ As a regular user, it allows the user to run the program with the permission of the file owner, giving it
temporary elevated privileges.

● Suppose we are changing the password, which is done by “passwd”.


● The changed password is updated in /etc/shadow file, which can only be done only by
the root user.
● To achieve this, “passwd” has the SUID bit set, so it runs with root privileges, regardless
of who runs it.
● If a program with the SUID bit has a vulnerability, an attacker might exploit it to gain full
root access to the system.
● Due to this risk, programs with the SUID bit need careful coding and thorough security
audits to ensure they are free from vulnerabilities.

Command:
Find / -name “ “ 2>/dev/null

● find: This is the command used to search for files and directories in a directory
hierarchy.
● /: This specifies the starting point for the search, and in this case, it is the root directory,
which is the top-level directory in a Unix/Linux file system.
● -name: This option is used to search for files based on their names.
● 2>/dev/null: This part of the command redirects standard error (stderr) to /dev/null. The
2>/dev/null part ensures that any error messages generated during the search are
discarded and not displayed on the terminal. The result is a cleaner output with only the
found files and directories.

Rm -rf /home/cyberaces/” “

Rf - which is used to forcefully and recursively delete a directory and its entire contents,
including all subdirectories and files, without asking for confirmation. This command should be
used with extreme caution because once executed, the data cannot be easily recovered.

TASK 7: Installing Software


Software comes in 2 different forms :
Source → has to be compiled
Packages → Install easily and are generally distro-specific

You might also like