JTCyberTech / Cybersecurity-Home-Labs

5 stars 1 forks source link

2. 25 Intermediate Commands Hands-On Tasks #78

Open JTCyberTech opened 11 months ago

JTCyberTech commented 11 months ago

25 Intermediate Commands Hands-On Tasks

Task 1:

Query the Domain Name System for "Udemy.com".



Task 2:

Identify the location of executable "bash". - Command: ```which bash```. - Description: - ```which```: used to locate and display the path of an executable program or script in the system's directories. [Command] - ```bash```: the executable program that you want "which" command to locate. [Name of Command of Program]



Task 3:

List all running processes with full format listing for each process. - Command: ```ps -ef```. - Description: - ```ps```: print the running process. [Command] - ```-e```: select all the processes from system. [Option] - ```-f```: provide full format listing for every process running on system. [Option]



Task 4:

Display what programs are currently running on the system and how much system resources they are utilizing. - Command: ```top```. - Description: - ```top```: show the real-time view of running processes in the Linux System. [Command]



Task 5:

Which command is used to download/upload data to a server with supported protocols such as HTTP, FTP, SFTP, IMAP, POP3, etc? - Command: ```curl udemy.com```. - Description: - ```curl```: used by developers to transfer data to and from any server. [Command] - ```udemy.com```: hostname or IP address of the host you want to send the GET request. [destination hostname] **Forbidden**

Task 6:

Retrieves content from web "udemy.com" into index.html file. - Command: ```wget udemy.com```. - Description: - ```wget```: multiple features like downloading large files, retrieving content from web servers. [Command] **Forbidden**

Task 7:

Search "Git" package for Linux machine. - Command: ```yum search git```. - Description: - ```yum```: allows users to install, update, remove or search a software package. [Package Manager] - ```search```: used to search the repository for packages matching a specific query. [Command] - ```git```: the search query. [Query]



Task 8:

Print information about your Linux system like the machine name, operating system. - Command: ```uname -a```. - Description: - ```uname```: print the name, operating system, and few other details about the current machine. [Command] - ```-a```: option short for "all". [Option]



Task 9:

Display the status of TCP and UDP endpoints, routing table info., and interface information. - Command: ```netstat```. - Description: - ```netstat```: print the network status and the protocol statistic. [Command]



Task 10:

Display the disk space used in the file system. - Command: ```df```. - Description: - ```df```: display the disk space information. [Command]



Task 11:

Display the disk space used in the Human-Readable format (eg: in MB/GB) - Command: ```df -h```. - Description: - ```df```: display the disk space information. [Command] - ```-h```: human-readable format. [Option]



Task 12:

Print the network interface configuration information on screen. - Command: ```ifconfig```. - Description: - ```ifconfig```: print the network interface configuration information. [Command]



Task 13:

Display details about block devices on your Linux machine. - Command: ```lsblk```. - Description: - ```lsblk```: display detail about block device on your Linux machine. [Command]



Task 14:

Print the message buffer of the kernel on your Linux OS. - Command: ```dmesg```. - Description: - ```dmesg```: used to examine the kernel's ring buffer and also to display the kernel related messages. [Command]



Task 15:

Create a new User name as "devops" on Linux. - Command: ```adduser devops```. - Description: - ```adduser```: used to add a new user. [Command] - ```devops```: the desired username for the new user you want to create. [Argument]



Task 16:

Delete the User "devops" from your machine. - Command: ```userdel devops```. - Description: - ```userdel```: used to delete user. [Command] - ```devops```: the desired username for the new user you want to create. [Argument]



Task 17:

Install a new package "httpd" on your machine. - Command: ```yum install httpd```. - Description: - ```yum```: allows users to install, update, remove or search a software package. [Package Manager] - ```install```: This is the subcommand that instructs "yum" to install a package. [Subcommand] - ```httpd```: the name of the package you want to install. [Package]



Task 18:

Remove package "httpd" form your machine. - Command: ```yum remove httpd```. - Description: - ```yum```: allows users to install, update, remove or search a software package. [Package Manager] - ```remove```: This is the subcommand that instructs "yum" to remove a package. [Subcommand] - ```httpd```: the name of the package you want to install. [Package]



Task 19:

Put your terminal on sleep for 30 Seconds. - Command: ```sleep 30```. - Description: - ```sleep```: used to pause the execution of subsequent commands for a specified amount of time. [Command] - ```30```: argument you are providing to the sleep command, indicating that it should wait for 30 seconds before allowing the command after it to execute. [Argument]



