Friday, March 21, 2008

Enabling or Disabling ROOT on Ubuntu o

Jika Ingin memperbolehkan ROOT maka berikan pasword root dengan cara (tidak disarankan) :


$sudo passwd root

sedangkan jika terlanjur dan anda sadar dan ingin memperbolehkan ROOT maka lakuka

$sudo passwd -l root

Saran:

untuk bekerja sebagi ROOT selama sesi maka gunakan saja

$sudo -i

Atau bisa juga

$sudo -s


Tuesday, March 18, 2008

Cara Ngeredirect Halaman website

How to automatically redirect a browser
to another web page from one of your own

diambil dari

http://35.9.68.172/services/computing/faq/auto-redirect.html.

________________________________________________________________________
Server-based redirect
This is the preferred method of redirecting to other web pages, and
additional information can be found at
http://www.w3.org/QA/Tips/reback.


As the P-A Department's main web server uses the Apache HTTP server
program, here is how to do it on that system (for other systems'
servers, see the references in the www.w3.org web page noted above).

Create a file in the directory in question called ".htaccess" and put
into it the line

Redirect /path-of-file-to-be-redirected URL-of-page-to-go-to

For example, if you are a professor teaching the (fictitious - for the
sake of the example only) PHY386 course during Spring Semester 2007, but
you want to keep your web pages in a subdirectory of your own user area
instead of in the courses area provided, you can go to the appropriate
courses area on the server, /web/documents/courses/2007spring/PHY386 and
put

Redirect /courses/2007spring/PHY386/index.html http://www.pa.msu.edu/people/username/subdir/index.htm


(all on one line, in case the above example is wrapped by your browser)
into a file called .htaccess which has world-read permissions (that's
the default).

The "path" argument is relative to the "web root", so in the above
example, "/web/documents" is left off. The "page to go to" URL is a full
URL, even if the web page is on the same server. More than one Redirect
command can be put into the .htaccess file, and you can redirect all
files in a directory to their equivalents in a "to go to" directory by
leaving the filenames off.

A case where more than one Redirect command may be necessary is when a
web page may be accessed via more than one URL. In the above "PHY 386"
example, in fact, the instructor will have to add a second line, the
same as the first, except for lower-case "phy386" instead of "PHY386" in
the "path" argument, because the web page may be accessed with the
"phy386" URL, too. During Spring Semester 2007, the page could also be
accessed with URLs with "current" in place of "2007spring" and with
"2007spring" left out entirely, bringing the number of Redirect commands
up to six for that one page. Fortunately, a URL which leaves off the
"index.html" filename defaults to assuming it, or else three more
Redirect commands would be needed to handle those cases. (The folks at
w3.org still consider this as preferable to a single "refresh" meta
command in the file itself, which would be read and acted upon
regardless of how the file was accessed, as described below.)

If there is already a .htaccess file in the subdirectory in question,
see the Apache HTTP server documentation to see where in it the Redirect
command should be placed. If you are the person running the Apache web
server program on a system, you can also put instances of the Redirect
command into the server configuration file instead of, or in addition
to, .htaccess files in specific subdirectories (again, see the Apache
HTTP server documentation for the details).


________________________________________________________________________
"refresh" meta command
Note that this method is deprecated by the official HTML standards
organization in favor of the server-based redirect method described
above.

You can set up a web page to inform any browser which happens to load it
that there is another web page it should go to instead, after an
optional delay.

This is accomplished using a "refresh" meta command in the header
section

<head>
.
.
</head>

of your HTML file, along with the title and any "keywords" or other meta
commands.
Syntax
The syntax for the "refresh" meta command is

<meta http-equiv="refresh" content="N; URL=other-web-address">

