Saturday 10 November 2018

Linux FTP (vsftpd) Interview Questions & Answers

In Linux operating system  vsftpd Very Secure FTP Daemon) is used for downloading and uploading files to the ftp space.



2) What are the defaults ports used in linux ftp server ?


Port 20 – This is the data transfer port. All the all subsequent data transfers between the client and server are done using this port.
Port 21 – On this port control connection is established. All commands we send and the ftp server’s responses to those commands will go over the control connection, but any data sent back (such as “ls” directory lists or actual file data in either direction) will go over the data connection.

3) What are most common features of vsftpd ?


Some of the Common Features are listed below :
1.  Virtual IP configurations
2.  Virtual users
3.  Standalone or inetd operation
4.  Powerful per-user configurability
5.  Bandwidth throttling
6.  Per-source-IP configurability
7.  Per-source-IP limits
8.  IPv6
9.  Encryption support through SSL integration

4) What is the configuration file of vsftpd ?


 ‘/etc/vsftp/vsftpd.conf’

5) How to restart the service of ftp server in linux ?


 Service vsftpd restart or /etc/init.d/vsftpd restart

6) Which Users tare not allowed to login via ftp ?


Users mentioned in the file ‘/etc/vsftpd/ftpusers’ are not allowed to login via ftp.

7) How to disable standard ftpd xferlog log format and enable default vsftpd log ?

Edit the file ‘ /etc/vsftpd/vsftpd.conf’ & make the below changes:
§  xferlog_std_format=NO
§  log_ftp_protocol=YES
The default vsftpd log file is /var/log/vsftpd.log

8) What is default directory for ftp / Anonymous user ?


‘/var/ftp’ is the default directory for ftp or Anonymous user

9) How to change the default directory for ftp / Anonymous user ?

Edit the file ‘/etc/vsftpd/vsftpd.conf’ and change the below directive :
§  anon_root=/<Path-of-New-Directory>
After making above change either restart or reload vsftpd service.

10) How to disable Anonymous user in vsftpd ?


Edit the conf file ‘/etc/vsftpd/vsftpd.conf’ and change below directive and restart the ftp service.
§  anonymous_enable=NO

11) What is chroot environment in ftp server ?


Chroot environment prevents the user from leaving its home directory means jail like environment where users are limited to their home directory only. It is the addon security of ftp server.

12) How to enable chroot environment in vsftpd server ?


To enable chroot environment edit the file ‘/etc/vsftpd/vsftpd.conf’ and enable the below directives :
§  chroot_list_enable=YES
§  chroot_list_file=/etc/vsftpd.chroot_list
The chroot_list_file variable specifies the file which contains users that are chroot.

13) How to enable only limited/allowed users are able to login via ftp ?

This can be done by editing the file ‘/etc/vsftpd/vsftpd.conf’ and add the below directives :
userlist_enable=YES
1.       userlist_file=/etc/vsftpd.user_list
2.      userlist_deny=NO
The file specified by userlist_file will now contain users that are able to login.

14) How to set ftp banner in linux ?


Open the file ‘/etc/vsftpd/vsftpd.conf’ and set the below directive :
§  ftpd_banner= “Enter New Banner Here”

15) How To limit the data transfer rate, number of clients & connections per IP for local users ? 


Edit the ftp server’s config file(/etc/vsftpd/vsftpd.conf) and set the below directives :
§  local_max_rate=1000000 # Maximum data transfer rate in bytes per second
§  max_clients=50 # Maximum number of clients that may be connected
§  max_per_ip=2 # Maximum connections per IP

Saturday 18 August 2018

Best Laptops of 2018 for Linux


There was a time, not so long ago, when Linux was seen as an outcast operating system and indeed one that was labeled as a ‘cancer’ by Microsoft’s former CEO Steve Ballmer. Times have now changed as the operating system - which launched in September 1991, has made some serious inroads in the server market, then in the cloud – not forgetting that it underpins the most popular ecosystem out there: Android on smartphones.
Because none of the main notebook vendors – bar Dell – offer Linux as an OS option, this leaves other smaller companies the ability to carve a niche for themselves.
Below are the five best Linux laptops of 2018 I have picked out using  expert eye – note that they have been fine-tuned to run a specific flavor of Linux (such as Ubuntu, for example).

