One of the things that I really like about Linux is how much you can do from the terminal, which is much more powerful and flexible than the DOS/Windows command line. I keep notes on commands that I run frequently so that I don't have to recreate them from scratch.
These all work in Ubuntu Linux 8.10, 9.04, 9.10, 10.04, 10.10, 11.04, 11.10; Linux Mint Julia/Katya/Rebecca/Rafaela/Rosa; Fedora 14; and/or CrunchBang Waldorf. In some cases, the packages are not provided by default with the distribution, so sudo apt-get install <command name>
(Ubuntu/Mint/CrunchBang) or su -c 'yum install <command name>'
(Fedora) may be necessary.
for file in "ls -1"; do $(echo "$file"); done
(as-is, this does exactly the same thing as ls -1
— note that the -1
is a dash-one
, not dash-L
, and serves to list exactly one file per output line — but can be used to build more complex commands.)
sleep 5; echo "hello"
bash
history for a particular stringhistory | grep exiv
grep
through the contents of ZIP-compressed files, and output the same of the archive in which the match occursfind . -name \*.ods -print | while read f; do unzip -p "$f" | fgrep -q something && echo $f; done
alias rm="rm -i"
(Note that this can be made permanent by putting it in ~/.bashrc
)
for i in $(seq 1 20); do pcopy -u2 /dev/zero /dev/sdd; done
(the above command runs pcopy -u2 /dev/zero /dev/sdd
twenty times. I'm zeroing out an old hard drive repeatedly before throwing it away.)
echo "ls -l" | at midnight
echo $?
Ctrl-Z, then use the
bg
command.
find . -type l -exec bash -c "echo 'Replacing {} ...'; cp -LR '{}' '{}'.dereferenced; rm '{}'; mv '{}'.dereferenced '{}'" \;
ps ax
dlocate /usr/bin/eps2eps
or
dpkg -S usr/bin/eps2eps
(note that the first is much faster, but the dpkg
program is not installed by default under Ubuntu 8.10/9.04.)
vol_id --uuid /dev/sdd1
(useful when editing the /etc/fstab
file, and much more convenient than using udevinfo
.) (Using gparted
is almost as easy, though not as convenient from the command line)
Alternately
blkid -o value -s UUID /dev/sda1
stat /path/to/file
sudo apt-get -y install alsa-oss faac faad adobe-flashplugin gstreamer0.10-ffmpeg gstreamer0.10-plugins-bad gstreamer0.10-plugins-ugly gstreamer0.10-pitfdll libmp3lame0 non-free-codecs amarok tilda unrar gnome-mplayer audacity amarok zsnes gfceu flobopuyo libreoffice firefox thunderbird mate-desktop-environment mate-core wesnoth-all vlc audacity kid3 ffmpeg mencoder mplayer devede dia scribus xsane alien atomicparsley epiphany-browser exiftran gftp-gtk gparted ghostscript ghostscript-doc hfsplus hfsprogs hfsutils htop joystick lame lastfm dlocate macutils make mp3gain mp3splt mp3wrap mp3check build-essential joystick lame lastfm dlocate macutils make mp3gain mp3splt mp3wrap mp3check vorbisgain vorbis-tools w32codecs wine xsane-common tilda libgimp2.0-dev gimp=2.6.12-1ubuntu1 bluefish skype hugin qtpfsgui pcmanfm openbox obmenu obconf openbox-themes tidy autopano-sift tidy-doc transmission parcellite exiv2 && sudo apt-get update && sudo apt-get -y upgrade && sudo apt-get -y autoremove && sudo apt-get -y clean
Similar command under Crunchbang:
sudo apt-get install iceweasel konsole tilda libreoffice bluefish zsnes epiphany default-jdk openjdk-7-jdk tidy weblint icoutils vlc gcj-jre-headless hspell pulseaudio-esound-compat oss-compat myspell-en-us myspell-de-de libreoffice-help-en-us cups-bsd mythes-en-us libreoffice-lightproof-en libreoffice-gnome libreoffice-kde openclipart-libreoffice pstoedit imagemagick gstreamer0.10-plugins-ugly libreoffice-officebean libreoffice-style-hicontrast libmysql-java libreoffice-style-tango libreoffice-style-crystal libreoffice-style-oxygen icedtea-plugin phonon-backend-gstreamer openjdk-7-jre faad lame sox kid3 mencoder genisoimage cdrdao dlocate exiftran ffmpeg pdftk alsa-oss alsa-oss gstreamer0.10-ffmpeg gstreamer0.10-plugins-bad gstreamer0.10-plugins-ugly libmp3lame0 amarok unrar gnome-mplayer audacity amarok flobopuyo kid3 mplayer devede dia scribus xsane alien atomicparsley epiphany-browser exiftran gftp-gtk gparted ghostscript ghostscript-doc hfsplus hfsprogs hfsutils htop joystick lastfm macutils make mp3gain mp3splt mp3wrap mp3check build-essential lame dlocate macutils make vorbisgain vorbis-tools wine xsane-common libgimp2.0-dev gimp hugin qtpfsgui pcmanfm openbox obmenu obconf openbox-themes tidy-doc transmission parcellite exiv2 amarok-doc moodbar cups wodim cdrkit-doc ghostscript-cups ghostscript-x hpijs gimp-help-en gimp-data-extras imagemagick-doc autotrace html2ps finger oxygencursors tango-icon-theme libwine-sane libwine-print media-player-info libsox-fmt-all mplayer-doc mpg321 sun-java6-fonts icedtea-7-plugin phonon-backend-vlc scribus ufraw gocr; sudo apt-get -y autoremove; sudo apt-get -y clean; sudo apt-get update; sudo apt-get -y upgrade
Assumes already running on a root terminal, i.e. sudo -i
has been executed. Also assumes that the MATE repository has already been made available. This can be done with
sudo add-apt-repository "deb http://packages.mate-desktop.org/repo/ubuntu precise main"
(Obviously, this is based on my personal preferences, but I think it makes for a highly usable system.)
sudo apt-get -y install alsa-oss faac faad adobe-flashplugin gstreamer0.10-ffmpeg gstreamer0.10-plugins-bad gstreamer0.10-plugins-ugly gstreamer0.10-pitfdll libmp3lame0 non-free-codecs amarok tilda unrar gnome-mplayer audacity amarok zsnes gfceu flobopuyo libreoffice firefox thunderbird mate-desktop-environment mate-core wesnoth-all vlc audacity kid3 ffmpeg mencoder mplayer devede dia scribus xsane alien atomicparsley epiphany-browser exiftran gftp-gtk gparted ghostscript ghostscript-doc hfsplus hfsprogs hfsutils htop joystick lame lastfm dlocate macutils make mp3gain mp3splt mp3wrap mp3check build-essential joystick lame lastfm dlocate macutils make mp3gain mp3splt mp3wrap mp3check vorbisgain vorbis-tools w32codecs wine xsane-common tilda libgimp2.0-dev gimp=2.6.12-1ubuntu1 bluefish skype hugin qtpfsgui pcmanfm openbox obmenu obconf openbox-themes tidy autopano-sift tidy-doc transmission parcellite exiv2 && sudo apt-get update && sudo apt-get -y upgrade && sudo apt-get -y autoremove && sudo apt-get -y clean
Similar command under Crunchbang
sudo apt-get install iceweasel konsole tilda libreoffice bluefish zsnes epiphany default-jdk openjdk-7-jdk tidy weblint icoutils vlc gcj-jre-headless hspell pulseaudio-esound-compat oss-compat myspell-en-us myspell-de-de libreoffice-help-en-us cups-bsd mythes-en-us libreoffice-lightproof-en libreoffice-gnome libreoffice-kde openclipart-libreoffice pstoedit imagemagick gstreamer0.10-plugins-ugly libreoffice-officebean libreoffice-style-hicontrast libmysql-java libreoffice-style-tango libreoffice-style-crystal libreoffice-style-oxygen icedtea-plugin phonon-backend-gstreamer openjdk-7-jre faad lame sox kid3 mencoder genisoimage cdrdao dlocate exiftran ffmpeg pdftk alsa-oss alsa-oss gstreamer0.10-ffmpeg gstreamer0.10-plugins-bad gstreamer0.10-plugins-ugly libmp3lame0 amarok unrar gnome-mplayer audacity amarok flobopuyo kid3 mplayer devede dia scribus xsane alien atomicparsley epiphany-browser exiftran gftp-gtk gparted ghostscript ghostscript-doc hfsplus hfsprogs hfsutils htop joystick lastfm macutils make mp3gain mp3splt mp3wrap mp3check build-essential lame dlocate macutils make vorbisgain vorbis-tools wine xsane-common libgimp2.0-dev gimp hugin qtpfsgui pcmanfm openbox obmenu obconf openbox-themes tidy-doc transmission parcellite exiv2 amarok-doc moodbar cups wodim cdrkit-doc ghostscript-cups ghostscript-x hpijs gimp-help-en gimp-data-extras imagemagick-doc autotrace html2ps finger oxygencursors tango-icon-theme libwine-sane libwine-print media-player-info libsox-fmt-all mplayer-doc mpg321 sun-java6-fonts icedtea-7-plugin phonon-backend-vlc scribus ufraw gocr; sudo apt-get -y autoremove; sudo apt-get -y clean; sudo apt-get update; sudo apt-get -y upgrade
Assumes already running on a root terminal, i.e. "sudo -i" has been executed. Also assumes that the MATE repository has already been made available. This can be done with
sudo add-apt-repository "deb http://packages.mate-desktop.org/repo/ubuntu precise main"
(Obviously, this is based on my personal preferences, but I think it makes for a highly usable system.)
cat /proc/cpuinfo
grep -a -B 25 -A 100 'some string in the file' /dev/sda1 > results.txt
find -name "Picasa.ini" -type f -print0 | xargs -0 /bin/rm -f
e2fsck -f -p -v -D /dev/sdc1
sudo aptitude hold gqview amarok
sudo nvidia-xconfig --xinerama --separate-x-screens --no-twinview
To find out how much space the home directory occupies
du -hs ~
To find what files were changed today in the current directory
ls -lrt | grep 'May 22'
Same, but just display file name and modification date
ls -lrt | awk '{print $6" "$7" "$9 }' | grep 'May 22'
Or all files from a past year
ls -lR | grep 2006
To find what changed in the current directory between three and six minutes ago
find . -mmin +3 -mmin -6
To find the top five largest files in the named directory or subdirectory
du -a directoryname | sort -nr | head -n 5
To find the five biggest files on the system, and sort them from largest to smallest
find / -type f -printf '%s %p\n' |sort -nr| head -5
Same, but excluding the /proc filesystem
find / -wholename '/proc' -prune -o -type f -printf '%s %p\n' |sort -nr| head -5
Same, but limited to the current filesystem
find / -xdev -wholename '/proc' -prune -o -type f -printf '%s %p\n' |sort -nr| head -5
Source for these commands
gunzip -c installed-mint.img.gz | sudo dd of=/dev/sda5
IMPORTANT NOTE: Doing this thoughtlessly is incredibly stupid and may completely bork an installed system or otherwise destroy data. Make absolutely sure you know what you're doing; read on for more information. It is OF COURSE necessary to be absolutely sure that you're writing to the correct partition, which can be easily checked by running gparted, parted, fdisk, or, if the file system is currently mounted, mount (though the system should be unmounted before you proceed).
RATIONALE AND BACKGROUND: After freshly installing an OS onto my computer, I create a (compressed) image of that installation; rewriting this compressed image onto the device is then faster and easier than reinstalling the OS from scratch, should this ever need to be done.
The compressed image can be created with something like
sudo dd if=/dev/sda5 | gzip - > ~/Desktop/installed-mint.img.gz
I then burn the file onto a data DVD or keep it on an external drive.
Before creating the image, it's useful to zero unused space on the drive; this vastly improves the compression of the disk. (Otherwise, the compression program winds up trying to compress whatever random junk is on the drive, and random junk doesn't compress well. This wastes a lot of space.) The empty space can be zeroed with
dd if=/dev/zero of=/mnt/mint/000.000
Let this run until the disk is full, when dd will quit and complain that there is no more space. Then
rm /mnt/mint/000.000
This ensures that all empty space on the device is overwritten with zeroes, a long string of which compresses down to take up almost no space.
Note that it is incredibly important to check that the device name is correct; this can be done with parted
, gparted
, fdisk
, or perhaps mount
(if the drive is currently mounted, though the filesystem being imaged should be unmounted before it is imaged). Note that the sudo
before the dd
is necessary to get full access to the device in /dev
; it's possible to just do sudo -i
, then exit, to ensure that the dd
command doesn't ask for elevated privileges while running.
find /some/path -type f -printf '%f\n' | grep -o '\..\+$' | sort | uniq -c | sort -rn
padsp BasiliskII
nice -n 10 {some command}
ps -o user,pid,ppid,command ax | grep {process id of parent process}
sudo xrandr --output LVDS1 --auto --rotate normal --pos 0x0
gpg --export 505AB18E --output > "/home/patrick/Desktop/keys.gpg"
then,
gksudo seahorse
... and import the key.
route -n
(It's the last line under "gateway").
ifconfig
(it's under "inet addr")
sudo /etc/init.d/nfs-kernel-server restart
showmount -e {server name/server IP address}
curl -u patrick_mooney -d status="♫♬♪ And some folks loves ham hocks/ And some folks loves po'k chops/ And some folks loves vegetable soup ... ♪♬♫" -d source="cURL" http://twitter.com/statuses/update.xml
— not anymore: Twitter now requires that clients use OAuth.
sudo restart smbd
sudo restart nmbd
wget -mpNHk -D .media.tumblr.com,patrickbrianmooney.tumblr.com -R "*avatar*","*\?*","*_[0-9][0-9][0-9].*" http://patrickbrianmooney.tumblr.com -o wgetLog.txt
rsync -avv --progress --log-file-format="" --log-file="/home/patrick/Desktop/nfs.log" --exclude "*jpg" --exclude "*png" --exclude "*pdf" --exclude "*odt" --exclude "*doc" --exclude "*docx" --exclude "*ppt" --exclude "*pptx" /~patrick/* patrickbrianmooney_patrickbrianmooney@ssh.phx.nearlyfreespeech.net:/home/public/~patrick/
host patrickbrianmooney.nfshost.com
wget --wait=20 --limit-rate=20K -m -p -U Mozilla http://www.stupidsite.com/restricedplace.html
-m turns on "mirroring" options, including recursion and infinite recursion depth. If wget should convert links to other documents that were downloaded to links to the local files, add -k.
flac
to .mp3
for file in *.flac; do $(flac -cd "$file" | lame --replaygain-accurate -t --id3v2-only -V 2 -h - "${file%.flac}.mp3"); done
.mp4
to .mp3
for file in *.m4a; do $(faad -o - "$file" | lame --tt "" --ta "David Bowie" --tl "ChangesBowie" --tg "Pop" --ty 1990 --pad-id3v2 --replaygain-accurate --id3v2-only -V 2 -h - "${file%.m4a}.mp3"); done
for i in *.ape; do mac "$i" - -d | flac -o "${i%*.ape}.flac" -; done
(a Monkey's Audio .deb package suitable for Ubuntu can be found here)
.wma
to .mp3
for i in *.wma ; do mplayer -vo null -vc dummy -af resample=44100 -ao pcm -waveheader "$i" && lame -m j -h --vbr-new -b 160 audiodump.wav -o "`basename "$i" .wma`.mp3"; done; rm -f audiodump.wav
Source — this seems kind of an ugly hack and could almost certainly be done better with a pipe.)
.wav
s to .mp3
for file in *.wav; do $(lame -h -V 2 "$file"); done
.wav
s to .m4b
audiobooksfor file in *.wav; do $(faac -q 80 --artist "Pimsleur" --title "French Short Course" --genre "Audiobook" --disc 1 -w "$file" "${file%.wav}.m4b"); done
.mp3s
to iPod audiobook formatsox -V0 Heidegger_MP3WRAP.mp3 -t wav -c 1 -r 16000 - | faac -w -q 60 --artist "Hubert Dreyfus" --writer "Hubert Dreyfus" --title "Philosophy 185: Heidegger's Being and Time" --genre "College Course" --album "Lectures, Fall 2000" --compilation --track 1 --year 2000 --disc 1 --cover-art "dreyfus.jpg" -o Heidegger.m4b -
find . -type f \! -iname "*mp3" -exec /usr/bin/lame -m j --replaygain-accurate -V 2 --add-id3v2 --id3v2-only '{}' \;
A CD ripper I used to use (RipperX) used to fail to encode to .mp3 on files with really long paths (I presume that long
means over 255 characters, but haven't tested this). Rather than worrying about it, I just leave this running when I go to bed after a day when I've been ripping CDs. Of course, the better option is to use a non-idiotic CD ripper.
It searches the directory tree from the current point for anything that's a file (not a directory or symlink) with a name that doesn't end in .mp3
(note the !, which is POSIX not
, preceeded by a backslash to protect it from being interpreted by the shell) and runs lame
over it, converting the .wav
file to .mp3
(when RipperX fails on a file, it's almost certain that the file doesn't end in .wav
, so searching for .wav
produces few useful results). The first -exec ...
argument is the command to be run, where {}
is replaced with the name of the (non-mp3) file. It's quoted to protect the bash shell from interpreting it. The semicolon (backslashed to — again — protect it from expansion by the bash shell) ends the command.
transcode -i /dev/dvd -x dvd -T A,B,1 -a 0 -y raw -m track-a.mp3
where A is the number of the title to rip from, and B is the chapter number.
to find the title/chapter info
lsdvd
(no arguments!)
ffmpeg -i 100_4001.MOV -f wav -vn -acodec copy output.wav
(note that with my little Kodak, this creates m-law files, which are hard to postprocess. VLC can play them, though.)
or, somewhat more simply
ffmpeg -i 100_4001.MOV output.flac
To dump a segment of mp3 audio from a video file containing mp3 audio to a file
ffmpeg -i Dummy.2003.avi -acodec copy -vn -ss 71 -t 0:04:09 ~/Desktop/MikeRueckberg-Years.mp3
(This dumps the mp3 audio from 1:11 to 4:09 in the movie.)
for file in *.mp3; do $(lame --pad-id3v2 --id3v2-only -V 2 "$file" "${file%.mp3}_processed.mp3"; id3cp -1 "$file" "${file%.mp3}_processed.mp3"); done
(Note that this copies only the id3 version 1 tags ... id3cp seems to have a problem with version 2 tags in which the copied text shows up with an incorrect character encoding much of the time. I do realize that lossy recompression occurs under these circumstances, but am willing to put up with this in certain circumstances, such as when some idiot distributes mp3s created with --preset insane
. [At this point, just use FLAC. Honestly])
rec -V -S -b 16 -r 48k -c 2 /media/Patrick\!/Mahler3.flac
sox "Lecture 05 - The Day the World Went Away (23 January 2013).alaw.wav" -b 16 -t wavpcm - | lame --replaygain-accurate -q 0 -V 8 -b 8 -B 40 --tt "The Day the World Went Away" --ta "Patrick Mooney, M.A." --tl "English 165EW, Winter 2013" --ty 2013 --tn "05/18" --id3v2-only --tg "College Lecture" - "as .mp3/Lecture 05 - The Day the World Went Away (23 January 2013).mp3"
To replace JPEG comments
wrjpgcom -replace -c "3 June 2004 - View of people from entrance to Trinity College campanile - Dublin, Ireland" 46.12\ -\ People\ walking.jpg > 46.12\ -\ People\ walking.jpg
(notice the use of output redirection to specify output filename)
for i in *jpg; do echo $i >> all-comments.txt; rdjpgcom "$i" >> all-comments.txt; echo "--------" >> all-comments.txt; echo >> all-comments.txt; done
To create the above-style all-comments.txt
files in each subdirectory below the current working directory
for j in ??\ -\ Roll*; do cd "$j"; for i in *jpg; do echo $i >> all-comments.txt; rdjpgcom "$i" >> all-comments.txt; echo "--------" >> all-comments.txt; echo >> all-comments.txt; done; cd ..; done
(note that the pattern in the first for
statement is specifically chosen to match the directory structure in which I last used this command)
The EXIFtool documentation recommends this to dump all tags in a photo, which may be a useful alternate method of accomplishing the same task
exiftool -r -w .txt -common pictures
mplayer video.nut -vo gif89a:fps=15:output=test.gif
(order of suboptions is, apparently, important)
First, convert the photos to the appropriate size, e.g. 450 pixels wide
for file in *JPG; do $(convert "$file" -resize 450 "${file%JPG}png"); done
Then, assemble the photos into an animated GIF
convert -delay 20 -loop 0 *JPG result.gif
ffmpeg -i out.avi -r 25 -f image2 image%4d.png
(-r
is frame rate; set it correctly.) Source
To crop all image files in a directory
mogrify -crop 640x520+4+21 *png
exiftool -tagsfromfile 100_0702.JPG Circles\ of\ Stones.jpg
(I do this to embed an EXIF tag from one of the original images that gets stitched into a panorama.)
for file in *png; do $(ocroscript rec-tess "$file" > "${file%png}html"); done
for file in *CR2; do $(dcraw -w -6 -T "$file"; exiftool -tagsfromfile "${file%CR2}JPG" "${file%CR2}tiff"); done
exiv2 mv -r "%Y-%m-%d_%H:%M:%S" *
exiftool "-alldates-=2:00:00" "-FileModifyDate-=2:00:00" -overwrite_original *
for file in *JPG; do $(convert "$file" -resize 700x1000 "${file%JPG}.png"); done
dd if=/dev/dvd of=dvd.iso
dd if=/dev/cdrom of=cd.iso
cdrdao read-cd --read-raw --datafile ~/ClockTower.bin --device /dev/cdrom --driver generic-mmc-raw ~/ClockTower.toc
... but note that this is really best done through PCSX's GUI
It seems not to be possible to create images of audio CDs, probably because the audio CD format is so different from data-based optical discs. (Please correct me if I'm wrong.) — Well, it's not possible to create an .iso. But there are other possibilities, like BIN/CUE, or .wav/.flac+CUE, etc.
mkisofs -o /tmp/cd.iso /tmp/directory/
genisoimage -hide-joliet-trans-tbl -hide-rr-moved -iso-level 3 -J -joliet-long -nobak -r -T -hfs -probe -map /usr/bin/genisoimage-default-mappings.hfs -hfs-creator GKON -hfs-type "????" -o /mnt/Externa/EuroPhotos.iso /mnt/Externa/Photos/pictures from Europe/
dd if=/dev/sde of=~/macHD.dd
(note that this provides an image of the entire disk, not of a particular partition ... which is desirable, for instance, when recovering data from old Mac hard drives, because HFS+ volumes actually include a dummy HFS partition.)
dd if=/dev/zero of=~/applications.hfv count=4194304
(count
is in blocks of 512 bytes. The above command creates a 2GB blank (zeroed) disk image. It can then be formatted by the emulator.)
mencoder 100_1969.mov -o 100_1969-rotated.avi -vf rotate=1 -oac mp3lame -ovc lavc
NOTE: This recompresses video and audio, with all that implies; mencoder
doesn't really write Quicktime video ...
Alternately, commandlinefu.com recommends
mencoder -vf rotate=1 -ovc lavc -oac copy "$1" -o "$1"-rot.avi
mencoder 100_1999.mov -o 100_1999-trimmed.avi -ss 61 -endpos 114 -oac mp3lame -ovc lavc -lavcopts vcodec=mjpeg:mbd=1
NOTE: mjpeg compression really isn't that efficient ...
mencoder 100_0778.MOV -o 100_0778-rotated.avi -vf rotate=1 -oac mp3lame -ovc lavc -af resample=8000:0:0,channels=1,volume=-200
(decreases the volume to the minimum possible volume and downsamples it to the lowest allowable samplerate & number of channels.)
Alternately, to remove sound from a video completely, commandlinefu.com recommends
mencoder -ovc copy -nosound ./movie.mov -o ./movie_mute.mov
mencoder 100_2168.MOV -o 100_2168-shrunk.avi -oac mp3lame -ovc lavc -vf scale=320:240
First, do a simple concatenation
cat VTS_01_1.VOB VTS_01_2.VOB VTS_01_3.VOB VTS_01_4.VOB VTS_01_5.VOB > FORBIDDEN_ZONE.VOB
Then, re-sync audio/video with mencoder
mencoder -forceidx -oac copy -ovc copy FORBIDDEN_ZONE.VOB -o FORBIDDEN_ZONE-final.VOB
As a one-step, just use multiple input files as arguments to mencoder
mencoder -forceidx -oac copy -ovc copy -o "Wristcutters: A Love Story.avi" Wristcutters-\ A\ Love\ Story\ CD1.avi Wristcutters-\ A\ Love\ Story\ CD2.avi
Alternately, commandlinefu.com recommends this for .avi files
avimerge -o output.avi -i file1.avi file2.avi file3.avi
mplayer dvd://1 -dumpstream -dumpfile /media/Externa/unloading-dock/DVD-rips/ForbiddenZone.vob
(useful if ripping software fails, but the disc is playable. It can then be postprocessed ...)
(working on this ... Suggestions?)
the man page for mplayer
has this option, which may be helpful:
-dvd-device <path to device> (DVD only)
Specify the DVD device or .iso filename (default: /dev/dvd). You can also specify a directory that contains files previously copied di‐ rectly from a DVD (with e.g. vobcopy).
Also, in this regard, see this example
Here's a sample that does this:
mencoder -forceidx -dvd-device "/home/patrick/Desktop/Adaptation.iso" dvd://1 -alang "en" -ovc lavc -oac mp3lame -sid 8190 -ss 1:06:25 -endpos 0:05:20 -forceidx -o Adaptation.avi
(which means: extract only the English track, only 5:20 of it, re-encoding, from an .ISO, and avoid hard-coding subtitles by specifying non-existent subtitle track ID# 8190)
.3g2
to .avi
ffmpeg -threads 2 -i filefromyourphone.3gp -f avi -r 29.97 -vcodec libxvid -vtag XVID -s 1024x768 -aspect 4:3 -maxrate 1800kb -b 1500kb -qmin 3 -qmax 5 -bufsize 4096 -mbd 2 -bf 2 -flags +4mv -trellis -aic -cmp 2 -subcmp 2 -g 300 -acodec libmp3lame -ar 48000 -ab 128kb -ac 2 fileonpc.avi
mencoder -oac lavc -aid 0 -ovc lavc -of mpeg -mpegopts format=dvd:tsaf:telecine -ofps 24000/1001 -vf harddup -lavcopts threads=2:vcodec=mpeg2video:trell:mbd=2:sc_threshold=1000000000:cgop:vstrict=0:vrc_maxrate=7002:vrc_buf_size=1835:vbitrate=1200:aspect=80/33 -srate 48000 -o "Poltergeist.mpeg" "Poltergeist 1982 BRrip 720p x264 [Herakler].mkv"
(based on an invocation of mencoder invoked automatically by DeVeDe. DeVeDe seems to fail on my system when provided with a Matroska file as input, so I manually convert the file to a DVD-ready MPEG and tell DeVeDe to use it as-is.)
First, find the subtitle stream number
mkvmerge -i Shutter.Island.2010.720p.BluRay.x264.DTS-WiKi.mkv
Then, extract that stream to a subtitle file
mkvextract tracks Shutter.Island.2010.720p.BluRay.x264.DTS-WiKi.mkv 3:Shutter.Island.2010.720p.BluRay.x264.DTS-WiKi.srt
(in this example, the subtitles were in track 3.)
mkvmerge -S -M -o Crash.mkv Crash\ \(remove\ subtitles\).mkv
export VIDEO_FORMAT=NTSC
ffmpeg -i inputfile.mkv -target ntsc-dvd {"-aspect 16:9", if widescreen} DVD-output-filename.mpg
Note: using dumped VOBs? It may help to start off by modifying the ffmpeg command more or less as follows
ffmpeg -i "StepBrothers (DVD dump).vob" -target ntsc-dvd -map 0:0 -map 0:1 -acodec copy -vcodec copy "Stepbrothers (ready).mpeg
Note the use of mappings here: in this case, the first and second streams (one audio, one video, because stream numbers are zero-based). Dumped VOBs often contain multiple audio streams, and ffmpeg doesn't always make good choices about which ones to include in the final product. Stream information can be found simply by executing ffmpeg -i [filename]
and/or with VLC media player. Note that ffmpeg requires that if any streams are mapped, all streams to be included in the output file must be mapped explicitly.
Using -acodec copy -vcodec copy
prevents ffmpeg from recompressing audio and video. This is not only much faster, but prevents loss of quality.
mkdir Stepbrothers
dvdauthor -o Stepbrothers/ -t "Stepbrothers (ready).mpeg"
dvdauthor -o Stepbrothers/ -T # can't be combined with the first invocation of dvdauthor
genisoimage -dvd-video -V STEPBROTHERS -o "Stepbrothers (ready).iso" Stepbrothers/
growisofs -dvd-compat -Z /dev/sr0=Stepbrothers\ \(ready\).iso
Based on this article
The first-pass invocation of mencoder
that DeVeDe runs is
mencoder -srate 48000 -af lavcresample=48000 -noautosub -oac lavc -aid 1 -ovc lavc -of mpeg -mpegopts format=dvd:tsaf -ofps 30000/1001 -vf scale=720:480,harddup -lavcopts vcodec=mpeg2video:trell:mbd=2:sc_threshold=1000000000:cgop:vstrict=0:vrc_maxrate=5050:vrc_buf_size=1835:vbitrate=2525:keyint=12:acodec=ac3:abitrate=224:aspect=4/3:vpass=1 -passlogfile /media/Backup/movies 2/Sybil (ready)/Sybil (ready).log -o /media/Backup/movies 2/Sybil (ready)/Sybil (ready)_01_01.mpg /media/Externa/movies/Sybil.divx
Second pass
mencoder -srate 48000 -af lavcresample=48000 -noautosub -oac lavc -aid 1 -ovc lavc -of mpeg -mpegopts format=dvd:tsaf -ofps 30000/1001 -vf scale=720:480,harddup -lavcopts vcodec=mpeg2video:trell:mbd=2:sc_threshold=1000000000:cgop:vstrict=0:vrc_maxrate=5050:vrc_buf_size=1835:vbitrate=2525:keyint=12:acodec=ac3:abitrate=224:aspect=4/3:vpass=2 -passlogfile /media/Backup/movies 2/Sybil (ready)/Sybil (ready).log -o /media/Backup/movies 2/Sybil (ready)/Sybil (ready)_01_01.mpg /media/Externa/movies/Sybil.divx
Ideally, the screencast video is .mp4. The original screencast might plausibly be created with something like
ffmpeg -f x11grab -r 12 -s 1280x800 -i :0.0 -qscale 0.1 ~/Desktop/web.mp4
or
avconv -f x11grab -r 15 -s 1366x768 -i :0.0 ~/Desktop/out.mp4
First, trim the audio and/or video so they're synchronized. Then, mux them with mencoder
mencoder -forceidx "Machines Read, Too (just not well).mp4" -forceidx -audiofile "machines.flac" -oac mp3lame -ovc copy -forceidx -o "Machines Read, Too (just not well) (with audio).mp4"
Then, trim any front matter from the video and put a "fast start" MOOV atom at the beginning of the video for YouTube
ffmpeg -ss 74 -i "Machines Read, Too (just not well) (with audio).mp4" -acodec copy -vcodec copy -movflags +faststart "Machines Read, Too (just not well) (final).mp4"
(note that doing this requires a version of ffmpeg more recent than that in the Crunchbang/Debian repos; this can be found in the repo here.)
for file in *; do $(mencoder -srate 22050 -af lavcresample=22050 -oac mp3lame -ovc lavc -ofps 30000/1001 -vf scale -zoom -xy 720 -lavcopts vcodec=mpeg4:trell:mbd=2:keyint=75:vbitrate=1001:autoaspect -lameopts vbr=4:q=2:mode=1 -o "${file%flv}-processed.avi" "$file"); done
(Of course, parameters can be adjusted as needed.)
ffmpeg -f x11grab -r 12 -s 1280x800 -i :0.0 ~/Desktop/out.avi
Even better (Source)
ffmpeg -f x11grab -r 25 -s 1280x800 -i :0.0 -qscale 0.1 ~/Desktop/out.mp4
Using avconv
avconv -f x11grab -r 15 -s 1366x768 -i :0.0 -qscale 0.1 ~/Desktop/out.mp4
avconv -f alsa -i pulse -f x11grab -r 15 -s 1366x768 -i :0.0 -vcodec libx264 -acodec ac3 -threads 2 ~/Desktop/test.mp4
for a file for my website (XHTML)
tidy -m -i -w 0 -asxhtml -utf8 --add-xml-decl true --bare true --clean true --doctype strict --drop-empty-paras true --drop-proprietary-attributes true --enclose-block-text true --logical-emphasis true --quote-marks true --replace-color true --word-2000 true --preserve-entities yes --tab-size 3 test.html
for a file on my website (HTML5)
tidy -m -i -w 0 -utf8 --bare true --clean true --drop-empty-paras true --drop-proprietary-attributes true --enclose-block-text true --logical-emphasis true --quote-marks true --replace-color true --word-2000 true --preserve-entities yes --tab-size 3 test.html
to clean up Thunderbird's HTML
tidy -m -i -w 0 -utf8 --doctype omit --drop-empty-paras true --enclose-block-text true --replace-color true --word-2000 true --preserve-entities yes --tab-size 3 temp.html
pdftk CriticalLegalHistories-1.pdf cat 1-endE output CriticalLegalHistories-rotated.pdf
(to rotate counterclockwise instead, change cat 1-endE
to cat 1-endW
; to rotate 180 degrees, it should be cat 1-endS
.)
pdftk 01.pdf 02.pdf 03.pdf 04.pdf 05.pdf 06.pdf 07.pdf 08.pdf 09.pdf 10.pdf cat output Richard.pdf
pdftk "Selections From Early American Writers.pdf" cat 5-7 182-193 output wigglesworth.pdf
pdftk cummings\ backwards.pdf cat end-1 output "cummings.pdf"
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.3 -dNOPAUSE -dQUIET -dBATCH -sOutputFile=output.pdf input.pdf
OR
pdf2ps file.pdf - | ps2pdf13 - file2.pdf
pdftohtml -s -noframes -enc UTF-8 -hidden -nomerge "Student Name.pdf" "student-name.html"
.eml
files in a directorymunpack *eml
ebook-convert
gutcheck
(program must be downloaded from SourceForge)
man
page as pdfman -t awk | ps2pdf - awk.pdf
find /~patrick -iname "*html" -type f -print0 | xargs -0 /usr/bin/bluefish
grep -ilR --null "<link" "/home/patrick/Documents/current websites/NearlyFreeSpeech.net" | xargs -0 $(which bluefish)
find . -iname "*html" -print | xargs grep -iL favicon.ico | xargs $(which bluefish)
grep -R -Z -l "profile/hcard" . | xargs -0 grep -Z -L vcard | xargs -0 $(which bluefish) &
grep -R -B2 -A2 "hcite" /~patrickmooney/
(use the -l switch to just print a list of the matching files without spitting out matching lines within the file.) (use the -i switch for a case-insensitive search.)
cat "djibriel's walkthrough.txt" | sed 's/\B\w*//g;s/\s//g' > "1st letters.txt"
awk '!x[$0]++' 150.txt > 150-unique.txt
echo " test test test " | sed -e 's/^ *//g' -e 's/ *$//g'
cat titles.txt | awk '{print length,$0}' | sort -n | awk ' {$1="";print $0}' | cut -f2- -d' ' > sorted\ titles.txt
grep -v file2.txt file1.txt > file3.txt