Category Archives: Linux Command Line

Uncompress on the fly when copying a file from a remove location with scp

Don’t use scp, do it with ssh: ssh backups@server “cat /home/backups/backup_2010-09-27.tar.gz”| tar zxvf – You can probably use something similar also for: Compress on the fly when copying a file from a remove location with scp

Posted in Linux Command Line | Tagged , | Leave a comment

Linux bash – tar tricks

Change directory: tar xzvf /var/backups/dbserver/dbserver-backup*.tar.gz -C /var/backups/dbserver Specifing the destination file: tar –create -zvPh -f /tmp/backup.tar.gz /usr/local/bin /usr/local /etc/var/spool/cron /var/svn /home/*/.ssh /home/*/.bash*

Posted in Linux Command Line | Tagged | Leave a comment

Linux command Line – copy a file from remote to local

Copy a file from a remote location to a local directory (for example to burn a backup on DVD): scp backups@server1:backup20100105 local/path

Posted in Linux Command Line | Leave a comment

PHP function to get the most recurrent words in a file – it uses Linux command line

/** * Extracts the most recurrent one-word and two-word terms in a file * Filters out some common stop words and you can also pass extra ones * * @param string $filepath * @param int $minWordLength – the minimal word … Continue reading

Posted in Linux Command Line, PHP | Leave a comment

Linux Bash: Append and Prepend Strings to Files

I want to append the string “BYE” to the file test.txt echo “BYE” >> test.txt Now, I want to prepend the string “HI” to the file test.txt echo “HI”|cat – test.txt > /tmp/out && mv /tmp/out test.txt

Posted in Linux Command Line | Leave a comment

PHP – Execute Linux Commands

There are 4 functions: _ exec _ system _ passthru _ shell_exec They basically differ for the return. The best seems to be the last one, if you need the whole command output in your PHP script.

Posted in Linux Command Line, PHP | Leave a comment

SSH Without Password

Use Public/Private Keys for Authentication Using encrypted keys for authentication offers two main benefits. Firstly, it is convenient as you no longer need to enter a password (unless you encrypt your keys with password protection) if you use public/private keys. … Continue reading

Posted in Linux Command Line, System Administration | Leave a comment

List Which Ports Are Listening – Open Ports – Open Connections

This is the most reliable method because is actually scans the ports: nmap -sT -O localhost Other methods based on internal checks that give you also the information about the program using the ports: netstat -anp lsof -i

Posted in Linux Command Line, System Administration | Leave a comment

Building Scalable Web Sites – Scalability

A scalable system has got 3 simple characteristics: The system can accommodate increased usage The system can accomodate an increased dataset The system is maintainable It’s not about speed or complexity, those are other topics. For exampel, this is a … Continue reading

Posted in Linux, Linux Command Line, Microsoft, Web Development | Leave a comment

Linux: How To Count The Number Of Files Under a Directory

find . -type f | wc -l

Posted in Linux Command Line | Leave a comment