It’s been a while, but in the oh so distant past I stumbled upon the following error on my then fairly new Debian Wheezy system:

bash: ldconfig: command not found

You might encounter this error or something very similar, especially when you are using sudo instead of changing to root with su (see my article on how to enable sudo).

 

Problem

The problem is that programs like ldconfig are located in the  /sbin folder, but this folder is not added to the PATH variable.

If you don’t know what PATH is:

The path variable is essentially a list of folders. When you type a command in bash (the terminal/command line) like this:

ldconfig

then bash will go through all the folders listed in the PATH variable and see if a program with that name is in that folder. If it finds that program, it will execute it.

The problem here is that PATH (the list of directories where bash will look for the program) does not contain the folder /sbin. But because the program is in this folder and bash does not look there, bash will not find the program and instead annoy you with an error.

 

Solution

The solution is to add  “/sbin” to the PATH variable. This can be done by editing the file “/etc/profile”.

Type

sudo nano /etc/profile

or – if you are more comfortable with a GUI based text editor – you can also type

sudo gedit /etc/profile

 

At the beginning of the file, you will see the following:

if [ "`id -u`" -eq 0 ]; then
  PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
else
  PATH="/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games"
fi

This sets the PATH variable for the root user and every other user. The first line that starts with “PATH=…” sets the PATH for the root user and the second line sets PATH for everybody else. So the code fragment basically translates to:

if user=root then
  PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
otherwise
  PATH="/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games"

The second line is what we have to care right now. The directories in the list are separated by a colon, so the list contains the following directories:

  • /usr/local/bin
  • /usr/bin
  • /bin
  • /usr/local/games
  • /usr/games

We want to add a few directories to that, namely:

  • /usr/local/sbin
  • /usr/sbin
  • /sbin

For ldconfig and a lot of other programs, adding “/sbin” would be enough, but I added the others as well, because I thought: “I don’t wanna come back two more times, just because I might realize later that I should have added them as well in the first place”

You could add the directories anywhere in the list, but I like to add them in the same order they appear in the PATH variable for the root user, so I will change the beginning of the file to this (remember to separate the directories with a colon):

if user=root then
  PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
otherwise
  PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games"
fi

Save the file; when using nano, just

  • hit “Ctrl+X” to quit
  • then “Y” to confirm that you want to save the modified version
  • then hit the enter key to confirm the filename

And finally: Log out and log back in.

 

Introduction

What Aliases Are

Here is a short introduction to aliases in case you have not idea what they are:

An alias is simply a different name for a specific command line command. You can call an alias like any other program and the shell will then replace the alias with the command it represents.

If you find yourself typing”aptitude” a lot you could, for example, define an alias “a” for this command instead. Now, instead of typing

aptitude install <package>

you just need to type

a install <package>

Bash will recognize that the command a is really just an alias that stands for “aptitude” and therefore replace a with “aptitude”. You could make your like even easier by assigning an alias “ai” to the command “aptitude install”. Then, when typing

ai <package>

bash will notice that the command “ai” is really just an alias for “aptitude install” and replace “ai” accordingly. Therefore, the command that bash will execute is:

aptitude install <package>

Continue reading »

 

Gnome3 has the annoying habbit of turning off the monitor after a while, even if you are watching a video. Unfortunately, if you go to

System Settings > Screen
 

you will be surprised that if offers you the possibility to change the time the system has to be idle for the monitor to be turned off from 1 minute to 1 hour. But what is missing is an option to turn this function off entirely.

Fortunately, it is possible to do that, just not in System Settings and you can either do that from command line or with a GUI.

Continue reading »

 

Problem

When using a virtual machine in VirtualBox you might want to switch to a different console by hitting

Ctrl+Alt+F<n>
 

where <n> stands for the number of the console you want to access (like Ctrl+Alt+F1 to get a text console and Ctrl+Alt+F7 to get back to your X session).

Unfortunately, key combinations with Ctrl+Alt like the mentioned Ctrl+Alt+F<n> or Ctrl+Alt+Del will not be sent to the guest operating system. Continue reading »

 

 

There are several ways one can batch rename files in Linux. One of the possibilities is the linux command rename.

Usage

To rename files you have to supply a Perl expression. Using Perl expressions might be scary for beginners (because they look like someone hit his head on the keyboard), but they allow for complex renaming with a minimum of characters.

Although I won’t go into detail about Perl expressions here, I will try to make it a little easier for beginners to use them for batch renaming.

According to the man page of rename, this is the way to use rename:

rename [ -v ] [ -n ] [ -f ] perlexpr [ files ]

If you have not worked with Perl expressions before, this might not be enough to get you started. So let me present you with the way one would probably use rename most of the time:

rename 's/OLD/NEW/' FILES

OLD is an expressions which describes a pattern in the name filenames. If rename can find this pattern in the name of a file, it will replace this part of the filename with what is defined as NEW. The files rename should rename are defined by FILES.

Let me provide you with two examples: Continue reading »

 

The Linux command mkdir (make directory/make directories) can be used to create new directories.

Basic Usage

Creating directories in the current working directory

The most basic usage of mkdir is the following:

mkdir <name>

This will create a new directory with the given name in the current directory. Therefore, if your username is “me” and in the terminal you are using you are currently in your home folder (/home/me) then running the command

mkdir backup

will create a the directory /home/me/backup.

Continue reading »

 

If you ever wanted to create screenshots of a virtual machine (for a tutorial, a presentation, a forum post or any other reason), you probably already noticed that the VirtualBox GUI does not offer a screenshot function.

Continue reading »

 

 (Download the script from this article flac2mp3.sh)

When converting FLAC files to MP3, the first problem you will notice is that lame does not support FLAC files. This might now seem like big problem, because you can easily decode FLAC files using the command line tool flac and then use the decoded file with lame.

The Problem

The real problem is that you will loose your metadata in this process, so the tags you added to your FLAC won’t be copied to the MP3 file. While you could “easily” add them by hand, it is pretty annoying to do that even if you only want to convert a handful of files.

Continue reading »

 

Introduction

One of the possibilities of taking screenshots in Linux is using

xwd

, a utility of the X Window System.

I just want to give a short overview on how to take interactive and non-interactive screenshots, view them and convert them to different formats. Continue reading »

 

(Download the script here: reflac.sh)

Problem

When using oggenc to convert a FLAC file to OGG Vorbis using oggenc, you might encounter the following error:

"ERROR: Input file <file> is not a supported format"

Explanation

One possible reason for this can be an ID3 tag in the flac file. This can happen if the program you used to create your FLAC files uses ID3 tags instead of native FLAC tags to store metadata.

Continue reading »