0% found this document useful (0 votes)
30 views28 pages

Ubantu basic commands

The document provides a comprehensive guide on various Ubuntu commands for system monitoring and troubleshooting, including `top`, `vmstat`, `iostat`, `netstat`, `sar`, `fdisk`, and `mount`. It details steps for diagnosing performance issues related to CPU, disk, memory, and network, as well as addressing login and boot problems. Each section includes commands, their purposes, key features, and usage examples to assist users in managing their Ubuntu systems effectively.

Uploaded by

aithitdepartment
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views28 pages

Ubantu basic commands

The document provides a comprehensive guide on various Ubuntu commands for system monitoring and troubleshooting, including `top`, `vmstat`, `iostat`, `netstat`, `sar`, `fdisk`, and `mount`. It details steps for diagnosing performance issues related to CPU, disk, memory, and network, as well as addressing login and boot problems. Each section includes commands, their purposes, key features, and usage examples to assist users in managing their Ubuntu systems effectively.

Uploaded by

aithitdepartment
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 28

Certainly!

Here's a detailed explana on of each of these commands in Ubuntu:

### 1. `top`

- **Purpose**: Displays the system's resource usage, showing a real- me summary of the system's
processes.

- **Key Features**:

- CPU usage by process

- Memory usage by process

- Load average

- Number of tasks

- Detailed informa on about each running process (PID, user, priority, etc.)

- **Usage**:

```sh

top

```

You can interact with `top` by pressing keys like `k` to kill a process, `r` to renice, `q` to quit, etc.

### 2. `vmstat`

- **Purpose**: Reports virtual memory sta s cs.

- **Key Features**:

- Informa on about processes

- Memory

- Paging

- Block IO

- Traps

- CPU ac vity

- **Usage**:

```sh

vmstat

```
You can specify a delay and count to repeatedly update the display, e.g., `vmstat 2 5` (update every 2
seconds, 5 mes).

### 3. `iostat`

- **Purpose**: Reports CPU sta s cs and input/output sta s cs for devices and par ons.

- **Key Features**:

- CPU u liza on

- Device u liza on

- Disk throughput

- **Usage**:

```sh

iostat

```

You can use op ons to display specific informa on, e.g., `iostat -d` for device u liza on.

### 4. `netstat`

- **Purpose**: Displays network connec ons, rou ng tables, interface sta s cs, masquerade
connec ons, and mul cast memberships.

- **Key Features**:

- Ac ve connec ons

- Listening ports

- Network sta s cs

- **Usage**:

```sh

netstat

```

Common op ons include:

- `-a`: Display all connec ons

- `-t`: Show TCP connec ons


- `-u`: Show UDP connec ons

- `-l`: Show only listening ports

- `-p`: Show the PID and program name of the socket owner

### 5. `sar`

- **Purpose**: Collects, reports, and saves system ac vity informa on.

- **Key Features**:

- CPU ac vity

- Memory and swap space u liza on

- I/O ac vity

- Network ac vity

- **Usage**:

```sh

sar

```

The `sysstat` package must be installed to use `sar`. You can use op ons like `-u` for CPU usage, `-r` for
memory, etc.

### 6. `fdisk`

- **Purpose**: Manipulates disk par on tables.

- **Key Features**:

- Create, delete, change, and list par ons

- Print the par on table

- Modify disk par ons interac vely

- **Usage**:

```sh

sudo fdisk /dev/sdX

```

Replace `/dev/sdX` with the appropriate disk iden fier. Use `m` for help within the interac ve session.

### 7. `mount`
- **Purpose**: Mounts a filesystem.

- **Key Features**:

- Mounts filesystems

- Displays mounted filesystems

- Unmounts filesystems with `umount`

- **Usage**:

```sh

mount

```

Common uses include:

- Moun ng a device: `sudo mount /dev/sdX1 /mnt`

- Viewing mounted filesystems: `mount` or `df -h`

Each of these commands is powerful and provides detailed insights and controls for system
administra on in Ubuntu.

To troubleshoot system performance issues related to CPU, disk, memory, and network, you can u lize
various Linux commands and techniques. Here is a detailed guide:

### 1. **Troubleshoo ng CPU Performance**

#### Tools:

- `top`

- `vmstat`

- `sar`

#### Steps:

1. **Check real- me CPU usage with `top`**:

- Run `top` and observe the `%CPU` column to see which processes are consuming the most CPU
resources.