1. Dell XPS 13 Developer Edition
Ideal for those looking for a sleek-and-chic portable

Gorgeous design
Plenty of connectivity options
Poor webcam positioning
Little hardware customization
The XPS 13 retains its crown as the undisputed champion of the Ultrabook market, and one can only admire Dell for its unwavering Linux support on a flagship machine.
The laptop is customize able you can configure it to be suitable for everything from routine office tasks to gaming, depending on how much you’re willing to pay.
If you wish, you can plump for the most expensive XPS 13, which has a 4K (3,840 x 2,160) InfinityEdge touchscreen. The slightly more wallet-friendly configuration runs with a Full HD (1,920 x 1,080) 13.3-inch InfinityEdge non-touch display. It’s also worth bearing in mind that the higher-res screen will tax the GPU and CPU more, and may affect battery life adversely.
As this is touted as a 'Developer' edition, it's surprising there aren't more customization options. The basic model - which costs $1049.99 at the time of writing - comes with 4GB of RAM and a 128GB SSD, and cannot be upgraded during checkout. 
The more expensive version allows you to choose between the default 512GB SSD or to pay extra for a 1TB solid-state drive. All models come preinstalled with Ubuntu 16.04 LTS and 8th-generation Intel CPUs.

2. System76 Serval WS
A powerhouse of a laptop, but a hefty beast

Desktop CPU
Up to 64GB system RAM
Hefty price
System76's Serval WS is the ultimate powerhouse of laptops. Available with a 15-inch or 17-inch display, it incorporates an 8th generation Intel Core i7 CPU which is usually found in desktop machines.
The Serval WS is highly customizable incorporating up to 64GB of system RAM and up to 12TB of storage. Buyers are also offered a variety of Nvidia GeForce GTX 10-series GPUs, and gamers will further appreciate the choice of either a Full HD or 4K display.
It's clear that a lot of thought and care has gone into the design of the Serval WS, given that each key on the keyboard comes with its own multi-colour backlight. The laptop, like all System76 models, comes preinstalled either with the firm’s own custom POP!_OS or Ubuntu Linux.
This notebook also offers impressive connectivity chops with both USB 3.1 Type-C and Type-A ports (the exact number of ports varies by model). One thing to be aware of is that this laptop is a fairly hefty beast, with the basic 15-inch model weighing 3.4kg and the 17-inch version tipping the scales at 4.17kg.
This heftiness is matched only by the weighty price tag: the base 15-inch model is equipped with a GTX1060 and a relatively basic 8GB of RAM and a 250GB SSD for storage, but costs an eye-watering $1,989 (around £1,515, AU$2,695).
3. Purism Librem 13
Great for privacy fanatics

Designed to be ultra-secure
Upgrade option to three-year warranty
Rather expensive
Purism embarked upon a quest to build the most secure laptop ever and (obviously) chose Linux (PureOS) to power the device – it is the only notebook vendor on the market to offer physical kill switches as standard on its laptops.
Instead of going mainstream, the company tapped into the crowd funding community to gain more than $430,000 (around £300,000, AU$550,000) worth of funding, allowing it to adopt a stricter ethos than most firms when it comes to privacy, rights to free software and security.
The Librem 13 might look and feel like a bog-standard laptop but there's far more to it than meets the eye (for example, the company designed its own motherboards).
In addition, Purism’s commitment to Linux (and security in general) certainly goes beyond most of the vendors on this list.
4. System76 Oryx Pro
A highly configurable notebook with plenty of potential

Choice of 15.6 or 17.3-inch display
Nicely configurable
Can be very expensive
The Oryx Pro was built for Linux and indeed currently offers a choice of either Ubuntu 16.04 or System76’s own Ubuntu-based Pop!_OS 17.10 on purchase.

