Sunday, 5 July 2020

How many characters can a file name have?


101. How many characters can a file name have?

The maximum amount of characters that a file name in Linux may have is 255.

102. What is the similarity and difference between cron and anacron? Which one would you prefer to use?

Cron and Anacron are used to schedule the tasks in cron jobs. Both of these are the daemons that are used to schedule the execution of commands or tasks as per the information provided by the user.

Differences between cron and anacron:

cron works on the system that are running continuously that means it is designed for the system that is running24*7. While anacron is used for the systems that are not running continuously.

jobs can run every minute, but anacron jobs can be run only once a day.
Any normal user can do the scheduling of cron jobs, but the scheduling of anacron jobs can be done by the superuser only.

Cron should be used when you need to execute the job at a specific time as per the given time in cron, but anacron should be used in when there is no any restriction for the timing and can be executed at any time.

If we think about which one is ideal for servers or desktops, then cron should be used for servers while anacron should be used for desktops or laptops.

103. What are the default port numbers used for SMTP, FTP,DNS, DHCP, SSH?

Service      Port

SMTP 25
FTP         20 for data transfer and 21 for Connection established
DNS          53
DHCP 67 (UDP for DHCP server), 68  (UDP for DHCP client)
SSH         22

104. Explain file content commands along with the description.

There are many commands present in Linux which are used to look at the contents of the file.

head: to check the starting of a file.
tail: to check the ending of the file. It is the reverse of head command.
cat: used to view, create, concatenate the files.
rrep: used to find the specific pattern or string in a file.
more: used to display the text in the terminal window in pager form.
less: used to view the text in the backward direction and also provides single line movement.

105. Explain cd command in Linux?

In Linux, when a user needs to change the current directory then “cd” command is input in the shell.
Syntax: $cd

The purpose that can be fulfilled by the current command are –
Redirect to a new directory from the current directory.
Change a directory using absolute path and relative path.

The following commands are under the cd:
cd ~:  Redirect to home directory.
cd-:  Redirect to previous directory.
cd/: Redirect to entire system directory.

106. How will you check if the two files are hard-linked to each other?

# ls –i, check the inode numbers are same or not.

107. What is the command that displays the settings for all services and run-levels?

# chkconfig --list # This output shows SysV services only
# systemctl list-unit-files #list systemd services

108. What is the command to list the hidden files in your HOME directory?

# ls -la ~/

108. Explain system calls used for process management?

System call provides additional control over the system. Processes are the most basic unit on Linux System and process management need some system calls in Linux, some of them are:-

System calls Explanation

Fork         Creates a new process
Exec         Execute the program
Wait         Force process to wait
Exit         Exit/terminate the process
Clone Creates Child Process
Exit_Group Exit/terminate all threads in the process
Nice         Change the priority of the running process
Getppid Find parent ID of the process
Vfork Create Child Process and block parent

109. What is page frame?

A page frame is a block of RAM that is used for virtual memory. It has its page frame number. The size of a page frame may vary from system to system, and it is in the power of 2 in bytes. Also, it is the smallest length block of memory in which an operating system maps memory pages.

110. What is the difference between rm and rm –r?

The rm command is used to delete all the files while rm –r command is used to delete all the files in a directory and also in subdirectories.

For Example,

# rm file.txt: It will delete the file with name file.txt
# rm –r directory: It will remove directories and subdirectories and also their contents.

111. How can we edit a file without opening in Linux?

sed command is used to edit a file without opening. sed is the acronym for StreamEditor. The sed command is used to modify or change the contents of a file

For example, 

# cat test.txt
one six three four five

to replace the content of the file and we want to replace "six"  with “two”. So, we will use below command for this.

# sed 's/six/two/' test.txt > out.txt

# cat out.txt
one two three four five
So, "six" is replaced with "two" in the text.

112. What are shared, slave, private, and unbindable mountpoints?

A mount point that is shared may be replicated as many times as needed, and each copy will continue to be the exact same. Other mount points that appear under a shared mount point in some subdirectory will appear in all the other replicated mount points as it is.

A slave mount point is similar to a shared mount point with the small exception that the “sharing” of mount point information happens in one direction. A mount point that is slave will only receive mount and unmount events. Anything that is mounted under this replicated mount point will not move towards the original mount point.

A private mount point is exactly what the name implies: private. Mount points that appear under a private mount point will not be shown elsewhere in the other replicated mount points unless they are explicitly mounted there as well.

An unbindable mount point, which by definition is also private, cannot be replicated elsewhere through the use of the bind flag of the mount system call or command.

113. What are some basic measures that you would take to harden a server’s SSH service?

There are a some very simple steps that can be taken to initially harden the SSH service, such as:

Forcing the service to use only version 2 of the protocol will introduce both security and feature enhancement.

Disabling root login, and even password-based logins, will further reinforce the security of the server.

The whitelist approach can be taken, where only the users that belong to a certain list can login via SSH to the server.

Disabling password-based login will require you to then allow key based logins, which is secure, but can be taken further by restricting their use from only certain IP addresses.

Changing the port to something other than 22 significantly decreases random brute force attempts from the internet.

Sometimes the use of having an SSH service on a server may just be transferring files to and from the server (typically using tools like scp). In such a case, it is possible to change the shell of the user to something restrictive, such as rssh.

Finally it is often desirable to know exactly what is going on while you are not logged into the server. The logging verbosity may be increased if needed. Often, it is the logs that allow one to figure out if a key has indeed been stolen and is being abused.

114. What would be a simple way to continuously monitor the log file for a service that is running?

Probably the simplest and most common way to do this would be by using the command:
tail -f $LOGFILE

where $LOGFILE is an environment variable corresponding to the path to the log file to be monitored.
By default, the Linux tail command prints the last 10 lines of a given file to standard output. The -F option causes additional file content to be displayed in realtime as the file continues to grow. This yields a simple mechanism for monitoring services via their log files in close to realtime.

Two other specific command line options of interest in this context are:

The -s option causes tail to sleep for a specified number of seconds between updates (e.g., tail -F -s 10 will update the displayed file contents roughly every 10 seconds rather than in close to realtime as the file is updated).

The -n option can be used to specify a number of lines other than 10 to initially display (e.g., tail -n 20 -F will first display the last 20 lines of the file and will then continue updating the output in realtime).

115. How to check the default route and routing table?

To display the default route and routing table, we use the following commands.

$ route -n
 
$ netstat -rn
 
$ ip

116. How to check which ports are listening in my Linux Server?

To check which ports are in listening in Linux Server, 

# netstat --listen
# netstat -l

117. What are the different modes of Network bonding in Linux?

Mode-0(balance-rr): It is a default mode and based on Round-Robin policy. It offers fault tolerance and load balancing features. It used round-robin fashion to transmit the packets.

Mode-1(active-backup): It is based on Active Backup policy and only one slave will act in the band and another one will act when the others fail in the band. It also provides fault tolerance.

Mode-2(balance-xor): It sets a xor mode between the source Mac address and destination Mac address to provide fault tolerance.

Mode-3(broadcast): It is based on broadcast policy and transmitted everything in the slave interface. It also provides fault tolerance and it can be used only for a particular purpose.

Mode-4(802.3ad): It is a dynamic aggregation mode, it created aggregation groups which is having the same speed. It uses transmit hashing method to select the slaves for outgoing traffic.

Mode-5(balance-tlb): The outgoing traffic is according to the current load on the slave, and the incoming traffic is received by the slave. It is called an adaptive transmit load balancing mode. 

Mode-6(balance-alb): It is an adaptive load balancing mode. It does not require any switch support. 

118. Why we use LINUX? 

We are some many reasons, in that few important reasons are listed out. Following are

High Stability: It is very stable and does not lead to crashes, it runs fastly as it is when it installed first. 

Security: It is a dependable server, that offers high security to the user. Using Linux on your system it is easy to avoid virus and malware. The attacker cannot change any changes in the system until the user logged in at as root user.

Easy to Operate: Linux is easy to operate and we can install easily on to the system because all the variants of the Linux have there owned software repositories. You can update the system periodically with just a few clicks or you can set automatic updation.

Hardware Compatibility: Linux can use on any hardware, it doesn’t have any hardware restrictions. It uses efficiently all system resources.

Open Source: The source code is available as it is under Free and Open Source Software(FOSS).
119. Why is Linux considered more secure than other operating systems?

Linux is an open-source operating system, nowadays it is rapidly growing in the technology market. A few reasons why Linux is more secure than other OS.

The perk of accounts: Linux allows only a few users to access the system. Thus, the virus cannot attack the whole system, it may cause only a few files in the system. 

