Friday, August 28, 2015

some useful linux commands and their full forms

ACL                            Access control list.
awk                             Aho, Weinberger, and Kernighan.
BIOS                          basic input output system.
cd                               change Directory.
chmod                        change mode.
chown                        change owner.
CIFS                          common Internet File System
df                                disk free.
DHCP                        Dynamic Host Configuration Protocol.
DNS                           Domain Name System.
du                              disk usage.
ext2                            second extended file system.
ext3                            third extended file system.
ext4                            fourth extended file system.
fdisk                           fixed disk.
FTP                            File Transfer Protocol.
grep                            Global  regular expression print.
GRUB                        Grand unified Bootloader.
http                            HyperText Transfer Protocol.
ifconfig                       Interface Configuration.
IMAP                         Internet Message Access Protocol.
KVM                          Kernel Virtual Machine.
LVM                          logical volume manager.
MBR                          Master Boot Record.
mkfs                           make filesystem.
NFS                            Network file system
pop                             Post Office Protocol.
ps                                process status.
pwd                            present working directory.
rm                              remove.
RPM                          Redhat package Manger.
scp                              secure copy.
sed                              Stream Editor.
SGID                          set group id.
SMB                           Server Message Block
ssh                              Secure Shell.
su                               substitute user or switch user.
sudo                           substitute user do or super user do .
SUID                          set user id .
tar                              tape archive.
TFTP                         Trivial File Transfer Protocol.
umask                        User's File Creation Mask.
Vim                            Visual Improved
VSFTP                       very secure  File Transfer Protocol.
YUM                          Yellowdog updater modified.

Wednesday, August 26, 2015

Commands to check the Linux Version, Release name & Kernel version.

uname -a (print all information)


uname -r (print the kernel name)


cat /proc/version


cat /etc/issue



cat /etc/redhat-release



lsb_release -a



Friday, August 21, 2015

what is virtual memory, paging , swap space ?

Swapping
A process normally runs on physical memory where the memory is divided into sets of pages. A page is a 4kb area of memory and is the basic unit of memory with which both kernel and CPU deal.

There might be a situation when all the pages in physical memory goes full. In such cases all the inactive pages inside physical memory is shifted to the secondary storage or the swap space using the paging technique. By doing this physical memory gets free pages which can again be utilized by new processes. This entire process is termed as swapping.

NOTE: Swapping is a good idea as it gives you an additional space to store data files and programs when your physical memory is out of space but accessing a hard disk is hundred times slower than accessing memory.

Virtual memory is a memory management technique that is implemented using both hardware and software which gives an application program the impression that it has contiguous working memory (an address space).

In simple terms Virtual memory is a logical combination of RAM memory and swap space which is used by running process

NOTE: It is NOT just an additional space used in hard disk to make it act as physical memory

Paging
This is one of the memory management technique schemes by which a computer can store and retrieve data from secondary storage for use in main memory.

Swap space
This is a space on the hard disk which is used by the operating system to store data pages that are currently not needed. This swap sapce can be a partition as well as swap file. Generally swap space is double of the RAM .

Amount of RAM in the system recommended amount of swap space
4GB of RAM or less  a minimum of 2GB of swap space
4GB to 16GB of RAM  a minimum of 4GB of swap space
16GB to 64GB of RAM  a minimum of 8GB of swap space
64GB to 256GB of RAM  a minimum of 16GB of swap space

256GB to 512GB of RAM  a minimum of 32GB of swap space

Wednesday, August 5, 2015

linux interview questions and answers part 2

1. What is ldd?
List dynamic dependencies – print shared library dependencies
Eg: – # vim new.c
# gcc new.c –o new
# ldd new

2. What is the command to uninstall processes in Linux?
rpm –e sendmail
-e – remove

3. What is the command for finding the highest memory occupied file in Linux?
du –ah / | sort –n –r | head –n 1
du – estimate file space usage
-a – write counts for all files, not just directories
-h – print sizes in human readable format (eg. 1K 234M 2G)
sort – sort lines of text files
-n – compare according to string numerical value
-r – reverse the result of comparisons
head – output the first part of files
-n – number of lines