The chassis is made from lightweight aluminum with a matte black finish and you even have a choice of display size (15.6 or 17.3-inch). Graphics are provided by GeForce GTX 10 series GPUs and the Oryx packs an Intel Core i7 quad-core processor (with Turbo to 3.8GHz) into its thin frame.
The online store encourages you to customize the Oryx to suit your needs. By default you get 8GB of RAM and a 250GB SSD, but you can pay extra to upgrade to 64GB of system memory with a 2TB SSD if you wish – although the top-end configurations get very expensive here.
You can also choose between Nvidia’s GTX 1060 and GTX 1070 when it comes to the GPU, and it’s possible to add extra drives, or purchase a laptop bag designed to carry and protect your machine. The warranty of the notebook can be extended to provide coverage for three years.
5. System76 Galago Pro
Looking for the ultimate Linux powerhouse?

Extraordinary expansion capabilities
Matte Full HD display as default
A cheaper Full HD version should be offered
On paper, the Galago Pro from System76 is an absolute beast of a machine, and yet it weighs less than most laptops which also have a 13-inch screen. This is a notebook that rivals the Dell XPS 13 Developer Edition, featuring an aluminum chassis, and managing to make space for up to 32GB of RAM (yes, 32GB).

The Galago Pro has two hard drive bays. The 'OS Drive' in the first bay is a 120GB SSD by default but can be specified at up to 2TB when you order. You can also choose to install a second SSD in the other bay of up to 4TB capacity.
If that wasn’t enough, it has a 13.3-inch display with a resolution of 3,200 x 1,800, an Ethernet port, an SD card reader, two USB ports and a Thunderbolt 3/USB Type-C/mini-DisplayPort connector. In a nutshell, you will be hard pressed to get anything in Windows-land that can deliver this sort of compute power and storage capacity.

Thursday 16 August 2018

Linux Based Data Recovery Tools


Data Recovery on Linux Systems
If you are looking for tools to help you recover data on a Linux system, there are plenty to be had. This post offers you a look into what is available for admins to use ─ from full-blown disk recovery suites to individual tools.
Data is the crucial bit in our personal and professional existence. Without data we would be lost in a vast expanse of nothingness. Spreadsheets, email, documents, contacts, databases, files, folders … the list goes on and on. In a perfect world, every byte of local storage would be backed up to an external hard drive or cloud storage service.
See also:




Sometimes data has to be recovered. When that tragedy strikes, it’s good to know you have the tools on hand to get the job done. Thankfully, Linux is no stranger to data recovery. In fact, there are a number of solid tools you can use to get back lost data. I want to introduce you to a few tools that do a great job of recovering data.
As with any instance of recovering lost data ─ nothing is perfect. You can try any of the various tools available only to find the data simply not recoverable. That is the nature of the digital age. To that end, always make sure you have a solid, recent backup available in the event your system goes down hard.

System Rescue CD


Let’s first start with tools to help you recover data from a downed machine (say a machine with file system or partition issues). These tend to be the easiest to work with as they are all-inclusive tools. My favorite of these tools is SystemRescueCD. This particular rescue CD supports most of the known partition formats and includes all the tools you need to recover data (including sfdisk, Gparted, TestDisk, PhotoRec, FSArchiver, and much more) and includes plenty of tools to work with.

Like most rescue disks, SystemRescueCD works by booting your system from either the CD or USB drive and then uses the tools to work with your file system. Unlike a lot of other rescue tools of this nature, SystemRescueCD offers a full-blown graphical environment to aid you in the task of recovering data.
If you are rescuing data from one machine to another, you will need to attach an external hard drive to the system in order to move the rescued data (or you can use the built-in Samba support and copy data to a networked location). If the idea is to recover or repair a partition table, I strongly suggest copying sensitive data over over anyway ─ on the chance the partition table or file system is further damaged.
There are other rescue systems available that are similar in both intent and style as SystemRescueCD. Each has its pros and cons but, in the end, will get the job done. Some of my favorite Linux data/system recovery distributions include:
·         Trinity Rescue Kit
·         Knoppix
·         Ultimate Boot CD.

