Archive for the ‘manual of the day…’ Category

flush memcached via command line

Just this simple command will flush the memcached cache: echo “flush_all” | nc 127.0.0.1 11211 assuming that it runs on the localhost with the default port.

Completely remove MySQL server including all the data from Debian

I just tried to uninstall MySQL on Debian via apt-get remove –purge mysql-server apt-get remove –purge mysql-client apt-get autoremove and wondered that the directories /var/lib/mysql /etc/mysql still existed after the commands. Then I recognized, that a apt-get remove –purge ‘mysql-server.*’ is doing better and removes everything. Note: if you get a /etc/init.d/mysql: WARNING: /etc/mysql/my.cnf cannot [...]

get text between 2 lines from a file with sed

I just had the problem that I wanted to get 2000 lines of text from a big log file (> 20 million lines). It was too much to select it in my Terminal. The only thing I know was where the text of interest started and where it ended. Sed what the hero of this [...]

Kill processes by their name

Sometimes you have lots of processes running on your Linux system and you want to kill them all. But you don’t want to spend too much time on killing each process by their process id. A good way to handle with this problem is to combine ps, with grep and awk: ps -lax | grep [...]

Completely remove MySQL server and MySQL client in Debian

Sometimes it is necessary to remove MySQL completely from your Debian system. E.g. after a complete misconfiguration. I had this problem and found this commands to get rid of MySQL server and client (in this case in version 5.1). Both commands need to be executed as root: # apt-get autoremove –purge mysql-server mysql-server-5.0 # apt-get [...]

Repeat a shell command with a script N times

If you want to execute a shell command N times you can do this with a simple shell script. Let’s say your command is something like curl http://www.website.com/file.txt > output.xml and you like to execute this 10 times. Then just create a file (e.g. myscript.sh) and put for i in {1..10}; do curl http://www.website.com/file.txt > [...]

Extracting a .war file

If you want to extract a .war file, because you need for example to change some files in it, just execute the following command: jar xvf file.war file.war is in this case the name of the war file. You need to change it of course to the correct filename from your system. :)

Getting information about a secure web server using openssl

To retrieve information about a web server which runs with https you can use openssl on the command line like this: openssl s_client -connect www.INSERTSERVERHERE.com:443

Recursively remove .svn directories in Linux

Sometimes it’s necessary to get rid of all the .svn directories in a subversion managed project. You can easily do this on the Linux console by executing rm -rf `find . -type d -name .svn` in the base directory of the project.

Enable crontab logging in Debian Linux

By default the logging for the cron demon is not active in Debian Linux. To activate it, please open the file /etc/rsyslog.conf via vi /etc/rsyslog.conf and uncomment the line # cron.* /var/log/cron.log After that you need to restart rsyslog via /etc/init.d/rsyslog restart and you will find the cron logs in /var/log/cron.log