Deleting All Lines in Vim
2025-09-02 204 views 后端 Ubuntu Linux

There are two common methods to delete all lines in Vim. First, in command mode, press `gg` to jump to the beginning of the file, then enter `dG`. Here, `gg` positions the cursor at the first line, and `dG` deletes from the current line to the end of the file. Second, directly enter `:%d` in command mode and press Enter. The `%` denotes the entire file range, and `d` is the delete command. After execution, the file content is cleared. If there are unsaved changes, Vim will prompt whether to save when exiting.

Read More
Command to Output Current Time in Ubuntu Terminal
2025-09-02 161 views 后端 Ubuntu

In the Ubuntu system, the `date` command can output the current time. The basic `date` command displays the complete date and time, including the weekday, month, day, specific time, and time zone. To display only the time part, formatting parameters can be used, such as `date +"%H:%M:%S"` to output the 24-hour format time; `date +"%I:%M:%S %p"` to output the 12-hour format with AM/PM indicator.

Read More
The Use and Trade-offs of Foreign Keys in Databases
2025-09-02 186 views 后端 database

There is debate over whether foreign keys should be used in database design. While foreign keys ensure data integrity, they introduce issues such as reduced write performance, increased system coupling, high operational risks, poor flexibility, uncontrollable cascading operations, failure in distributed scenarios, and redundant validation with the application layer. The alternative is to ensure data integrity at the application layer. Foreign keys may be considered for small systems, but modern high-concurrency systems often avoid them. The essence lies in balancing the database's strong constraints with system performance and flexibility.

Read More
Changing the Owner and Group of Folders and Files in Ubuntu
2025-09-02 216 views 后端 Ubuntu

In the Ubuntu system, the `chown` command is used to modify the owner user and group of a file or folder. The basic syntax is `chown [options] username:group filename/foldername`. Common operation examples include: using `sudo chown username filename.txt` to change the file owner;

Read More
Checking for Malicious Logins on Ubuntu System
2025-09-02 168 views 后端 Ubuntu server Ubuntu

In Ubuntu system, there are multiple ways to check for malicious login situations. To view login history, commands like `last`, `lastb`, and `last -i` can be used. For system log inspection, commands such as `sudo grep "Failed password" /var/log/auth.log` are applicable; in newer Ubuntu versions, `journalctl -u ssh -g "Failed password"` can be used instead. To check recently logged-in users, commands like `who`, `w`, and `lastlog` are useful. For SSH login records, `sudo grep sshd /var/log/auth.log` combined with relevant keywords can be employed.

Read More
How to Install or Update Graphics Card Drivers in Ubuntu System
2025-09-02 453 views 后端 Ubuntu Linux

There are common methods to update graphics card drivers in Ubuntu. The third method is recommended in the introduction. Method 1 uses the official repository: first, run `sudo apt update` to update the package list, then `sudo apt upgrade -y` to upgrade. Method 2 is for NVIDIA: you can install a driver management tool or use the graphical tool `sudo nvidia-settings`. Method 3 is to add the Graphics Drivers PPA repository by executing `sudo add-apt-repository ppa:graphics-drivers/ppa` and other steps in sequence.

Read More