- Look for processes with high CPU usage and consider if they are necessary or can be op mized.

2. **Use `vmstat` to get an overview of CPU performance**:

- Run `vmstat 2 5` to collect data every 2 seconds for 5 itera ons.


- Pay a en on to the `us`, `sy`, `id`, and `wa` columns which show user me, system me, idle me, and
I/O wait me respec vely.

3. **Historical CPU usage with `sar`**:

- Ensure `sysstat` package is installed.

- Run `sar -u 1 10` to display CPU usage sta s cs at 1-second intervals for 10 itera ons.

- Review `%user`, `%system`, `%iowait`, and `%idle`.

### 2. **Troubleshoo ng Disk Performance**

#### Tools:

- `iostat`

- `df`

- `du`

#### Steps:

1. **Check disk I/O sta s cs with `iostat`**:

- Run `iostat -x 2 5` to get extended I/O sta s cs at 2-second intervals for 5 itera ons.

- Look at `%u l` to see if the disk is heavily u lized, and `await` for average wait me for I/O requests.

2. **Check disk space usage with `df`**:

- Run `df -h` to see disk space usage in a human-readable format.

- Iden fy filesystems that are close to 100% u liza on and consider cleaning up or expanding them.

3. **Iden fy large files and directories with `du`**:

- Run `du -h --max-depth=1 /path/to/directory` to see the size of directories within the specified path.

- Drill down into directories to find large files that can be removed or archived.

### 3. **Troubleshoo ng Memory Performance**

#### Tools:

- `free`

- `vmstat`
- `top`

#### Steps:

1. **Check memory usage with `free`**:

- Run `free -h` to see the total, used, and free memory.

- Pay a en on to `available` memory which indicates how much memory is available for new processes
without swapping.

2. **Use `vmstat` to monitor memory and swap usage**:

- Run `vmstat 2 5` to get a snapshot of memory and swap usage.

- Look at `free`, `buff`, `cache`, `si`, and `so` columns for available memory and swap ac vity.

3. **Iden fy memory-hungry processes with `top`**:

- Run `top` and sort by memory usage by pressing `M`.

- Iden fy processes consuming high memory and consider op mizing or restar ng them.

### 4. **Troubleshoo ng Network Performance**

#### Tools:

- `netstat`

- `i op`

- `ping`

- `traceroute`

#### Steps:

1. **Check network connec ons and usage with `netstat`**:

- Run `netstat -an` to list all network connec ons.

- Use `netstat -i` to see network interface sta s cs.

2. **Monitor real- me network traffic with `i op`**:

- Install `i op` if not already installed.

- Run `sudo i op` to see real- me bandwidth usage per connec on.
3. **Test network connec vity with `ping`**:

- Run `ping google.com` to test connec vity to an external host.

- Look for packet loss or high latency which can indicate network issues.

4. **Trace the network path with `traceroute`**:

- Run `traceroute google.com` to see the path packets take to reach the des na on.

- Iden fy any hops with high latency or packet loss which can indicate network bo lenecks.

### General Troubleshoo ng Tips:

- **Check System Logs**: Use `dmesg`, `journalctl`, or check logs in `/var/log/` for error messages or
warnings that might indicate hardware or so ware issues.

- **Review System Updates**: Ensure the system is up-to-date with patches and updates which might fix
performance-related bugs.

- **Consider System Load**: Use `up me` to check the system load average. High load averages can
indicate the system is under heavy use and might need resource scaling.

- **Manage Running Services**: Use `systemctl` to review and manage running services. Disable
unnecessary services to free up system resources.

By systema cally using these tools and steps, you can iden fy and address performance issues related to
CPU, disk, memory, and network on your Ubuntu system.

Troubleshoo ng system login issues can involve several steps to iden fy and resolve the problem. Here is
a comprehensive guide to troubleshoot login issues on an Ubuntu system:

### 1. **Iden fy the Type of Login Issue**

1. **GUI Login Issues**: Problems with graphical login (GDM, LightDM, etc.).

2. **TTY Login Issues**: Problems logging in through terminal (TTY) interface.

3. **SSH Login Issues**: Problems with remote login via SSH.

### 2. **GUI Login Issues**

#### Steps:

1. **Check if the Display Manager is Running**:


- Ensure that the display manager (e.g., `gdm3`, `lightdm`) is running:

