Skip to content
All Posts

Linux Command-Line Tips

A short Linux shell reference for locating commands, reloading Bash configuration, and writing here-documents.

Learning about a command

Using ping as an example:

Terminal window
which ping
whatis ping
whereis ping
man ping
type ping

type ping displays:

ping is /sbin/ping

type source displays:

source is a shell builtin

Reloading a Bash profile

Reload a profile file without signing out and back into the terminal:

Terminal window
source /etc/profile

The source command runs a file’s contents as input to the current shell. A single dot, ., is an equivalent command.

For example, after moving phantomjs into /usr/local/bin, pressing Tab may still fail to complete the command. Completion becomes available after running source.

cat <<EOF versus cat <<-EOF

A common use is to write input to a file, as in this Scrapy example:

Terminal window
cat > myspider.py <<EOF

This is a convenient way to add lines to a new file. Both forms read standard input until the EOF marker. The -EOF form strips leading tabs from each line—tabs only, not spaces.

The original image has been removed from the source site: original image URL


Originally published on SegmentFault.