Frequently Asked Questions

Change the Default Shell on Fedora to Zsh



usermod -s $(which zsh) $USER

Or add the line below to your ~/.bash_profile or ~/.bashrc. If you have a .bashrc add it to that one; the .bashrc is for user specific aliases and functions.

export SHELL=$(which zsh)

Or use chsh.

chsh -s $(which zsh)

Instal the Grml Zsh Configuration


Just retrieve and install the configuration files in your home directory via executing for example:

# IMPORTANT: please note that you might override an existing
# configuration file in the current working directory! =>
wget -O .zshrc

# Optionally also grab the user configration:
wget -O .zshrc.local

Determine the total size of a directory from the command line


The command du “summarizes disk usage of each FILE, recursively for directories,” e.g.,:

du -hs

This finds the size recursively and puts it next to each folder name, along with total size at the bottom, all in the human format:

du -hsc *

Also from:

To get the size of a directory on the command line, du -sh is a good place to start. The options are (from man du):

du -sh
-s, --summarize
        display only a total for each argument

-h, --human-readable
        print sizes in human readable format (e.g., 1K 234M 2G)

To check more than one directory and see the total, use:

du -sch
-c, --total
        produce a grand total

Use the “find” Command Recursively


find . -name "foo*"

Piping find into grep is often more convenient; it gives you the full power of regular expressions for arbitrary wildcard matching.

For example, to find all files with case insensitive string “foo” in the filename:

find . -print | grep -i foo

How to Use the “grep” Command to Find Text Including Subdirectories


grep -rl "string" /path


-r (or --recursive) option is used to traverse also all sub-directories of /path, whereas
-l (or --files-with-matches) option is used to only print filenames of matching files, and not the matching lines (this could also improve the speed, given that grep stop reading a file at first match with this option).

Shell Script to Find File Name from its Path


name=$(basename "$path" ".php")
echo "$name"