Cannot set LC_CTYPE to default locale: No such file or directory

When ssh into a production server, Debian, and noticed there is a warning or error as follows: Terminal manpath: can’t set the locale; make sure $LC_* and $LANG are correct mkyong@test-server:~$ Check the server’s locale; there are warning about the LC_CTYPE and LC_ALL variables. Terminal $ locale locale: Cannot set LC_CTYPE to default locale: No …

Read more

How to check OpenSSH version

On Linux, macOS, or Windows, we can use ssh -V (uppercase V) to check the OpenSSH version currently installed. Example 1 Terminal $ ssh -V OpenSSH_9.0p1, LibreSSL 3.3.6 Example 2 Terminal $ ssh -V OpenSSH_8.4p1 Debian-5+deb11u1, OpenSSL 1.1.1n 15 Mar 2022 References Wikipedia – OpenSSH OpenSSH Release Notes

How to backup MySQL / MariaDB database to Amazon S3, shell script example

This article shows a shell script to backup or export a MySQL / MariaDB database, gzip the exported file, and upload the gzipped backup file to Amazon S3. Table of contents 1. Install AWS CLI 2. Backup MySQL/MariaDB database to S3 (Shell Script) 3. How to run the backup script? 4. Run the backup script …

Read more

An Introduction to Kernel Live Patching on Linux

Live patching is slowly catching on, but not for the reasons you might think. In this article, I’ll explain what Linux kernel live patching is, what it isn’t, what services there are, who might use it and why. I’ll show the basic installation steps for Livepatch (on Ubuntu), Kpatch (on Red Hat), and one other, …

Read more

CSF – How to limit the number of connections per IP address

In the ConfigServer Security & Firewall (CSF) configuration file, update the CT_LIMIT value to limit the number of connections per IP address. This is a simple trick to prevent some types of Denial of Service (DOS) attack. Note To stop the Denial of Service (DoS) attack immediately, read this null route example. 1. /etc/csf/csf.conf SSH …

Read more

Debian – Show apt-get package version

On Debian, you can use apt-cache policy ‘package name’ to check the package version. 1.1 Display Tomcat7 version. $ sudo apt-cache policy tomcat7 tomcat7: Installed: (none) Candidate: 7.0.52-1ubuntu0.3 Version table: 7.0.52-1ubuntu0.3 0 500 http://archive.ubuntu.com/ubuntu/ trusty-updates/main amd64 Packages 500 http://security.ubuntu.com/ubuntu/ trusty-security/main amd64 Packages 7.0.52-1 0 500 http://archive.ubuntu.com/ubuntu/ trusty/main amd64 Packages 1.2 Display OpenJDK-7 version. $ sudo …

Read more

How to check Debian version

On Debian, type cat /etc/debian_version to display the Debian version. Terminal $ cat /etc/debian_version 9.5 Alternatively, cat /etc/issue Terminal $ cat /etc/issue Debian GNU/Linux 9 \n \l The last one, lsb-release -a, it will display the Debian detail. Terminal $ lsb-release -a -bash: lsb-release: command not found $ sudo apt-get install lsb-release $ lsb_release -a …

Read more

Multiple SSH private keys Examples

To allow multiple private keys connect to different servers, edit ~/.ssh/config : ~/.ssh/config Host 10.10.10.1 IdentityFile ~/.ssh/linode_rsa Host 200.20.20.2 IdentityFile ~/.ssh/id_rsa If you SSH to 10.10.10.1, private key ~/.ssh/linode_rsa will be used. If you SSH to 200.20.20.2, private key ~/.ssh/id_rsa will be used. 1. Single Private Key for Multiple Servers 1.1 You have following public …

Read more

Linux – How to extract a tar.gz file

In this tutorial, we will show you how to extract a tar.gz file : tar vxf filename.tar.gz Example For example, apache-ant-1.9.4-bin.tar.gz in your ~/Download folder. $ cd ~ $ pwd /Users/mkyong # Optionally, create a new folder for the archived file. $ mkdir tools $ cd tools $ pwd /Users/mkyong/tools # Copy archived file to …

Read more

Linux : How to gzip a folder

On Linux, gzip is unable to compress a folder, it used to compress a single file only. To compress a folder, you should use tar + gzip, which is tar -z. Note $ tar –help -z, -j, -J, –lzma Compress archive with gzip/bzip2/xz/lzma For example, tar -zcvf outputFileName folderToCompress 1. Tar + Gzip a folder …

Read more

Download file from server using SSH

Normally, you use Secure copy or SCP to download a file from another server via SSH connection. For example, scp username@remotehost:remoteFileToDownload localFolderNameToSaveTheFile 1. SCP Examples 1.1 Download File From Server Example to download a log file (hc.audit.log) from server (198.58.x.x), into your current local folder. scp [email protected]:/var/log/tomcat7/hc.audit.log . 1.2 Upload File To Server Example to …

Read more

Debian : Change default Java version

Deployed a Debian 7.5 on Linode server, the default is using OpenJDK 1.6. How to upgrade to OpenJDK 1.7? $ java -version java version "1.6.0_31" OpenJDK Runtime Environment (IcedTea6 1.13.3) (6b31-1.13.3-1~deb7u1) OpenJDK 64-Bit Server VM (build 23.25-b01, mixed mode) Tracing the java, it’s using the Debian’s alternative settings : $ ls -lsa /usr/bin/ | grep …

