Count Lines of Code of Git-Project

With this handy command you get the lines of code of your git project:

git ls-files | xargs wc -l

It presents you you the lines of code for every single file of your project as well as the total count.

Find and Delete Broken Symlinks on Linux and macOS

Symbolic links or symlinks are an essential file system feature of UNIX-based operating systems. These files are used for referencing another files or even directories.

Moving referenced files can cause symlinks to become broken. In case a symlink references a file by a relative path, moving the symlink can also break the link.

With the following command, broken symlinks can be found in a specified directory:

find -L [directory] -type l

This command deletes found broken symlinks immediately:

find -L [directory] -type l -delete

Determine an Application's Path in a UNIX Shell

Very often, due to start scripts of the used terminal or shell application, a great number of applications can be executed in every current directory just by typing the application’s name. In case one wants to know the path to such an application which is not lying in the current directory and is not part of the shell’s basic commands, these two commands help out:

type -p [application name]

which [application name]

Using rdesktop or freerdp to connect remotely to a Windows Machine

Microsoft offers its tool Remote Desktop freely for Windows and macOS. This handy tool allows to connect remotely to another Windows machine in the network. Remote Desktop does not need the installation of a software package on the remote machine, but only some remote login configuration.

For UNIX-based OSes like Linux, there are two alternative tools using the Remote Desktop protocol: rdesktop and freerdp. To connect to a configured Windows machine, you have to use one of the following commands depanding on the tool you use:

rdesktop [remote_windows_machine] -g [resolution e.g. 1920x1170] -u [username]

xfreerdp [remote_windows_machine] -g [resolution e.g. 1920x1170] -u [username]

Essential yum Commands

Some of the most popular Linux distributions use the RPM Package Manager. For those systems, yum is an essential tool working as an layer above RPM, allowing package and dependency management as well as automatic updates.

These are the most important commands for yum:

  1. Update all packages: yum update or yum upgrade (like update, but removes packages which are not part of the distribution anymore)

  2. Install package/group/environment: yum install [package] (groups start with an @, environments with an ^@)

  3. Remove package/group/environment: yum remove [package] (groups start with an @, environments with an ^@)

  4. Clean yum cache: yum clean all

  5. List all repositories: yum repolist all

  6. Disable/enable a repository: yum-config-manager --disable [repository] or yum-config-manager --enable [repository]