4. What are the Linux boot files?
1./boot/grub/grub.conf: contains boot disk parameters
2./etc/fstab: contains File systems which need to mount at boot time
3./etc/initab: Contains default run level
4./etc/init.d/rc.d/rcN.d: This is a dir it contains

5. Difference between swap partition and swap file?
Swap partition is maintained as a separate partition. Same swap partition can be used for two OS within single machine.
Suppose if the system crashes, there is a chance to recover or it may not  corrupt the partition.
Less fragmented.
Where as swap file takes very less space. We can increase the space very easily, compared to swap partition. Swap file system fragmented.
If  the system crashes then there is a huge chance to lost the swap file system.

6. A file which is not deleted by normal user and also root (using rm), for that type of file how we delete it?
Using chattr command, we need to change the attributes and then we remove using rm command.
Eg: – chattr -iIu example
rm -rf example

7. Difference between nfs soft and hard mounting points?
Hard mount option: – If the client fails to access the server, then the connection hangs and once the system is up then it will again access the server.
Soft: – If the client failed to connect the server, it immediately gives the error report and closes the connection.

8. If we transfer 100 files by ftp to remote server, how to know the files are successfully transfer or some file are not transferred?
ftp>mput 1 2 3 …. 100
ftp> ls –l

9. I know ssh, telnet, dns,apache all are worked on TCP/UDP but i want to know any one service which are working on UDP only?
snmptrap 162/udp
snmptrap – simple network management protocol trap
snmptrapd is an SNMP application that receives and logs

10. I want to built a fire wall using iptables. My condition is ” inbound to 192.168.0.2 with a port of 80 from 172.168.0.1 should accept”
iptables –A INPUT –p tcp –dport 80 –s 172.168.0.1 –d 192.168.0.2 –j ACCEPT

11. I want to see how many interfaces (Ethernet cards) are working using single command?
ifconfig

12. What is the status code 403,404 represented in apache server?
403 represent forbidden error, means if a file misses some selinux security context.
404 represent that there is a cgi script missing or web pages missing.

13. How to monitor ports in a linux machine, with single command?
nmap localhost

14. In my linux machine, i lost /etc/passwd file and /etc/shadow file, then how can i recover it?
Normally in linux we must have backup by default for /etc/passwd and /etc/shadow files
/etc/passwd —> /etc/passwd-
/etc/shadow —> /etc/shadow-
from there we can copy or restore. If both are not available. Then follow below steps:
1. reboot
2. Single user mode [ single init=/bin/bash ]
3. pwconv
4. check /etc/passwd and /etc/shadow files are there
5. sync
6. init 3 or reboot with init 3

15. what r the different command to check ram,process and hdd of linux machine
To check ram in your system:
#free
To check process
#ps
#top
To check hdd
#fdisk
#sfdisk -l

16.If i run ls command it will show me the junk output what is problem and how to resolve it
Set your terminal setting by stty and before that, export ls command to PATH variable

17. WHAT IS THE MEANING OF AIX
AIX (Advanced Interactive eXecutive) is an open operating system from IBM which is based on a version of UNIX. AIX/ESA was designed for IBM’s System/390 or large server hardware platform. AIX/6000 is an operating system that runs on IBM’s workstation platform, the RISC System/6000.

18. Why ls -F dev/log file output indicate as = sign at end of the file name?
Standard output

19. What is nis server?
NIS is a service that provides any user on a network with the same working environment irrespective of the system on that network, which has been used for login purpose.
For example if NIS server is set up in a single system and configured to hold user accounts and their passwords and access information. Then any user on that network can login to his/her account from any system (with nis client running) on that configured network. This gives a look and feel that the user is logged into his/her own system. But actually it’s the account on the NIS server that is mounted on the local sytem user login.

20. What command can you use to review boot messages?

Dmesg

Tuesday, July 14, 2015

Linux Configuration Files and their explanations


