Shell snippets
A bit of magic for the shell.
Published: Mar 19, 2025
Updated: Jun 20, 2025

Normalize file/directory permissions

Directories need execute (x) permissions to change (cd) into.

1find -type f -exec chmod a+r {} \;
2find -type d -exec chmod a+xr {} \;

MIME types

Check MIME type of a file

1file -b --mime <file>

Alternatively, with the xdg-utils package.

1xdg-mime query filetype <file>

Be aware that it will first try to recognize the MIME type by file extension. If it fails, it will look at the content of the file.

NetworkManager

Get active connection

nmcli -g type,name connection show --active


← Go to parent
Category:  Linux UNIX systems Code snippets
Tags:  Bash Shell