1 .Boot Process in Linux.
2. Checking Disk Health.
3. Info on syslogd daemon.
4. Adding a static route.
5. Changing kernel parameters without reboot.
6. File systems supported by linux & increasing the process priority.
7. Network traffic on particular interface, speed and duplex settings.
8. Memory Leak.
Learn unix
Friday, January 7, 2011
Wednesday, December 15, 2010
How to on and off services for different run-levels?
This is very common and easy thing in Unix.
Many services run on OS if we want to check whether specific service is running or not we will use the command:
chkconfig --list which list the services running in all run-levels
to turn on\off the service we take the help of above command:
chkconfig --levels 35 service on\off.
Many services run on OS if we want to check whether specific service is running or not we will use the command:
chkconfig --list which list the services running in all run-levels
to turn on\off the service we take the help of above command:
chkconfig --levels 35 service on\off.
Installing and removing packages in RHEL
Tutorial on installing software packages in RHEL.
RPM stands for Red Hat Package Manager.With RPM, you can install, upgrade and uninstall software on Linux, as well as keep track of already installed RPM packages on your system. This can be done because RPM keeps a database of all software that was installed with it.
Installing a package:
rpm –ivh software-2.3.4.rpm
Upgrading a package:
rpm -Uvh software-2.3.4.rpm
Removing a package:
rpm -e software-2.3.4
Note that when installing software, you have to type the name of the RPM package. But when removing software, you don't have to type the whole name of the package that contained the software. You don't have to type the .rpm extension when removing software. Probably you don't have to type the version number, either, so this would do exactly the same as the above:
rpm -e software
Checking the packages installed:
The RPM database contains a list of all installed RPM packages on your system. You can query this database to get info of the packages on your Linux system. To query a single package, you use the -q option. For example, to query a package whose name is "software":
# rpm -q software
After issuing this command, rpm either tells you the version of the package, or that the package isn't installed.
If you want a list of all packages installed on your system, you'll have to query all with -qa:
rpm -qa
check the installed package from all list we use grep command
rpm -qa| grep -i software
Source:
RPM stands for Red Hat Package Manager.With RPM, you can install, upgrade and uninstall software on Linux, as well as keep track of already installed RPM packages on your system. This can be done because RPM keeps a database of all software that was installed with it.
Installing a package:
rpm –ivh software-2.3.4.rpm
Upgrading a package:
rpm -Uvh software-2.3.4.rpm
Removing a package:
rpm -e software-2.3.4
Note that when installing software, you have to type the name of the RPM package. But when removing software, you don't have to type the whole name of the package that contained the software. You don't have to type the .rpm extension when removing software. Probably you don't have to type the version number, either, so this would do exactly the same as the above:
rpm -e software
Checking the packages installed:
The RPM database contains a list of all installed RPM packages on your system. You can query this database to get info of the packages on your Linux system. To query a single package, you use the -q option. For example, to query a package whose name is "software":
# rpm -q software
After issuing this command, rpm either tells you the version of the package, or that the package isn't installed.
If you want a list of all packages installed on your system, you'll have to query all with -qa:
rpm -qa
check the installed package from all list we use grep command
rpm -qa| grep -i software
Source:
Tuesday, December 14, 2010
Cron Tab use
Crontab is mainly used to solve the some of the sysadmin jobs which can be done by running crontab entry.
A usual crontab entry can be checked by command:
crontab -l.
Entry for crontab:
crontab -e
A typical crontab entry:
30 08 10 06 * reboot
| | | | | |
| | | | | |_ command or script which we want to run.
| | | | |
| | | | |_____DAY OF THE WEEK(0-SUNDAY OR 7-SUNDAY)
| | | |_______MONTH
| | |__________ DATE
| |______________ HOURS
|________________MINUTES
To remove crontab entries we use the command crontab -r
To view your current crontab file, use the -l (for ``list'') option:
crontab -l
To delete your file, use:
crontab -d
If you are superuser, you can delete any user's crontab file with:
crontab -d username
where username is the user's login name.
To run a crontab, crond daemon should be running.
A usual crontab entry can be checked by command:
crontab -l.
Entry for crontab:
crontab -e
A typical crontab entry:
30 08 10 06 * reboot
| | | | | |
| | | | | |_ command or script which we want to run.
| | | | |
| | | | |_____DAY OF THE WEEK(0-SUNDAY OR 7-SUNDAY)
| | | |_______MONTH
| | |__________ DATE
| |______________ HOURS
|________________MINUTES
To remove crontab entries we use the command crontab -r
To view your current crontab file, use the -l (for ``list'') option:
crontab -l
To delete your file, use:
crontab -d
If you are superuser, you can delete any user's crontab file with:
crontab -d username
where username is the user's login name.
To run a crontab, crond daemon should be running.
Monday, December 13, 2010
Port Blocking in Linux
For example i am blocking FTP port which is 21.
We can block ports using GUI and command line in Linux.
Command line:
Rejecting:
iptables -A INPUT -p tcp --dport 21 -j REJECT
Enabling:
iptables -A INPUT -p tcp --dport 21 -j ACCEPT
Before Enabling or blocking the port flush the iptables using the command
iptables --flush
Using GUI:
go to the system configuration and open firewall and uncheck the service which is running on the port which u want 2 disable.
For further Info See the below links:
We can block ports using GUI and command line in Linux.
Command line:
Rejecting:
iptables -A INPUT -p tcp --dport 21 -j REJECT
Enabling:
iptables -A INPUT -p tcp --dport 21 -j ACCEPT
Before Enabling or blocking the port flush the iptables using the command
iptables --flush
Using GUI:
go to the system configuration and open firewall and uncheck the service which is running on the port which u want 2 disable.
For further Info See the below links:
Sunday, December 12, 2010
Super block
Reference for Super blocks in Unix:
http://www.angelfire.com/myband/binusoman/Unix.html#inodelist
Unix File System
The arrangement of disk blocks in Unix is as shown in the figure below.
Figure 1. Disk arrangement
The boot block contains the code to bootstrap the OS. The super block contains information about the entire disk. The I-node list a list of inodes, and the data blocks contains the actual data in the form of directories and files. Now let us dissect each block one by one.
The super block contains the following information, to keep track of the entire file system.
Size of the file system
Number of free blocks on the system
A list of free blocks
Index to next free block on the list
Size of the inode list
Number of free the inodes
A list of free inodes
Index to next free inode on the list
Lock fields for free block and free inode lists
Flag to indicate modification of super block
Size of the file system represents the actual no of blocks (used + unused) present in the file system.
The super block contains an array of free disk block numbers, one of which points to the next entry in the list. That entry in turn will be a data block, which contains an array of some other free blocks and a next pointer. When process requests for a block, it searches the free block list returns the available disk block from the array of free blocks in the super block. If the super block contains only one entry which is a pointer to a data block, which contains a list of other free blocks, all the entries from that block will be copied to the super block free list and returns that block to the process. Freeing of a block is reverse process of allocation. If the list of free blocks in super block has enough space for the entry then, this block address will be marked in the list. If the list is full, all the entries from the super block will be copied to the freed block and mark an entry for this block in the super block. Now the list in super block contains only this entry.
Index indexes to the next free disk block in the free disk block list.
Figure 2 Allocation of Data Blocks
The super block also contains an array to represent free inodes. The size of this array need not be the actual number of free inodes. During assignment of an inode to a new file, the kernel searches the free inode list. If one free inode is found, that one is returned. If the free inode list is empty, then it searches the inode list for free inodes. Each inode will contain a type field, which if 0, means the inode is free. It then fills the free inode list of super block as much as it can, with number of free inodes from inode list. It then returns one of these ones. It then remembers the highest inode number. Next time it has to scan the inode list for free ones, it starts from this remembered one. Hence it doesn't have to scan already scanned ones. This improves the efficiency. While freeing an inode, if the free list in super block has space enough, the freed one is put there. If there is not enough space, and the freed inode number is less than the remembered inode, then the remembered inode is updated with the freed inode. If the freed inode number is greater than the remembered one, then it doesn't have to update, because it will be scanned from the remembered node and the freed one will be covered later.
Index indexes to the next free inode in the free disk block list.
Figure 3 Assignment of new inodes
During all these allocations, in a multi-tasking environment, there is a chance of the inodes getting corrupted. Like if one process was trying to allocate an inode and was preempted by the scheduler, and a second process does the same for same inode, it will be a critical problem. Hence lock flags are introduced. While accessing inodes, that inode will be locked. One more flag to indicate that the super block has been modified, is present in the super block.
The I-node list (which server the purpose as FAT+ directory entries in DOS) is a list of inodes, which contains the following entries.
Owner
Type
Last modified time
Last accessed time
Last inode modified time
Access Permissions
No of links to the file
Size of the file
Data blocks owned
Owner indicates who owns the file(s) corresponding to this inode.
Type indicates whether inode represents a file, a directory, a FIFO, a character device or a block device. If the type value is 0 then the inode is free.
The times represent when, the file has been modified, when it was last accessed, or when the inode has been modified last. Whenever the contents of the file is changed, the "inode modified time" also changes. Moreover it changes when there are changes for the inode like permission change, creating a link etc.
Each file will be having nine access permissions for read, write and execute, for the owner, group and others in rwx rwx rwx format.
In Unix we can create links to some files or directories. So we need to have a count of how many links are pointing to the same inode, so that if we delete one of the links the actual data is not gone.
Size of the file represents the actual size of the file.
In Unix, we have a kind of indexing to access the actual data blocks that contains data. We have an array of which (in each inode) first ten elements indicate direct indexing. The next entry is single indirect, then comes double indirect and then triple indirect. By direct indexing we mean that, the value in the array represents the actual data block. If the file needs more than 10 blocks, it uses single indirect indexing, means this is an index to the a block which contains an array of disk block numbers which in turn represent the actual disk block. If all these are exhausted, then double indirect indexing is used and then triple indirect. For further clarifications, refer figure.
Figure 4. Inode DataBlock representation
The data blocks contain the actual data contained in the files or directories. In Unix, a directory is a special file. A directory file contains names of the subdirectories and files present in that directory and its corresponding inode number.
Reference:
The Design of the Unix Operating System By Maurice J. Bach
Advanced Programming in the Unix Environment By W. Richard Stevens
http://www.angelfire.com/myband/binusoman/Unix.html#inodelist
Unix File System
The arrangement of disk blocks in Unix is as shown in the figure below.
Figure 1. Disk arrangement
The boot block contains the code to bootstrap the OS. The super block contains information about the entire disk. The I-node list a list of inodes, and the data blocks contains the actual data in the form of directories and files. Now let us dissect each block one by one.
The super block contains the following information, to keep track of the entire file system.
Size of the file system
Number of free blocks on the system
A list of free blocks
Index to next free block on the list
Size of the inode list
Number of free the inodes
A list of free inodes
Index to next free inode on the list
Lock fields for free block and free inode lists
Flag to indicate modification of super block
Size of the file system represents the actual no of blocks (used + unused) present in the file system.
The super block contains an array of free disk block numbers, one of which points to the next entry in the list. That entry in turn will be a data block, which contains an array of some other free blocks and a next pointer. When process requests for a block, it searches the free block list returns the available disk block from the array of free blocks in the super block. If the super block contains only one entry which is a pointer to a data block, which contains a list of other free blocks, all the entries from that block will be copied to the super block free list and returns that block to the process. Freeing of a block is reverse process of allocation. If the list of free blocks in super block has enough space for the entry then, this block address will be marked in the list. If the list is full, all the entries from the super block will be copied to the freed block and mark an entry for this block in the super block. Now the list in super block contains only this entry.
Index indexes to the next free disk block in the free disk block list.
Figure 2 Allocation of Data Blocks
The super block also contains an array to represent free inodes. The size of this array need not be the actual number of free inodes. During assignment of an inode to a new file, the kernel searches the free inode list. If one free inode is found, that one is returned. If the free inode list is empty, then it searches the inode list for free inodes. Each inode will contain a type field, which if 0, means the inode is free. It then fills the free inode list of super block as much as it can, with number of free inodes from inode list. It then returns one of these ones. It then remembers the highest inode number. Next time it has to scan the inode list for free ones, it starts from this remembered one. Hence it doesn't have to scan already scanned ones. This improves the efficiency. While freeing an inode, if the free list in super block has space enough, the freed one is put there. If there is not enough space, and the freed inode number is less than the remembered inode, then the remembered inode is updated with the freed inode. If the freed inode number is greater than the remembered one, then it doesn't have to update, because it will be scanned from the remembered node and the freed one will be covered later.
Index indexes to the next free inode in the free disk block list.
Figure 3 Assignment of new inodes
During all these allocations, in a multi-tasking environment, there is a chance of the inodes getting corrupted. Like if one process was trying to allocate an inode and was preempted by the scheduler, and a second process does the same for same inode, it will be a critical problem. Hence lock flags are introduced. While accessing inodes, that inode will be locked. One more flag to indicate that the super block has been modified, is present in the super block.
The I-node list (which server the purpose as FAT+ directory entries in DOS) is a list of inodes, which contains the following entries.
Owner
Type
Last modified time
Last accessed time
Last inode modified time
Access Permissions
No of links to the file
Size of the file
Data blocks owned
Owner indicates who owns the file(s) corresponding to this inode.
Type indicates whether inode represents a file, a directory, a FIFO, a character device or a block device. If the type value is 0 then the inode is free.
The times represent when, the file has been modified, when it was last accessed, or when the inode has been modified last. Whenever the contents of the file is changed, the "inode modified time" also changes. Moreover it changes when there are changes for the inode like permission change, creating a link etc.
Each file will be having nine access permissions for read, write and execute, for the owner, group and others in rwx rwx rwx format.
In Unix we can create links to some files or directories. So we need to have a count of how many links are pointing to the same inode, so that if we delete one of the links the actual data is not gone.
Size of the file represents the actual size of the file.
In Unix, we have a kind of indexing to access the actual data blocks that contains data. We have an array of which (in each inode) first ten elements indicate direct indexing. The next entry is single indirect, then comes double indirect and then triple indirect. By direct indexing we mean that, the value in the array represents the actual data block. If the file needs more than 10 blocks, it uses single indirect indexing, means this is an index to the a block which contains an array of disk block numbers which in turn represent the actual disk block. If all these are exhausted, then double indirect indexing is used and then triple indirect. For further clarifications, refer figure.
Figure 4. Inode DataBlock representation
The data blocks contain the actual data contained in the files or directories. In Unix, a directory is a special file. A directory file contains names of the subdirectories and files present in that directory and its corresponding inode number.
Reference:
The Design of the Unix Operating System By Maurice J. Bach
Advanced Programming in the Unix Environment By W. Richard Stevens
Sunday, December 5, 2010
Adding a printer in Linux
In Linux to add a Network printer we use CUPS which need to be installed to add a printer.
To add a printer from command line we use the command
lpadmin -p LaserJet -E -v socket://ip address
to make the above printer default we use d option with lpadmin
lpadmin -d printername
To add the printer using GUI
we type the command system-config-printer which opens a GUI for the user which is very easy to configure.
To add a printer from command line we use the command
lpadmin -p LaserJet -E -v socket://ip address
to make the above printer default we use d option with lpadmin
lpadmin -d printername
To add the printer using GUI
we type the command system-config-printer which opens a GUI for the user which is very easy to configure.
Subscribe to:
Posts (Atom)