Archive for Tech Writing

Understanding passwd file in Linux

/etc/passwd file in linux is a text file that contains a list of the system’s accounts which is required during login. It contains essential information like user ID, group ID, home directory, shell, etc.

/etc/passwd contains one entry per line for each user (or user account) of the system. All fields are separated by a colon (:) symbol. There are total of seven fields per line.

ujjwal:x:512:513:/var/www/html:/bin/bash:xx

Now, let’s elaborate the fields for the entries

  • Username: Username is needed for user login. It should be between 1 and 32 characters.
  • Password: Password is stored encrypted in /etc/shadow file which is indicated by x character above.
  • User ID (UID): Each user must be assigned a user ID (UID). UID 0 (zero) is reserved for root and UIDs 1-99 are reserved for other predefined accounts. Further UID 100-999 are reserved by system for administrative and system accounts/groups.
  • Group ID (GID): Group ID of a user which is stored in /etc/group file
  • User ID Info: This is the comment field which allows you to add extra information about the users such as user’s full name, phone number etc. This field is used by finger command.
  • Home Directory: The absolute path to the directory the user will be in when they log in. If this directory does not exists then users directory becomes /
  • Command/Shell: The absolute path of a command or shell (/bin/bash). Typically, this is a shell but that does not mean it has to be a shell.

SMTP vs. POP3 and IMAP

SMTP, POP3 and IMAP are TCP/IP protocols used for mail delivery. Each protocol is just a specific set of communication rules between computers.

SMTP
SMTP stands for Simple Mail Transfer Protocol. SMTP is used when email is delivered from an email client, such as Outlook Express, to an email server or when email is delivered from one email server to another. SMTP uses port 25.

POP3
POP3 stands for Post Office Protocol. POP3 allows an email client to download an email from an email server. The POP3 protocol is simple and does not offer many features except for download. Its design assumes that the email client downloads all available email from the server, deletes them from the server and then disconnects. POP3 normally uses port 110.

IMAP
IMAP stands for Internet Message Access Protocol. IMAP shares many similar features with POP3. It, too, is a protocol that an email client can use to download email from an email server. However, IMAP includes many more features than POP3. The IMAP protocol is designed to let users keep their email on the server. IMAP requires more disk space on the server and more CPU resources than POP3, as all emails are stored on the server. IMAP normally uses port 143

Multilanguage in Yii

If you are wondering about using multi-language feature in your Yii application, then you came to the right spot. In this tutorial, I will be showing you how to implement the multi-language using Message Translation feature in Yii.

In Yii, Message translation is done by calling Yii::t(). This method translates the given message from source language to target language. Also, when translating a message, its category has to be specified since a message may be translated differently under different contexts.

Message translation could be achieved using any three of the message sources.

  • CPhpMessageSource
  • CGettextMessageSource
  • CDbMessageSource

In this tutorial, I will be focusing on CDbMessageSource. CDbMessageSource represents a message source that stores translated messages in database. Let us begin now.

Since we are using database to store the message, we need two tables; one is to store the Source Message and the other to store the Translated Message. Here is the schema for it.[http://www.yiiframework.com/doc/api/1.1/CDbMessageSource]

CREATE TABLE SourceMessage
(
    id INTEGER PRIMARY KEY,
    category VARCHAR(32),
    message TEXT
);
CREATE TABLE Message
(
    id INTEGER,
    language VARCHAR(16),
    translation TEXT,
    PRIMARY KEY (id, language),
    CONSTRAINT FK_Message_SourceMessage FOREIGN KEY (id)
         REFERENCES SourceMessage (id) ON DELETE CASCADE ON UPDATE RESTRICT
);

The ‘SourceMessage’ table stores the messages to be translated, and the ‘Message’ table stores the translated messages.

000webhost logo