Saturday, December 10, 2016

Linux Interview Question - Basic Linux 1

Q : What is the difference between service and process?

A process is any piece of software that is running on a computer. For example, your anti-virus software runs in the background as a process, which was automatically started when the computer booted. Some processes start when your computer boots, others are started manually when needed.

Some processes are services that publish methods to access them, so other programs can call them as needed. Printing services would be an example of a service type of process, where your email program can just call the print services process to say it wants to print, and the service does the actual work.

Q : How to view crond status? If it’s show service is not found.
Service crond restart
Q. How to FTP user access other directory except his own home directory?
vim /etc/vsftpd/vsftpd.conf
Chroot_list_enable=yes
Q. What are the Linux-based security tools?
Selinux
Firewall
iptables
Tcp-wrappers

Q. What are the basic elements of firewall?
A firewall should be able to filter packets (drop/pass them) based on certain rules specified by the user. The rules may be used to identify an incoming packet to the computer or outgoing packet from the computer, it can be based on target port number/ip add , traffic from a particular Network card etc…
The firewall rules can be in a tabular form (saved on the disk) from where the firewall software can read them and implement it. iptables firewall on Linux is a great example
Q. What is a command to display top 10 users who are using huge space?
du -sh /home/* | sort -r | head -10

Q. How do find all failed login attempts via ssh?
tail -f /var/log/secure | grep Failed

Q. How do you configure Linux system as a router?
vim /etc/sysctl.conf
net.ipv4.ip_forward=1
system-config-network
eth0 192.168.1.120 eth0:1 172.24.0.1
255.255.255.0 255.255.0.0
172.24.0.1 192.168.1.120

Q. What is the UID and GID of root user? Can a normal user can change the ownership of a file? What is the command to change ownership of a file?      
The root UID/GID is 0 (zero). Which is why he can able to intervene in all normal users files even though he don’t had permission. A normal user will don’t have the permission to change ownership of file. The command to change ownership is < chown user.user file >
  
Q. What is the diff b/w ext2 and ext3?
Ext3 is a tiny bit slower than ext2 is, but it holds tremendous advantages. There is really only one difference between ext2 and ext3, and that is that ext3 uses a journal to prevent filesystem corruption in the case of an unclean shutdown (ie. before the filesystem is synced to disk). That makes ext3 a bit slower than ext2 since all metadata changes are written to the journal, and then flushed to disk, but on the other hand you don’t risk having the entire filesystem destroyed at power failure or if an unwitted person turns the computer off uncleanly. You don’t have to check the filesystem after an unclean shutdown either. Ext3 has three levels of journalling. Metadata (ie. internal filesystem structures) are always journalled, so that the filesystem itself is never corrupted. How ordinary data is written to the file system is controllable, though. The default option is the “ordered” mode, which causes file contents to be written to the filesystem before metadata is even committed to the journal. The highest reliable mode is called the “journal” mode, which causes file data to be committed to the journal before it is flushed to its final place, like the metadata. The least reliable mode, but rumoured to be the fastest, is called the “writeback” mode, which makes no promises at all regarding the consistency of file data. Only metadata is output reliably in writeback mode. So as for anything else, it’s mainly a matter of priority. If you don’t want ultimate speed, go with ext3. If you need the highest speed that is theoratically aquirable though, then go with ext2. For that to be effective you’ll probably need a really advanced hard drive controller, though.
Q. As the system administrator you need to review Bob’s cronjobs. What command would you use?
crontab –lu Bob

Q. What command is used to remove the password assigned to a group?
gpasswd –r groupname

Q. What are the different RAID levels?
 RAID level 0
 RAID level 1
 RAID level 2
 RAID level 3
 RAID level 4
 RAID level 5
 RAID level 6
 RAID level 10
 RAID level 50

Q. How do you create a swapfile?
dd if=/dev/zero of=/swapfile bs=1024 count=200M
mkswap /swapfile
swapon /swapfile


Q. What does nslookup do?
Nslookup is a program used to find information about internet Domain Name server.
The two modes of nslookup are: Interactive and non-interactive.
Using ‘interactive mode’ user can query the name servers for the information pertaining to hosts and domains.
Using ‘non-interactive mode’ the user can just print the name and requested information of a host.

Q. What is the difference between UDP and TCP?
TCP is a Transmission Control Protocol.
UDP is a User Datagram Protocol.
There are four major differences between UDP and TCP:

1. TCP can establish a Connection and UDP cannot.
2. TCP provides a stream of unlimited length, UDP sends Small packets.
3.TCP gurantees that as long as you have a connection data sent will arrive at the destination, UDP provides not guarantee delivery.
4.UDP is faster for sending small amounts of data since no connection setup is required, the data can be sent in less time then it takes for TCP to establish a connection.

Q. What command do you run to check file system consistency?
Need to run fsck [file system consistency check] command to check file system consistency and repair a Linux / UNIX file system.
Fsck

Q. What is the command to remove Lvm ,Pv and vg
1st remove the entry on /etc/fstab file & save – quit.
2nd remove LVM – lvremove lvname
3rd remove VG – vgremove vgname
4th remove PV – pvremove pvname

Q. How to create SAMBA server in fedora 9 Linux?
yum install samba -y
yum install samba-swat –y
vi /etc/samba/smb.conf

comment = windows sharing
path = path/your/share/directory
valid users = surendra
writable = yes
browseable = yes

then type testparm for code testing.

smbpasswd -a username
smbpasswd -e username

service smb restart
chkconfig smb on

Q. How to schedule cron backup to run on 4th Saturday of month?
* * * * 6 weekdaynum 4 && sh /backup/test.sh

Q. What is an inode?
ext2 and ext3 file systems keep a list of the files they contain in a table called an inode table. The inode is referenced by its number. This is unique within a file system.

The inode contains the metadata about files. Among the data stored in the inode is

File type
File permissions
Link count

User ID number of the file owner and the group ID number of the associated group

Last modification time
Location of the data on the hard disk
Other metadata about the file
ls -li – view inode number only
stat /etc/passwd – view inode details

Q. How to see unallocated hard disk space on linux
df -h

Q. How do u find remote machine operating system and version?
nmap -A –v 192.168.1.100

Q. How do you port scanning with netstat command?
netstat –an

Q. Linux system monitoring Tools?

top – Process Activity Command
vmstat – System Activity, Hardware and System Information
w – Find out Who Is Logged on And What They Are Doing
Uptime – Tell How Long the System Has Been Running
ps – Displays the Processes
free – Memory Usage
iostat – Average CPU Load, Disk Activity
sar – Collect and Report System Activity
mpstat – Multiprocessor Usage
pmap – Process Memory Usage

Q. Linux Network monitoring Tools?

netstat and ss – Network Statistics
iptraf – Real-time Network Statistics
tcpdump – Detailed Network Traffic Analysis
strace – System Calls

/Proc file system – Various Kernel Statistics
# cat /proc/cpuinfo
# cat /proc/meminfo
# cat /proc/zoneinfo
# cat /proc/mounts

Nagios – Server And Network Monitoring
Cacti – Web-based Monitoring Tool
Gnome System Monitor – Real-time Systems Reporting and Graphing

Q. What is mean by system calls?
A system call is the mechanism used by an application program to request service from the operating system.
On Unix-based and POSIX-based systems, popular system calls are open, read, write, close, wait, exec, fork, exit, and kill. Many of today’s operating systems have hundreds of system calls. For example, Linux has 319 different system calls. FreeBSD has about the same (almost 330). Tools such as strace and truss report the system calls made by a running process.

Q. How do u extract files from iso cd images in linux?
mount –o loop disk1.iso /mnt/iso

Q. What is Clustering?
Clustering means it is a group of two or more server running same application and fault tolerance it is called Clustering.


No comments:

Post a Comment