Q1. How to find files greater than specific size.
A1.
Here’s a quick tip for finding files over 100M on Linux.
# find /home/adam/ -size +100M -exec ls -lh {} \; | awk '{print $5 , $8}'
OR
# find /home/adam/ -size +100M -exec ls -lh {} \;
If you just need a quick method for finding files over 100M all you need is this:
# find /home/adam/ -size +100M
You can also look for files under 100M:
# find /home/adam/ -size -100M
Or files between 90M and 110M
# find /home/adam/ -size +80M -and -size -110M
You can also see file size in blocks using ls -s
# ls -slrt
-s, --size
with -l, print size of each file, in blocks
-S sort by file size
Note: Ouput format
rajagriha:/tmp # find ./ -size +80M -and -size -110M
./2Aug/Nodes/dvt151749/snap.151749.110802.144137.tgz
./2Aug/Nodes/dvt151769/snap.151769.110802.201059.tgz
./2Aug/Nodes/dvt151769/livedump.151769.110802.201321
rajagriha:/tmp # find ./ -size +80M -and -size -110M -exec ls -lh {} \;
-rw-r--r-- 1 root root 97M 2011-08-02 20:23 ./2Aug/Nodes/dvt151749/snap.151749.110802.144137.tgz
-rw-r--r-- 1 root root 99M 2011-08-02 20:21 ./2Aug/Nodes/dvt151769/snap.151769.110802.201059.tgz
-rw-r--r-- 1 root root 81M 2011-08-02 20:20 ./2Aug/Nodes/dvt151769/livedump.151769.110802.201321
rajagriha:/tmp #
Q2. How to Linux NFS Export / share directory to other UNIX / Linux computer
A2.
Step-1: In order to export or share directory called /data2, you need to edit a file called /etc/exports. The file /etc/exports serves as the access control list for
file systems which may be exported to NFS clients.:
# vi /etc/exports
Add config directive as follows:
/data2 *(rw,sync)
Each line contains an export point and a whitespace-separated list of clients allowed to mount the file system at that point. Each listed client may be immediately followed by a parenthesized, comma-separated list of export options for that client.
Where,
rw - Allow both read and write requests on /data2 NFS volume
sync - Reply to requests only after the changes have been committed to stable storage
Step-2: Save and close the file. Restart the nfs service:
# /etc/init.d/nfs restart
Step-3: NFS client configuration
Client computer need to mount file system using mount command or /etc/fstab file, enter:
# mkdir /mnt/nfs
# mount -t nfs4 nfsserver-name-or-ip:/data2 /mnt/nfs
Read the man page for more configuration options:
$ man exports
Example:
[root@ETZ-TestServer ~]# cat /etc/exports
/dumps0 *(rw,insecure,sync,no_root_squash)
/dumps1 *(rw,insecure,sync,no_root_squash)
/candidate *(ro,insecure,sync,no_root_squash)
/dumps_pune54 *(rw,insecure,sync,no_root_squash)
/home/shrikant/candidate *(rw,insecure,sync,no_root_squash)
Q3. How to make persistent mount point (???)
A3. Edit /etc/fstab file
The fstab (/etc/fstab) (or file systems table) file is a system configuration file commonly found on Unix systems. The fstab file typically lists all available disks and disk partitions, and indicates how they are to be initialized or otherwise integrated into the overall system's file system. The file has other names on some versions of Unix, eg it is /etc/vfstab on Solaris.
Example:
persistent mount point for linux to a windows share in FC6
In a terminal window, gain root access, edit your /etc/fstab
An example line to add would be this (1 line):
//10.10.10.9/data /mnt/data cifs uid=username,credentials=/etc/cifscred 0 0
the //10.10.10.9/data is the IP address of the windows PC and its share the /mnt/data refers to where on your linux filesysem you will mount the share.
If you don't have one, you will need to create one - It might make sense to name it the windows sharename.
the cifs refers to the way to communicate with the windows share -
uid=username - same as one i put in creds file below - name to access the share with i imagine - the name of account with access on windows box
credentials=/etc/cifscred - this is a file I created (cifscred) that you will need to as well. I put mine in /etc. this file is only 2 lines:
username=yourusername
password=yourpassword
the 0 0 (Zero Zero )relates to whether the partition needs to be auto-checked on bootup, the are a true/false field (whether to check) and a priority to
determine in what order they are checked and weather a failed check is serious or not. More info can be found at "man fstab
for more refer https://sites.google.com/site/testinggyan/goal/operating-systems/linux
Q4. How to make static IP
A4. Refer
http://corz.org/comms/hardware/router/static.ip.address.php
Q5. What is Active, Primary,Extended, Logical partitions
A5. There can be maximum four primary (1-4) partitions and one extended. (Note total sum can be max 4)
Note: Only one primary partition can be active at a time from which the OS is going to boot.
Refer
http://www.sharkyforums.com/showthread.php?t=154604
http://www.pcguide.com/ref/hdd/file/structPartitions-c.html
Q6. What are the different filesystem types in Linux,Unix,Windows, Solaris
A6. Linux supports quite a large selection of file systems such as:
cramfs, efs, ext2, ext3, vfat, fat, nfs, udf, sysv, smbfs, minix, msdos, reiserfs, hpfs, hfs, iso9660, and many more.
Windows : FAT, NTFS
Solaris : UFS (Unix File System)
To know more click here
Q7. How to add a new hard disk in Linux
A7.
Refer http://www.yolinux.com/TUTORIALS/LinuxTutorialAdditionalHardDrive.html
http://www.skullbox.net/newsda.php
Q8. How To Optimize USB drive with NTFS
A8. You need to format it.
See more at : http://www.makeuseof.com/tag/how-to-optimize-usb-drive-with-ntfs/
Q9. How to Work with Linux Partitions from Windows
A9. Ext2 IFS solves that problem. Unlike other programs which merely create their own Explorer-type interface to work with Linux partitions, this program seamlessly integrates your Linux drives, making them behave like any native Windows file system type which any program can access. It adds an additional driver for mounting Ext2 file systems (and Ext3 since it’s backwards compatible, although it won’t take advantage of Ext3′s journaling ability).
See more at : http://www.makeuseof.com/tag/work-with-linux-partitions-from-windows/
Q10. How to rescan the LUN on FC host
echo 1 > /sys/class/fc_host/host0/issue_lip # not necessarily needed -reinitializes the HBA
echo "- - -" > /sys/class/scsi_host/host0/scan
echo 1 > /sys/class/fc_host/host1/issue_lip # not necessarily needed - reinitializes the HBA
echo "- - -" > /sys/class/scsi_host/host1/scan
and do "service multipathd restart"
http://www.linuxquestions.org/questions/linux-hardware-18/cant-see-new-lun-on-redhat-box-545698/
Q11. How to block an IP address on my Linux system
A11.
iptables -A INPUT -s IP-ADDRESS -j DROP
Replace IP-ADDRESS with your actual IP address. For example, if you wish to block an ip address 65.55.44.100 for whatever reason then type the command as follows:
# iptables -A INPUT -s 65.55.44.100 -j DROP
If you have IP tables firewall script, add the above rule to your script.
If you just want to block access to one port from an ip 65.55.44.100 to port 25 then type command:
# iptables -A INPUT -s 65.55.44.100 -p tcp --destination-port 25 -j DROP
The above rule will drop all packets coming from IP 65.55.44.100 to port mail server port 25.
Type the following two command:
# iptables -A INPUT -s 65.55.44.100 -j DROP
# service iptables save
Use the following syntax (the -d options deletes the rule from table):
# iptables -D INPUT -s xx.xxx.xx.xx -j DROP
# iptables -D INPUT -s 65.55.44.100 -j DROP
# service iptables save
Q12.Linux how to determine the file system type
A12. $ df -T
Output:
Filesystem Type 1K-blocks Used Available Use% Mounted on
/dev/hdb1 ext3 19228276 14737848 3513680 81% /
tmpfs tmpfs 383960 4 383956 1% /dev/shm
df command report filesystem disk space usage and if you pass -T option it will report filesystem type. As you see second command displays file system type (ext3). Type, mount command as follows at shell prompt:
$ mount
Output:
/dev/hdb1 on / type ext3 (rw,errors=remount-ro)
/dev/hdb2 on /home type ext3 (rw,errors=remount-ro)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs (rw)
usbfs on /proc/bus/usb type usbfs (rw)
automount(pid3558) on /data type autofs (rw,fd=4,pgrp=3558,minproto=2,maxproto=4)
As you can see, second last column displays the file system type. For example first line [/dev/hdb1 on / type ext3 (rw,errors=remount-ro)] can be interpreted as follows:
/dev/hdb1 : Partition
/ : File system
ext3 : File system type
(rw,errors=remount-ro) : Mount options
Ref: http://www.cyberciti.biz/faq/linux-how-to-determine-find-out-file-system-type/
Q13. Locating the WWPN for a Linux host
A13.
This topic describes several methods you can use to locate the worldwide port names (WWPN) for a Linux host.
Locating the WWPN without restarting the host
To locate the WWPN without restarting the host, you can use any of the following methods:
For QLogic or Emulex adapters, you can find the WWPN in the /proc/scsi/adapter_type/n directory, where adapter_type is the host adapter type and n is the host adapter number for your card. Your host adapter type can be either qlaxxxx for QLogic adapters or lpfc for Emulex adapters.
If you downloaded a QLogic adapter from the QLogic website instead of using the default version that is included with RHEL, to find the WWPN run the cat /proc/scsi/adapter_type/n command, where adapter_type is the host adapter type (for example, qla2xxx or qla2300), and n is the host adapter number for your card.
For a QLogic adapter that is included with RHEL 4.x or earlier, to find the WWPN run the cat /proc/scsi/adapter_type/n command, where adapter_type is the host adapter type, and n is the host adapter number for your card. In most cases, the adapter type is qla2xxx.
For a QLogic adapter that is included with RHEL 5.x or later, the adapter WWPN information might not be available in the/proc/scsi/adapter_type/n directory because of the migration to sysfs, If so, run the following command:
cat /sys/class/scsi_host/hostn/device/fchost\:hostn/port_name
where n is the host adapter number for your card.
Locating the WWPN when restarting the host
To locate the WWPN when restarting the host, perform the following steps:
Restart the server.
Press Alt+Q to get the FAST!Util menu.
Note: If you have more than one Fibre Channel adapter installed, all the Fibre Channel adapters display. Scroll down to the adapter you want and press Enter.
From the FAST!Util menu, scroll down and click Select Host Adapter.
Scroll up and select Configuration Settings, and then press Enter.
From the Configuration Settings menu, click Host Adapter Settings.
Write down the 16-digit alphanumeric string that is displayed on your screen.
When you configure storage on the storage unit for Fibre Channel attachment, you must specify the worldwide name (WWN) of the Fibre Channel adapter in the IBM® System Storage® DS Storage Manager or DS CLI.
On Linux systems, the required WWN displays in the /var/log/messages system log file when you load the driver. This location, however, depends on the system configuration. You can perform this task automatically during startup, or you can manually perform the task to load the module using the insmod or modprobe command.
The following is example output for the more /var/log/messages command.
# more /var/log/messages
...
Nov 2 08:55:05 skywalker kernel: (scsi): Found a QLA2200 @ bus 1, device 0x1,
irq 20, iobase 0x2300
Nov 2 08:55:10 skywalker kernel: scsi(3): Configure NVRAM parameters...
Nov 2 08:55:10 skywalker kernel: scsi(3): Verifying loaded RISC code...
Nov 2 08:55:10 skywalker kernel: scsi(3): Verifying chip...
Nov 2 08:55:10 skywalker kernel: scsi(3): Waiting for LIP to complete...
Nov 2 08:55:10 skywalker kernel: scsi(3): LOOP UP detected
Nov 2 08:55:10 skywalker kernel: scsi3: Topology - (F_Port), Host Loop address 0xffff
Nov 2 08:55:10 skywalker kernel: scsi(3): Waiting for LIP to complete...
Nov 2 08:55:10 skywalker kernel: scsi3: Topology - (F_Port), Host Loop address 0xffff
Nov 2 08:55:10 skywalker kernel: scsi-qla1-adapter-node=200000e08b02e534;
Nov 2 08:55:10 skywalker kernel: scsi-qla1-adapter-port=210000e08b02e534;
Nov 2 08:55:10 skywalker kernel: scsi-qla1-target-0=5005076300c08b1f;
...
Refer :
Q14. What is the difference between Soft and Hard link
A14.
hardlink.file shares the same inode (73478) as basic.file
hardlink.file shares the same data as basic.file
If we change the permissions on basic.file, then the same permissions change on hardlink.file. The two files (basic.file and hardlink.file) share the same inode and data, but have different file names.
Although softlink.file accesses the same data as basic.file and hardlink.file, it does not share the same inode (73479 vs 73478), nor does it exhibit the same file permissions. It does show a new permission bit: the 'l' (softlink) bit.
If we delete basic.file: then we lose the ability to access the linked data through the softlink: However, we still have access to the original data through the hardlink:
Refer : http://linuxgazette.net/105/pitcher.html
Q15. Various Unix Commands
A.15
The following table lists the basic Unix job control commands:
Refer : http://kb.iu.edu/data/afnw.html
External Links:
How to export NFS File system
1. http://linux.die.net/man/5/exports
3. http://nfs.sourceforge.net/nfs-howto/ar01s03.html
How To create persistent Mount point
1. http://www.tuxfiles.org/linuxhelp/fstab.html
2. http://www.ghacks.net/2009/01/03/understanding-linux-etcfstab/
3. http://en.wikipedia.org/wiki/Fstab
How to block an IP address
1. http://www.cyberciti.biz/faq/how-do-i-block-an-ip-on-my-linux-server/
1. General overview of the Linux file system
http://tldp.org/LDP/intro-linux/html/sect_03_01.html
2. Swap File system
http://fengnet.com/book/Solaris_admin/ch09lev1sec4.html
3. Unix Book (Sed & Awk Command)