Linked Search

Wednesday, August 10, 2011

System Admin Questions 7

Q: - What is LVM Snapshot ?
 An LVM snapshot is an exact copy of an LVM partition that has all the data from the LVM volume from the time the snapshot was created. The big advantage of LVM snapshots is that they can be used to greatly reduce the amount of time that your services/databases are down during backups because a snapshot is usually created in fractions of a second. After the snapshot has been created, you can back up the snapshot while your services and databases are in normal operation.

Q: - How to verify the signature of an rpm ?
rpm -K test-1.0-1.i386.rpm

Q: - What is the meaning of  Hard & soft mount option in NFS server ?
Hard mount
- If the NFS file system is hard mounted, the NFS daemons will try repeatedly to contact the server. The NFS daemon retries will not time out, will affect system performance, and you cannot interrupt them
Soft mount
- If the NFS file system is soft mounted, NFS will try repeatedly to contact the server until either:
  • A connection is established
  • The NFS retry threshold is met
  • The nfstimeout value is reached
Q: - What is an inode ?
 An inode is a data structure on a traditional Unix-style file system such as UFS. An inode stores basic information about a regular file, directory, or other file system object.
When a file system is created, data structures that contain information about files are created. Each file has an inode and is identified by an inode number (often "i-number" or even shorter, "ino") in the file system where it resides. Inodes store information on files such as user and group ownership, access mode (read, write, execute permissions)
and type of file. There is a fixed number of inodes, which indicates the maximum number of files each filesystem can hold.

Q: - What is the role of udev daemon in Unix ?
udev
is the device manager for the Linux 2.6 kernel series. Primarily, it manages device nodes in /dev. It is the successor of devfs and hotplug, which means that it handles the /dev directory and all user space actions when adding/removing devices, including firmware load.

Q: - What is Super Block in Linux/Unix ?
Each file system is different and they have type like ext2, ext3 etc.Further eachfile system has size like 5 GB, 10 GB and status  such as mount status. In short each file system has a superblock, which contains informationabout file system such as:
File system type 
1. Size  
2. Status  
3. Information about other metadata structures
 If this information lost, you are in trouble (data loss) so Linux maintains multiple redundant copies of thesuperblock in every file system. This is very important in many emergency situation,
for example you can use backup copies to restore damaged primary super block.
Following command displays primary and backup superblock location on /dev/sda3:
# dumpe2fs /dev/hda3 | grep -i superblock

Q: - What is the load average of the server and What is an acceptable Server Load Average ?
The load average is the sum of the run queue length and the number of jobs currently running on the CPUs. The three load-average values in the first line of top output are the 1-minute, 5-minute and 15-minute average. (These values also are displayed by other commands, such as uptime, not only top.)
There are a few factors involved to determine the server average load. If your server (s) use dual processors, the acceptable Server Load Average is 2.00. This load is considered "optimal".
Q: - What is Greylisting  ?
Greylisting (or graylisting) is a method of defending e-mail users against spam. A mail transfer agent (MTA) using greylisting will "temporarily reject" any email from a sender it does not recognize. If the mail is legitimate the originating server will, after a delay, try again and, if sufficient time has elapsed, the email will be accepted. If the mail is from a spam sender, sending to many thousands of email addresses, it will probably not be retried.

Q: - Can we have two apache servers having diff versions? 
Yes, you can have two different apache servers on one server, but they can't listen to the same port at the same time.Normally apache listens to port 80 which is the default HTTP port. The second apache version should listen to another port with the Listen option in httpd.conf, for example to port 81.
For testing a new apache version before moving your sites from one version to another, this might be a good option.You just type www.example.com:81 in the browser window and you will be connected to the second apache  instance.
Q: -What do we use for managing hash table collisions?
There are two ways of managing hash table collisions: one is open addressing and the other is separate chaining. The first way the data items are moved from the full array they hash to and their new place is another cell from the array. The second way every element of the array is made from a linked list and in this list the data items are moved.
Q:- What actually means Linux?
Linux is an open source operating system kernel that is behaving better than many others and it has all the required features for a modern and complete operating system: real multitasking, shared libraries, threads, virtual memory, executables, excellent management of memory, device drivers that can be loaded , frame buffering of video or TCP/IP.
Q:- How can we recover a file that was deleted in Linux?
We can see what was the partition where the lost file was located with the pwd (means present work directory) and with the unmount command we can unmount the directory. Then the “debugfs” command will manage and repair the majority of sever errors or bugs from Linux. The entire code is: #debugfs /usr/directory name. the next step is using “Isdel”.
Q:-How can we see the boot messages?
For viewing the boot messages we can use dmesg, a command that prints on the screen the kernel ring buffer messages; the command is to be used just after the boot sequence. The syntax of a ring buffer is like this: dmesg [options]. If dmesg is called with no options the messages from the kernel will be written to the standard output.
Q:- How do we give a shadow password?
Shadow passwords are given using pwconv command and their purpose is the increase in system security. The file /etc/shadow gets created with that command and modifications are made to the passwords, they will be replaces with “x” in /etc/passwd file.
Q:-In what way are home directories different from working directory?
The directory over which we as users have the control and when we log in it is the working directory. But the current user working directory is not necessarily the home directory.
Q:-What separates Unix Linux?
The graphics are different, Linux has more commands, Linux has more user-friendly features than Unix, Linux is versatile and independent while Unix requires special machine for installation, kernel and file system is different.