Strong Community: Linux users first accomplished the files before they open. So they can save their systems from vulnerabilities. 

Iptables: Iptables used by the Linux because it checks the security circle of the system. 

Different Working Environment: Linux system has different working environments like Linux Mint, Debian, Arch and many more, these working environments protect from the virus.

Recording in Linux: It maintains log history because later it can view the details of the system files easily. 

Few User: Linux users are less compared to others, due to this security will be more.

120. How can you setup Password Aging?

In Linux, the system administrators use chage command to apply password ageing. This command is used to modify the number of days among resets of a mandatory password. 
The /etc/login.defs file is accountable for managing the configuration in the system. It can be edited for:
PASS_MIN_DAYS – States the minimum days allowed between password reset.
PASS_MAX_DAYS – States the maximum days to use a password.
PASS_WARN_AGE – States the days to give warning before a password expires.

121. Name some troubleshooting and Linux networking commands?

All computers are linked to network externally or internally for the aim of information exchange. Network configuration and troubleshooting are some of the essential elements of network administration. The networking commands allow you to rapidly troubleshoot issues related to the connection with another system; check another host response, etc.

A network administrator upholds network of a system including network troubleshooting and configuration. Some commands with their description are mentioned below:

Hostname: This command is used to view the machine hostname (IP address and domain) and for hostname setting.

ifconfig: used to manipulate and display network and route interfaces. It shows the configuration of the network. ‘IP’ is the ifconfig command replacement.

Traceroute: It is a utility of network troubleshooting, used to find the hops needed for a packet for accessing the destination.

Dig:  used for DNS name servers query for any job related to the DNS lookup.

Route: It displays the route table details and operates the IP routing table.

Ifplugstatus: it tells if the network cable is plugged in or not.

Ping: this command is used to identify if the remote server is accessible or not.

netstat: It shows network links, interface statistics, routing tables. ‘ss’ is the netstat command replacement, used to get more data.

Tracepath: It like a traceroute with a change that it does not need root rights.

nslookup: This command is used to find query related to DNS.

mtr: it combines track path and ping into a single command.

122. What is the device tree concept?

Device tree is a data structure which is used to remove the repetitive codes in different boards. They are loaded in the memory with the help of bootloader to a binary file. Here the kernel is used to settle the structure of the device tree on the binary.

123. How can we reduce the size of the kernel?

There are codes which are unnecessary and are not executed, we can find and disable them to make the processing faster in the project. The kernel comes with an editor known as “kernel’s configuration editor” by which we can remove and disable chunks of code that are not required.

There may be the codes for which the hardware is not present in the system and you have to make your system understand about what are your system’s requirements. Below are some guiding principles by which you can find the codes to be removed.

Hardware Networking Drivers: Several of system-on-chips have Wi-Fi drivers, serial and other hardware that are not used, you can remove those drivers that are built on the kernel.

File Systems: The system has the only requirement of few file systems but in the kernel you will find many file systems drivers that are not in use e.g. Devices which make use of flash file systems do not require ext2 or ext3 file system so they can be removed. Be cautious that do not remove the file systems that are essential or you may have the use of the systems in the future.

Debugging and Profiling: All the systems which come under kernel hacking entry could be disabled if not in use.

124. Explain the command and method to change the file permissions in Linux?

chmod command is used to change the permissions of a file. There are three parts to consider to set the file permissions.

User (or Owner)
Group
Other

3 types of file permission that is given to a file.

r – Reading permission
w – Writing permission
x – Execution permission

For example, chmod 751 filename
Then, three number 751 describes permissions given to the user, group and other in the order. Each number is the sum of the values,i.e. 4 for reading, 2 for write, 1 for execute.
Here 751 is the combination of (4+2+1), (4+0+1), (0+0+1).

So, chmod 751 filename will provide read, write and execute permission to the owner; read and execute permission to the group and only execute permission to the others.

125. Where is the target path of a symlink stored? How are permission settings for symlinks handled?

The target path of a symlink is stored in an inode - the data structure used to store file information on disk.

Typically, the permission settings of the symlink itself only control the renaming and removal operations performed on the symlink itself. Any operation that deals with the contents of the file linked to are controlled by the permission settings of the target file.

                                                                                           MENU         PREVIOUS | NEXT

No comments:

Post a comment