FREQUENTLY ASKED INTERVIEW QUESTIONS

Subh Singh
Invent the Future

In Linux, the setenforce command is used to change the SELinux mode. It means the user can use this command to change SELinux from Enforcing mode to Permissive mode. In Permissive mode, SELinux does not enforce security rules, but it records policy violations.

Command:

sudo setenforce 0

Example:

If you want to change the SELinux mode to Permissive in Linux, you can use the following command.

sudo setenforce 0

Output:

[user@localhost ~]$

Here:

  • setenforce 0 changes SELinux to Permissive mode.
  • Permissive mode allows actions but records policy violations.

How to use:

  • Open the Linux terminal.
  • Type the command.
  • Press Enter to run the command.
Subh Singh
Invent the Future

The file is /etc/selinux/config, which is used to configure SELinux in Linux. It helps you set the SELinux mode.

File:

/etc/selinux/config

Example:

If you want to check the SELinux settings in Linux, you can use the following command.

cat /etc/selinux/config

Output:

SELINUX=enforcing
SELINUXTYPE=targeted

Here:

You can use the /etc/selinux/config file to set the SELinux mode in Linux.

  • enforcing follows SELinux security rules.
  • permissive records rule breaks but does not stop actions.
  • disabled turns off SELinux.
Subh Singh
Invent the Future

In Linux, the hostname command is used to show or change the computer's name.

Command:

hostname

Example:

If you want to see your computer's name in Linux, you can use the following command.

hostname

Output:

localhost.localdomain

Here:

  • The output shows the computer's name.

How to use:

  • Open the Linux terminal.
  • Type the command.
  • Press Enter to see the computer's name.

To change the computer's name:

sudo hostname newname
Subh Singh
Invent the Future

In Linux, the systemctl command is used to manage system services. It helps you start, stop, and check services.

Command:

systemctl

Example:

If you want to check a service in Linux, you can use the following command.

systemctl status sshd

Output:

sshd.service - OpenSSH server daemon
     Loaded: loaded
     Active: active (running)

Here:

  • sshd.service shows the service name.
  • Loaded shows that the service is loaded.
  • Active shows that the service is running.

How to use:

  • Open the Linux terminal.
  • Type the command.
  • Press Enter to check the service.
Subh Singh
Invent the Future

In Linux, the ifconfig command is used to show or change network settings.

Command:

ifconfig

Example:

If you want to see network information in Linux, you can use the following command.

ifconfig

Output:

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>
        inet 192.168.1.10
        netmask 255.255.255.0

lo: flags=73<UP,LOOPBACK,RUNNING>
        inet 127.0.0.1

Here:

  • eth0 shows the network interface name.
  • inet shows the IP address.
  • netmask shows the network mask.
  • lo is the loopback network interface.

How to use:

  • Open the Linux terminal.
  • Type the command.
  • Press Enter to see network information.

RELATED QUESTIONS