Recent Posts

Featured image for How to Delete Old Journal Logs in Ubuntu

How to Delete Old Journal Logs in Ubuntu

If you’re running Ubuntu, you might accumulate a large amount of journal logs over time. These logs can take up valuable disk space. Fortunately, you can easily delete old journal logs to free up space on your system. Here’s how you can do it using the journalctl command with the --vacuum-time option.

Deleting Old Journal Logs

To delete old journal logs in Ubuntu, follow these steps:

Featured image for Bash Check if Shell on Interactive or Login

Bash Check if Shell on Interactive or Login

In Bash, you can check whether the shell is running in an interactive or login mode using the provided commands. Here’s an explanation of each command and what it checks for:

  1. [[ $- == *i* ]] && echo 'Interactive' || echo 'Not interactive':

    • This command checks the value of the special shell variable $-, which contains a string of options and flags that are currently set for the shell.
    • The *i* pattern is used to check if the letter ‘i’ appears anywhere in the value of $-. If it does, it indicates that the shell is running in interactive mode.
    • If ‘i’ is found, it echoes ‘Interactive’, otherwise, it echoes ‘Not interactive’.
  2. shopt -q login_shell && echo 'Login shell' || echo 'Not login shell':

    • This command uses the shopt built-in command to check the status of a shell option called login_shell.
    • If shopt -q login_shell returns true (exit status 0), it means that the shell is a login shell, so it echoes ‘Login shell’.
    • If shopt -q login_shell returns false (exit status non-zero), it means that the shell is not a login shell, so it echoes ‘Not login shell’.
Featured image for How to Fix Wrong Indentation When Pasting Source Code in VIM

How to Fix Wrong Indentation When Pasting Source Code in VIM

When copying and pasting source code into the VIM text editor, you might encounter issues with incorrect indentation due to the way VIM handles auto-indentation. This happens because VIM’s default behavior tries to adjust the indentation based on the surrounding code, which can lead to unwanted results when pasting code from external sources. To prevent this, you can use the :set paste and :set nopaste commands to toggle the paste mode. Here’s how to do it:

Featured image for Wsl2 Ram Overload Om Host (draft)

Wsl2 Ram Overload Om Host (draft)

WSL 2 (Windows Subsystem for Linux 2) has gained significant popularity among developers for its ability to run a full Linux kernel alongside the Windows operating system. However, one common issue that users may face is RAM overload on the host machine. This can lead to performance degradation and even system crashes. One approach to mitigate this problem is by limiting memory and processor usage for WSL 2 by editing the wsl.conf configuration file.

Featured image for Kill Child Process and Parent Process Bash Linux

Kill Child Process and Parent Process Bash Linux

you want a set of Bash commands for managing processes in a Linux environment. Here’s an explanation of what each command does:

  1. Kill Child Process and Parent Process:

    bash
    1
    
    pid=17844 && pkill -TERM -P $pid && kill $pid

    This command first assigns the value 17844 to the variable pid. Then, it uses pkill with the -TERM option to send a termination signal to all processes with a parent process ID (PPID) equal to the value stored in pid. Finally, it uses the kill command to send a termination signal to the process with the PID stored in pid.

  2. Print PID from Command:

    bash
    1
    
    ps aux | grep "/root/bin/ssh-port-forward 45.77.47.134 12006" | grep -v grep | awk '{print $2}'

    This command lists all processes using ps aux, searches for lines containing “/root/bin/ssh-port-forward 45.77.47.134 12006” using grep, excludes the grep command itself using grep -v grep, and then uses awk to print the second column of the output, which is the PID of the matching process.

  3. Kill Child Process and Parent Process By Command:

    bash
    1
    2
    
    PC="/root/bin/ssh-port-forward 45.77.47.134 12006" &&
    PID=$(ps aux | grep "$PC" | grep -v grep | awk '{print $2}') && pkill -TERM -P $PID && kill $PID

    This command first assigns the command string “/root/bin/ssh-port-forward 45.77.47.134 12006” to the variable PC. Then, it uses a combination of commands to find the PID of the process that matches the command stored in PC, and it sends a termination signal to both the child and parent processes.

  4. Kill and Run Background Process:

    bash
    1
    2
    
    PC="/root/bin/ssh-port-forward 45.77.47.134 12006" && 
    PID=$(ps aux | grep "$PC" | grep -v grep | awk '{print $2}') && pkill -TERM -P $PID ; kill $PID ; $PC &

    This command is similar to the previous one but with an additional step. It first finds the PID of the process matching the command in PC, sends termination signals to both the child and parent processes, and then restarts the command in the background using &. This effectively stops the existing process and starts a new one in the background.

Featured image for Modifying Indentation in Vim

Modifying Indentation in Vim

Indentation settings are crucial for maintaining consistent and readable code. In Vim, you can easily modify indentation preferences using various commands. Here’s a breakdown of your provided commands and their effects:

Converting Tabs to Spaces

To replace tabs with spaces, follow these steps: