Linux Shell
This page is a brief collection of Linux shell commands I’ve worked out over time. Most of them are simplifying frequently occurring tasks. The advanced shell geeks among you will find most of them obvious. But this page keeps me from re-elaborating these things over and over again…
Image Processing
find . -iname "*.jpg" | xargs -l -i convert -resize 1024x1024 -quality 85 {} ./output/{}
Resizes all JPEG images in the current directory to the given size and using the given image quality. ImageMagick preserves aspect ratio and the output images are stored in the subdirectory ‘output’.
Document Handling
gs -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE=out.pdf -dBATCH in1.pdf in2.pdf in3.pdf
GhostScript strings together an arbitrary number of PDF documents in the given order.
System
mount myiso.iso /media/iso/ -t iso9660 -o ro,loop=/dev/loop0
Mount an ISO disc image to a given mount point.
find . -name '*.txt' | while read L; do foo "$L"; done
Executes a command foo for every file in the current directory matching the file name pattern.
Bash Prompt
export PS1='\[\e[0;33m\]\u\[\e[0;39m\]@\[\e[0;32m\]\h\[\e[0;39m\][\[\e[0;37m\]\w\[\e[0;39m\]]\n\$ '
Under bash, you can set your prompt by changing the value of the
PS1environment variable. For system wide permanent usage put this into/etc/bashrc.
Tiny stuff (just can’t keep this **** in mind!)
rpm -qa : List of all installed packages (Fedora)
tar xvzf file.tar.gz : Decompress and extract a .tar.gz
lspci : Hardware info
uname -r : Kernel in use (all: uname -a)
yum whatprovides "*filename*" : Search repos for file names