Some Handy Linux Commands

Here are some commands I use ALL THE TIME when working on a web server through SSH. I'll try to update it as I think of other stuff that comes in handy.

Create Tarball

This will create an archive of "folder_name" called "folder_name.tar.gz".
tar -czpf folder_name.tar.gz folder_name

Recursively Find a String Within Files

This will find all occurances of "something" within all HTML files. Prints the results in the terminal
find ./ -name '*.html' -exec grep "breadcrumbs.inc.php" '{}' \; -print

Search and Replace within a File

This will find a "b" and replace it with "strong" in the file index.html
sed -i 's/b/strong/g' index.html

Disk Space / Disk Usage

Shows the disk space available and disk space used on each device.
du -d 1 | sort -n -r

Directory Space Used

Shows the disk space used by each directory (in current directory). Linux:
du -h --max-depth=1 | sort -n -r
FreeBSD:
du -d 1 | sort -n -r
Did you enjoy Some Handy Linux Commands? If you would like to help support my work, A donation of a buck or two would be very much appreciated.
blog comments powered by Disqus
Linux Servers on the Cloud IN MINUTES