Sudo su vs sudo -i

If you ever wondered, sudo su and sudo -i are not exactly the same. sudo suCalls sudo with command su, i.e. Bash is called as interactive non-login shell. It executes only .bashrc and you remain in the same directory.sudo su -Logs in as super user, i.e. /etc/profile, .profile and ``.bashrc`are executed and you are logged in to root’s home directory with root’s environment.sudo -i-i = simulate initial login. The manpage for sudo says:
Read more →

Find All Directories

I needed to go through a directory structure and do a git-fetch if there was a .git repository inside. Finding all directories containing the .git is quite easy with find command. find $root-directory -regex '^.*/.git$' -printf '%h\n' | sort -d This is nice but it also prints unneccesary data. It does not only print the leaf directories but also all the partial paths to them. The original project structure is something like:
Read more →

Bash Autocomplete

MotivationI have inherited several Bash installation scripts for our software developed in CertiCon. What a user could do was to call the following command in the terminal and the application behaved as requested. $ myApp start|stop|restart The magic was hidden in the keyword complete in a file called autocomplete_app.sh. autocomplete_app.sh complete -o nospace -F _myApp_autocomplete myApp complete -o nospace -F _myApp_autocomplete /opt/myApp/compose.sh AutocompletionBash auto completion is quite a well-known feature from user point of view.
Read more →