Summary: To find the PID of a running UNIX/XWindow process: $ xprop _NET_WM_PID If that fails: $ ps -ww -fp <PID> $ pwdx <PID> Detailed explanation: So How can you find the PID (not Window ID!) of a running UNIX/XWindow process? Method 1 (simple): $ xprop _NET_WM_PID … and then click on window of interest […]
Shell and environment
Tips on how to customize your environment and how to configure and use the shell (bash) in the most efficient way
The ‘ls’ command – how to show seconds?
Being able to see seconds in the UNIX ‘ls’ command is particularly useful for comparing/viewing recently created files, because by default ‘ls -l’ will simply show “Today” in the date/time field for such files. Here’s how you can make ‘ls’ show also the seconds (and not only seconds but also microseconds, for that matter… oh […]
Adding actions to Thunar’s “Send to” context menu (xfce)
Using Kdiff3 tool as example action to add to the SendTo menu of Thunar. Create the following file in ~/.local/share/Thunar/sendto and name it <whatever>.desktop (I named mine ‘kdiff3.desktop’) : # kdiff3.desktop – Integrate kdiff3 into # the “Send To” menu. [Desktop Entry] Type=Application Version=1.0 Encoding=UTF-8 TryExec=kdiff3 Exec=kdiff3 %F Icon=kdiff3 Name=Kdiff3 # MimeType=text/plain; The MimeType […]
Using curl and POST requests to automate data retrieval from a website
Problem: A site contains data which is of interest to us. The data is uniformly structured and available for examination by the general public (i.e. no login required) but is not automatically accessible, i.e. viewing it requires repetitive user interaction (such as setting a date range, clicking a ‘submit’ button, etc). In addition, usually the […]
How to resize multiple images in Linux
Use imagemagick – this is exactly what it was designed for! 🙂 For example: – to resize all .jpeg files in the current directory to be 320 pixels wide, preserving the aspect ration, do this:  $ convert ‘*.jpeg[320x]’ resized%03d.jpeg – to shrink all .jpg files in the current directory to be 200 pixels wide, at […]
The linux ‘find’ command by example
find ~ -type f -name “.*” FIND the hidden files in your home directory (~) find . -name *~ -type f -delete Delete all files ending in ~ find . -name *.svn -type d -print0 | xargs -0 /bin/rm -rf Delete all .svn files under current dir find . -name *.c -perm /u+x -type f […]
RPM/yum : List (installed) packages versions (and grep ‘OR’)
Here’s how to list all packages whose names start with ‘nss’ yum info -v nss* | grep -v Committer | grep -w ‘Name\|Version\|Release\|Description\|Repo’ Here’s how to list all INSTALLED packages whose names start with ‘nss’ yum info -v nss* | grep -A12 -B5 -w ‘installed’ | grep -v Committer | grep -w ‘Name\|Version\|Release\|Description\|Repo\|installed’ And since […]
sed how-to: replace strings containing special charcters like . (dot) and / (slash)
I don’t know about the other people but to me the scariest UNIX command is by far sed. Today I found myself in a situation where I found no other way to solve my problem but to use sed… and it worked… and was not all that scary 🙂 I needed to replace a bunch […]
Bash quick cheatsheat (‘if’ checks and other useful commands)
Creating this post to dump here various bash shell and script commands, tips and tricks which I found useful in my everyday work. Will update it with new info continually… ——— Check in bash if a file exists or not and do something in each case: if [ -f $FILE ]; then echo “File $FILE […]
Convert UNIX time_t into a date/time text string
Often times, when working with the standard Linux/UNIX time format (time_t) one needs to quickly find out what is the “human readable” date and time text string a particular time_t value corresponds to. NOTE: The ‘C’ time_t type is the number of seconds elapsed since the “epoch”, the epoch being January 1st 1970 at 00:00:00. […]