Senin, 30 November 2009

Explanation of common error messages in Linux

As a beginner, you would sometimes get confused with some error messages in the Linux shell command line is quite short with no explanation. For example, when you want to run a command, the result is "Permission denied". But exactly why permission denied, when you are logged in as root, which should have been able to do anything? Or "command not found". How? Though the name is correct according to instructions in the book / manual, not a typo.

This article describes some common error messages in more detail: mean error messages, some common causes of the emergence of these error messages, along with tips that are relevant.
Command not found

This error message appears if the shell can not find the command you want.

One of the most common cause for beginners, indeed, is the wrong type or forget what the exact command name. The names of the Linux command sometimes "kriptik" or weird, so hard to remember. Some very abbreviated command name, a short course of 2-3 letters, because the first was in Unix memory and disk space is very very limited so that all superpendek department. Contohlah: ls, pwd, du, df. Not only beginners, even veteran users sometimes forget to various commands or scripts that numbering thousands. Say a2ensite or a2dismod, two helper scripts in Debian which very often I forget until now. Not to mention sometimes every distro has a different command name: the distribution of a "useradd", on the other "adduser".

Another cause is indeed the program you want is not installed. When you install a new system, sometimes the default settings of the distribution is minimalist. A good policy, though. For example, when installing a Debian system without a GUI and many frills, and even less any such orders not yet exist. Especially popular utilities such as wget or mc or your favorite editor, which must be installed first. How to install it outside the discussion of this article, because it varies according to distribution (apt-get, yum, click, etc.) and taste (GUI, TUI, or command line).

Other causes of common, but the program is located in the shell does not search. Please note that when you type in the name of a shell command like this:

$ Beats

So bash shell as usual for this knock on the list of functions or aliases that have been defined previously, or programs or scripts called beats in the filesystem. For program or script that is in the filesystem, the shell will look only at specific locations which are defined according to the PATH environment variable. Let us look at the contents of PATH:

$ Echo $ PATH
/ usr / local / bin: / usr / bin: / usr/bin/X11: / bin

Means is, the shell will only find in the directory / usr / local / bin, / usr / bin, / usr/bin/X11, and / bin, in that order. The programs in other locations, such as / sbin, / usr / sbin, / opt/VirtualBox-1.3.8, even in the current directory that you are (current directory) will be ignored. So you may be confused, how programs that are in front of the eyes, that if the "ls" are clearly there, when they want to be executed kok still considered "not found"?

To execute programs outside the standard location in the PATH, you can mention the location before the name of the program, for example:

$ / Opt/Ketuk-1.2/bin/ketuk

Or if you are currently located in the directory / opt/Ketuk-1.2/doc, you can use the relative location:

$ .. / Bin / tap

One common case is: in some distros, if you change to root (using the command "su"), then the PATH has not changed. As a result, if you try to run the command:

# Traceroute www.google.com

the shell did not find this traceroute program, which is generally located in / usr / sbin, which is not listed in the standard normal users PATH. To get root's PATH that contains the locations sbin: / sbin, / usr / sbin, / usr / local / sbin then switch to root when you need to use the command "su -".

By the way, why the behavior of such shells, only to find programs in the PATH? The first, obviously, so that the program search process did not take too long. In a system there could be hundreds to thousands of directories and there is no index to its real time, too time-consuming if a shell trying to trace all these directories one by one.

Another reason is, in the case of current directory, for security. The program will only be sought in a particular location is known and safe (/ usr / bin, / bin, etc.). Current directory sometimes "not safe". You could be walking into / tmp or other user's directory. Aja could have a program called "ls", "cat", "less" in that directory but it is entirely different. Now imagine you're an admin or staff shared hosting, and one of your users pretending to ask for help you to see an own directory, with the goal of keeping you "accidentally" run program "ls", gratitude-gratitude as root. This program may be intended to install malware or install a backdoor for the user. Well, have not understood why the default shell does not include the current directory in the PATH?

For the record, to execute a command in the current directory, use the syntax:

$. / Tap

And if you still insist want to be able to execute programs that have a plain current directory, then you can add this current directory (".") to the PATH, for example:

