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 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…

 

How to view threads of a process on Linux

Question: My program creates and executes multiple threads in it. How can I monitor individual threads of the program once they are created? I would like to see the details (e.g., CPU/memory usage) of individual threads with their names. Threads are a popular programming abstraction for parallel execution on modern operating systems. When threads are […]
Continue reading…

 

How to add a cron job on Linux

Question: I would like to schedule a task on my Linux box, so that the task runs periodically at fixed times. How can I add a cron job for this task on my Linux system? The cron utility is the default task scheduler used in Linux. Using cron, you can schedule a task (e.g., a […]
Continue reading…

 

How to check memory usage on Linux

Question: I would like to monitor memory usage on my Linux system. What are the available GUI-based or command-line tools for checking current memory usage of Linux? When it comes to optimizing the performance of a Linux system, physical memory is the single most important factor. Naturally, Linux offers a wealth of options to monitor […]
Continue reading…

 

How to fix “XXX is not in the sudoers file” error

Question: I am trying to use sudo to run some privileged command on my Linux. However, when I attempt to do so, I am getting “[my-user-id] is not in the sudoers file. This incident will be reported.” error message. How can I resolve this sudo error? sudo is a program which enables specific groups of […]
Continue reading…

 

How to change date and time from the command line on Linux

Question: In Linux, how can I change date and time from the command line? Keeping the date and time up-to-date in a Linux system is an important responsibility of every Linux user and system administrator. Many applications rely on accurate timing information to operate properly. Besides, inaccurate date and time render timestamp information in log […]
Continue reading…

 

How to install htop on CentOS or RHEL

Question: I heard nice things about htop as an alternative to top command. When I tried to install htop with yum package manager on CentOS, I got “No package htop available” error. How can I install htop on CentOS/RHEL? Htop vs. Top htop is an ncurses-based real-time process viewer for Linux. While its interface is […]
Continue reading…

 

How to check what libraries are used by a program or process on Linux

Question: I would like to know which shared libraries are loaded at run-time when I invoke a particular executable. Is there any way to identify shared library dependencies of a program executable or a running process on Linux? Check shared library dependencies of a program executable To find out what libraries a particular executable depends […]
Continue reading…

 

How to check if I am in a running screen session

Question: I often use screen command to run multiple pseudo terminal sessions. Oftentimes I find it difficult to remember whether I am inside a screen session, or in a regular terminal. Is there any convenient way to check whether or not I am inside a running screen session? One quick and easy way to tell […]
Continue reading…

 

How to change timezone on Linux

Question: The current timezone of my Linux box is inaccurate, and I want to change the timezone of the system. How can I change time zone on Linux? If the default timezone of your Linux system is not correct, you need to correct it to get accurate local time. Note that configuring NTP is not […]
Continue reading…

 

How to install Wine on Linux

Question: I need to run a Windows application on Linux, and for that, I would like to try Wine. How can I install Wine on [insert your Linux distro]? Wine is a popular user-space software program which allows one to run Windows applications on Linux. Wine provides a run-time environment for a Windows application by […]
Continue reading…

 

How to check if .deb package is installed

Question: How can I check whether or not a particular .deb package is installed on Debian or Ubuntu? If you want to check if a particular Debian package is installed on your system, you can use dpkg command with “-s” option, which returns the status of a specified package. Use the following command line to […]
Continue reading…

 

How to run nohup without generating nohup.out

Question: When I use nohup, I do not want to have nohup.out file generated. How can I run nohup without nohup.out file? By default, nohup command redirects its output to nohup.out. If you want to run nohup without creating nohup.out, you can simply redirect nohup output to /dev/null as follows. $ nohup some_command > /dev/null […]
Continue reading…