Report writing for fundamental of computing (week 11)

 Topic E02

Linux Network and Process Management.

WHAT IS PROCESS IN LINUX?
In Linux, a process refers to an active program, essentially an occurrence of a program that the Linux kernel is currently running. Every process is distinguished by a distinct Process ID (PID) and possesses its individual allocation of resources, including memory and CPU usage.

 

PROCESS ID (PID)

A process ID (PID) serves as a distinctive label given to a process.

PROCESS STATE 
1. Running: This means the process is actively executing its code at the moment.
2. Ready: The process is prepared to run but is in a queue, waiting for its turn to utilize the         CPU.
3. Sleeping: The process is temporarily paused and is waiting for some event or another process to become accessible before it can resume.
4. Stopped: The process has been intentionally halted either by the user or by the system itself.
5. Zombie: In this state, the process has concluded its execution, yet it still retains an entry in the process table, signifying that it hasn’t been entirely cleaned up yet.

 

PROCESS MANAGEMENT 
You can manage processes using various commands:

1.ps: The ps command is used to show a snapshot of the current processes. For example:
  • ps: Displays a list of processes running in your current session.
  • ps aux: Provides a more detailed list of all processes on the system.
  • ps aux | grep username: Filters and displays processes specific to a user.
2./proc/PID/status: You can view detailed information about a specific process using this command. Replace <PID> with the actual Process ID of the process you want to inspect. For example, cat /proc/1234/status would display information about the process with PID 1234.

3.top: The top command is a real-time process monitor that displays information about all running processes. For example:
  • top: Displays a dynamic list of processes and their resource usage.
  • top -u root: Displays processes owned by the “root” user.
  • top -u username: Displays processes specific to a user.
4.kill: The kill command is used to halt a process. You can use it as follows:
  • kill <PID>: Stops a specific process by replacing <PID> with the actual process ID.
  • kill -9 <PID>: Forcefully terminates a process using the SIGKILL signal.
5.systemctl: If your system has services, you can use the systemctl command to check the status, start, or stop a service with commands like:
  • sudo systemctl status service_name (replace service_name with the actual service name)
  • sudo systemctl start service_name
  • sudo systemctl stop service_name


NETWORK CONFIGURATION 
You can access network interface information using commands such as ifconfig, ip addr, and ip link. To retrieve routing information for the network your device is connected to, use the ip route command.
Network-related configuration files can be found in the /etc/netplan/ directory, usually in YAML format. Default configuration often employs NetworkManager for network management. For specific network configurations, you can explore /etc/NetworkManager/system-connections/<connection-name> where <connection-name> is the name of your network connection. To list all available network connections, navigate to /etc/NetworkManager/system-connections/.

 

NETWORK COMMANDS
Here are some additional network commands and their purposes:
1.netstat: This command is used to display a wide range of network information, including routing tables, network interfaces, active connections, and open ports, among others.

 

2.ping: Used to test the reachability of a host by sending ICMP echo requests and waiting for responses. It’s commonly used to check network connectivity and measure latency.

  

3.traceroute: Helps you trace the path that network packets take from a source to a destination. It provides information about each hop along the way, including IP addresses and response times.

 

4.nslookup: Used to obtain DNS (Domain Name System) information. You can use it to find the IP address associated with a domain name (forward lookup) or to find the domain name associated with an IP address (reverse lookup).

 

5.ssh: Secure Shell is used for remote login and executing commands on a remote machine. It provides encrypted communication for secure access to remote systems.
These network commands are essential for diagnosing network issues, testing connectivity, and managing remote systems.

 


FIREWALL CONFIGURATION 
Configuring the firewall with UFW (Uncomplicated Firewall) is a good way to enhance your system’s security. Here are the steps:
1. Check UFW Status:
  • To check the status of UFW, use the command: sudo ufw status.
  • f the status is “inactive,” enable UFW by running: sudo ufw enable.


2. Blocking a Website:
  • If you want to block access to a specific website, use the following command: sudo ufw deny out to <ip-address>. Replace <ip-address> with the actual IP address of the website you want to block. You can use the nslookup command to find the IP address of the website.

 

3. Reload Firewall Rules:
  • After making changes to the firewall rules, it’s a good practice to reload the firewall with: sudo ufw reload.
4. Additional Firewall Commands:
  • To remove a previously blocked website or IP address, use the command: sudo ufw delete deny out to <ip-address>. Replace <ip-address> with the specific IP address you wish to unblock.
  • To turn off the firewall entirely, you can do so with the command: sudo ufw disable.
  • To expand your firewall rules and add more specific configurations, you can use commands like sudo ufw allow and sudo ufw deny. These commands allow you to define rules based on port numbers, protocols, application names, or other criteria, providing you with flexibility in managing your firewall settings.

Comments

Popular posts from this blog

Report writing for fundamental of computing (week 12 and 13)

Report writing for fundamental of computing (week 14)

Report writing for fundamental of computing (week 8)