Beginner command-line tool examples
These examples introduce a few useful command-line tools with simple commands you can try or adapt.
curl
Use curl to fetch information from a URL and print it in the terminal.
$ curl https://cheat.sh/tar
Save the downloaded content to a file:
$ curl https://raw.githubusercontent.com/ubc-library-rc/advanced-shell/main/README.md -o README.md
wget
Use wget to download a file from the web.
$ wget https://github.com/ubc-library-rc/advanced-shell/archive/refs/heads/main.zip
Choose the name of the saved file:
$ wget https://github.com/ubc-library-rc/advanced-shell/archive/refs/heads/main.zip -O advanced-shell.zip
$ mc ~/Downloads
pdftk
Use pdftk to split, merge, and rotate PDF files from the terminal.
Combine two PDF files into one file:
$ pdftk first.pdf second.pdf cat output combined.pdf
Extract a few pages from a PDF:
$ pdftk original.pdf cat 1-3 output first-pages.pdf
Rotate all pages clockwise:
$ pdftk original.pdf cat 1-endright output rotated.pdf
mplayer
Use mplayer to play audio or video files from the terminal.
$ mplayer song.mp3
Play a video file:
$ mplayer video.mp4
ffmpeg
Use ffmpeg to convert, trim, or extract information from audio and video files.
Convert a video file from one format to another:
$ ffmpeg -i input.mov output.mp4
Extract the audio from a video:
$ ffmpeg -i video.mp4 audio.mp3
Create a short clip from a longer video:
$ ffmpeg -i video.mp4 -ss 00:00:10 -t 00:00:05 clip.mp4
imagemagick
Use ImageMagick to inspect, resize, and convert image files. On many systems, the command is magick.
Resize an image:
$ magick input.jpg -resize 800x600 output.jpg
Convert an image from one format to another:
$ magick input.png output.jpg
Create a thumbnail:
$ magick input.jpg -thumbnail 200x200 thumbnail.jpg
If your system uses the older ImageMagick command style, replace magick with convert:
$ convert input.png output.jpg
Loading last updated date...