where N is the approximate number of seconds that you want the current
web page to be displayed before the browser automatically goes to the
other web address. If N = 0, then the browser should go immediately to
the other web address.
Netiquette tip
In case someone's browser doesn't handle these automatic redirects (most
browsers do handle them, but some allow them to be turned off, as a way
of discouraging "web spam", which often uses this type of "refresh"
redirect), you may want to provide a second route to the intended
destination by way of a standard link (see the example, below).
Example
<html>
<head>
<title>A web page that points a browser to a different page after 2 seconds</title>
<meta http-equiv="refresh" content="2; URL=http://www.pa.msu.edu/services/computing/">
<meta name="keywords" content="automatic redirection">
</head>
<body>
If your browser doesn't automatically go there within a few seconds,
you may want to go to
<a href="http://www.pa.msu.edu/services/computing/">the destination</a>
manually.
</body>
</html>

Select Example above or here to see how the example works in practice.


________________________________________________________________________
Notes on scripting languages
There are also ways of doing this with JavaScript, VBscript, and other
internal web page scripting languages, but explaining them in detail is
beyond the scope of this web page. A few examples may illustrate the
method, however, and encourage users to obtain actual JavaScript
documentation (a book, or online) to guide them in developing their own
variants suited to their own needs.

The following JavaScript example, which would go ahead of the first
<html> flag on the web page, or between the <HEAD> and </HEAD> tags,
opens the new site in the same browser window (effectively instead of
the rest of the contents of the page that the script is in):


<script language="javascript" type="text/javascript">
<!--
window.location="http://www.pa.msu.edu/services/";
// -->
</script>

This JavaScript example opens the new site in the same browser window
after displaying the current page in the window for 2 seconds (2000 ms):


<script language="javascript" type="text/javascript">
<!--
window.setTimeout('window.location="http://www.pa.msu.edu/services/"; ',2000);
// -->
</script>

(Note that this does exactly what the HTML META tag above does, but as
the META tag method does not depend on the browser's having JavaScript
available and active, in most cases the META tag method would be
preferable).

The next JavaScript example opens the new site in a new* browser window:


<script language="javascript" type="text/javascript">
<!--
Newsite= window.open("http://www.pa.msu.edu/services/","newsite");
// -->
</script>

* sometimes, the "new" window is one of those already opened in the
session; this seems to be somewhat random, and I don't know if it's a
browser bug or a "JavaScript thing" with the window.open command. Just
note that browser behavior may not always be consistent if you use this
script (or the next one, which also uses window.open). -- GJP.

This JavaScript example opens the new site in a new browser window after
a 4.5 second (4500 ms) delay:


<script language="javascript" type="text/javascript">
<!--
window.setTimeout('window.open("http://www.pa.msu.edu/services/","newsite")',4500);
// -->
</script>


________________________________________________________________________
WARNING: With these capabilities for automatic redirection to other web
pages, it is possible to set up a redirection loop -- try to avoid
making it a no-wait-time infinite loop! (An infinite loop with a
reasonable delay, on the other hand, might have its uses as a sort of
slide show, among other possibilities).
________________________________________________________________________
Still have questions? Try sites such as http://www.w3.org/,
http://httpd.apache.org/,

http://www.iis.net/ or
http://www.javascript.com/

(or just use Google™).

Mounting LVM2 Disk On UBUNTU 8.04

Ubuntu 8.04 alpha 6 yang saya gunakan untuk mengupgrade Fedora 3 dengan
LV2 format disk. Permasalahan nya adalah saya tidak bisa mounting LVM
langsung

- Disk SCSI 72 GB saya isi dengan Ubuntu 8.04
- Disk IDE 80 GB berisi Fedora 3 LVM format

Langkah nya :
1) Detect Hardisk IDE
$sudo fdisk -l
Disk /dev/sdb: 80.0 GB, 80026361856 bytes
255 heads, 63 sectors/track, 9729 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x303bd925

Device Boot Start End Blocks Id System
/dev/sdb1 * 1 13 104391 83 Linux
/dev/sdb2 14 9729 78043770 8e Linux LVM

2) Install paket LVM2

$ sudo apt-get install lvm2 -y

3) Active-kan dm-*