Read more

How to install a Vim color scheme

In this tutorial, we will show you how to install a Vim editor color scheme named “distinguished“. 1. Default Color Scheme Default syntax highlight in the “homebrew” profile terminal. 2. Install a new Vim Color Scheme 2.1 Download a new Vim color scheme – “distinguished“. Extracts and move the downloaded *.vim file to this folder …

Read more

Grep for Windows – findstr example

I love grep command on Linux, it helped to search and filter strings easily, always wonder what is the equivalent tool on Windows, and found this findstr recently. In this article, I will share some of my favorite “grep” examples on Linux, and how to “port” it to Windows with “findstr” command. 1. Filter a …

Read more

Copy file to / from server via SCP command

SCP uses Secure Shell (SSH) to transfer data between client and remote server, it’s fast and secure. In this article, we will show you two common SCP copying examples : Copying data from your computer to remote server. Copying data from remote server to your computer. 1. Copying data to Remote Server Example 1.1 – …

Read more

Linux Search and Replace example

I was recently in a situation of having to change some text that appeared in a bunch of config files that were inside nested sub-directories. Not having time to dust off 10-year old perl skills, I was looking for some shell commands that would work. Surprisingly, there are many examples on the web that do …

Read more

How to find a file in linux

In *nix, you can use the find command to find a file easily. $find {directory-name} -name {filename} 1. Find a file in the root directory If you have no idea where the file is located, you can search the entire system via the “/” root directory. Below example shows you how to find a file, …

Read more

How to unzip a WAR file in Java

In J2EE web development, Web Application Archive(WAR) file is just a normal JAR file, which consists all of your web application components like, servlets, Java classes, libraries, resources and etc. Read Wiki for detail. Problem Current web application WAR file is generated via Ant or Maven tool, copy to *nix environment for deployment, but no …

Read more

How to access Windows shares in Ubuntu

Problem Ubuntu doesn’t has build-in tool for browsing or accessing the Windows share in network. Is there any ways to access the Windows share in Ubuntu? Solution Ubuntu has smb installed by default, you can use smb to access the Windows shares. 1. File Browser Open “Computer – File Browser”, Click on “Go” –> “Location…” …

Read more

How to download a website in Linux (wget)

The wget is a useful command to download a website in Linux. For example , wget [url]. [mkyong@snake ~]$ wget -r -p -k -E http://www.google.com –2009-07-19 14:07:27– http://www.google.com/ Resolving www.google.com… 64.233.189.104 Connecting to www.google.com|64.233.189.104|:80… connected. HTTP request sent, awaiting response… 302 Found Location: http://www.google.com.my/ [following] –2009-07-19 14:07:27– http://www.google.com.my/ Resolving www.google.com.my… 64.233.189.147 Connecting to www.google.com.my|64.233.189.147|:80… connected. …

Read more

How to check reboots history in Linux

As Unix / Linux server administrator, we always need to know when is our last rebooted date and time. Actually, we are able to list out the system rebooted history by issue following command. last reboot Output mkyong@mkyong:~$ last reboot reboot system boot 2.6.28-11-generi Thu Jul 16 21:42 – 23:46 (02:04) reboot system boot 2.6.28-11-generi …

Read more

How to Limit the application CPU usage in Linux (CPUlimit)

CPULimit is a simple program to limit the CPU usage of certain application in Linux. It’s reside in the Ubuntu repositories by default. We can install it by issue the following command in Ubuntu sudo apt-get install cpulimit Output mkyong@mkyong:~$ sudo apt-get install cpulimit [sudo] password for mkyong: Reading package lists… Done Building dependency tree …

Read more

How to know the Hardware Details in Linux

The “dmidecode” is a handy tool in Linux to display the hardware specification detail. For example, memory, processor , BIOS and etc. man dmidecode DMI TYPES The SMBIOS specification defines the following DMI types: Type Information —————————————- 0 BIOS 1 System 2 Base Board 3 Chassis 4 Processor 5 Memory Controller 6 Memory Module 7 …

Read more

How to set static IP address on Unix

In Unix system like Debian, Ubuntu or Red Hat, It is possible to set a static IP address with ifconfig command. My current Debian system IP address is 10.70.0.61 mkyong:~# ifconfig eth0 Link encap:Ethernet HWaddr 00:15:17:1D:CE:2F inet addr:10.70.0.61 Bcast:10.70.3.255 Mask:255.255.252.0 I want change it to 10.70.0.66, just issue following command to set a static IP …

Read more

How to check Linux / Unix distribution version

Today my boss ask me install a tomcat in linux machine. After i ssh into that machine, i wonder what is the Linux distribution version? Red Hat? Ubuntu? Fedora? Debian? However with a simple command, i can check what is linux distribution version mymachine:~# cat /proc/version Linux version 2.6.18-5-686-bigmem (Debian 2.6.18.dfsg.1-13etch3) ([email protected]) (gcc version 4.1.2 …

Read more

How to Enable Mouse Wheel Scrolling in Ubuntu (VMware)

Problem Ubuntu…beside Default VI is suck, here is another issue for me. My mouse wheel scrolling is not working in Ubuntu8.04. However i installed Ubuntu in vmware, but i do not think it is vmware cause of this issue. Solution Here i find some useful information regarding Mouse Wheel Scrolling malfunction issuse, please check Ubuntu …

Read more