Skip to main content

Posts

Showing posts from March, 2017

Unix - System Performance & System Logging

We will introduce you to a few free tools that are available to monitor and manage performance on Unix systems. These tools also provide guidelines on how to diagnose and fix performance problems in the Unix environment. Unix has following major resource types that need to be monitored and tuned − CPU Memory Disk space Communications lines I/O Time Network Time Applications programs Performance Components The following table lists out five major components which take up the system time − S.No. Component & Description 1 User State CPU The actual amount of time the CPU spends running the users’ program in the user state. It includes the time spent executing library calls, but does not include the time spent in the kernel on its behalf 2 System State CPU This is the amount of time the CPU spends in the system state on behalf of this program. All I/O routines require kernel services. The programmer can affect this value by blocking I/O transf

Unix - User Administration

There are three types of accounts on a Unix system − Root account This is also called superuser and would have complete and unfettered control of the system. A superuser can run any commands without any restriction. This user should be assumed as a system administrator. System accounts System accounts are those needed for the operation of system-specific components for example mail accounts and the sshd accounts. These accounts are usually needed for some specific function on your system, and any modifications to them could adversely affect the system. User accounts User accounts provide interactive access to the system for users and groups of users. General users are typically assigned to these accounts and usually have limited access to critical system files and directories. Unix supports a concept of Group Account which logically groups a number of accounts. Every account would be a part of another group account. A Unix group plays important role in han

Unix - Network Communication Utilities

 When you work in a distributed environment, you need to communicate with remote users and you also need to access remote Unix machines. There are several Unix utilities that help users compute in a networked, distributed environment. This chapter lists a few of them. The ping Utility The ping command sends an echo request to a host available on the network. Using this command, you can check if your remote host is responding well or not. The ping command is useful for the following − Tracking and isolating hardware and software problems. Determining the status of the network and various foreign hosts. Testing, measuring, and managing networks. Syntax Following is the simple syntax to use the ping command − $ping hostname or ip-address The above command starts printing a response after every second. To come out of the command, you can terminate it by pressing CNTRL + C keys. Example Following is an example to check the availability of a host available o

Unix - Pipes and Filters

To make a pipe, put a vertical bar ( | ) on the command line between two commands. When a program takes its input from another program, it performs some operation on that input, and writes the result to the standard output. It is referred to as a filter . The grep Command The grep command searches a file or files for lines that have a certain pattern. The syntax is − $grep pattern file(s) The name "grep" comes from the ed (a Unix line editor) command g/re/p which means “globally search for a regular expression and print all lines containing it”. A regular expression is either some plain text (a word, for example) and/or special characters used for pattern matching. The simplest use of grep is to look for a pattern consisting of a single word. It can be used in a pipe so that only those lines of the input files containing a given string are sent to the standard output. If you don't give grep a filename to read, it reads its standard input; that&#

Unix Basic Utilities - Printing, Email

Printing Files Before you print a file on a Unix system, you may want to reformat it to adjust the margins, highlight some words, and so on. Most files can also be printed without reformatting, but the raw printout may not be that appealing. Many versions of Unix include two powerful text formatters, nroff and troff . The pr Command The pr command does minor formatting of files on the terminal screen or for a printer. For example, if you have a long list of names in a file, you can format it onscreen into two or more columns. Following is the syntax for the pr command − pr option(s) filename(s) The pr changes the format of the file only on the screen or on the printed copy; it doesn't modify the original file. Following table lists some pr options − S.No. Option & Description 1 -k Produces k columns of output 2 -d Double-spaces the output (not on all pr versions) 3 -h "header" Takes the next item as a report

Unix - Environment

 An important Unix concept is the environment , which is defined by environment variables. Some are set by the system, others by you, yet others by the shell, or any program that loads another program. A variable is a character string to which we assign a value. The value assigned could be a number, text, filename, device, or any other type of data. For example, first we set a variable TEST and then we access its value using the echo command − $TEST = "Unix Programming" $echo $TEST It produces the following result. Unix Programming Note that the environment variables are set without using the $ sign but while accessing them we use the $ sign as prefix. These variables retain their values until we come out of the shell. When you log in to the system, the shell undergoes a phase called initialization to set up the environment. This is usually a two-step process that involves the shell reading the following files − /etc/profile profile The process

UNIX-File Permission / Access Modes

File ownership is an important component of Unix that provides a secure method for storing files. Every file in Unix has the following attributes − Owner permissions − The owner's permissions determine what actions the owner of the file can perform on the file. Group permissions − The group's permissions determine what actions a user, who is a member of the group that a file belongs to, can perform on the file. Other (world) permissions − The permissions for others indicate what action all other users can perform on the file. The Permission Indicators While using ls -l command, it displays various information related to file permission as follows − $ls -l /home/amrood -rwxr-xr-- 1 amrood users 1024 Nov 2 00:10 myfile drwxr-xr--- 1 amrood users 1024 Nov 2 00:10 mydir Here, the first column represents different access modes, i.e., the permission associated with a file or a directory. The permissions are broken into groups of threes, and each pos

UNIX- Directory Management & File System Basics

A directory is a file the solo job of which is to store the file names and the related information. All the files, whether ordinary, special, or directory, are contained in directories. Unix uses a hierarchical structure for organizing files and directories. This structure is often referred to as a directory tree. The tree has a single root node, the slash character ( / ), and all other directories are contained below it. Home Directory The directory in which you find yourself when you first login is called your home directory. You will be doing much of your work in your home directory and subdirectories that you'll be creating to organize your files. You can go in your home directory anytime using the following command − $cd ~ $ Here ~ indicates the home directory. Suppose you have to go in any other user's home directory, use the following command − $cd ~username $ To go in your last directory, you can use the following command − $cd - $ Absolu