Ubuntu System Information: Viewing Hardware Configuration with lscpu/lspci

In the Ubuntu system, understanding hardware configuration is fundamental for operations, and you can quickly obtain information using the `lscpu` and `lspci` commands. `lscpu` focuses on CPU and memory: executing it directly reveals details such as CPU architecture, number of logical/physical cores, model, cache, and total memory capacity. For example, "Model name" shows the CPU model, "CPU(s)" indicates the number of threads, and "Memory" displays the memory size. `lspci` is used to list PCI devices (such as graphics cards and network cards). Commonly used parameters include `-v` (detailed information), `-t` (tree structure), and `-nn` (hardware ID). The output includes device type, manufacturer, and model. For instance, "01:00.0 VGA compatible controller: NVIDIA Corporation..." can identify the graphics card. Practical tips: Redirect output to a file to save configurations, use `lspci -vnn | grep -i vga` to filter graphics card information, and `lspci -t` to display the device connection structure. These two commands help quickly troubleshoot hardware issues or confirm compatibility.

Read More
Ubuntu sudo Command: The Correct Way to Perform Privilege Escalation

In Ubuntu, "sudo" is an abbreviation for "superuser do," allowing ordinary users to temporarily gain root privileges to execute administrative commands, such as using `sudo apt install` to elevate permissions when installing software. Its necessity lies in avoiding the high risks of directly using the root account (such as system crashes caused by accidental operations). It enables secure privilege elevation through temporary permissions, hiding the root password, and supporting multi-user collaboration. Basic usage: `sudo [command]`, for example, installing software (`sudo apt install [package name]`), system updates (`sudo apt update/upgrade`), and modifying configurations (`sudo nano /etc/...`). Common options: `sudo -i` switches to the root shell, and `sudo -u [username] [command]` executes commands as another user. Password-free configuration: Edit the sudoers file using `visudo` and add `your_username ALL=(ALL:ALL) NOPASSWD: ALL` (suitable for personal environments, use cautiously in public environments). Notes: If you forget your password, you can reset it with `su -`; avoid dangerous operations (e.g., `rm -rf /`); if a command fails, check for spelling errors or permission requirements. Summary: Sudo is a secure privilege escalation tool. Correct usage (considering scenarios, options, and rules) can prevent system issues.

Read More