Linux Ask!

Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.

Exclude files when using the du to estimate disk usage

Answer:

It is easy to use du command to estimate disk usage, however, sometimes you want to ignore some files during the calculation.

To do so, try

# du -h --exclude='*.bak'

The above command will exclude all the file end with the extension .bak during the disk space calculation.

Post a file to a server using the Curl command

Answer:

You can simulate a HTTP form post, with a file being uploaded to a remote server using the curl command.

curl -F 'photo=@/upload/image.jpg' http://example.com/upload.php

Assume the name of the form element of your upload is called "photo"

Debug and verify Postfix configurations

Answer:

A simple way to debug and verify your Postfix configurations is the use the sendmail command with the -bv flag.

Example:

# sendmail -bv username@example.com

No email will be sent using the above command, it just report after verifying each recipient address. This is very useful for testing the Postfix configurations.

Create a transparent image using ImageMagick

Answer:

You can use the following command to create an empty png file, using the ImageMagick.

# convert -size 100x100 xc:none empty.png

an empty png of size 100x100 will be created.

Edit a remote file with vim over SSH

Answer:

If you have a remote file and you can have a quick edit, if you use the following command:

# ssh -t john@remote-server vim /data/test.txt

You will be prompted to login if you don't have proper ssh key in the remote server, and after finishing editing the file, you will quit the ssh session automatically.