```sh

sudo systemctl status gdm3

```

- If it is not running, start it:

```sh

sudo systemctl start gdm3

```

2. **Examine Display Manager Logs**:

- Check logs for errors:

```sh

journalctl -xe | grep gdm

```

3. **Restart the Display Manager**:

- Restart the display manager to refresh the login screen:

```sh

sudo systemctl restart gdm3

```

4. **Check Disk Space**:

- Ensure that the root filesystem has enough space:

```sh

df -h

```

- Free up space if necessary.

5. **Check User's Home Directory**:

- Ensure the user's home directory exists and has the correct permissions:

```sh

ls -ld /home/username

```
- The user should own their home directory, and it should have appropriate permissions (usually `755`).

6. **Look for .Xauthority Issues**:

- Some mes, the `.Xauthority` file can cause login issues. Rename it to create a new one:

```sh

mv ~/.Xauthority ~/.Xauthority.backup

```

### 3. **TTY Login Issues**

#### Steps:

1. **Switch to a TTY**:

- Press `Ctrl + Alt + F3` to switch to a TTY.

2. **Check for Locked Accounts**:

- Ensure the account is not locked:

```sh

sudo passwd -S username

```

- Unlock the account if it is locked:

```sh

sudo passwd -u username

```

3. **Check Password Expiry**:

- Verify if the password has expired:

```sh

chage -l username

```

- Update the password if necessary:

```sh

sudo passwd username


```

4. **Check Shell Configura on**:

- Ensure the user has a valid shell:

```sh

cat /etc/passwd | grep username

```

- It should look something like:

```sh

username:x:1000:1000:User Name:/home/username:/bin/bash

```

5. **Examine Auth Logs**:

- Check the authen ca on logs for any errors:

```sh

sudo tail -f /var/log/auth.log

```

### 4. **SSH Login Issues**

#### Steps:

1. **Verify SSH Service Status**:

- Ensure that the SSH service is running:

```sh

sudo systemctl status ssh

```

- Start the service if it is not running:

```sh

sudo systemctl start ssh

```

2. **Check SSH Configura on**:

- Verify the SSH configura on file (`/etc/ssh/sshd_config`) for any issues.


- Restart the SSH service a er making changes:

```sh

sudo systemctl restart ssh

```

3. **Check SSH Logs**:

- Examine SSH logs for errors:

```sh

sudo tail -f /var/log/auth.log

```

4. **Check Firewall Se ngs**:

- Ensure that the firewall is not blocking SSH:

```sh

sudo ufw status

```

- Allow SSH through the firewall if necessary:

```sh

sudo ufw allow ssh

```

5. **Verify User Permissions**:

- Ensure that the user has the correct permissions to access the system via SSH.

- Check the user's home directory and `.ssh` directory permissions:

```sh

ls -ld /home/username

ls -ld /home/username/.ssh

ls -l /home/username/.ssh

```

- Correct permissions if needed:

```sh
chmod 700 /home/username/.ssh

chmod 600 /home/username/.ssh/authorized_keys

```

### General Troubleshoo ng Tips:

- **Reboot the System**: Some mes a simple reboot can resolve login issues.

```sh

sudo reboot

```

- **Check System Logs**: Use `journalctl -xe` to view system logs for any errors related to login a empts.

- **Ensure Account is Not Disabled**: Verify that the account is not disabled by checking `/etc/shadow`:

```sh

sudo grep username /etc/shadow

```

Look for any `!` or `*` characters which indicate a disabled account.

- **Test with Another User Account**: Check if the issue is specific to one user by a emp ng to log in
with another user account.

By following these steps, you can iden fy and resolve most system login issues on an Ubuntu system.

Troubleshoo ng system boo ng issues can be complex because they can be caused by hardware
problems, so ware misconfigura ons, or corrupted files. Here’s a detailed guide to diagnosing and
resolving boot issues on an Ubuntu system:

### 1. **Ini al Checks**

#### Steps:

1. **Power and Hardware Checks**:

- Ensure the computer is properly powered on.

- Check all cables (power, data, etc.) and hardware components (RAM, disk, etc.).

2. **Check Boot Order**:


- Enter the BIOS/UEFI se ngs (usually by pressing `F2`, `F12`, `Del`, or `Esc` during startup).

- Ensure the boot order is correct and the boot drive is priori zed.

### 2. **GRUB Bootloader Issues**

