Archive for the ‘linux’ Category

TAR command

Thursday, March 11th, 2010 by dreamluverz

create:
tar -cvf mystuff.tar mystuff/
tar -czvf mystuff.tgz mystuff/
extracting:
tar -xvf mystuff.tar
tar -xzvf mystuff.tgz
testing/viewing:
tar -tvf mystuff.tar
tar -tzvf mystuff.tgz





Note that .tgz is the same thing as .tar.gz
Tar “tars up” a bunch of files into one “tar-file”
gzip is compression, but only works on one file, so the entire “tarfile” is compressed.

Also when creating a tar or cpio backup, never, never, never use an “absolute” path — you have been warned; also linux tar warns you of this too. The problem is that when you want to unpack, you cannot choose where to unpack to, you will be forced to unpack to the “same” absolute path. When creating a tar or cpio you should change the the appropriate directory and tar from there.

Also when creating a tar or cpio it is general good practice to tar up a directory (appropriately named) which contains your files, rather than just the files. This is good courtesy to anyone unpacking your tarfile.

If you would like to create a tar file while saving ownership and permissions, add the “p” flag.

Creating and saving ownership and permissions:
tar -cpvf mystuff.tar mystuff/
tar -cpzvf mystuff.tgz mystuff/

Also take note of the following commands:
gzip
gunzip
cat
zcat
bzcat
bzip2
bunzip2
zgrep
bzgrep

(cd /mydir && tar -czf – .)|(cd /destdir && tar -xzvf -)
tar -czf – . | ssh user@dest “(cd /destdir && tar -xzvf -)”
(cd /mydir && tar -czf – .) | ssh user@dest “(cd /destdir && tar -xzvf -)”

Errors:
If you receive an error such as the following:

[root@localhost test]# ssh user@dest "(cd /rh62/home/kernel && tar -czvf - linux-2.2.22.tar.bz2)"|tar -xzvf -
user@dest's password:
linux-2.2.22.tar.bz2
linux-2.2.22.tar.bz2

gzip: stdin: decompression OK, trailing garbage ignored
tar: Child returned status 2
tar: Error exit delayed from previous errors
[root@localhost test]#

Then try leaving off the compression as follows:

[root@localhost test]# ssh user@dest "(cd /rh62/home/kernel && tar -cvf - linux-2.2.22.tar.bz2)"|tar -xvf -
user@dest's password:
linux-2.2.22.tar.bz2
linux-2.2.22.tar.bz2
[root@localhost test]# echo $?
0
[root@localhost test]#

Spaces in your filenames?
Having fun with spaces in the filename or directory name? Here’s your answer:

find . -type f -name '*jpg' | grep " " | while read REPLY; do
     tar -cf - "$REPLY" | (cd /tmp/jpg && tar -xvf -)
done

Bonus:

find . -type f | while read REPLY; do
     cp -a "$REPLY" /tmp/jpg/`echo $REPLY \
       | sed -e 's/ //g' -e 's/\///g' -e 's/^\._//'`
done

ssh root@dest 'tar -C / -czf - --exclude ./proc/* --exclude ./dev/pts/* .' > gmaster.tgz
proc and dev was empty for the following command, so I didn't exclude them:
tar -czf - . | ssh user@dest "cat - > k12ltsp.master.tgz"

source: http://roffle.us/blog/archives/13-Linux-TAR-Command.html

Error installing apache,php on windows vista

Thursday, March 26th, 2009 by dreamluverz

I’ve done this before, I’ve installed it several times but how come this time it’s not working with the same settings that needed to be changed… a moment of confusion, annoyance and craziness flashed on my eyes. I’ve exerted every bit of energy left in my body, wasted every precious moment of my time, tried and checked every possible way to no luck at all!!!

What have I done wrong was all I can say. I can’t make Apache 2.2 and PHP 5.2 run on my notebook. A moment of silence…then I realized that whatever changes I’ve made on the php test file was not being reflected on the browser. I then again checked the path on the config files but everything was correct.

Btw, I was using php editor to modify the config files for I have read on some forums that you won’t be able to edit it with notepad in windows vista environment but you can with any php editors. Realizing that, I viewed the files using windows explorer if the changes I’ve made was reflected. Behold it’s not!!! Then I remembered another thing  mentioned on that thread that it’s because of the UAC (User Account Control) setting which you can find in Control Panel => User Accounts. Then right away I  turned it OFF, restarted the computer and re-opened the config files for apache(httpd.conf) and php(php.ini), applied the settings, saved it and problem solved!!! What a nightmare!!!

So first and foremost before installing apache or php always check your operating system if you’re running on windows vista environment which has some user settings that will make you CRAZY!!! :P

You can check the installation guide of apache 2.2, php 5.2 and mysql 5 for windows here. Goodluck! :P





linux cheat sheet

Wednesday, May 14th, 2008 by dreamluverz

Click on the image below to view the linux cheat sheet

linux: change ownership and permission for file or directory via ssh

Thursday, February 7th, 2008 by dreamluverz

sources: http://webtools.live2support.com/linux/chown.php, http://www.tuxfiles.org/linuxhelp/fileowner.html

I’ve tried this 2 lines in order.

chown -R -v [username]  [directory/file]

chmod -R -v [permission]  [username]  [directory/file]

-R = recursively, including sub directories
-v = verbose, you will see it in action

Linux / Unix rmdir command

Wednesday, February 6th, 2008 by dreamluverz

About rmdirDeletes a directory.

Syntax

rmdir [OPTION]… DIRECTORY…

–ignore-fail-on-non-empty ignore each failure that is solely because a directory is non-empty.
-p, –parents Remove DIRECTORY and its ancestors. E.g., `rmdir -p a/b/c’ is similar to `rmdir a/b/c a/b a’.
-v, –verbose output a diagnostic for every directory processed.
–version output version information and exit.

Examples

rmdir mydir – removes the directory mydir

rm -r directory – would remove a directory, even if files existed in that directory.

source: http://www.computerhope.com/unix/urmdir.htmÂ