Author: admin

How to disable bash shell history

You can use two methods to disable saving shell history in bash. Method 1: Add the following line at the end of /etc/profile or make a new file in /etc/profile.d/ with .sh extension. unset HISTFILE With the above option, the user’s bash shell will not save history unless manually configures the HISTFILE variable. Method 2: …

Read more

error “Cannot allocate memory” while executing commands

You should increase /proc/sys/kernel/pid_max sysctl. Otherwise, execute the following command to check which app is forking multiple threads. #ps -eLF Error “Cannot allocate memory” indicates that the system is running out of PID (process ids). In other words, the number of threads/processes present on the system has reached the maximum limit, which is delimited by …

Read more

How to configure system wide proxy for all users shells and yum

http_Proxy environment variable is used to specify proxy settings to wget and curl. To find the proxy server already set on a Linux machine, use the following command: echo $http_proxy To set http_proxy without username and password: export http_proxy=http://SERVER-NAME:PORT/ To set http_proxy with username and password: export http_proxy=http://USER-NAME:PASSWORD@SERVER-NAME:PORT/ To set http_proxy with username, password, and …

Read more

How to log all bash history commands to syslog

shopt is a built-in bash variable that enables bash history to be written to /var/log/messages. shopt -s syslog_history If you want to unset it, run the following command. shopt -u syslog_history In order for these audit activities to persist in all bash sessions, append the following to the bottom of /etc/bashrc file. shopt -s syslog_history

Read more

Bash Shell Scripting Cheat Sheet for Linux

Bash is by default installed on most Linux distributions like Alma Linux, CentOS, Kali, and Ubuntu. The following cheat sheet outlines some important features of bash scripting. Bash Script Header #!/usr/bin/env bashecho “Hello World” Variables #!/usr/bin/env bashMSG=”Hello World”echo “$MSG Albert” # Hello World Albertecho ‘$MSG Albert # $MSG Albert Strings MSG=”hello world” Replace echo ${MSG/w/W} …

Read more

How to install Nvidia drivers on Kali linux

First, update Kali Linux based server as follows: sudo apt updatesudo apt -y full-upgrade Reboot server as follows: reboot Find out which video card is installed in the Kali Linux server and verify using the nouveau open-source driver. lspci | grep -i vga You will get the following output: 00:02.0 VGA compatible controller: NVIDIA Corporation …

Read more

SSH connection fails with messages “no hostkey alg”

Getting the following ssh debug output: debug2: mac_setup: found hmac-sha1debug1: kex: server->client aes128-ctr hmac-sha1 nonedebug2: mac_setup: found hmac-sha1debug1: kex: client->server aes128-ctr hmac-sha1 noneno hostkey alg On CentOS 6, you generate ECDSA hostkeys with correct permissions: ssh-keygen -t ecdsa -f /etc/ssh/ssh_host_ecdsa_key -C '' -N ''chmod 600 /etc/ssh/ssh_host_ecdsa_keychmod 640 /etc/ssh/ssh_host_ecdsa_key.pubrestorecon /etc/ssh/ssh_host_ecdsa_key.pub To allow ssh clients to accept …

Read more

NFS server configuration file in AlmaLinux 8, CentOS

The new configuration file for NFS server setup in AlmaLinux 8 is /etc/nfs.conf. /etc/sysconfig/nfs is deprecated and replaced by /etc/nfs.conf. # cat /etc/nfs.conf## This is a general configuration for the# NFS daemons and tools#[general]# pipefs-directory=/var/lib/nfs/rpc_pipefs#[exportfs]# debug=0#[gssd]# use-memcache=0# use-machine-creds=1use-gss-proxy = yes# avoid-dns=1# limit-to-legacy-enctypes=0# context-timeout=0# rpc-timeout=5# keytab-file=/etc/krb5.keytab# cred-cache-directory=# preferred-realm=#[lockd]# port=0# udp-port=0#[mountd]# debug=0# manage_gids=n# descriptors=0# port=0# threads=1# reverse-lookup=n# …

Read more

How to set default Java version with alternatives tool in AlmaLinux

When different Java versions are installed on a Linux server, use the alternatives tool to set the default Java version as follows: alternatives --config java There are 2 program that provides 'java'. Selection Command ----------------------------------------------- *+ 1 java-1.9.0-openjdk.x86_64 (/usr/lib/jvm/java-1.9.0-openjdk-1.9.0.292.b10-1.el8_4.x86_64/jre/bin/java) 2 java-12-openjdk.x86_64 (/usr/lib/jvm/java-12-openjdk-11.0.11.0.9-2.el8_4.x86_64/bin/java) Enter to keep the current selection[+], or type selection number: 2 Type 1 …

Read more