Essential Linux Commands Guide
Essential Linux Commands Guide
The `lsblk` command is used to list all available block devices on the system without showing RAM disks. It provides detailed information about the hard disk drives and their partitions, including device name, major and minor device numbers, size, and mount points .
Two methods to read large data files slowly in the terminal are using `cat /etc/passwd | less` and `cat /etc/passwd | more`. The `less` command allows navigation back and forth within the file, providing more flexible browsing, whereas `more` only allows forward navigation through the file .
To modify the system date and time, you use the `date` command with the `-s` option followed by the new date and time formatted as "DD MMM YYYY HH:MM:SS". For example, `date -s "30 May 2025 3:30:45"` sets the date and time to 3:30:45 AM on May 30, 2025 .
To temporarily change the hostname of a server, you use the command `hostname newname`, where `newname` is the desired temporary hostname. This change will only last until the next system reboot .
The `find` command can perform a case-insensitive search using the `-iname` option instead of `-name`. This allows the command to match files irrespective of case in their names, which is useful when users may not remember the exact casing of file or directory names, ensuring that all possible matches are found .
To permanently change the hostname in a Linux system, you can use the `nmtui` command, which stands for Network Manager Text User Interface. It allows you to modify system network settings including the hostname, and the changes persist through reboots .
The `tail` command outputs the last part of files. By default, it shows the last 10 lines of each file. To target a specific number of lines, the `-n` option is used followed by the desired number of lines, e.g., `tail -n 4 /etc/passwd` displays the last 4 lines of the `/etc/passwd` file .
The command to view the system's server uptime and the load averages is `uptime`. It displays the current time, how long the system has been running, the number of users currently logged on, and the system load averages for the past 1, 5, and 15 minutes .
To check the current system's kernel name, you use the command `uname`. To find the kernel version, you append the `-r` option, resulting in `uname -r` to obtain detailed kernel version information .
The hardware platform of a Linux system can be checked using the command `uname -i`. This command will output `x86` for a 32-bit architecture and `x86_64` for a 64-bit architecture .