#### Steps:

1. **GRUB Menu Access**:

- If the GRUB menu does not appear, hold `Shi ` (for BIOS systems) or `Esc` (for UEFI systems) during
boot to access it.

2. **Rescue Mode**:

- From the GRUB menu, select `Advanced op ons for Ubuntu`.

- Select a recovery mode entry, which is usually labeled as `(recovery mode)`.

3. **Update GRUB Configura on**:

- If you can boot into recovery mode or a live USB, update the GRUB configura on:

```sh

sudo update-grub

```

4. **Reinstall GRUB**:

- Boot from a live USB.

- Open a terminal and mount the root par on:

```sh

sudo mount /dev/sdXn /mnt

```

Replace `/dev/sdXn` with your root par on.

- Bind the necessary directories:

```sh

sudo mount --bind /dev /mnt/dev

sudo mount --bind /proc /mnt/proc


sudo mount --bind /sys /mnt/sys

```

- Chroot into your system:

```sh

sudo chroot /mnt

```

- Reinstall GRUB:

```sh

grub-install /dev/sdX

update-grub

```

Replace `/dev/sdX` with your boot drive (e.g., `/dev/sda`).

- Exit chroot and unmount:

```sh

exit

sudo umount /mnt/dev

sudo umount /mnt/proc

sudo umount /mnt/sys

sudo umount /mnt

```

### 3. **Filesystem Issues**

#### Steps:

1. **Check and Repair Filesystem**:

- Boot from a live USB.

- Open a terminal and list your par ons:

```sh

sudo fdisk -l

```
- Check and repair the filesystem:

```sh

sudo fsck /dev/sdXn

```

Replace `/dev/sdXn` with the appropriate par on.

2. **Mount the Root Filesystem**:

- Mount the root filesystem to inspect it:

```sh

sudo mount /dev/sdXn /mnt

cd /mnt

```

### 4. **Kernel Issues**

#### Steps:

1. **Boot with an Older Kernel**:

- From the GRUB menu, select `Advanced op ons for Ubuntu`.

- Choose an older kernel version to see if the issue is kernel-related.

2. **Reinstall the Kernel**:

- Boot into recovery mode or from a live USB.

- Chroot into your system as described above.

- Reinstall the kernel package:

```sh

sudo apt-get update

sudo apt-get install --reinstall linux-image-$(uname -r)

```

### 5. **Logs and Diagnos cs**

#### Steps:

1. **Check Boot Logs**:

- If you can boot into recovery mode, check boot logs for errors:

```sh
journalctl -b

```

2. **Use `dmesg` for Boot Messages**:

- Check kernel ring buffer messages:

```sh

dmesg | less

```

### 6. **Reinstall Ubuntu**

#### Steps:

1. **Backup Data**:

- Boot from a live USB.

- Mount your par ons and backup important data to an external drive or cloud storage.

2. **Reinstall Ubuntu**:

- Boot from the Ubuntu installa on media.

- Choose the `Reinstall Ubuntu` op on to preserve your data or `Erase Ubuntu and reinstall` for a clean
slate.

### General Troubleshoo ng Tips:

- **Check Hardware Health**: Use tools like `smartctl` to check the health of your hard drives.

```sh

sudo smartctl -a /dev/sdX

```

Replace `/dev/sdX` with your drive iden fier.

- **Check for Memory Issues**: Use `memtest86+` from the GRUB menu to test your RAM.

- **Minimal Boot**: Remove or disable unnecessary peripherals to isolate the issue.

By systema cally following these steps, you can diagnose and resolve most boot issues on an Ubuntu
system.

System logs are crucial for diagnosing issues and understanding the behavior of your Ubuntu system.
Here's a detailed guide on how to troubleshoot using system logs:

### 1. **Understanding System Logs**

#### Key Logs:


- **`/var/log/syslog`**: General system log.

- **`/var/log/auth.log`**: Authen ca on logs (login a empts, sudo usage).

- **`/var/log/kern.log`**: Kernel logs.

- **`/var/log/dmesg`**: Boot and hardware logs.

- **`/var/log/boot.log`**: Boot process logs.

- **`/var/log/apt/history.log`**: Logs related to package installa ons.

- **`/var/log/Xorg.0.log`**: X server logs for graphical issues.

### 2. **Viewing Logs**

#### Commands:

- **`cat`**: Display the en re content of a file.

