From CleanPosts

Revision as of 00:02, 22 April 2019 by Selah (Talk | contribs)
Jump to: navigation, search

Linux Jedi Mind Tricks

  • Make an image of a CD on your hard drive:

dd if=/dev/sr0 of=image.iso

  • Mount that image on your system to use it:

mount -o loop image.iso /mnt/temp

  • Make a new .iso image in /mnt/burn from the contents in /mnt/hold:

mkisofs -o /mnt/burn/image.iso /mnt/hold

  • Burn that image to another CD:

cdrecord dev=/dev/sr0 /mnt/burn/image.iso

  • Convert RPM package to DEB package:

alien file.rpm

  • Copy a file


  • Add a CD-ROM to your list of repositories.

apt-cdrom -m add

  • List only non-blank lines in a file:

awk 'NF >0' file.txt

  • Create a custom command to list files:

alias l = 'ls -l --color=auto'

  • Add line numbers to a file:

cat -n file.txt

  • Find text in a file:

awk 'chevy' cars.txt

  • Backup Master Boot Record:

dd if=/dev/sda of=MBR.img bs=446 count=1

  • Make a file lowercase:

cat FILE1.TXT | tr '[A-Z]' '[a-z]' > FILE2.TXT

  • Change the owner of a directory and all its contents:

chown -R teresita DIRECTORY

  • Grab a copy of a website:

wget -w9 -r --random-wait -l3 -np -E URL

  • Display time since boot:


  • Get the sizes of all subdirectories under a directory

du -sh MYDIR

  • Display unique lines in a sorted file:

uniq <FILE1 >FILE2

  • Use CUPS printer management system:

localhost:631 (in a browser address bar)

  • MP3 to WAV conversion:

madplay --output=wave:OCEANLAB.WAV OCEANLAB.MP3

  • Convert to OGG:

oggenc *

  • Create a link:

ln -s /initrd/mnt/dev_ro2 HOME

  • Extract tarball:

tar -xvf /dev/hda/FILE

  • Make archive:

tar -c DIRECTORY | bzip2 > DIR.TAR.BZ2

  • Make a file executable for all users:

chmod u+x FILE

  • Turn a directory into a SquashFS file:

mksquashfs /tmp/merge PUP_412.SFS

  • Mount your SquashFS file:

mount -o loop -t squashfs PUP_412.SFS /mnt/pup

  • Upload a file to your webspace:


  • Convert a MIDI file to a .WAV file:

timidity -Ow -oRUBY.WAV RUBY.MID

  • Replace spaces in a filename with hyphens:

find . -name "* *mp3" -exec rename 's/\ /-/g' {} \;

  • Print the current month in Julian dates:

cal -j

  • Make a new file of the individual words in another file:

tr ' ' '\012' <INFILE >OUTFILE


for WORD in `cat FILE`


echo $WORD


  • Strip carriage returns from a DOS file:

'tr -d '\015' <INFILE >OUTFILE

  • Downshift all file names:

  1. !/bin/bash

for x in `ls` do if [ ! -f $x ]; then continue fi lc=`echo $x | tr '[A-Z]' '[a-z]'` if [ $lc != $x ]; then mv -i $x $lc fi done

  • Rename in bulk:



for F in $OLD*


SUFFIX=`expr $F : '$OLD\(.*\)'`



  • Install from tarball

tar -zxvf ARCHIVE.TAR.GZ


  • Format floppy disk:

fdformat' /dev/sde

  • List directories:

find . -type d -print

  • Convert avi to mpeg:

mencoder MOVIE.AVI -of mpeg -mpegopts format=mpeg1:tsaf:muxrate=2000 -o MOVIE.MPG -oac lavc -lavcopts acodec=mp2:abitrate=224 -ovc lavc -lavcopts vcodec=mpeg1video:vbitrate=1152:keyint=15:mbd=2:aspect=4/3

  • Factorial function implemented by recursion.

define fact(n)


if (n <= 1) return (n);

return (n * fact(n-1));


  • Perform a ROT 13 conversion:
echo "$1" | tr '[A-Za-z]' '[N-ZA-Mn-za-m]'

  • Download streaming videos and convert them to MP3s

sudo curl -o /usr/local/bin/youtube-dl

sudo chmod a+x /usr/local/bin/youtube-dl

youtube-dl --title --extract-audio --audio-format mp3 [LINK]

ffmpeg -i yourvideo.mp4 -f mp3 -ab 192000 -vn yourvideo.mp3

Personal tools
Strangers In Paradise