Previous: ErrorDocument in .htaccess Returns 302 Response
Next: Resize Your NTFS Partition Using GParted LiveCD

Some Handy Linux Commands

October 30th, 2007

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



Categories
Linux Web Development

Related Posts


Technorati Tags

5 Responses to “Some Handy Linux Commands”

RSS Subscription Comments RSS Feed

  1. Ken Jackson Says:

    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.: '{}'.

  2. Ken Jackson Says:

    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.

  3. rtoot3 Says:

    how do i download linux?

  4. 小技巧: 实用的一行 Linux 命令 | LinuxDig Says:

    [...] [via Micah Carrick] [...]

  5. Elizabeth Says:

    Your posts are the best! Always helpful!

Leave a Reply