- **`less`**: View large files interac vely.

- **`tail`**: View the end of a file.

- **`grep`**: Search for specific pa erns within files.

- **`journalctl`**: Query and display messages from the systemd journal.

### 3. **Analyzing Logs**

#### General Steps:

1. **Check Recent Logs**:

- For general system logs:

```sh

sudo tail -f /var/log/syslog

```

- For authen ca on logs:

```sh

sudo tail -f /var/log/auth.log

```

2. **Use `journalctl` for Systemd Logs**:


- View the en re log:

```sh

sudo journalctl

```

- View logs since the last boot:

```sh

sudo journalctl -b

```

- Filter by specific unit (e.g., SSH):

```sh

sudo journalctl -u ssh

```

- View logs in real- me:

```sh

sudo journalctl -f

```

3. **Search for Specific Issues**:

- Search for errors:

```sh

sudo grep -i "error" /var/log/syslog

```

- Search for warnings:

```sh

sudo grep -i "warning" /var/log/syslog

```

4. **Check Boot and Kernel Logs**:

- View boot messages:

```sh

sudo dmesg | less


```

- Check kernel logs:

```sh

sudo tail -f /var/log/kern.log

```

### 4. **Specific Troubleshoo ng Scenarios**

#### System Boot Issues:

1. **Check Boot Logs**:

- View the boot log:

```sh

sudo less /var/log/boot.log

```

2. **Check for Boot Errors**:

- Use `dmesg` to find boot- me errors:

```sh

sudo dmesg | grep -i "error"

```

#### Login Issues:

1. **Check Authen ca on Logs**:

- View the auth log:

```sh

sudo less /var/log/auth.log

```

2. **Check for Failed Login A empts**:

- Search for login failures:

```sh

sudo grep "Failed password" /var/log/auth.log

```

3. **Check Sudo Usage**:


- View sudo commands:

```sh

sudo grep "sudo" /var/log/auth.log

```

#### Network Issues:

1. **Check Network Logs**:

- View network logs:

```sh

sudo less /var/log/syslog

```

2. **Search for Network Errors**:

- Use `journalctl` to filter network-related logs:

```sh

sudo journalctl -u NetworkManager

```

#### Disk Issues:

1. **Check Disk-Related Logs**:

- View logs related to disk:

```sh

sudo dmesg | grep -i "disk"

```

2. **Check Filesystem Errors**:

- Search for filesystem errors:

```sh

sudo grep -i "ext4" /var/log/syslog

```

### 5. **Using Log Rota on**

Ubuntu uses `logrotate` to manage log file sizes and archival. Configura on files for log rota on are
located in `/etc/logrotate.d/`.
#### Check Log Rota on Configura on:

1. **View Logrotate Configura on**:

- List the contents of the logrotate directory:

```sh

ls /etc/logrotate.d/

```

2. **Inspect Specific Configura on**:

- View a specific logrotate configura on file:

```sh

cat /etc/logrotate.d/syslog

```

### 6. **Automa ng Log Monitoring**

Automa ng log monitoring can help you stay ahead of issues.

#### Tools:

- **`logwatch`**: Summarizes and reports log files.

- **`swatch`**: Monitors logs and takes ac on based on pa erns.

#### Install and Configure Logwatch:

1. **Install Logwatch**:

```sh

sudo apt-get install logwatch

```

2. **Configure Logwatch**:

- Edit the configura on file:

```sh

sudo nano /etc/logwatch/conf/logwatch.conf

```

- Set email delivery op ons and log file loca ons.


By systema cally using these tools and steps, you can effec vely troubleshoot system logs and resolve a
wide range of issues on your Ubuntu system.

Troubleshoo ng network connec vity issues in Ubuntu involves a systema c approach to iden fy where
the problem lies, whether it's a hardware issue, a so ware configura on problem, or an external
network problem. Here's a detailed guide:

### 1. **Ini al Checks**

#### Steps:

1. **Check Physical Connec ons**:

- Ensure all cables are properly connected.

- For wireless connec ons, ensure the device is within range of the access point.

2. **Check Network Interfaces**:

- List all network interfaces and their status:

```sh

ip link show

```

3. **Check Network Manager**:

- Ensure NetworkManager is running:

```sh

sudo systemctl status NetworkManager

```

- Restart NetworkManager if necessary:

```sh

sudo systemctl restart NetworkManager

```

