To display the files sorted in ascending order, we use the command ‘sort’. Suppose we have the following file and we want to sort out the data.
linux:~ # more sort.txt
Barrack Obama
George Bush
Bill Clinton
Ronald Reagan
Jimmy Carter
linux:~ #
To sort the file we use the following command:
The environment variables are used by the shell and its child processes for normal execution of the programs. However, there are times when there is a need to add new variables for specific applications to work. First of all, check the environment parameters with ‘env’ command as shown below:
To add the parameter simply use the new parameter name and assign it a value. Lets say, we want to add a parameter called ‘NEWPARAM’ to the environment, first define the parameter as follows:
linux:~ #
linux:~ # NEWPARA=’test’
linux:~ #
Tags: add environment parameter, env, export
Capturing the packets on a given interface is vital for troubleshooting problems caused by the application or even network. The commercial servers have multiple Ethernet cards some of which are active and others in a standby mode. In this situation, we must for know which interface card is active and then make the trace on that interface. The following command will reveal the active interfaces.
SUNOS # pnmstat –l
group adapters status fo_time act_adp
nafo0 ce1:ce3 OK 49747670 ce2
As we can see under the column name act_adp, the current active adapter is ce2. After knowing the active interface, we run the following command:
SYNTAX:
snoop -d <device/NIC> -t <Relative(r),Absolute(a) or Delta(d)> -x <Hex dump from offset for length> -o <File Name> port <Port Number>
EXAMPLE:
SUNOS # snoop -d ce2 -t a -x 42 -o Capture.snoop port 1800
The above command will capture the packets on ce2 network interface card and port 1800, it will store the output in the file Capture.snoop which can later be read with Wire Shark software.
Tags: capture packets, pnmstat, snoop
If you need to drop a table in informix and create it again, you require the script which was initially used to create that table. To get the SQL script, we use dbschema command. Most frequently, the command is used in the following format.
dbschema -d <database> -t <tablename> -ss <file_name>
|__ To Generate Server Specific Information
An example is given below:
The above command will take the backup of all the tables in the database smdb and store it in the file ‘smdb_20100624.sql’.
Tags: dbschema, sql script for tables
Most of the programs use dynamic linked libraries so that they can take advantage of pre-prepared procedures in those libraries. However, if such a program doesn’t find the required library present on the system, it won’t run. In such a situation, you can use the ‘ldd’ command to check how many libraries that program is dependent on.
# ldd /bin/bash
/bin/bash:
libtermcap.so.2 => /lib/libtermcap.so.2 (0x40018000)
libc.so.6 => /lib/libc.so.6 (0x4001c000)
/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)
The above command checks the dependency of bash and it shows the bash program is dependent upon 3 DLLs.
Tags: dll, ldd, linux libraries
The file /etc/fstab contains the information about the mounted systems. The system reads this configuration at start-up to mount the required partitions on to the file system. An example of this file is shown below:
As you can see, this file has all the information about the mounted partitions. Now, you can take a separate backup of any of these partitions. For example,
linux # dd if=/dev/sda1 of=/dev/sda2
Tags: backup partition data, dd command, sfdisk
The design of the hard drive and the formation of the partitions of the file system varies from server to server. It mainly depends upon how much hard disk space is available and which applications would be installed on the server. If the server space is low, which should not be the case with commercial servers having critical applications installed on them, we may choose to have less partitions. For example if we have a server having a hard drive with 1GB space available, we may break it down as follows:
/boot –> 50MB
A small file system space in the first partition ensures 1024-cylinder limit.
/ –> 850MB
A large chunk is allocated to the root directory to compensate the application data.
swap –> 100MB
Usually, the switching between GUI and command line interface becomes essential for example, there can be a situation where a server might be having resource problems with its existing specifications. To enhance performance, one might shun the GUI. This can be done by simply changing the run level of the system. If the system is running in GUI, it will probably be in run level 5 which you can verify with ‘runlevel’ command. To change it to command line, you can run the following command:
linux:/ # init 3
This will change the run level of the system to 3 which does not initiate the X-Windows. Hence, you’ll be working in a command line interface. Please read further about run levels here.
The ‘shutdown’ command brings the system down in a secure and planned manner. By default, running this command with no options will bring the system to a single user mode. However, options can be used with this command to halt or reboot the system. Take some examples as follows:
linux:/ # shutdown -r now
The ‘r’ option is used to reboot the system and ‘now’ keyword tells the system to reboot immediately.
linux:/ # shutdown -r +5 System maintenance is required
The run level determines which services will run and which will be stopped during system initialization. The run levels are given below:
0 Halt the system.
1 Single-user mode (for system maintenance).
2 Local Multiuser with Networking but without network service (like NFS)
3 Full Multiuser with Networking
4 Not Used
5 Full Multiuser with Networking and X Windows(GUI)
6 Reboot.
Tags: change runlevel, init, runlevel