From CleanPosts

Jump to: navigation, search


Convert .avi video files to smaller .mp4 format

ffmpeg -i 'U2 - New Years Day.avi' 'U2 - New Years Day.mp4'

Convert GIFs from Twitter that download as MP4s back into uploadable GIFs again

ffmpeg -y -i input.mp4 -filter_complex "scale=320:-1:flags=lanczos[x];[x]split[x1][x2]; [x1]palettegen[p];[x2][p]paletteuse" output.gif

Convert man page to text file

man concalc | col -bx >concalc.txt

Convert RPM package to DEB package

alien file.rpm

Convert text files from MS-DOS format to UNIX format

tr -d '\r' <MULE.ASC >mule.txt

Convert WordStar files to plain text

cat | tr -c '[:print:]\t\r\n' '[ *]' >rubymae.txt

Copy a file


Create a custom command to list files

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

Create a directory using today's date

mkdir $(date +%Y%m%d)

Create a file and a directory with unique names from the system clock

touch "$(date +"%y%m%d%H%M%S")";sleep 1; mkdir "$(date +"%y%m%d%H%M%S")"

Create a link

ln -s /initrd/mnt/dev_ro2 HOME

Remove empty directories under the working directory

find . -empty -exec rm -rf {} \;

Display all subdirectories in a tree format

ls -R | grep ":$" | sed -e 's/:$//' -e 's/[^-][^\/]*\//----/g' -e 's/^//' -e 's/-/|/'

Display time since boot


Display unique lines in a sorted file

uniq <FILE1 >FILE2

Download streaming videos and convert them to MP3s

sudo curl -L -o /usr/local/bin/youtube-dl sudo chmod a+x /usr/local/bin/youtube-dl youtube-dl --title --extract-audio --audio-format mp3

Extract audio from any video file

ffmpeg -i Pet-Shop-Boys---West-End-Girls.mp4 -vn west-end-girls.ogg

Extract gzip compressed tar archives

gunzip progs.tar.gz tar xvf progs.tar

Extract pages from a PDF to build a new PDF

ps2pdf -dFirstPage=4 -dLastPage=8 input.pdf output.pdf

Extract tarball

tar -xvf /dev/hda/FILE

Find duplicates on your filesystem

duff -r *

Find files by name

find . -name *wav -print

Find man page for a command

whereis -m genisoimage genisoimage: /usr/share/man/man1/genisoimage.1.gz

Find ten biggest hogs of disk space under a directory

du -s /usr/share/* | sort -nr | head

Find text in a file

awk 'chevy' cars.txt

Format floppy disk

fdformat /dev/sde

Generate a pdf from a man page

man -t vim | ps2pdf - > vim.pdf

Generate a random password

openssl rand -base64 12


openssl rand -base64 24


Get a weather forecast for your city


Get information about all files of a certain type

find . -name *com -exec file {} \;

Get the sizes of all subdirectories under a directory

du -sh MYDIR

Get your public IP address

curl; echo

Grab a copy of a website

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

List primes between 2 and any number

for (( i=2; i<=$1; i++ ));do
l=$(factor $i | cut -d : -f 1)
r=$(factor $i | cut -d : -f 2 | sed 's/ //g')
if (( $l == $r ));then
echo $i

List the misspelled words in a file

enchant -l matthew

Make a file executable for all users

chmod u+x FILE

Make a file lowercase

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

Make all filenames in a directory lowercase

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

paste into file called lowerit chmod u+x lowerit ./lowerit

Make a new file of the individual words in another file

tr ' ' '\012' <INFILE >OUTFILE


for WORD in `cat FILE`
echo $WORD

Make an image of a CD on your hard drive

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

Make archive

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

Make directories for 36 months using brace expansion:

mkdir {2021..2023}-{01..12}

Make ISO from temp directory

genisoimage -r -joliet-long -o files1.iso temp

Make the ls command print in a tree format

alias tree="ls -R | grep ":$" | sed -e 's/:$//' -e 's/[^-][^\/]*\//--/g' -e 's/^//' -e 's/-/|/'"

Make the ls command useful for a change

alias ls='ls -lhGpt --color=always'

Make the text in a file all uppercase

cat testa.txt | tr '[a-z]' '[A-Z]' > testb.txt

Mount that image on your system to use it

(The mount point must already exist) mount -o loop image.iso /mnt/temp

Mount your SquashFS file

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

Move all files starting with "B" into the b subdirectory

find -name "B*.*" -exec mv {} b \;

Move all the .jpg images from one folder to another folder, recursively

find -type f -name *.jpg -exec mv '{}' /home/teresita/Downloads \;

MP3 to WAV conversion

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

Perform a ROT 13 conversion

echo "$1" | tr '[A-Za-z]' '[N-ZA-Mn-za-m]'

Prime factors of first 100 integers

echo {1..100} | factor

Print a complete date-time group

date '+%Y-%m-%d/%k:%M:%S'

Print the current month in Julian dates

cal -j

Recursively move mp3 files in many directories to a single target directory

find -name '*.mp3' -exec mv -i {} /home/minix/Desktop/music \;

Rename all files with extension .OUT with the extension .txt

rename 's/\.OUT$/.txt/' *

Rename in bulk

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

Replace spaces in a filename with hyphens

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

Replace spaces in the filename of all the files in a directory with hyphens

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

Return pi to the number of digits specified on the command line (Answer grows more accurate the longer the fractional part)

echo "scale=$1;a(1)*4" | bc -l

Return the name of the most-recently modified file in a directory

$ ls -t | head -1

Run the last command again as root

sudo !!

Send a man page to the terminal minus the embedded backspace characters

man genisoimage | col -b | less

Tally up a column of figures

#! /bin/sh
case "$1" in 
[1-9]*) colnum="$1"; shift;; 
*) echo "Usage: `basename $0` colnum [files]" 1>&2; exit 1;; 
awk '{sum += $col} 
END {print sum}' col=$colnum OFMT='%.2f' ${1+"$@"}

Turn a directory into a SquashFS file

mksquashfs /tmp/merge PUP_412.SFS

Turn the capslock key into a second ESC key

setxkbmap -option caps:escape

Upload a file to your webspace


Use imagemagick to take a screen shot

import screenshot.jpg

Use CUPS printer management system

localhost:631 (in a browser address bar)

Use the command line as a quick calculator

echo $((145+5))
echo $((145-5))
echo $((145*5))
echo $((145/5))
echo $((145%5))
echo $((145**5))
Personal tools
Strangers In Paradise