How to change sys.path or PYTHONPATH in Python

Question: When I run a Python application, it is not able to find one of imported modules and fails. Looks like the directory of the Python module is not included in the default sys.path used by the Python interpreter. How can I change the default sys.path in Python? When the Python interpreter executes a program […]
Continue reading…

 

How to fix “ImportError: No module named setuptools” on Linux

Question: I was trying to install a Python package using setup.py (“python setup.py install”). However, it failed with the following error message: Traceback (most recent call last): File “setup.py”, line 2, in import setuptools ImportError: No module named ‘setuptools’ How can I fix this error? There are several ways to package, distribute and install Python […]
Continue reading…

 

How to resume a large SCP file transfer on Linux

Question: I was downloading a large file using SCP, but the download transfer failed in the middle because my laptop got disconnected from the network. Is there a way to resume the interrupted SCP transfer where I left off, instead of downloading the file all over again? Originally based on BSD RCP protocol, SCP (Secure […]
Continue reading…

 

How to remove trailing whitespaces in a file on Linux

Question: I have a text file in which I need to remove all trailing whitespsaces (e.g., spaces and tabs) in each line for formatting purpose. Is there a quick and easy Linux command line tool I can use for this? When you are writing code for your program, you must understand that there are standard […]
Continue reading…

 

How to install Node.js on Linux

Question: How can I install Node.js on [insert your Linux distro]? Node.js is a server-side software platform built on Google’s V8 JavaScript engine. Node.js has become a popular choice for building high-performance server-side applications all in JavaScript. What makes Node.js even more attractive for backend server development is the huge ecosystem of Node.js libraries and […]
Continue reading…

 

How to set JAVA_HOME environment variable automatically on Linux

Question: I need to compile a Java program on my Linux box. For that I already installed JDK (Java Development Kit), and now I’m trying to set JAVA_HOME environment variable to point to the installed JDK. What is the recommended way to set JAVA_HOME environment variable on Linux? Many Java programs or Java-based IDE environments […]
Continue reading…

 

How to find which shell I am using on Linux

Question: I often change between different shells at the command line. Is there a quick and easy way to find out which shell I am currently in? Also how can I find out the version of the shell? Find out Which Shell You are In There are different ways to tell what shell you are […]
Continue reading…

 

How to change default Java version on Linux

Question: When I am trying to run a Java program on Linux, I am getting the following error. Looks like the Java program is compiled for a different Java version than the default Java program installed on my Linux. How can I switch the default Java version on Linux? Exception in thread “main” java.lang.UnsupportedClassVersionError: com/xmodulo/hmon/gui/NetConf […]
Continue reading…

 

How to install Ubuntu desktop behind a proxy

Question: My computer is connected to a corporate network sitting behind an HTTP proxy. When I try to install Ubuntu desktop on the computer from a CD-ROM drive, the installation hangs and never finishes while trying to retrieve files, which is presumably due to the proxy. However, the problem is that Ubuntu installer never asks […]
Continue reading…

 

How to force password change at the next login on Linux

Question: I manage a Linux server for multiple users to share. I have just created a new user account with some default password, and I want the user to change the default password immediately after the first login. Is there a way to force a user to change his/her password at the next login? In […]
Continue reading…

 

How to find information about built-in kernel modules on Linux

Question: I would like to know what modules are built into the kernel of my Linux system, and what parameters are available in each module. Is there a way to get a list of all built-in kernel modules and device drivers, and find detailed information about them? The modern Linux kernel has been growing significantly […]
Continue reading…

 

How to change USB device permission permanently on Linux

Question: I am trying to run gpsd on my Linux with a USB GPS receiver. However, I am getting the following errors from gpsd. gpsd[377]: gpsd:ERROR: read-only device open failed: Permission denied gpsd[377]: gpsd:ERROR: /dev/ttyUSB0: device activation failed. gpsd[377]: gpsd:ERROR: device open failed: Permission denied – retrying read-only Looks like gpsd does not have permission […]
Continue reading…

 

How to find out which CPU core a process is running on

Question: I have a Linux process running on my multi-core processor system. How can I find out which CPU core the process is running on? When you run performance-critical HPC applications or network-heavy workload on multi-core NUMA processors, CPU/memory affinity is one important factor to consider to maximize their performance. Scheduling closely related processes on […]
Continue reading…

 

How to remove unused old kernel images on Ubuntu

Question: I have upgraded the kernel on my Ubuntu many times in the past. Now I would like to uninstall unused old kernel images to save some disk space. What is the easiest way to uninstall earlier versions of the Linux kernel on Ubuntu? In Ubuntu environment, there are several ways for the kernel to […]
Continue reading…

 

How to check weather forecasts from the command line on Linux

Question: I often check local weather forecasts on the Linux desktop. However, is there an easy way to access weather forecast information in the terminal environment, where I don’t have access to desktop widgets or web browser? For Linux desktop users, there are many ways to access weather forecasts, e.g., using standalone weather apps, desktop […]
Continue reading…

 

How to check MariaDB server version

Question: I am on a VPS server where MariaDB server is running. How can I find out which version of MariaDB server it is running? There are circumstances where you need to know the version of your database server, e.g., when upgrading the database or patching any known server vulnerabilities. There are a few ways […]
Continue reading…

 

How to fix Wireshark GUI freeze on Linux desktop

Question: When I try to open a pre-recorded packet dump on Wireshark on Ubuntu, its UI suddenly freezes, and the following errors and warnings appear in the terminal where I launched Wireshark. How can I fix this problem? “(wireshark:3480): GLib-GObject-WARNING **: invalid unclassed pointer in cast to ‘GObject’ (wireshark:3480): GLib-GObject-CRITICAL **: g_object_set_qdata_full: assertion ‘G_IS_OBJECT (object)’ […]
Continue reading…

 

How to count the number of threads in a process on Linux

Question: I have an application running, which forks a number of threads at run-time. I want to know how many threads are actively running in the program. What is the easiest way to check the thread count of a process on Linux? If you want to see the number of threads per process in Linux […]
Continue reading…

 

How to install PlayOnLinux on Linux

Question: I want to run a Windows-based game in my Linux environment. For that, I would like use Wine/PlayOnLinux to install and run the Windows software on top of Linux. How can I install them on [insert your Linux distro]? Wine was developed as compatibility layer software for Linux, allowing you to run Microsoft Windows […]
Continue reading…