Some Handy Linux Commands
October 30th, 2007Here 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
Categories
Popular Posts
RSS Feeds
Archives
November 23rd, 2007 at 5:48 am
In the 'find' command above, filenames are surrounded by a backtick (`) and a single quote ('). I think they should both be single quotes, e.g.: '{}'.
November 23rd, 2007 at 5:51 am
Ah! Not that I see my comment waiting moderation, I see that the website software fiddled with the post and replaced my leading single quote with a backtick. That's very inconvenient for someone trying to be precise.
February 12th, 2008 at 8:26 pm
how do i download linux?
May 1st, 2008 at 2:34 am
[...] [via Micah Carrick] [...]