Individual rescue tools

Once you get beyond a full-blown distribution, you start looking at purpose-driven tools geared toward recovering data. Linux has just about any tool you need for this task. Let’s take a look at some of them.
Ddrescue
If you’re looking for the command line tool that will copy data from one file or block device to another, it’s Ddrescue that you need. There are a few things you should know about using the Ddrescue:
·         Never use this tool on a read/write mounted drive or partition.
·         Do not try to repair a file system with I/O errors.
·         Destination will be overwritten ─ so make sure destination is free of important data.
This tool is great for recovering data from a failing drive to an external source. You would first need to install the tool on your working system, attach both the failing drive and a destination drive, via USB, and use the tool to extract the necessary data.
Installing the tool on an Ubuntu system can be done with a single command:
sudo apt-get install gddrescue
The command structure of Ddrescue is:
ddrescue [options] infile outfile [logfile]
Let’s use Ddrescue to copy a partition from drive /dev/sdg to drive /dev/sdb. The command (run on a system that works with sudo) would look like:
sudo ddrescue /dev/sdg /dev/sdb
The above command would copy everything from the failing source to the healthy target. Data recovered!
Testdisk
This particular data recovery tool doesn’t actually try to copy data. Instead it attempts to correct partition-level issues that might be preventing you from accessing or recovering your data. Testdisk can:
·         Recover lost partitions
·         Make disks bootable again
·         Fix a partition table
·         Restore the master boot record
·         Restore boot sectors
·         Restore filesystem tables
·         Undelete files from NTFS, FAT, exFAT, and ext2 filesystems
·         Copy files from deleted NTFS, FAT, exFAT, and ext2/3/4 filesystems.
Testdisk is an ncurses tool that runs within a terminal.
To install Testdisk on an Ubuntu system, issue the command:
sudo apt-get install testdisk
Run the tool with sudo testdisk and walk through the easy-to-use wizard for working with your externally attached drive.
Photorec
If you’re looking to recover lost files, photos, videos, etc. Photorec is what you want. This tool is part of Testdisk, so once you’ve installed Testdisk, Photorec is ready to serve. This particular tool completely ignores the file system and looks directly at the underlying data. This means, if your file system is damaged, there’s a chance the data can still be recovered.
To start Photorec, issue the command:
sudo photorec
The interface for Photorec is similar to that of Testdisk. As Photorec works, it will display, in real time, what types of files it has recovered.
You do want to make sure the destination partition has enough space to contain the rescued data (you can copy the data to internal storage or external storage).

Wednesday 15 August 2018

Linux Operating System Job Interview Questions Part 3





Top Job Interview Questions for Linux Professionals






See also:

Linux Interview Questions Part 1

Linux Interview Questions Part 2

Threat modeling for Penetration Testers Kali Linux

36) What are environmental variables?
Environmental variables are global settings that control the shell's function as well as that of other Linux programs. Another common term for environmental variables is global shell variables.

37) What are the different modes when using vi editor?
There are 3 modes under vi:- Command mode – this is the mode where you start in- Edit mode – this is the mode that allows you to do text editing- Ex mode – this is the mode wherein you interact with vi with instructions to process a file

38) Is it possible to use shortcuts for a long pathname?
Yes, there is. A feature known as filename expansion allows you do this using the TAB key. For example, if you have a path named /home/iceman/assignments directory, you would type as follows: /ho[tab]/ice[tab]/assi[tab] . This, however, assumes that the path is unique and that the shell you're using supports this feature.

39) What is redirection?
Redirection is the process of directing data from one output to another. It can also be used to direct an output as an input to another process.

40) What is grep command?
grep a search command that makes use of pattern-based searching. It makes use of options and parameters that are specified along with the command line and applies this pattern in searching the required file output.

41) What could be the problem when a command that was issued gave a different result from the last time it was used?
One highly possible reason for getting different results from what seems to be the same command has something to do with case sensitivity issues. Since Linux is case sensitive, a command that was previously used might have been entered in a different format from the present one. For example, to lists all files in the directory, you should type the command ls, and not LS. Typing LS will either result in an error message if there is no program by that exact name exist or may produce a different output if there is a program named LS that performs another function.