$sudo modprobe dm-mod
$sudo vgchange -ay

4) mounting Volume

$ ls -l /dev/mapper/
total 0
crw-rw---- 1 root root 10, 63 2008-03-18 18:14 control
brw-rw---- 1 root disk 254, 0 2008-03-18 18:15 VolGroup00-LogVol00
brw-rw---- 1 root disk 254, 1 2008-03-18 18:15 VolGroup00-LogVol01

$sudo mkdir /mnt/sdb-lvm
$ sudo mount /dev/VolGroup00/LogVol00 /mnt/sdb-lvm

Selesai
__wd
(suwidi dev-NET)

Monday, March 17, 2008

Membuang file .src di Flashdisk dengan command line Linux

saya ingin mencari semua file .scr di flashdisk kemudian membuangnya. ini terjadi karena flashdisk kena VIRUS tatik.exe.

berikut cuplikannya

lakukan pencarian dulu supaya tidak salah pilih

#/media/disk# find ./  -name *.scr

kalo sudah pasti kemudian buang langsung

#/media/disk# find ./  -name *.scr -print -exec rm -r {} -f \;

ini ada ti[s yang lain yang bisa dipelajari


http://www.linux.org/lessons/tips/cmndline.html


Misc.

show libraries a binary uses

Sometimes its necessary to see what libraries a binary is using. For example, if you wanted to know what libraries MySQL is using, just issue this command:

ldd /usr/bin/mysql


substitutes for Netcraft

If you want to find out what operating system a server is using, you can go to Netcraft.com and use their 'What's that site running' service. But there are alternatives. With tools available for Linux, you can do it yourself. It requires curl and/or Lynx to be installed.

lynx -mime_header http://www.domain.com | grep Server

curl -sI http://www.domain.com | grep Server


show files changed on a certain date

If you need to find a file you changed on a certain date, this handy one liner will do it

ls -lt * | grep 'May 8' | awk '{print $9}'


change default editor

The default editor on some Linux machines may not be to your liking. This is particularly important for remote logins. If you wanted to change the editor to 'vim', an improved version of vi, you would do this:

export VISUAL=/usr/bin/vim


sort directories from smallest to biggest

Sometimes you check available space on your hard disk and you're surprised to find that you've recently occupied a lot more. If you're curious as to what's taking up the space, you can find out this way:

du -s -k * | sort -n


strings

If you've got some files that were created by proprietary software that's not longer supported and you need to get data out of them, you might try the 'strings' utility. It will find plain text in binary or other types of non-text formatted files.

strings file > newfile


date in YYYY-MM-DD

This comes in handy for shell scripts, especially if you're making backups. This date format is easily understood by all.

date +%Y-%m-%e

Here's an example of it in use:

tar -zcvpf backup_`date +%Y-%m-%e`.tar.gz *.*


change time stamp of a file

For some reason, you may need to timestamp a file. To simply change the date of a file to the current date and time, do this:

touch file

To change the timestamp to some time in the pass, issue this command:

touch -t YYYYMMDDHHMM file

Where YYYY = year, MM = month, DD = day, HH = hour and MM = minutes.


list all files except

This will list all the files in a directory except the wildcard you specify.

ls -I '*.html'


what's using memory

You may find that your computer is running a bit slower. You can easily find out what's using up your memory:

ps -aux | awk '{print $5,$6,$11}' | sort +1n


complete memory information

To see complete information about the memory your machine is using:

cat /proc/meminfo


change text colors

You can change the color of text in an xterm. This can come in handy it you're writing shell scripts. Try this example:

echo -e "\033[42;1m Pretty colors \033"


Erase the contents of a file

This will erase the contents of a file without eliminating the file

cat /dev/null > some.file


'shred' a file

Just like destroying documents with a paper shredder, computer files with sensitive information in them should also be 'shredded'. To do this, there is a command line utility on Linux systems called 'shred'. What this does is to overwrite the file multiple times with random output. This is secure, because if you simply erase a file with 'rm', all this does is to tell the operating system that this part of your hard disk is free to use, but the information still exists until that space is used. Special tools can be used to recover information from a file that's simply been deleted, but if you've 'shred' it, it would be nearly impossible to get that information back. So shred would be especially useful if you're going to sell or give your computer away to somebody.

The following command will shred a file, "zero" it (to hide shredding) and then remove it.

shred -zuv some.file

You could also 'manually' shred a file by doing the following:

cat /dev/urandom > some.file

This procedure also writes random information to a file. Unlike shred, you'll need to stop this process after a few seconds or some.file will begin to grow until it takes up all available space. When you've finished, simply erase (rm) the file.


delete files with 'bad' names

If you've ever had to delete a file you inadvertantly made, starting with a dash, for example, as you might have found out, it's not as easy as rm -file. You can delete it though - like this:

rm -- -file

or

rm ./-file


pop-up a reminder

You can pop up a message on your Linux desktop with this command:

(sleep 60; xmessage -near One Minute has gone by) &

This will pop up the message 'One Minute has gone by' after 60 seconds. Adjust to your needs accordingly.


Using 'find'


find files bigger than 1mb

This will find files in your home directory that are bigger than 1 megabyte

find /tmp -size +1000k -print


find recently modified files

This will show files that were modified within the last 24 hours in your home directory (if your name is mike)

find ./ -ctime -1 -user mike -print


find with size and access time

You can combine file size and access time with find

find ./ -size +1000k -and -atime +7 -print

Finds files larger than 1 MB that haven't been accessed in more than 7 days.


find and copy into multiple dirs

If you ever need to copy the same file into multiple directories and you can't use a symbolic link, then this trick will work:

find . -type d -name "2004*" -exec cp /file.html {} \;


remove unwanted dirs

Using a modification of the above example, you can remove directories. The following example will remove the temporary directories that the GIMP leaves behind.

find . -type d -name .xvpics -print -exec rm -r {} -f \;

Using 'grep'

Grep is a command line utility that's used mostly to find words in files. It is very powerful. After getting up to speed with it, you'll find that you can't work without it. The basic syntax is:

grep word file, or to use a real example, grep kiwi fruits.txt. This will show the line where the word appears in the file.

You don't have to restrict this to one word. You can search for entire sentences if you like. Just put more than one word inside single quotes.


Show only file name

The following will only show the names of the files where a given word appears

grep -wl 'word' *.*


grep file in a directory

This will search for a given word in an entire directory, including subdirectories

grep -r kiwi ~/my_files/*.rtf


You've got mail!

You can use grep to keep track of recently arrived mail. This one-liner will show you who's sent you mail

grep -c '^From:' /var/spool/mail/bob

The caret '^' tells grep to look for any line beginning with what you specify after.


End of the line

Here's an example of the reverse of the previous example. We can look for lines that end with a particular word or words. The following will show us the users on a Linux system that aren't real people

grep nologin$ /etc/passwd

Accounts for programs and daemons will normally end with 'nologin'.

grep this and this and this

Grep will also let you look for words that appear separately in a file. The following will look for the information for users bob, ted and joe in the /etc/passwd file:

grep "\(bob\|ted\|joe\)" /etc/passwd


Directory Assistance

If you have entered telephone numbers in files, you can use grep to look for them. The following will show you all of the telephone numbers in a given file:

grep '[0-9]\{3\}-[0-9]\{4\}' members.txt

This takes for granted that you've entered them in 000-000-0000 format. Different cultures write down telephone numbers in different ways, so you may have to substitute the the number of digits in the curly braces {2\} instead of {3\} ,for example, or subsitute the separating dash '-' with the character that's more common in your locale (a period '.', for example)


grep and grep

You can use grep more than once if you want to apply different options to two different things that you're looking for. The following pipes the Apache webserver log file to two different instances of grep. We're looking to see who's logged in at a page that are outside of our local network.

cat access | grep login.php | grep -v 192.168