Tuesday, April 9, 2024

How to see specific information about disk

hdparm -i /dev/sda smartctl -A /dev/sda hdparm -tT /dev/sda used to Do a read speed test on disk sda badblocks -s /dev/sda used to Test for unreadable blocks on disk sda

How to check the tcp udp and network sockts in linux

netstat -ntlp to view the open TCP sockets netstat -nulp to view the open UDP sockets netstat -nxlp to view the open Unix sockets

How to find the hidden files in Linux

du -sh .[!.]* *

How to check which shells are already installed and configured on our machine ?

by using the chsh -l [user@localhost ~]$ chsh -l /bin/sh /bin/bash /sbin/nologin /usr/bin/sh /usr/bin/bash /usr/sbin/nologin /usr/bin/fish Or by using cat /etc/shells we can change the following default shell using chsh -s /usr/bin/bash Now all that is left to do is preform a logoff-logon cycle, and enjoy our new default shell.

How to Shows all bad login attempts into the system

Try with the following command lastb

Sunday, April 7, 2024

How to mount the nfs share in all the hosts.

--- - name: Mount the NFS share hosts: all become: true vars: mynfs: "172.2.0.200:/nfs/data" mountpoint: "/share" permission: '0777' myopts: 'rw,sync' tasks: - name: utility present redhat-like ansible.builtin.yum: name: - nfs-utils - nfs4-acl-tools state: present when: ansible_os_family == 'RedHat' - name: utility present debian-like ansible.builtin.apt: name: - nfs-common - nfs4-acl-tools state: present when: ansible_os_family == 'Debian' - name: check mountpoint exist ansible.builtin.file: path: "{{ mountpoint }}" state: directory mode: "{{ permission }}" owner: root group: root - name: mount network share ansible.posix.mount: src: "{{ mynfs }}" path: "{{ mountpoint }}" fstype: nfs opts: "{{ myopts }}" state: mounted

How to restart the ssh service in all the hosts.

--- - name: restart ssh service in all the hosts. hosts: all become: true tasks: - name: sshd restart ansible.builtin.service: name: sshd state: restarted enabled: true

How to restrict a user a login @ specefic time in Linux

Use the pam_time module in the Pluggable Authentication Modules (PAM) system to restrict login times. Edit the /etc/security/time.conf file to specify time restrictions. You can define rules for specific users or groups. Edit the /etc/security/time.conf login ; * ; !gurudatta ; Wk0630-1500 This line denies login for all users except "user1" from Monday to Friday between 6:30 AM to 15:00 PM. Ensure that the pam_time module is enabled and configured properly in the PAM configuration files (/etc/pam.d/).

Tuesday, April 2, 2024

How to start the cell nodes in Exadata

for host in `cat cell_group`; do echo ${host}: `ipmitool -H ${host}-ilom -U root -P welcome1 chassis power on` done

Tuesday, March 19, 2024

The maximum file size in Linux depends on the file system being used

The maximum file size in Linux depends on the file system being used. Here are the maximum file size limits for some common Linux file systems: ext2/ext3: Maximum file size is 2TB. ext4: Maximum file size is 16TB with 4KB blocks and 50TB with 64KB blocks. XFS: Maximum file size is 8 exbibytes (EiB). Btrfs: Maximum file size is 16 exbibytes (EiB). ReiserFS: Maximum file size is 8TB. ZFS: Theoretical maximum file size is 16 exbibytes (EiB) but practically limited by the size of the pool.

Monday, March 18, 2024

How to remove Orphan Packages in Linux

yum autoremove in RHEL based Linux apt-get autoremove in Debain based Linux

Monday, March 11, 2024

Sunday, February 11, 2024

Ext 2 to Ext4 difference

Ext2, Ext3, and Ext4 are three different versions of the extended file system (Ext), which is the default file system for many Linux distributions. Here are the key differences between Ext2, Ext3, and Ext4: Ext2: Ext2 was the first version of the extended file system. It provided basic features for managing files and directories but lacked features such as journaling. Without journaling, file system consistency in the event of a crash or power failure depended on time-consuming file system checks (fsck) during boot. It had limitations in terms of maximum file and partition sizes. Ext3: Ext3 was developed to address the lack of journaling in Ext2. It introduced journaling, which improved file system consistency and reduced the need for lengthy fsck operations after crashes or power failures. With journaling, Ext3 offered faster recovery times and improved reliability compared to Ext2. Ext3 maintained backward compatibility with Ext2, allowing Ext2 file systems to be upgraded to Ext3 without data loss. It still had limitations regarding maximum file and partition sizes, though these were improved compared to Ext2. Ext4: Ext4 is the latest version of the extended file system and offers several significant improvements over Ext3. It provides support for larger file systems and files, with maximum file size increased to 16 terabytes and maximum volume size to 1 exabyte. Ext4 also improves performance through various enhancements such as delayed allocation, extent-based allocation, and multiblock allocation. It includes support for extents, which replaces the traditional block mapping scheme and reduces metadata overhead for large files. Ext4 offers faster file system checks (fsck) and better scalability by using multiple block groups concurrently. It introduced other features like online defragmentation, improved timestamps, and sub-directory scalability. Ext4 maintains backward compatibility with Ext3 and allows for an in-place upgrade from Ext3 to Ext4 without data migration. In summary, each version of the extended file system introduced improvements in terms of reliability, performance, scalability, and feature set. Ext4 represents the most advanced version, offering significant enhancements over both Ext2 and Ext3, including support for larger file and partition sizes, improved performance, and new features like extents.

Friday, February 9, 2024

How to upgrade the linux kernel on every month ubuntu/redhat

vi kernel_update.sh chmod +x kernel_update.sh #!/bin/bash # Update package lists sudo apt update # Upgrade the Linux kernel sudo apt upgrade -y linux-image-generic linux-headers-generic # Reboot the system to apply the new kernel sudo reboot crontab -e 0 0 1 * * /home/kernel_update.sh For Redhat/Centos vi kernel_update.sh chmod +x kernel_update.sh #!/bin/bash # Update package lists sudo yum check-update # Upgrade the Linux kernel sudo yum update kernel -y # Reboot the system to apply the new kernel sudo reboot crontab -e 0 0 1 * * /home/kernel_update.sh Note: We can call the script from ansible also every month. --- - hosts: All become: yes tasks: - name: Kernal upgrade script as Cron job cron: user: "root" day: "1" hour: "00" minute: "00" name: "Kernal upgrade script as Cron job" job: "/home/kernel_update.sh /tmp/lupdate.log"

How 'ps' command works.

ps command read files from /proc and the content of these files are generated by the kernel.

when you get a "filesystem is full" error, but `df` shows there is free space.

When a filesystem it's out of inode, it can happen when you have a huge amount of small files, in a small filesystem. `df -i` will show. check the ulmit also once

What is mknod command and when you'd use it.

- mknod command creates a new device in `/dev` but actually udev creates automatically each device, if something very terrible happen we can recreate some devices using mknod to fix or make some backup.