$ Export PATH = "$ PATH:."

Command can be added eg to ~ /. Bash_profile you to be executed each time you login. Keep in mind that adding the current directory to the PATH so is not recommended because of security risks, especially if it is done for the root user.
Permission denied

This error message appears if you are deemed not to have sufficient rights to run the program.

Some programs, especially the nature setuid, protected from certain users or groups. For example:

$ Ls-l / bin / su
-rwsr-x --- 1 root su-users 27000 2006-12-08 01:28 su

Here seen that only root and members of the group "su-users" are allowed to access / bin / su.

Sometimes you have a new program or upload your coffee can not be executed with the permissions denied error message is. This is generally because there is no file permissions bits x (execute), examples of 0644 and not 0755:

$ Ls-l tap
-rw-r - r - 1 steven steven tap 373 2007-05-05 06:42

To run a program, it takes bits x (execute) the permissions. Even if you root, the kernel will still refuse to execute a program or script that does not have bits of x.

To fix this problem, give bit x in the program:

$ Chmod + x tap
$ Ls-l tap
-rwxr-xr-x 1 steven steven tap 373 2007-05-05 06:42


Note: if the program is a script, then you can also call this script with the interpreter's name begins / programming language. In this way, you do not need a bit of x on the script but just bits r (read) it. For example, if the tap in the above examples are Perl scripts:

$ Perl tap

Connection refused, Connection timed out, Connection reset by peer

Three error messages are also often encountered in working in the network, and the beginner sometimes does not understand the clear meaning and the difference between each other. The cause of the appearance of error messages are indeed diverse.

If translated, "connection refused" means that our connection request is rejected. This generally happens if we want to contact a service that was dead. The point here is to die no program (daemon, a server) that are listening (listen) at the port we want to contact. For example, try contacting a random port on your own computer:

$ Telnet localhost 23056
Trying 127.0.0.1 ...
telnet: Unable to connect to remote host: Connection refused

This is because generally there is no daemon that listen on that port. Unlike for example the common port like 80 (HTTP). If your system already installed the web server:

$ Telnet localhost 80
Connected to localhost.
Escape character is'^]'.

This means we succeeded in connecting to port 80 to talk with the web server. Press Ctrl-] (hold down the Control key followed by the press the "]") to exit.

What if we turn off the webserver? For example:

# / Etc/init.d/apache2 stop

(in particular distro you may use sudo / etc/init.d/apache2 stop).

$ Telnet localhost 80
Trying 127.0.0.1 ...
telnet: Unable to connect to remote host: Connection refused

Now the result is Connection refused, because there is no program listening on port 80 connections. So sometimes this error message can be used for monitoring purposes, as an indication of whether a service life or death.

But it could be a message Connection refused due to a firewall. For example, a rule in the firewall to the remote REJECT packet to port 25, to prevent the program on the local computer to contact the remote SMTP server (and spam, for example). So if we try:

$ Telnet mx.yahoo.com 25
Trying 68.142.195.60 ...
telnet: Unable to connect to remote host: Connection refused

Not necessarily mean that the SMTP service on the Yahoo! dead, but there may be a firewall that makes your connection fails.

"Connection timed out" means that when you try to contact a remote port, no answer back from the other end. The reasons may vary: could be your connection to the remote host is very slow so that the time limit specified connection exceeded. There could also blocked by the firewall to DROP (not to REJECT) packets that are sent so that your connection request is not never got to goal.

What about the "Connection reset by peer"? This error message occurs if the connection to the remote host has happened, but it broke. Causes of rupture could include: programs on remote hosts disconnect intentionally. This too can cause all kinds: IP you disliked by the program, there are already too many connections from IP or block your IP, on the other side of the program was killed because of one thing after another, etc.. Another cause is the internet connection problems, for example, if you are using dialup and telephone lines disconnected or hang up.

In short, if you are experiencing network connection problems, need to see first whether the cause in your system side, on the remote system, or in between (ISP, firewall gateway, proxy, etc).

Tidak ada komentar:

Posting Komentar