Task 20:

List all the files under "/etc" directory which are modified in last 30 days. - Command: ```find /etc -iname "*" -type f -mtime -30```. - Description: - ```find```: used for searching files and directories in the file system. [Command] - ```/etc```: starting directory or path where the search begins. In this case, the search will start in the /etc directory. [Directory] - ```-iname "*"```: used to specify the name of the files being searched for. The "-iname" option is used for a case-insensitive search. "*" is a wildcard that matches any file name. So, it will search for files with any name. [Option] - ```-type f```: specifies that the search is limited to regular files. - ```-type```: option is used to filter by file type [Option] - ```f```: stands for regular files. [Option] - ```-mtime -30```: specifies the condition based on modification time. - ```-mtime```: used to search for files modified within a specific time frame [Option] - ```-30```: indicates files modified within the last 30 days. [Option]



Task 21:

Grep "root" keyword from "/var/log/dnf.log" file. - Command: ```grep "root" /var/log/dnf.log```. - Description: - ```grep```: used to search for text patterns in files. [Command] - ```"root"```: the search pattern or string enclosed in double quotes. In this case, you are looking for lines that contain the word "root". [Search Pattern] - ```var/log/dnf.log```: the file path specifying the location of the file in which you want to search for the pattern. In this case, you are searching in the "/var/log/dnf.log" file. [File Path]



Task 22:

Print the count (# of times, root keyword found) by performing grep "root" keyword from "/var/log/dnf.log" file. - Command: ```grep -c "root" /var/log/dnf.log```. - Description: - ```grep```: used to search for text patterns in files. [Command] - ```-c```: used to instruct grep to count the number of matching lines rather than displaying the actual lines. Count how many times the string "root" appears in the file. [Option] - ```"root"```: the search pattern or string enclosed in double quotes. In this case, you are looking for lines that contain the word "root". [Search Pattern] - ```var/log/dnf.log```: the file path specifying the location of the file in which you want to search for the pattern. In this case, you are searching in the "/var/log/dnf.log" file. [File Path]



Task 23:

Follow the below steps: 1. Create an empty file "devops.txt" 2. echo "Test" > devops.txt 3. Replace the "Test" word with "Hello" and update the same file using suitable command - Command: ```sed -i "s/Test/Hello/" devops.txt```. - Description: - ```sed```: used for text stream editing. [Command] - ```-i```: option for sed, which stands for "in-place." When used with -i, it instructs sed to edit the file in-place, meaning it will directly modify the file rather than just displaying the changes on the terminal. [Option] - ```s/Test/Hello/```: a sed script or expression. It specifies the replacement to be made in the text stream. In this case, it's looking for the string "Test" and replacing it with "Hello." The format is s/pattern/replacement/, where "pattern" is what you're searching for, and "replacement" is what you want to replace it with. [Script] - ```devops.txt```: the filename of the file you want to edit using the sed command. [File]



Task 24:

Print Second Column of top 100 rows from '/var/log/dnf.log' file. - Command: ```awk '{print $2}' /var/log/dnf.log | head -100```. - Description: - ```awk```: used to invoke the Awk text-processing utility. [Command] - ```'{print $2}'```: This is an Awk script enclosed in single quotes. It specifies what action Awk should perform on each line of input. [Script] - ```print```: an Awk command that tells it to print or display the specified value. [Script] - ```$2```: refers to the second column in each line of input. [Script] - ```|```: used to take the output of the command on the left and use it as input for the command on the right. [Pipe] - ```head```: This is the command used to display the beginning lines of a text file. [Command] - ```-100```: specifies that you want to display the first 100 lines of the input. [Option]



Task 25:

Print second and third column from '/var/log/dnf.log' file , print only for top 50 rows - Command: ```awk '{print $2, $3}' /var/log/dnf.log | head -50```. - Description: - ```awk```: used to invoke the Awk text-processing utility. [Command] - ```'{print $2, $3}'```: This is an Awk script enclosed in single quotes. It specifies what action Awk should perform on each line of input. [Script] - ```print```: an Awk command that tells it to print or display the specified value. [Script] - ```$2, $3```: refers to the second column and third column in each line of input. [Script] - ```|```: used to take the output of the command on the left and use it as input for the command on the right. [Pipe] - ```head```: This is the command used to display the beginning lines of a text file. [Command] - ```-50```: specifies that you want to display the first 50 lines of the input. [Option]