Pages

Saturday, September 24, 2011

HTML Error Codes

HTML Error Codes

HTML
When your browser balks, you may be able to find a reason here.

Code Description Comment/Reason
100 Continue  
101 Switching Protocols  
200 OK Action complete successfully
201 Created Success following a POST command
202 Accepted The request has been accepted for processing, but the processing has not yet been completed.
203 Partial Information Response to a GET command, indicates that the returned information is from a private web.
204 No Content Server has received the request but there is nothing to send back. (Empty Document)
205 Reset Content  
206 Partial Content The requested file was partially sent.   Usually caused by stopping or refreshing a web page before it loads.
300 Multiple Choices The request could fit multiple files.
301 Moved Permanently Requested a directory instead of a file.   The web server substituted the index.html file.
302 Moved Temporarily  
303 See Other  
304 Not Modified The cached version of the requested file is the same as the file to be sent.
305 Use Proxy  
400 Bad Request The request had bad syntax or could not be interpreted.
401 Unauthorized User failed to provide a valid user name / password required for access to file / directory.
402 Payment Required  
403 Forbidden Access to a protected or private password protected folder was attempted.
404 Not Found The requested file was not found.
405 Method Not Allowed  
406 Not Acceptable  
407 Proxy Authentication Required  
408 Request Time-Out The server did not respond in the allocated time.
409 Conflict   
410 Gone  
411 Length Required  
412 Precondition Failed  
413 Request Entity Too Large  
414 Request-URL Too Large The submitted URL was too long to be interpreted by the server.
415 Unsupported Media Type  
500 Server Error The server encountered an unexpected condition which prevented it from fulfilling the request
501 Not Implemented The server does not support the service required.
502 Bad Gateway   
503 Out of Resources The server cannot process the request due to a system overload.  This is usually a temporary condition.
504 Gateway Time-Out The service did not respond within the time frame that the gateway was set to wait.
505 HTTP Version not supported The Web Server does not understand the version of http used by the browser.

Common FTP Error Codes

Common FTP Error Codes