### 2. **IP Configura on Issues**

#### Steps:

1. **Check IP Address Configura on**:

- Display the current IP configura on:


```sh

ip addr show

```

- Ensure the interface has a valid IP address.

2. **Renew DHCP Lease**:

- For interfaces using DHCP, renew the lease:

```sh

sudo dhclient -r

sudo dhclient

```

3. **Sta c IP Configura on**:

- Ensure sta c IP configura ons are correct in `/etc/netplan` or `/etc/network/interfaces`.

### 3. **DNS Issues**

#### Steps:

1. **Check DNS Configura on**:

- View the current DNS servers:

```sh

cat /etc/resolv.conf

```

- Ensure there are valid DNS servers listed.

2. **Test DNS Resolu on**:

- Use `nslookup` or `dig` to test DNS resolu on:

```sh

nslookup google.com

dig google.com

```

3. **Use Alterna ve DNS Servers**:

- Temporarily use a different DNS server (e.g., Google’s 8.8.8.8):


```sh

sudo nano /etc/resolv.conf

```

- Add the line:

```sh

nameserver 8.8.8.8

```

### 4. **Rou ng Issues**

#### Steps:

1. **Check Rou ng Table**:

- Display the rou ng table:

```sh

ip route show

```

- Ensure there is a default route.

2. **Add/Modify Default Route**:

- Add a default route if missing:

```sh

sudo ip route add default via <gateway_ip>

```

3. **Test Connec vity**:

- Ping the default gateway:

```sh

ping <gateway_ip>

```

### 5. **Firewall Issues**

#### Steps:

1. **Check Firewall Status**:


- View the status of `ufw` (Uncomplicated Firewall):

```sh

sudo ufw status

```

2. **Disable Firewall Temporarily**:

- To test if the firewall is causing issues, disable it temporarily:

```sh

sudo ufw disable

```

- Re-enable the firewall a er tes ng:

```sh

sudo ufw enable

```

3. **Review Firewall Rules**:

- List all ac ve rules:

```sh

sudo iptables -L

```

### 6. **Connec vity Tes ng**

#### Steps:

1. **Ping Test**:

- Ping a local network device:

```sh

ping <local_ip>

```

- Ping an external device:

```sh

ping google.com
```

2. **Traceroute**:

- Trace the route to an external server to iden fy where the connec on fails:

```sh

traceroute google.com

```

3. **Check Port Connec vity**:

- Use `telnet` or `nc` to test connec vity to specific ports:

```sh

telnet google.com 80

```

or

```sh

nc -vz google.com 80

```

### 7. **Wireless Network Issues**

#### Steps:

1. **Check Wireless Interface**:

- List wireless interfaces and their status:

```sh

iwconfig

```

2. **Scan for Available Networks**:

- Scan for wireless networks:

```sh

sudo iwlist wlan0 scan

```

3. **Connect to Wireless Network**:


- Connect to a wireless network using `nmcli`:

```sh

nmcli device wifi list

nmcli device wifi connect <SSID> password <password>

```

4. **Check Wireless Driver**:

- Ensure the correct wireless driver is installed and loaded:

```sh

lshw -C network

### 8. **Logs and Diagnos cs**

#### Steps:

1. **Check System Logs**:

- View network-related logs:

```sh

sudo journalctl -u NetworkManager

sudo less /var/log/syslog

```

2. **dmesg for Hardware Issues**:

- Check `dmesg` for hardware-related messages:

```sh

dmesg | grep -i "network"

```

### 9. **Advanced Network Tools**

#### Tools:

1. **`tcpdump`**: Network packet analyzer.

- Capture network traffic:

```sh

sudo tcpdump -i eth0

```
2. **`nmap`**: Network scanner.

- Scan network for open ports and services:

```sh

sudo nmap -sP 192.168.1.0/24

3. **`ethtool`**: Network interface diagnos cs.

- Display or change Ethernet device se ngs:

```sh

sudo ethtool eth0

```

### General Troubleshoo ng Tips

- **Restart Networking Service**:

```sh

sudo systemctl restart NetworkManager

```

- **Use a Different Network Interface**: If available, try using another network interface (e.g., switch
from wired to wireless).

- **Consult Network Equipment Logs**: Check the logs of routers, switches, or access points for any
anomalies.

By following these steps, you can systema cally diagnose and resolve network connec vity issues on
your Ubuntu system.

You might also like