Lecture 11 Linux Network and Process Management

 Process

In Linux, a process is a currently executing program, representing an instance of a program managed by the Linux kernel. Every process is distinguished by a specific Process ID (PID) and possesses its own allocated resources, including memory and CPU time.

Process States

Process States in a System:

  • Running: Actively executing code.
  • Ready: Awaiting CPU time to run.
  • Sleeping: Paused, pending an event or resource.
  • Stopped: Halted intentionally by user or the system.
  • Zombie: Process finished, but still listed in the process table.


Process Management



Commands for Managing Processes in Linux:

  • ps: Displays a snapshot of the current processes.
            Example: ps
  • ps aux: Shows detailed information about all processes.
            Example: ps aux
  • ps aux | grep username: Filters processes by a specific username.
            Example: ps aux | grep your_username

  • cat /proc/<PID>/status: View detailed information about a specific process using its Process ID (PID).
            Example: cat /proc/1234/status

  • top: Real-time process monitor, providing information on running processes.
            Example: top

  • top -u root: Lists processes owned by the "root" user.
            Example: top -u root

  • top -u username: Displays processes owned by a specific username.
        Example: top -u your_username

  • gnome-system-monitor: Opens a GUI-based system monitor for a more user-friendly interface.

  • kill <PID>: Used to stop a process by its Process ID (PID).
            Example: kill 1234 (replace 1234 with the actual PID)

  • kill -9 <PID>: Forcefully stop a process using the SIGKILL signal.
            Example: kill -9 1234 (replace 1234 with the actual PID)

For managing services:

  • sudo systemctl status service_name: Check the status of a service, replacing "service_name" with the actual service name.
        Example: sudo systemctl status apache2
  • sudo systemctl start service_name: Start a service.
        Example: sudo systemctl start apache2

  • sudo systemctl stop service_name: Stop a service.
        Example: sudo systemctl stop apache2


These commands help you manage and monitor processes in a Linux system.


Network Configuration


Networking commands and configuration in Linux:

To access network interface information:

  • ifconfig: Display network interface details (deprecated on some systems).
  • ip addr or ip link: Show network interface information using the ip command.
To access routing information:

  • ip route: View the routing table and network routes for the connected device.
To access network configuration files:

Configuration files are typically located in the /etc/netplan/ directory.
The default configuration file is often in YAML format.
NetworkManager is a commonly used tool for managing network configurations.

These commands and locations are essential for managing and configuring network interfaces in a Linux system.

Specific network connection configuration:

Configuration files for specific network connections can be found in /etc/NetworkManager/system-connections/.
You can access details about your current connection in /etc/NetworkManager/system-connections/<connection-name>.
Listing network connection names:

To list all network connection names, navigate to /etc/NetworkManager/system-connections/ and view the files located there.
Other network-related configuration files include:

  • /etc/host.conf: Specifies the order in which hostnames are resolved.
  • /etc/hosts: Maps IP addresses to hostnames/domain names for local resolution.
  • /etc/hostname: Contains the name of your system's hostname, which helps identify your system on the network.
  • /etc/hosts.deny and /etc/hosts.allow: Used for configuring access control rules for network services.
These files hold important network configuration details and can be edited to modify network settings on your Linux system.


Network Commands


Network Commands in Linux:

netstat: Displays various network information, including routing tables, network interfaces, active connections, and open ports. Note that ss is becoming a more common and efficient alternative to netstat.

ping: Tests the reachability of a host and measures round-trip latency by sending ICMP echo requests.

traceroute: Shows the path and network hops taken by packets from the source to the destination host, helping diagnose network connectivity issues.

nslookup: Obtains information about the mapping between IP addresses and domain names or vice versa, primarily used for DNS troubleshooting.

ssh: Allows remote login to another system over a secure shell (SSH) connection. It provides a secure and encrypted way to access and manage remote systems.

These network commands are essential for network diagnostics, troubleshooting, and remote system administration in a Linux environment.

Firewall Configuration

We will make use of ufw(uncomplicated firewall) firewall which comes built in. It is simple to use it. Try out:
  • sudo ufw status
  • sudo ufw enable (in case status is inactive run this command)
Now if you want to block the certain website you can use the command.
  • sudo ufw deny out to <ip-address> [replace ip address with actual ip address of website, make use of nslookup command to know the ip address of website].
  • sudo ufw reload [to reload firewall]
To unblock outgoing traffic to a specific IP address:
  • sudo ufw delete deny out to <ip-address>

To disable the firewall:
  • sudo ufw disable.

Comments

Popular posts from this blog

Lecture 2 - Fetch, Execution and IO

Lecture 12 Clint Server Architecture