useful_linux_commands

Some Useful Linux Unix Commands

Mono In The Background

nohup mono myexe.exe &

SSH Command In The Background Then Exit

tmux
CTRL+B D
tmux attach   #to come back to the command in the next session

Join Multiple MP4 Using GUI

mkvtoolnix-gui  #apt-get install ...

Video Convertor

sudo add-apt-repository ppa:ffmulticonverter/stable
sudo apt-get update
sudo apt-get install ffmulticonverter
 

Generate Thumbnails From Images

mogrify -resize 200 *.png

Ebay Search All (old)

(th*,po*,a,and,at,condition,has,in,is,on,of,off,or,for,from,new,old,on,paypal,pick,up,to,was,where,when,will,with,%,$,1,2,3,4,5,6,7,8,9,0)

CCTV recorder

Turn a webcam into a CCTV recorder

streamer -q -c /dev/video0 -f rgb24 -r 24 -t 02:30:00 -o outfile.avi &

BSD Nameserver Bind Reload

rndc reload

Restart SSHD

kill -HUP `cat /var/run/sshd.pid`

Chmod Directories

find ./ -type d -exec chmod 755 {} \;

Chmod Files

find ./ -type f -exec chmod 644 {} \;

Remove ^M

:%s/^V^M//g

Make Thumbnails

mogrify -resize 80x80 -background white -gravity center -extent 80x80 -format png -quality 75 *.png

Images From PDF

convert -density 900 -depth 8 -quality 100 Voynich_Manuscript.pdf Voynich_Manuscript.png

Convert Directory to MP3

find -name "*.flac" -exec avconv -i {} -acodec libmp3lame -ab 320k {}.mp3 \;

Merge PDF

pdftk *.pdf cat output 1234567.pdf;

Sample Daemon Startup Script On Red Hat Systems

#!/bin/bash
# chkconfig: 2345 20 80
# description: Description comes here....

# Source function library.
. /etc/init.d/functions

start() {
  # code to start app comes here 
}

stop() {
  # code to stop app comes here 
}

case "$1" in 
 start)
     start
     ;;
 stop)
     stop
     ;;
 retart)
     stop
     start
     ;;
 *)
      echo "Usage: $0 {start|stop|restart}"
esac

exit 0

Create Site Mirror

wget -mk -w 20 http://www.example.com/

SCP Various Commands

Copy the file “foobar.txt” from a remote host to the local host

scp your_username@remotehost.edu:foobar.txt /some/local/directory

Copy the file “foobar.txt” from the local host to a remote host

scp foobar.txt your_username@remotehost.edu:/some/remote/directory

Copy the directory “foo” from the local host to a remote host's directory “bar”

scp -r foo your_username@remotehost.edu:/some/remote/directory/bar

Copy the file “foobar.txt” from remote host “rh1.edu” to remote host “rh2.edu”

scp your_username@rh1.edu:/some/remote/directory/foobar.txt your_username@rh2.edu:/some/remote/directory/

Bzcat & enWiki

bzcat dewiki-20120603-pages-articles.xml.bz2 | perl mwimport.pl | mysql -f -u [USERNAME] -p [DATABASE]
cat enwiki-<date>.xml | perl mwimport.pl | mysql -f -u<admin name> -p<admin password> --default-character-set=utf8 <database name>

Mount BSD Drive From Linux

sudo mount -t ufs -r -o ufstype=44bsd /dev/sdb1 /mnt/

Copy multiple files and append to end of filename

for f in /etc/*.conf; do cp -v -- "$f" "$f.orig"; done

How to file split at a line number

wc -l 100 file

Create Sitemap (Dirty)

find ./ > sitemap.test

Open in gvim search and replace

./ 

with

<url><loc>http://www.yoursite.com/

Open in vim and run command

:%s/$/\**##**/g \\

Open in gvim search and replace

  • *##**

with

</loc><lastmod>2014-03-05T22:44:12+11:00</lastmod></url>

Add the open and closing tags

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
 ~~~
 </urlset>
useful_linux_commands.txt · Last modified: 2015/06/11 15:35 (external edit)