Category Archives: Linux

Linux settings, tips and tricks, encountered problems, distros, …

Remote backup using rsync

To backup files on a remote server with sudo priviledges (on the server) first add the following into the /etc/sudoers file:

ALL= NOPASSWD:/usr/bin/rsync

Then backup the files from the local machine using:

rsync -atz -e "ssh" --rsync-path="sudo rsync" ./local_directory user@server:/path_to_backup

Exporting matlab animations (mpeg, gif)

To create a movie file from a matlab animated figure do the following:

frames(1:nFrames) = struct('cdata', [], 'colormap', []);
for i=1:nFrames
  % Do your plotting

To convert the movie file into a gif use:

convert -crop 0x0 -loop 0 my_movie.avi my_movie.gif

Silent make by removing echo

To remove default output of make command start each line of the Makefile that you wish to ‘silence’ with ‘@’:

@rm -f *.o

This can cause problems when the compiler generates an error. In that case you need to catch the error and terminate the make process. You should also generate a message saying which command caused the problem since this command won’t be printed on the screen (The error message will show up though). Use following code to do just that:

    @echo "Compiling helloworld.cpp";
    @gcc helloworld.cpp $(CFLAGS) -o helloworld \
    || (echo "Error in command: gcc helloworld.cpp $(CFLAGS) -o helloworld" && false)

ieee1394 (firewire) permissions on Linux

To to give certain group read/write access to firewire devices create new udev “*.rule” file in /etc/udev/rules.d/10.my_ieee1394.rule with following content:

KERNEL=="raw1394", NAME="%k", GROUP="video", MODE="0664"
KERNEL=="dv1394*", NAME="dv1394/%n", GROUP="video", MODE="0664"
KERNEL=="video1394*", NAME="video1394/%n", GROUP="video", MODE="0664"

“undefined reference to” error

One of possible causes of this error is incorrect linking order of libraries using gcc/g++.

Linking libraries before object files causes the error:

g++ -o $(LIBS) $(PROGRAM) $(OBJS)

Linking libraries after object files solves the problem:

g++ -o $(PROGRAM) $(OBJS) $(LIBS)

This is a solution for static library linking. Shared libraries should link both ways. Also order of respective libraries is important. If library A uses library B, library B has to linked first (-lB -lA).