Q:-Which is the required command for checking the file system?

For checking the disk integrity and file system the command used is fsck.

Monday, August 1, 2011

File Management

In the Linux file structure files are grouped according to purpose.
Ex: commands, data files, documentation. All directories are grouped under the root entry "/". That part of the directory tree is left out of the below diagram. See Filesystem standard.
  • root - The home directory for the root user
  • home - Contains the user's home directories along with directories for services
    • ftp
    • HTTP
    • samba
    • george
  • bin - Commands needed during bootup that might be needed by normal users
  • sbin - Like bin but commands are not intended for normal users. Commands run by LINUX.
  • proc - This filesystem is not on a disk. It is a virtual filesystem that exists in the kernels imagination which is memory.
    • 1 - A directory with info about process number 1. Each process has a directory below proc.
  • usr - Contains all commands, libraries, man pages, games and static files for normal operation.
    • bin - Almost all user commands. some commands are in /bin or /usr/local/bin.
    • sbin - System admin commands not needed on the root filesystem. e.g., most server programs.
    • include - Header files for the C programming language. Should be below /user/lib for consistency.
    • lib - Unchanging data files for programs and subsystems
    • local - The place for locally installed software and other files.
    • man - Manual pages
    • info - Info documents
    • doc - Documentation
    • tmp
    • X11R6 - The X windows system files. There is a directory similar to usr below this directory.
    • X386 - Like X11R6 but for X11 release 5
  • boot - Files used by the bootstrap loader, LILO. Kernel images are often kept here.
  • lib - Shared libraries needed by the programs on the root filesystem
    • modules - Loadable kernel modules, especially those needed to boot the system after disasters.
  • dev - Device files
  • etc - Configuration files specific to the machine.
    • skel - When a home directory is created it is initialized with files from this directory
    • sysconfig - Files that configure the linux system for devices.
  • var - Contains files that change for mail, news, printers log files, man pages, temp files
    • file
    • lib - Files that change while the system is running normally
    • local - Variable data for programs installed in /usr/local.
    • lock - Lock files. Used by a program to indicate it is using a particular device or file
    • log - Log files from programs such as login and syslog which logs all logins and logouts.
    • run - Files that contain information about the system that is valid until the system is next booted
    • spool - Directories for mail, printer spools, news and other spooled work.
    • tmp - Temporary files that are large or need to exist for longer than they should in /tmp.
    • catman - A cache for man pages that are formatted on demand
  • mnt - Mount points for temporary mounts by the system administrator.
  • tmp - Temporary files. Programs running after bootup should use /var/tmp.

User Management

Useradd - Adding a new user
Options:
  • -d home directory
  • -s starting program (shell)
  • -p password
  • -g (primary group assigned to the users)
  • -G (Other groups the user belongs to)
  • -m (Create the user's home directory
Example: To add a new user with
  • a primary group of users
  • a second group mgmt
  • starting shell /bin/bash
  • password of xxxx
  • home directory of vishal
  • create home directory
  • a login name of vishal                                                                                                                   

    In Detail :-  useradd -gusers -Gmgmt -s/bin/shell -pxxxx -d/home/vishal -m vishal                                                                                                                                                        

Usermod - Modifying existing user

Options:
  • -d home directory
  • -s starting program (shell)
  • -p password
  • -g (primary group assigned to the users)
  • -G (Other groups the user belongs to)
Example: To add the group 'others' to the user vishal

Userdel - Deleting a user

Options:
  • -r (remove home directory)
Example: To remove the user 'vishal' and his home directory
userdel -r vishal

Passwd - User's Password
Options:
  • user's name (Only required if you are root and want to change another user's password)
Example: To change the password for the account you are currently logged in as...
passwd
Enter existing password
Enter new password
Enter new password again (to validate)
Example: To change the password for the user 'roger' (only you are logged in as root)...
passwd vishal
Enter existing password (can be either vishal's password or root's password)
Enter new password
Enter new password again (to validate)

su - Switch User

To switch to another user, use the su command. This is most commonly used to switch to the root account.
Example: To switch to root account...
su
Enter root's passwd
Example: To switch to the user 'vishal'...
su roger
Enter vishal's or root's passwd
To return to original user, enter exit