How to kill multiple processes at once with grep

There are cases where you want to kill multiple processes that match a certain pattern in their command line strings. For example, suppose you want to kill all processes that are running commands with keyword “jppf” in their arguments. $ ps aux | grep jppf xmodulo 3324 0.1 2.9 156524 15176 pts/0 Sl 22:16 0:01 […]
Continue reading…

 

How to convert rows into space-delimited line and vice versa

As part of text-file batching processing job, if you would like to convert rows into a space-delimited line, or replace spaces with line break (or newline), you can use command line utilities such as tr and awk. The tr command can perform simple character translation or deletion on input text file, while the awk utility […]
Continue reading…

 

How to append current date and timestamp to filename in shell script

Sometimes it is useful to include current date or timestamp information in file names, especially when files are generated on a regular basis such as monthly/daily/hourly for backup, logging and other archiving purposes. Here is how you can format current date and time, and append formatted string to a file name, in a shell script. […]
Continue reading…

 

How to automatically run a script when logging into Ubuntu Desktop

There are circumstances where you wish to have a script run automatically when you log in to Ubuntu Desktop. Such a script can configure various user-specific or system-wide settings on your Ubuntu system, upon user’s desktop login. In Linux, there are start-up scripts named ~/.bash_profile, ~/.bashrc, or ~/.profile which get executed when you start a […]
Continue reading…

 

How to set system-wide environment variables in Linux

In RedHat-based Linux, login shell executes /etc/profile script when a user logs in. This script customizes environment variables for all users system-wide. The /etc/profile script also sources all .sh scripts placed in /etc/profile.d directory. Therefore, in order to set system-wide environment variables in RedHat-based Linux, you can create a custom file with .sh extension in […]
Continue reading…