In-Depth Guide to ServBay’s Third-Party Command-Line Tools
ServBay is a robust local web development environment that not only comes bundled with essential web servers, databases, and language runtimes, but also features a suite of third-party command-line tools invaluable for daily development tasks. These tools cover key areas such as image processing, networking, file compression and decompression, data encryption, security, and more.
This article provides a detailed introduction to the command-line tools integrated within the ServBay environment, explaining their functions, and supplying basic usage examples to help developers make the most of ServBay’s convenient offerings.
Why Does ServBay Include These Tools?
During the web development process, developers often need to complete various auxiliary tasks beyond writing code, such as:
- Optimizing or processing image assets
- Testing API endpoints or debugging network requests
- Managing or handling compressed files
- Generating or managing SSL certificates and keys
ServBay integrates these frequently-used command-line tools directly into its environment, so you don’t need to install or configure them separately. They’re available right out of the box in any ServBay terminal session, dramatically improving workflow efficiency and convenience.
Prerequisites
Before using the following command-line tools, make sure:
- ServBay is properly installed and running on your macOS system.
- You are operating within ServBay’s terminal, or you have configured your system terminal with ServBay’s environment variables, so you can call these tools directly.
Image Processing Utilities
ServBay includes several command-line tools for image processing, which are highly practical for frontend developers and backend engineers dealing with media assets.
ImageMagick
ImageMagick is a comprehensive suite of command-line tools and libraries supporting over 200 image file formats. It allows you to create, edit, compose, or convert bitmap images.
Basic Usage
Convert image format:
bashmagick convert input.jpg output.png
1Resize an image:
bashmagick convert input.jpg -resize 300x300 output.jpg
1Add a watermark:
bashmagick convert input.jpg -gravity southeast -draw "text 10,10 'ServBay'" output.jpg
1
cwebp
cwebp is a command-line encoder developed by Google to convert images into the WebP format. WebP is a modern image format that generally provides better lossless and lossy compression than JPEG or PNG, helping improve website loading speed.
Basic Usage
Convert a JPEG image to WebP format:
bashcwebp input.jpg -o output.webp
1Convert a PNG image to WebP format:
bashcwebp input.png -o output.webp
1Set compression quality (e.g., quality factor 80):
bashcwebp -q 80 input.jpg -o output.webp
1
jpegtran
jpegtran is a lossless JPEG conversion utility that allows rotation, flipping, and transposition without decompressing and recompressing the image, thereby avoiding additional compression artifacts.
Basic Usage
Rotate a JPEG image 90 degrees clockwise:
bashjpegtran -rotate 90 input.jpg > output.jpg
1Horizontally flip a JPEG image:
bashjpegtran -flip horizontal input.jpg > output.jpg
1
djpeg
djpeg is a tool for decompressing JPEG files into more basic pixel formats (such as PPM, PGM, BMP, or Targa). This is useful when you need access to raw pixel data from JPEG images.
Basic Usage
- Decompress a JPEG file into PPM format:bash
djpeg input.jpg > output.ppm
1
cjpeg
cjpeg performs the inverse operation of djpeg, allowing you to compress PPM, PGM, BMP, or Targa image files into the JPEG format.
Basic Usage
- Compress a PPM file into JPEG format:bash
cjpeg input.ppm > output.jpg
1
img2webp
img2webp is a tool for combining a series of static images (such as PNG or JPEG files) into a single animated WebP file.
Basic Usage
- Merge multiple images into an animated WebP:bash(Ensure that
img2webp -o output.webp frame1.png frame2.png frame3.png
1frame*.png
are sequential image frames.)
Networking Utilities
cURL
cURL is a widely-used command-line tool and library for transferring data via various network protocols. It’s indispensable for testing APIs, downloading files, and interacting with remote servers. ServBay comes with cURL pre-installed, making network debugging and data transfer straightforward for developers.
Basic Usage
Send an HTTP GET request to a sample API:
bashcurl -X GET https://api.servbay.demo/data
1Send an HTTP POST request with data payload:
bashcurl -X POST -d "param1=value1¶m2=value2" https://api.servbay.demo/data
1Download a file and save with the original filename:
bashcurl -O https://servbay.demo/file.zip
1Show request and response headers:
bashcurl -I https://servbay.demo
1
Compression and Decompression Utilities
ServBay bundles common tools for compressing and decompressing files, making it easy to handle a variety of file formats.
bzip2
bzip2 is a high-efficiency compression tool that uses the Burrows-Wheeler transform and Huffman coding. It usually produces smaller files than gzip, though compression and decompression may be a bit slower.
Basic Usage
Compress a file (the original file is replaced by a
.bz2
file):bashbzip2 input.txt
1Decompress a file (the
.bz2
file is replaced by the original):bashbunzip2 input.txt.bz2
1Decompress to standard output:
bashbzip2 -dc input.txt.bz2
1
gzip
gzip is a widely-used compression tool, especially common on Unix and Linux systems. It uses the Lempel-Ziv (LZ77) algorithm and provides fast compression and decompression speeds.
Basic Usage
Compress a file (the original file is replaced by a
.gz
file):bashgzip input.txt
1Decompress a file (the
.gz
file is replaced by the original):bashgunzip input.txt.gz
1Decompress to standard output:
bashgzip -dc input.txt.gz
1
xz
xz is a high-efficiency compression tool based on the LZMA2 algorithm. It generally offers higher compression ratios than gzip and bzip2, though compression speed is relatively slower. Decompression is typically fast.
Basic Usage
Compress a file (the original file is replaced by a
.xz
file):bashxz input.txt
1Decompress a file (the
.xz
file is replaced by the original):bashunxz input.txt.xz
1Decompress to standard output:
bashxz -dc input.txt.xz
1
zstd
zstd (Zstandard) is a fast lossless compression algorithm developed by Facebook. It offers an excellent balance between speed and compression ratio, typically much faster than gzip while achieving similar or better compression.
Basic Usage
Compress a file (the original file is replaced by a
.zst
file):bashzstd input.txt
1Decompress a file (the
.zst
file is replaced by the original):bashunzstd input.txt.zst
1Decompress to standard output:
bashzstd -dc input.txt.zst
1
Encryption and Security Utilities
OpenSSL
OpenSSL is a powerful open-source toolkit implementing SSL (Secure Sockets Layer) and TLS (Transport Layer Security) protocols, and provides extensive cryptographic functionality. Within the ServBay environment, OpenSSL is essential for generating keys, creating certificate signing requests (CSRs), and managing SSL certificate files—particularly when testing HTTPS locally or working with ServBay’s SSL capabilities (such as the ServBay User CA or ACME support).
Basic Usage
Generate an RSA private key (2048-bit):
bashopenssl genpkey -algorithm RSA -out private_key.pem -pkeyopt rsa_keygen_bits:2048
1Derive the corresponding public key from a private key:
bashopenssl rsa -pubout -in private_key.pem -out public_key.pem
1Generate a certificate signing request (CSR):
bashopenssl req -new -key private_key.pem -out request.csr
1(After running this command, you’ll be prompted to input details like country, organization, and common name.)
Generate a self-signed certificate (for local testing):
bashopenssl req -x509 -days 365 -key private_key.pem -in request.csr -out certificate.crt
1(Note:
-in request.csr
assumes you’ve already generated a CSR. To generate a private key and a self-signed certificate in one step, there are more concise commands, but those are usually only suitable for simple testing purposes.)View certificate information:
bashopenssl x509 -in certificate.crt -text -noout
1
Notes
- The versions of these command-line tools may vary depending on the ServBay version you've installed.
- All tools are directly accessible from the operating system’s terminal session. If you can’t use them, please make sure ServBay’s environment variables (especially PATH) are correctly configured.
Summary
ServBay isn’t just a local web development environment—it comes packed with a range of handy third-party command-line tools, significantly expanding its functionality. These utilities help developers efficiently handle image processing, network debugging, file management, and security-related tasks. Becoming familiar with and making good use of these built-in tools will further elevate your development workflow and productivity.