intTypePromotion=1
zunia.vn Tuyển sinh 2024 dành cho Gen-Z zunia.vn zunia.vn
ADSENSE

7 More Red Hat® Linux™ Tips and Tricks

Chia sẻ: Huy Hoang | Ngày: | Loại File: PDF | Số trang:6

65
lượt xem
4
download
 
  Download Vui lòng tải xuống để xem tài liệu đầy đủ

Are you looking for a quick and simple reference guide to help you navigate Red Hat® LinuxTM systems? Look no further. Global Knowledge and Red Hat have assembled a second set of Tips and Tricks written by Red Hat Certified Engineers® (RHCEs) to give you an edge on managing these systems: 1. If a file has a link count greater than 1, is there a simpler way to find out what other file names are hard-linked to it? 2. Which interface is eth0? 3. Quick-and-dirty automounts 4. How can I make dd give me a progress report? 5. Tar vs. Star—The battle of xattrs 6. New default...

Chủ đề:
Lưu

Nội dung Text: 7 More Red Hat® Linux™ Tips and Tricks

  1. Written and Provided by Expert Reference Series of White Papers ® 7 More Red Hat Linux™ Tips and Tricks 1-800-COURSES www.globalknowledge.com
  2. 7 More Red Hat® Linux Tips and TM Tricks Introduction Are you looking for a quick and simple reference guide to help you navigate Red Hat® LinuxTM systems? Look no further. Global Knowledge and Red Hat have assembled a second set of Tips and Tricks written by Red Hat Certified Engineers® (RHCEs) to give you an edge on managing these systems: 1. If a file has a link count greater than 1, is there a simpler way to find out what other file names are hard-linked to it? 2. Which interface is eth0? 3. Quick-and-dirty automounts 4. How can I make dd give me a progress report? 5. Tar vs. Star—The battle of xattrs 6. New default mount options in Red Hat® Enterprise Linux® 5 7. How do I enable logging so that I can see all the queries on my DNS server? 1. If a file has a link count greater than 1, is there a simpler way to find out what other file names are hard-linked to it? by Steve Bonneville, Red Hat Certified Engineer® The obvious answer is that you can’t by just looking at the inode; the inode only contains a link count, not a list of the file names that are hard-linked to the inode. So you need to walk through the filesystem looking for files that have the same inode number as the file of interest. The not so obvious solution is that the find command can do this searching for you, once you’ve determined the inode number for the file with ls -i. For example, find /home -mount -inum 78442 works nicely to find all file names using inode 78442 on the filesystem mounted on /home. The -mount option is necessary to avoid accidentally searching other filesystems mounted on subdirectories of the /home filesystem, since inode numbers are only unique within a given filesystem. It is also very important to start the find at the mount point for the filesystem being searched, or some files might be missed by find. Copyright ©2007 Global Knowledge Training LLC. All rights reserved. Page 2
  3. 2.Which interface is eth0? by Paul Morgan, Red Hat Certified Engineer® If you’re not sure which physical interface is eth0 and which is eth1 (or eth2), run: ethtool -p eth0 5 This blinks the LED on the interface for five seconds—without interrupting network traffic. 3. Quick-and-dirty automounts by Joshua Hoffman, Red Hat Certified Engineer® 1. Enable the /net map in /etc/auto.master. 2. Create a new directory to hold your network mounts: mkdir /network 3. Create links for the mounts you want: cd /network ln -s /net/server1/var/ftp/pub/Server Server 4. Now you can just use the links: cd /network/Server 5. Best of all, this always works: ls /network 6. This trick even works for NIS user homedirs: cd /home ln -s /net/server1/home/guests guests 4. How can I make dd give me a progress report? by Andrew C. Dingman, Red Hat Certified Engineer® If you’ve been working with Linux very long, you’ve probably encountered dd, the deceptively simple utility for copying a stream of data from here to there. You may have used it to zero a disk before letting it leave the building, to benchmark IO hardware by writing a certain number of bytes, to put a disk image on a floppy or USB drive, or even to back up an entire disk. Like many commands, dd doesn’t generate much output as long as things are going well. This is great for scripting, but can be frustrating when you run it interactively. On large transfers, such as wiping or imaging a disk, it can be a total mystery how much longer you have to wait. Also like many other commands, dd has some tricks up its sleeve that it will show off if it gets the right sig- nal. In particular, dd will respond to the USR1 signal with a status report on TDERR. It is the same data you’d normally get at the very end of the transfer and will look something like this: Copyright ©2007 Global Knowledge Training LLC. All rights reserved. Page 3
  4. $ dd if=/dev/zero of=/tmp/demo bs=1M count=1536 33+0 records in 33+0 records out 34603008 bytes (35 MB) copied, 0.355191 seconds, 97.4 MB/s So how do we send this signal? Using your choice of kill, killall, or pkill. All of these will, by default, send a TERM signal (15), which is not what we want at all. Instead, use the following to send the USR1 signal to all processes you own named dd. $ pkill -USR1 ^dd$ kill and killall support the -USR1 option in the same manner. If you want a periodic status report, you can extend the same idea with watch in another terminal. Since we’re just sending a signal, there won’t be any output in the display from watch, but it’s a nice shortcut for periodic execution. $ watch -n5 -- pkill -USR1 ^dd$ Will send signal USR1 to any dd process you own every five seconds, triggering dd to tell you where it is in the transfer and how fast it’s going. Remember, look at dd’s terminal for the output! $ dd if=/dev/zero of=/tmp/demo bs=1M count=1536 137+0 records in 137+0 records out 143654912 bytes (144 MB) copied, 5.66717 seconds, 25.3 MB/s 249+0 records in 249+0 records out 261095424 bytes (261 MB) copied, 11.5736 seconds, 22.6 MB/s 388+0 records in 387+0 records out 5.Tar vs. Star – The battle of xattrs by Forrest Taylor, Red Hat Certified Engineer® In Red Hat® Enterprise Linux® 4, tar could not handle the extra information stored in ext2 and ext3 file sys- tems called Extended Attributes (EAs or xattrs). This is a potential problem for backups, because SELinux and ACLs use these Extended Attributes to store the security contexts and access control lists respectively. star shone brightly as it has options for backing up and restoring each of these attributes. Great strides have taken place in rebuilding tar to acknowledge these Extended Attributes, and with Red Hat® Enterprise Linux® 5 comes a new tar with options for xattrs. tar now has three options for creating an archive with xattrs in mind: --selinux Archive the SELinux attributes of the files and directories --acls Archive the ACL attributes of files and directories --xattrs Archive all Extended Attributes of files and directories. Copyright ©2007 Global Knowledge Training LLC. All rights reserved. Page 4
  5. This includes both SELinux and ACL attributes, as well as any other xattr. Optionally, if you don’t want to use the xattrs there are three other options: --no-selinux Do not use the SELinux attributes --no-acls Do not use the ACL attributes --no-xattrs Do not use any xattrs, including SELinux and ACL. By default, tar does not archive the xattrs, thus the previous three options are normally used at the time of restore. Additionally, newly created file systems in Red Hat Enterprise Linux 5 now contain the acl and user_xattr default mount options, so these tar options are necessary for good backups. 6. New default mount options in Red Hat Enterprise Linux 5 by Forrest Taylor, Red Hat Certified Engineer® Newly created file systems in Red Hat® Enterprise Linux® 5 now have new default mount options. For instance, if I created /boot at install time on /dev/sda1, I can view these new mount options using tune2fs: # tune2fs -l /dev/sda1 tune2fs 1.39 (29-May-2006) Filesystem volume name: /boot Last mounted on: Filesystem UUID: ea84e45d-ba84-4346-bf7c-1988c123a4a5 Filesystem magic number: 0xEF53 Filesystem revision #: 1 (dynamic) Filesystem features: has_journal ext_attr resize_inode dir_index filetype needs_recovery sparse_super large_file Default mount options: user_xattr acl Filesystem state: clean Errors behavior: Continue Filesystem OS type: Linux ... We are interested in this line: Default mount options: user_xattr acl These options apply for the file system at mount time. Thus, these newly created file systems will be able to use access control lists (ACL) and user extended attributes with no additional options. ACLs are used to give multiple users and groups permissions to files and directories. This extends the standard Linux permissions of having one user permission, one group permission, and a permission for all others. Copyright ©2007 Global Knowledge Training LLC. All rights reserved. Page 5
  6. user_xattr is an option to store the user extended attributes. This allows added attributes to be stored with the file, including mime-types, descriptions, etc. Some programs, such as Beagle, use these extended attributes for storing data with the files. One caveat here: the installer runs the tune2fs command on newly created file systems, giving it the acl and user_xattr options. File systems that were created before or after the installation will not have these options by default. You can run tune2fs manually just like the installer did. Here is the exact command that anaconda runs, assuming that the partition is /dev/sda1: tune2fs -c 0 -i 0 -O dir_index -o user_xattr,acl /dev/sda1 7. How do I enable logging so that I can see all the queries on my DNS server? by Chris Tatman Release Found: Red Hat® Enterprise Linux® 3 and Red Hat® Enterprise Linux® 4 Resolution: The logging of DNS queries can be enabled by running the rndc command. To do so run the command below as root: # rndc querylog Once this is done, all the queries being sent to the DNS server will be logged in the /var/log/messages file. To view those queries, type: # tail -f /var/log/messages and the result will be similar to : Feb 2 16:30:01 dns-server named[1717]: client 192.168.1.10#32784: query: dns-server.redhat.com IN A + Feb 2 16:34:52 dns-server named[1717]: client 192.168.1.60#32807: query: dns-client.redhat.com IN A + Feb 2 16:34:52 dns-server named[1717]: client 192.168.1.60#32807: query: 60.1.168.192.in-addr.arpa IN PTR + For more information on the rndc command, see the man pages: # man rndc Learn More Learn more about how you can improve productivity, enhance efficiency, and sharpen your competitive edge. Check out our complete Red Hat Linux curriculum at www.globalknowledge.com/redhat. For more information or to register, visit www.globalknowledge.com or call 1-800-COURSES to speak with a sales representative. Copyright ©2007 Global Knowledge Training LLC. All rights reserved. Page 6
ADSENSE

CÓ THỂ BẠN MUỐN DOWNLOAD

 

Đồng bộ tài khoản
2=>2