Ubuntu/Debian/Mint news and tutorials | Linux stuff
Quick Tip
Find Files Containing a Text Pattern
find . -iname "*.txt" -exec grep -l "hello" {} +
Quick Tip
Create a Bootable USB from an ISO Image
sudo dd if=/path/to/image.iso of=/dev/sdX bs=4096k
Replace /dev/sdX with your USB device, for example, /dev/sdb.
Quick Tip
Disable Overlay Scrollbars in GNOME
gsettings set com.canonical.desktop.interface scrollbar-mode normal
Changes should occur instantly. The overlay scrollbars should now be replaced with normal scrollbars. This method works for Ubuntu 12.10 and above.
Linux Cheat Sheet
Have a look at our Linux Cheat Sheet for quick one-liners, commands and tips.
Take a screenshot in command-line

Taking a screenshot in command-line is very easy using the import tool, which is included in the ImageMagick suite. To take a screenshot of a single window use:

To take a screenshot of a single window and include window decorations, use:

To take a screenshot of the entire screen or a region, type:

And then select with the mouse the region which you want to save.

Mount an ISO image

To mount an ISO image, we’ll first create a mount point (an empty directory) and then we will use the mount command:

Kill processes with ‘pidof’

pidof is a command which will return the PID of the process specified as argument. To kill an application we would use:

For example:

The first one kills Amarok, while the second one kills Firefox.

Convert NRG images to ISO

For this one we will use a tool called nrg2iso:

Count lines, words and characters in a text file

wc is a command-line tool which returns the number of lines, words or characters in a file, depending on which parameter we specify at the command-line. To count the number of lines:

To count the number of words:

And to count the total number of characters:

Resize images from command-line

For this one we’ll need conver, a tool which comes included with ImageMagick. convert allows to convert between various image formats, and apply tons of effects to images. Here’s an example on resizing an image:

Which will resize an image to 30% keeping its aspect ratio.

Convert MKV to AVI with mencoder

This is a way of converting Matroska Video files to AVI with mencoder:

Create ISO images from command-line with genisoimage

We will use genisoimage for this one. Here’s how to create an ISO 9660 image from a directory, keeping that directory as root:

And to create an image from several files, without including a root directory:

Close a port

First, to see what ports are opened on your system use nmap:

This will output a list of open ports and the protocol currently using them. To close any of them, use the following syntax as root:

Which will close port 80, the default port used by the web server.

Split FLAC/WAV/APE with CUE file

For this one we will need the packages cuetools and shntool, which include the tools needed to split a big FLAC or WAV when a CUE file is available. Here’s the command:

The same goes for WAV, just replace the .flac extension.

For APE files, we will first need to convert them to WAV using the mac tool, which comes in monkeys-audio package:

And then split the WAV file just like it was showed above.

Format C code using indent

indent is a tool which allows to format and change the appearance of C code by inserting/deleting whitespace characters to make the code clearer and easier to read. Some of the coding styles it supports are GNU indent style (the default, also invoked with -gnu), Kernighan & Ritchie style (invoked with -kr) or Berkeley style (invoked with -orig). The example is as follows:

Which will format source_file.c using the Kernighan & Ritchie style.

Don’t exit the shell when pressing Ctrl+D

By default in Bash Ctrl+D will exit the current shell (unless used in a running application to mark end of file). To prevent this you can add the following line in ~/.bashrc:

And then source the file to read it again:

Get rid of the system beep

To temporarily disable the PC speaker you can remove its module from the kernel using the following command as root:

To permanently disable it, you can blacklist this module so it doesn’t load when the system starts. To do so, edit the /etc/modprobe.d/blacklist file as root and add the following line in it:

Extract audio only from DVD VOB files

For this we will use mplayer like this:

You can eventually concatenate VOB files first, e.g.:

And then proceed and use the mplayer on the newly create output_file.vob.

Use lm-sensors to monitor CPU temperature

For this we will need the lm-sensors package. After installing it, you will have to load several kernel modules for temperature detection (this is done automatically and you only have to agree or disagree loading the specified module). To run it, just type sensors in a terminal:

Convert video formats to Ogg Theora using ffmpeg2theora

ffmpeg2theora is a frontend to ffmpeg which will allow us to convert various video files to the open format Theora video. Here’s an example:

This will convert input_file.avi to Theora video using a video quality factor of 6 and an audio bitrate of 192 kbps. Here’s another example, which will use the default settings:

Or this one, which also adds meta tags to the video:

Convert OGV to FLV

We’ll use the ffmpeg audio and video encoder for this one:

To shrink the size of the resulting video use something like this:

To use a specific audio codec for audio output use the -acodec switch:

Create aliases

Aliases are a way of assigning a shorter, custom command to another single or a set of commands (or a one-liner and so on). To create aliases we can edit the ~/.bashrc file and add aliases like this:

The first one will define a new custom alias, called killfx, which will kill Firefox when used. The second one will go back to the previous working directory, while the third one will make the ls to be aliased to ls -lhXa, which shows hidden files, detailed information, human readable sizes and sorts the files according to their type.

Convert BIN/NRG/MDF images to ISO

For this one we will use the iat utility:

iat can supports many image formats, including ISO, NRG, BIN and MDF.

Rip FLAC/WAV to Ogg Vorbis or MP3

For converting FLAC or WAV to Vorbis or MP3 we’ll need the vorbis-tools and lame packages. To convert from FLAC/WAV to Ogg Vorbis:

Which will convert input_file.flac to Ogg Vorbis using a bitrate of 256 kbps. To convert FLAC to MP3 you will first need to convert it to WAV using flac -d input_file.flac and then convert the obtained WAV to MP3 using:

Which will use a bitrate of 192 kbps.

Have some more one-liners or tips? Please share them with us in the comments below!

Share this articleShare on RedditShare on StumbleUponShare on FacebookTweet about this on TwitterShare on TumblrShare on Google+
Rick Stanley says:


Instead of
“convert -sample 30%x30% input_image.png output_image.png”
convert -resize 30% input_image.png output_image.png”
to “Resize” an image! Aspect ratio will be preserved.


In addition to listing samples of aliases, also show the use of “alias” by itself to show what aliases are already defined!

Sandeep says:

Thank you!!

Dutchkind says:

When I use nmap localhost on my opensuse system, it shows some ports open, but they are only open from the inside because they are used by the system. When I do a scan from another computer to this computer using the ip address instead of localhost it confirms that there are no open ports. So I think you can not see which ports are open or closed when scanning from that same system.

Rohit Vaidya says:


Leave a Comment

Ballkleider - Ballkleider
Online Readers
Advertise on TuxArena