Monday, April 16, 2012

I needed to find a file in a list of jar files, but did not know which one.

The following command will list all jar files in the current directory, and pass them into the "jar tf" command to display the table of contents. The results will then be grep'd for the file_name

find -name "*.jar" | xargs -n 1 jar tf | grep -i

Restarting specific process id

Several times a day gnome-shell will crash and need to be restarted, normally I go into a virtual console and type:
ps -ef | grep gnome-shell
and see results like:
mdeimel 23496 2008 14 09:43 ? 00:00:01 /usr/bin/gnome-shell
mdeimel 23509 1 0 09:43 ? 00:00:00 /usr/libexec/gnome-shell-calendar-server
mdeimel 23522 20953 0 09:43 pts/1 00:00:00 grep --color=auto -i gnome-shell
then I type:
kill -1 23496
in order to kill and restart the service (the '-1' parameter calls a restart of the same process)

In an attempt to speed-up this process I created an alias to handle everything at once. Instead of using the "ps" command I started using "pidof" to get the exact process id right away, and pass that into the kill command:
kill -1 `pidof gnome-shell`
and to save as an alias in ~/.bashrc I have
#Restart gnome
alias gnome="kill -1 `pidof gnome-shell`"

Restarting audio

After having some problems with the quality of my audio, I needed to restart the service, here are the commands:

To kill the existing audio process run:
pulseaudio -k

To start a new daemon thread for audio run:
pulseaudio -D