Profile
System wide environment and startup script program.
/dev/MAKEDEV
The /dev/MAKEDEV file is a script written by the system administrator that creates local only device files or links such as device files for a non-standard device driver.
/etc/aliases
Where the user's name is matched to a nickname for e-mail.
/etc/bootptab
The configuration for the BOOTP server daemon.



/etc/crontab
Lists commands and times to run them for the cron deamon.
/etc/dhcpd.conf
The configuration file for the DHCP server daemon.
/etc/ethers
File for RARP mapping from hardware addresses to IP addresses. See the man page ethers(5).
/etc/exports
The file describing exported filesystems for NFS services.
/etc/fdprm
The floppy disk parameter table. Describes the formats of different floppy disks. Used by setfdprm.
/etc/filesystems
Can be used to set the filesystem probe order when filesystems are mounted with the auto option. The nodev parameter is specified for filesystems that are not really locally mounted systems such as proc, devpts, and nfs systems.
/etc/fstab
Lists the filesystems mounted automatically at startup by the mount -a command (in /etc/rc or equivalent startup file).
/etc/group
Similar to /etc/passwd but for groups rather than users.
/etc/groups
May contain passwords that let a user join a group.
/etc/gshadow
Used to hold the group password and group administrator password information for shadow passwords.
/etc/host.conf
Specifies how host names are resolved.
/etc/hosts
List hosts for name lookup use that are locally required.
/etc/HOSTNAME
Shows the host name of this host. Used for support of older programs since the hostname is stored in the /etc/sysconfig/network file.
/etc/inittab
Configuration file for init, controls startup run levels, determines scripts to start with.
/etc/inetd.conf
Sets up the services that run under the inetd daemon.
/etc/issue
Output by getty before the login prompt. Description or welcoming message.
/etc/issue.net
Output for network logins with LINUX version
/etc/ld.so.conf
Configuration file for ld.so, the run time linker.
/etc/lilo.conf
Configuration file for LILO.
/etc/limits
Limits users resources when a system has shadow passwords installed.
/etc/localtime
In Debian the system time zone is determined by this link.
/etc/login.defs
Sets user login features on systems with shadow passwords.
/etc/logrotate.conf
Configures the logrotate program used for managing logfiles.
/etc/magic
The configuration file for file types. Contains the descriptions of various file formats for the file command.
/etc/motd
The message of the day, automatically output by a successful login.
/etc/mtab
A list of currently mounted file systems. Setup by boot scripts and updated by the mount command.
/etc/named.conf
Used for domain name servers.
/etc/networks
Lists names and addresses of your own and other networks, used by the route command.
/etc/nologin
If this file exists, non-root logins are disabled. Typically it is created when the system is shutting down.
/etc/nsswitch.conf
Name service switch configuration file.
/etc/passwd
The user database with fields giving the username, real name, home directory, encrypted password and other information about each user.
/etc/printcap
A configuration file for printers.
/etc/profile, /etc/cshlogin,
/etc/csh/cshrc
Files executed at login or startup time by the Bourne or C shells. These allow the system administrator to set global defaults for all users.
/etc/protocols
Describes DARPA internet protocols available from the TCP/IP subsystem. Maps protocol ID numbers to protocol names.
/etc/rc or /etc/rc.d or /etc/rc?.d
Scripts or directories of scripts to run at startup or when changing run level.
/etc/rc.d/rc0.d
Contains files used to control run level 0. Usually these files are softlink files.
/etc/rc.d/rc1.d
Contains files to control run level 1. Scripts beginning with an S are for start, K for kill.
/etc/rc.d/rc.sysinit
Init runs this when it starts.
/etc/resolv.conf
Configures the name resolver, specifying the address of your name server and your domain name.
/etc/securetty
Identifies secure terminals from which root is allowed to log in.
/etc/services
Lists the network services that the system supports.
/etc/shadow
Shadow password file on systems with shadow password software installed. Shadow passwords move the encrypted password files from /etc/passwd to /etc/shadow which can only be read by root.
/etc/shadow.group
Systems with shadow passwords may have this file.
/etc/shells
Lists trusted shells. The chsh command allows users to change their login shell to shells listed only in this file.
/etc/skel/.profile
Can be used by administrator to set the editor environment variable to some editor that is friendly to new users.
/etc/sudoers
A list of users with special privileges along with the commands they can execute.
/etc/smb.conf
The configuration file for setting up Samba services.
/etc/sysconfig/amd
Used to configure the auto mount daemon.
/etc/sysconfig/clock
Used to configure the system clock to Universal or local time and set some other clock parameters.
/etc/sysconfig/i18n
Controls the system font settings.
/etc/sysconfig/init
This file is used to set some terminal characteristics and environment variables.
/etc/sysconfig/keyboard
Used to configure the keyboard.
/etc/sysconfig/mouse
This file is used to configure the mouse.
/etc/sysconfig/network-scripts/ifcfg-interface
Defines a network interface.
/etc/sysconfig/pcmcia
Used to configure pcmcia network cards.
/etc/sysconfig//routed
Sets up dynamic routing policies.
/etc/sysconfig/static-routes
Configures static routes on a network.
/etc/sysconfig/tape
Used for backup tape device configuration.
/etc/X11/XF86Config
The configuration file for the X server.
/etc/syslog.conf
Configuration file for the syslogd daemon.
/etc/termcap
The terminal capability database. Describes by what "escape sequences" various terminals can be controlled. See terminfo, termcap, curs_termcap man pages.
/etc/terminfo
Details for terminal I/O.
/etc/usertty
This file is used to impose special access restrictions on users.
$HOME/.bashrc
User aliases, path modifier, and functions.
$HOME/.bash_profile
Users environment stuff and startup programs.
$HOME/.bash_logout
User actions to be done at logout.
$HOME/.hushlogin
When this file exists in the user's home directory, it will prevent check for mail, printing of the last login time, and the message of the day when the user logs in.
$HOME/.inputrc
Contains keybindings and other bits.
$HOME/Xrootenv.0
Has networking and environment info.
/proc/cpuinfo
Information about the processor such as its type, make and performance.
/proc/devices
A list of devices configured into the currently running kernel.
/proc/dma
Shows which DMA channels are being used at the moment.
/proc/filesystems
Filesystems that are configured into the kernel. The file used to detect filesystems if the /etc/filesystems does not exist.
/proc/ioports
Shows which I/O ports are in use at the moment.
/proc/interrupts
Shows which interrupts are in use and how many of each there have been.
/proc/kcore
An image of the physical memory of the system.
/proc/kmsg
Messages output by the kernel. These are also routed to syslog.
/proc/ksyms
Symbol table for the kernel.
/proc/loadavg
The load average of the system.
/proc/meminfo
Information about memory usage, both physical and swap.
/proc/modules
Which kernel modules are currently loaded.
/proc/mounts
Contains information on filesystems currently mounted, similar to /etc/mtab
/proc/net
Contains status information about network protocols.
/proc/self
A symbolic link to the process directory of the program that is looking at /proc. When 2 process look at proc, they get different links.
/proc/stat
Various statistics about the system such as the number of page faults since the system was booted.
/proc/uptime
The time the system has been up.
/proc/version
The kernel version.
/tmp/fvwmrca01339
FVWM-M4 defines. Contains networking, Xwindows, other setup info.
/usr/lib/zoneinfo
Time zone datafiles are stored here on the Debian system
/var/log/lastlog
Used by finger to tell when a user was last logged in.
/var/log/wtmp
Binary info on users that have been logged on. The last command uses this info.
/var/run/utmp
Contains information about users currently logged in. Who and w commands use this file.
/var/named/root.hints
Used for domain name server. Placed here optionally, but this is the normal location.
/var/named/*
Files used by domain name server. Placed here optionally, but this is the normal location.
/var/log/btmp
Used to store information about failed logins. This file must be first created to activate it.
/var/log/lastlog
Contains information about the last time a login was done on the system. Works with lastb(1).
/var/log/maillog
The normal system mail log file.
/var/log/messages
The main system message log file.
var/log/secure
System tracking of user logins. Check this file periodically.
/var/spool/mail
Where mailboxes are usually stored.