42) What are the contents of /usr/local?
It contains locally installed files. This directory matters in environments where files are stored on the network. Specifically, locally-installed files go to /usr/local/bin, /usr/local/lib, etc.). Another application of this directory is that it is used for software packages installed from source, or software not officially shipped with the distribution.

43) How do you terminate an ongoing process?

Every process in the system is identified by a unique process id or pid. Use the kill command followed by the pid to terminate that process. To terminate all process at once, use kill 0.

44) How do you insert comments in the command line prompt?
Comments are created by typing the # symbol before the actual comment text. This tells the shell to completely ignore what follows. For example "# This is just a comment that the shell will ignore."

45) What is command grouping and how does it work?
You can use parentheses to group commands. For example, if you want to send the current date and time along with the contents of a file named OUTPUT to a second file named MYDATES, you can apply command grouping as follows: (date cat OUTPUT) > MYDATES

46) How do you execute more than one command or program from a single command line entry?
You can combine several commands by separating each command or program using a semicolon symbol. For example, you can issue such a series of commands in a single entry:
ls –l cd .. ls –a MYWORK which is equivalent to 3 commands: ls -l cd.. ls -a MYWORK
**Note that this will be executed one after the other, in the order specified.

47) Write a command that will look for files with an extension "c", and has the occurrence of the string "apple" in it.
Answer:
 Find ./ -name "*.c" | xargs grep –i "apple"
48) Write a command that will display all .txt files, including its individual permission.
Answer:
ls -al *.txt

49) Write a command that will do the following:
-look for all files in the current and subsequent directories with an extension c,v
-strip the,v from the result (you can use sed command)
-use the result and use a grep command to search for all occurrences of the word ORANGE in the files.
Find ./ -name "*.c,v" | sed 's/,v//g' | xargs grep "ORANGE"

50) What, if anything, is wrong with each of the following commands?
a) ls -l-s
b) cat file1, file2
c) ls - s Factdir
Answers:
a) there should be space between the 2 options: ls -l -s
b) do not use commas to separate arguments: cat file1 file2
c) there should be no space between hyphen and option label: ls –s Factdir


51) What is the command to calculate the size of a folder?
To calculate the size of a folder uses the command du –sh folder1.

52) How can you find the status of a process?
Use the command
ps ux

53) How can you check the memory status?
You can use the command
free -m to display output in MB
free -g to display output in GB

54) Explain how to color the Git console?
To color the Git console, you can use the command git config—global color.ui auto. In the command, the color.ui variable sets the default value for a variable such as color.diff and color.grep.

55) How can you append one file to another in Linux?
To append one file to another in Linux you can use command cat file2 >> file 1. The operator >> appends the output of the named file or creates the file if it is not created. While another command cat file 1 file 2 > file 3 appends two or more files to one.

56) Explain how you can find a file using Terminal?
To find a file you have to use a command, find . –name "process.txt" . It will look for the current directory for a file called process.txt.

57) Explain how you can create a folder using Terminal?
To create a folder, you have to use command mkdir. It will be something like these: ~$ mkdir LinuxOS

58) Explain how you can view the text file using Terminal?
To view the text file, go to the specific folder where the text files are located by using the command cd and then type less filename.txt.

59) Explain how to enable curl on Ubuntu LAMP stack?
To enable curl on Ubuntu, first, install libcurl, once done use following command sudo/etc/init .d /apache2 restart or sudo service apache2 restart.

60) Explain how to enable root logging in Ubuntu?
The command which enables root logging is
#sudo sh-c 'echo "greater-show-manual-login=true" >>/etc/lightdm/lightdm.conf'

61) How can you run a Linux program in the background simultaneously when you start your Linux Server?
By using nohup. It will stop the process receiving the NOHUP signal and thus terminating it you log out of the program which was invoked with. & runs the process in the background.