Favorite linux commands

Favourite linux commands

Notify script for watching files as they grow.

tail -f /var/log/messages | while read line; do accu=”$line”; while read -t 1 more; do accu=`echo -e “$accu\n$more”`; done; notify-send “Syslog” “$accu”; done 

Set reminder, and send it to the background

sleep 30m && notify-send -t 10000 -u critical “do stuff” & 

Random command from commandlinefu.com – cool

lynx –dump http://www.commandlinefu.com/commands/random/plaintext | grep .  

List directories only

ls -d */ 

Mail contents of file

mail -s “subject” youremail@mail.com </home/user/somedata.txt  — -f youremail@mail.com -F ‘John smith’; 

Check version

cat /etc/issue 

manage cron

crontab -e 

clean up filename

detox filename //might need to install sudo apt-get install detox 

grab screencast

ffmpeg -f x11grab -s wxga -r 25 -i :0.0 -sameq /tmp/out.mpg 

List by date

ls -lat

Replace typo in previous command

^typo^new^ 

Remove all but important.html from current directory

rm -f !(important.html) 

Remove all files except type txt or php

rm !(*.txt|*.php) 

Change file permissions to be same as other file

chmod --reference file1 file2 

mysql operations without entering mysql mode, and show databases starting with e

mysql -u user -h localhost -p -e "show databases;" | grep '^e' 

Create multiple directories at once

mkdir -p dir1/dir2 

Grep only certain files with find

find . -name "*.css" -exec grep -l "#content" {} \; 

Find files modified in the last day

find . -ctime -1 -type f 

Find files newer than myfile

find ~/src -newer myfile.txt 

Go home!

cd

monitor mysql processes

watch -n 1 mysqladmin --user=user --password=password processlist

change file permissions like other file

chmod --reference file.txt otherfile.txt

find ips in history

history 10000 |egrep '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}'

June 16, 2011