T.S. Eggleston FTP Error Codes, Explained
Code Description
100 Codes The requested action is being taken. Expect a reply before proceeding with a new command.
110 Restart marker reply.
120 Service ready in (n) minutes.
125 Data connection already open, transfer starting.
150 File status okay, about to open data connection.
200 Codes The requested action has been successfully completed.
200 Command okay.
202 Command not implemented
211 System status, or system help reply.
212 Directory status.
213 File status.
214 Help message.
215 NAME system type. (NAME is an official system name from the list in the Assigned Numbers document.)
220 Service ready for new user.
221 Service closing control connection. (Logged out if appropriate.)
225 Data connection open, no transfer in progress.
226 Closing data connection. Requested file action successful (file transfer, abort, etc.).
227 Entering Passive Mode
230 User logged in, proceed.
250 Requested file action okay, completed.
257 "PATHNAME" created.
300 Codes The command has been accepted, but the requested action is being held pending receipt of further information.
331 User name okay, need password.
332 Need account for login.
350 Requested file action pending further information.
400 Codes The command was not accepted and the requested action did not take place.
The error condition is temporary, however, and the action may be requested again.
421 Service not available, closing control connection. (May be a reply to any command if the service knows it must shut down.)`
425 Can't open data connection.
426 Connection closed, transfer aborted.
450 Requested file action not taken. File unavailable (e.g., file busy).
451 Requested action aborted, local error in processing.
452 Requested action not taken. Insufficient storage space in system.
500 Codes The command was not accepted and the requested action did not take place.
500 Syntax error, command unrecognized. This may include errors such as command line too long.
501 Syntax error in parameters or arguments.
502 Command not implemented.
503 Bad sequence of commands.
504 Command not implemented for that parameter.
530 User not logged in.
532 Need account for storing files.
550 Requested action not taken. File unavailable (e.g., file not found, no access).
552 Requested file action aborted, storage allocation exceeded
553 Requested action not taken. Illegal file name.

Tuesday, September 20, 2011

Change your Hostname without Rebooting in RedHat Linux

This helps you for  changing your hostname in RedHat Linux without having to do a reboot for the changes to take effect. I've tested this on RedHat 7.3, 9, Fedora Core 3, and CentOS 4.1. It should work for all the versions in between since they all closely follow the same RedHat configuration. Never reboot if you don't have to and keep your uptime intact.
Make sure you are logged in as root and move to /etc/sysconfig and open the network file in vi.
cd /etc/sysconfig
vi network


Look for the HOSTNAME line and replace it with the new hostname you want to use. In this example I want to replace localhost with redhat9.
HOSTNAME=redhat9

When you are done, save your changes and exit vi. Next we will edit the /etc/hosts file and set the new hostname.
vi /etc/hosts

In hosts, edit the line that has the old hostname and replace it with your new one.
192.168.1.110		redhat9

Save your changes and exit vi. The changes to /etc/hosts and /etc/sysconfig/network are necessary to make your changes persistent (in the event of an unscheduled reboot).
Now we use the hostname program to change the hostname that is currently set.
hostname redhat9
And run it again without any parameters to see if the hostname changed.
hostname

Finally we will restart the network to apply the changes we made to /etc/hosts and /etc/sysconfig/network.
service network restart

To verify the hostname has been fully changed, logout of your system and you should see your new hostname being used at the login prompt and after you've logged back in.

Quick, painless, and you won't lose your server's uptime.

Saturday, September 10, 2011

Common Linux commands

BASIC LINUX COMMANDS :





1. tty - reveals the current terminal
2. whoami - reveals the currently logged-in user
3. which - reveals where in the search path a program is located
4. echo - prints to the screen
 a. echo $PATH - dumps the current path to STDOUT
 b. echo $PWD - dumps ths contents of the $PWD variable
 c. echo $OLDPWD - dumps the most recently visited directory

5. set - prints and optionally sets shell variables
6. clear - clears the screen or terminal
7. reset - resets the screen buffer
8. history - reveals your command history
 a. !690 - executes the 690th command in our history
 b. command history is maintained on a per-user basis via:
  ~/.bash_history
~ = users's $HOME directory in the BASH shell
9. pwd - prints the working directory
10. cd - changes directory to desired directory
 a. 'cd ' with no options changes to the $HOME directory
 b. 'cd ~' changes to the $HOME directory
 c. 'cd /' changes to the root of the file system
 d. 'cd Desktop/' changes us to the relative directory 'Desktop'
 e. 'cd ..' changes us one-level up in the directory tree
 f. 'cd ../..' changes us two-levels up in the directory tree

11. Arrow keys (up and down) navigates through your command history
12. BASH supports tab completion:
 a. type unique characters in the command and press 'Tab' key
13. You can copy and paste in GNOME terminal windows using:
  a. left button to block
  b. right button to paste OR Ctrl-Shift-v to paste

14. ls - lists files and directories
 a. ls / - lists the contents of the '/' mount point
 b. ls -l - lists the contents of a directory in long format:
 Includes: permissions, links, ownership, size, date, name
 c. ls -ld /etc - lists properties of the directory '/etc', NOT the contents of '/etc'
 d. ls -ltr - sorts chronologically from older to newer (bottom)
 e. ls --help - returns possible usage information
 f. ls -a - reveals hidden files. e.g. '.bash_history'
Note: files/directories prefixed with '.' are hidden. e.g. '.bash_history'

15. cat - catenates files
 a. cat 123.txt - dumps the contents of '123.txt' to STDOUT
 b. cat 123.txt 456.txt dumps both files to STDOUT
 c. cat 123.txt 456.txt > 123456.txt - creates new catenated file

16. mkdir - creates a new directory
 a. mkdir testRH5 - creates a 'testRH5' directory

17. cp - copies files
 a. cp 123.txt testRH5/
By default, 'cp' does NOT preserve the original modification time

 b. cp -v 456.txt testRH5/

18. mv - moves files
 a. mv 123456.txt testRH5/ - moves the file, preserving timestamp

19. rm - removes files/directories
 a. rm 123.txt
 b. rm -rf 456.txt - removes recursively and enforces

20. touch - creates blank file/updates timestamp
 a. touch test.txt - will create a zero-byte file, if it doesn't exist
 b. touch 123456.txt - will update the timestamp
 c. touch -t 200801091530 123456.txt - changes timestamp

21. stat - reveals statistics of files
 a. stat 123456.txt - reveals full attributes of the file

22. find - finds files using search patterns
 a. find / -name 'fstab'
Note: 'find' can search for fields returned by the 'stat' command

23. alias - returns/sets aliases for commands
 a. alias - dumps current aliases
 b. alias copy='cp -v'


Wednesday, September 7, 2011

More about 'touch' command in Linux

More about 'touch' command in Linux  :

              “touch” resemble like a simple command for creating empty file but it is widely used by system for changing the Time stamp of files and for Service management.

Here’s an example of touch command that change the Time stamp of a file:

# ls -l
    total 3904
   -rw-r--r-- 1 vijay domain users   52422 Nov 12  2009 sg3_utils-libs-1.25-4.el5.x86_64.rpm
#
# touch sg3_utils-libs-1.25-4.el5.x86_64.rpm
# ls -l
   total 3904
 -rw-r--r-- 1 vijay domain users   52422 Sep 15 07:15 sg3_utils-libs-1.25-4.el5.x86_64.rpm                                       # Time stamp changed

# touch -t 1009240615 sg3_utils-libs-1.25-4.el5.x86_64.rpm
# ls -l sg3_utils-libs-1.25-4.el5.x86_64.rpm
    Fri Nov 26 06:30:34 CST 2010           <- Time stamp advanced to 06:30 11/26/2010
#


Service management:

When you get into the folder /var/lock/subsys, you could see list of empty files with service names. These files are basically created using touch command, when a service (say ntpd) is started/restarted.  Presence of these files ensures that same service willnot be started again and it gives an error message saying the service is already running. Further these files will let us know how long a particular service is being running.

# cd /var/lock/subsys
# ls -l
total 0
-rw-r--r-- 1 root root 0 Jul 12 20:25 acpid
-rw-r--r-- 1 root root 0 Jul 12 20:25 atd
-rw-r--r-- 1 root root 0 Jul 12 20:25 auditd
-rw-r--r-- 1 root root 0 Jul 12 20:25 autofs
-rw-r--r-- 1 root root 0 Jul 12 20:25 bluetooth
-rw-r--r-- 1 root root 0 Jul 12 20:24 cpuspeed
-rw-r--r-- 1 root root 0 Jul 12 20:25 crond
-rw-r--r-- 1 root root 0 Jul 12 20:25 cups
-rw-r--r-- 1 root root 0 Jul 12 20:26 firstboot
-rw-r--r-- 1 root root 0 Sep 12 04:02 funcd
-rw-r--r-- 1 root root 0 Jul 12 20:25 gpm
-rw-r--r-- 1 root root 0 Jul 12 20:26 haldaemon
-rw-r--r-- 1 root root 0 Jul 12 20:25 hcid
-rw-r--r-- 1 root root 0 Jul 12 20:25 hidd
-rw-r--r-- 1 root root 0 Jul 12 20:25 hpiod
-rw-r--r-- 1 root root 0 Jul 12 20:25 hplip
-rw-r--r-- 1 root root 0 Jul 12 20:25 hpssd.py
-rw-r--r-- 1 root root 0 Jul 12 20:25 iscsi
-rw-r--r-- 1 root root 0 Jul 12 20:24 iscsid
-rw-r--r-- 1 root root 0 Jul 12 20:24 kudzu
-rw-r--r-- 1 root root 0 Jul 12 20:28 local
-rw-r--r-- 1 root root 0 Jul 12 20:25 messagebus
-rw-r--r-- 1 root root 0 Jul 12 20:24 microcode_ctl
-rw-r--r-- 1 root root 0 Jul 12 20:24 multipathd
-rw-r--r-- 1 root root 0 Jul 12 20:25 netfs
-rw-r--r-- 1 root root 0 Jul 12 20:25 network
-rw-r--r-- 1 root root 0 Jul 12 20:25 nfslock
-rw-r--r-- 1 root root 0 Jul 12 20:32 ntpd
-rw------- 1 root root 0 Jul 12 20:25 pcscd
-rw-r--r-- 1 root root 0 Jul 12 20:32 portmap
-rw-r--r-- 1 root root 0 Aug 13 07:44 postfix
-rw-r--r-- 1 root root 0 Jul 12 20:25 rhnsd
-rw-r--r-- 1 root root 0 Jul 12 20:25 rpcidmapd
-rw-r--r-- 1 root root 0 Jul 12 20:25 sdpd
-rw-r--r-- 1 root root 0 Aug 17 03:08 sendmail
-rw-r--r-- 1 root root 0 Jul 12 20:28 smartd
-rw-r--r-- 1 root root 0 Jul 12 20:32 smb
-rw-r--r-- 1 root root 0 Aug 17 03:08 sm-client
-rw-r--r-- 1 root root 0 Jul 12 20:25 sshd
-rw------- 1 root root 0 Jul 12 20:25 syslog
-rw-r--r-- 1 root root 0 Sep  9 14:48 winbindd   # Indicates winbind service was restarted on Sep 9th.
-rw-r--r-- 1 root root 0 Jul 12 20:25 xfs
-rw-r--r-- 1 root root 0 Jul 12 20:25 xinetd
-rw-r--r-- 1 root root 0 Jul 12 20:25 yum-updatesd
#

Port numbers in Linux

 Port numbers in Linux :
                  Ports in computer networking is an application-specific or process-specific software construct serving as a communications endpoint. It is used by Transport Layer protocols of the Internet Protocol Suite, such as Transmission Control Protocol (TCP) and User Datagram Protocol (UDP). A specific port is identified by its number, commonly known as the port number, the IP address with which it is associated, and the protocol used for communication.
The Internet Assigned Numbers Authority (IANA) is responsible for maintaining the official assignments of port numbers for specific uses. However, many unofficial uses of both well-known and registered port numbers occur in practice.

The port numbers are divided into three ranges:

  • Well-Known/Standard Ports   (Range: 0 to 1023 )
                 Used by system processes that provide widely-used types of network services such as SSH, Telnet, SMTP, FTP etc

  • Registered Ports, and    (Range:  1024 to 49151 )
                 Used by specific service upon applications such as Oracle database listener (1521), MySql (3306), Microsoft Terminal server (3389) etc.

  • Dynamic and/or Private Ports. (Range: 49152 to 65535 )
               These ports can’t be registered by IANA.  This is used for custom or temporary purposes and for automatic allocation of short-lived (or ephemeral ) ports which is used internally by application/processes. You can see these ports by running ‘netstat’ command under “Local address” column.

         In Linux, the port details can be viewed by checking the /etc/services file  and the non-standard (un-registered) ports used by the server can be find using /proc/sys/net/ipv4/ip_local_port_range file.
# cat /proc/sys/net/ipv4/ip_local_port_range
32768   61000


Important ports used in linux :

20-FTP Data (For transferring FTP data)

21-FTP Control (For starting FTP connection)

22-SSH(For secure remote administration which uses SSL to encrypt the transmission)

23-Telnet (For insecure remote administration

25-SMTP(Mail Transfer Agent for e-mail server such as SEND mail)

53- DNS(Special service which uses both TCP and UDP)

67-Bootp

68-DHCP

69-TFTP(Trivial file transfer protocol uses udp protocol for connection less transmission of data)

80 -HTTP/WWW(apache)

88-Kerberos

110-POP3(Mail delivery Agent)

123-NTP(Network time protocol used for time syncing uses UDP protocol)

137-NetBIOS(nmbd)

139-SMB-Samba(smbd)

143-IMAP

161-SNMP(For network monitoring)

389-LDAP(For centralized administration)

443-HTTPS(HTTP+SSL for secure web access)

514-Syslogd(udp port)

995-POP3s

2049-NFS(nfsd, rpc.nfsd, rpc, portmap)

2401-CVS server

3306-MySql

6000-6063-X11
 

Converting a file from uppercase to lowercase and vice-versa

Converting a file from uppercase to lowercase and vice-versa:

          

Syntax to convert Upper to lowercase:
# dd if=[file with uppercase] of=[output filename] conv=lcase
[or]
# cat [file with uppercase] | tr '[:upper:]' '[:lower:]'  > output_file

Syntax to convert Lower to uppercase:
# dd if=[file with lowercase] of=[output filename] conv=ucase
[or]
# cat [file with lowercase] | tr '[:lower:]' '[:upper:]'  > output_file

Automatically logout inactive SSH sessions :

 
 Automatically logout inactive SSH sessions
 
             Typically in an Enterprise setup, we would see Users login from various terminals via SSH but never bother to disconnect the established session. This might cause a slight overload on the Network, since these Established sessions have to maintain their connections by sending Alive packets. So I guess it would be appropriate if make these Users automatically Logout after a certain period of Inactivity (say 1 hour).

Solution 1:
Create a file called "autologout.sh" under /etc/profile.d with execute permission.
# touch /etc/profile.d/autologout.sh
# chmod 711 /etc/profile.d/autologout.sh
Add the following entries to it (Assuming we have to automatically Logout the users after 1 hour, which is 3600 seconds).

TMOUT=3600
readonly TMOUT
export TMOUT

Solution 2:
Enable the following directives in SSH config file (/etc/ssh/sshd_config) and reload the 'sshd' service.

ClientAliveInterval 3600
ClientAliveCountMax 0

#service sshd reload  (or) #service sshd restart

Linux Basic File Permission File Directory Learn through simple screenshot

Linux Basic File Permission File Directory Learn through simple screenshot :

  Linux permission it has the eight type , it contain the type, no of links, date and time…, 

ScreenShot 1 :
Access Permission - refer to the files, d refer to the directories, l refers to the link, p means process file, s means socket files, c is the character device 

Screen Shot 2 :
Permission access mode for directory and files Depending upon read write execute it folder and file has the properties - 

Screen shot 5.
Numerical and Symbolic mode permission Numerical mode 456 Symbolic mode permission rwx - Screen shot 6.
 

Screenshot 1:

Screen Shot 2 :

 

 Screen Shot 3 :


Screen shot 4 :


 

Screen shot 5:


 

Screen shot 6 :