Frequently Asked Questions

Change the Default Shell on Fedora to Zsh

From: http://forums.fedoraforum.org/showthread.php?t=412

Run:

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

From: https://grml.org/zsh/

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 http://git.grml.org/f/grml-etc-core/etc/zsh/zshrc

# Optionally also grab the user configration:
wget -O .zshrc.local  http://git.grml.org/f/grml-etc-core/etc/skel/.zshrc

Determine the total size of a directory from the command line

From: http://askubuntu.com/questions/1224/how-do-i-determine-the-total-size-of-a-directory-folder-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: http://unix.stackexchange.com/questions/185764/how-do-i-get-the-size-of-a-directory-on-the-command-line

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

From: http://stackoverflow.com/questions/5905054/how-can-i-recursively-find-all-files-in-current-and-subfolders-based-on-wildcard

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

From: http://askubuntu.com/questions/55325/how-to-use-grep-command-to-find-text-including-subdirectories

grep -rl "string" /path

where:

-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

From: http://stackoverflow.com/questions/4645472/shell-script-to-find-file-name-from-its-path

path="/var/www/html/test.php"
name=$(basename "$path" ".php")
echo "$name"