How do I set up Sudo in Linux?
1. Login as the root user on the system.
2. Type the command: apt-get install sudo
3. To add a new user to the sudoers file, type the command: usermod -a -G sudo <username>
4. To edit the sudoers file, type the command: visudo
5. Add the user to the sudoers file with the text below: <username> ALL=(ALL) ALL
6. To confirm the changes, type in the command: sudo -l
7. All users added to the sudoers file will now be able to use sudo commands.
How to disable or set SELinux to permissive mode?
1. To disable or put SELinux into permissive mode, you can use the following command:
sudo setenforce 0
2. You can also edit the /etc/selinux/config file and set the SELinux mode to permissive. To do this, open the config file in a text editor, find the line that reads SELINUX=enforcing, then change it to SELINUX=permissive. Save and close the file, then reboot your system for the change to take effect.
3. You can also use the graphical interface provided by your Linux distribution. Look for the settings for SELinux in the Security or Administrative Tools section. You can then select the permissive mode and save the settings.
What are the Linux network commands?
1. ping: Tests a network connection.
2. traceroute: Traces the route taken by packets over an IP network.
3. ip: Displays network configuration and routing information.
4. netstat: Displays active network connections & protocol statistics.
5. arp: Displays, adds, and deletes entries in the Address Resolution Protocol (ARP) table.
6. hostname: Displays or sets a system's hostname.
7. ifconfig: Configures network interface parameters.
8. nmap: Network exploration and security auditing tool.
9. nslookup: Queries DNS name servers for DNS information.
10. route: Views and manipulates the IP routing table.
What are the different types of port scans in Linux?
1. TCP connect scan: This type of port scan uses the full three-way TCP handshake to connect to the target port in order to determine if it is open.
2. TCP SYN scan: This type of scan sends a SYN segment to the target port without completing the three-way handshake. If the port is open, then a SYN-ACK will be sent as a response; if not, then an RST packet will be sent.
3. FIN Scan: This type of scan sends FIN packets to the target port; if the port is open, then an RST packet is sent as a response.
4. XMAS Tree Scan: This type of scan sends a TCP segment to the target port with the FIN, URG, and PSH flags all set to 1. If the port is open, then an RST packet will be sent as a response.
5. NULL Scan: This type of scan sends a TCP segment to the target port with no flags set. If the port is open, then an RST packet will be sent as a response.
6. ACK Scan: This type of scan sends an ACK segment to the target port; if the port is open, then no response is sent, but if it is closed, then an RST packet will be sent in response.
Why does my Linux server freeze up?
There are several possible causes of a Linux server freezing up. The most common causes are memory leaks, hardware and software incompatibilities, outdated software, insufficient disk space, misconfigured services, and a system overload. It is important to try to determine the source of the problem before attempting to resolve it. If the problem persists, it may be necessary to restart the system or back up important data and restore the server.
How to check if a Linux driver is working?
1. Run the command "lsmod" to check the installed modules and their status.
2. Check the device log files with their entry in the /var/log/ directory.
3. Check the device name or driver name in the output of the command “lsusb” or “lspci -v.”
4. Inspect the output of “dmesg” command.
5. Utilize “lshw” command to know more about the driver.
6. Confirm if the driver is loaded with “modinfo module_name” command.
7. Under sysfs, check the state file of the drivers in the path /sys/devices/module_name/state.
8. Search for the driver in “/proc/interrupts” to identify any hardware interrupts.
Where can I find the latest version of Samba on Linux?
The latest version of Samba on Linux can be found on the official Samba website at https://www.samba.org/samba/download.html. Alternatively, you can also use a package manager to install the latest version of Samba on Linux.
How to take Linux file system backup?
1. Create a Full Backup of Your Linux File System
To back up all files, directories, and system data from your Linux file system, you can use the built-in command line utility, tar (tape archive). Using tar, you can easily create a full backup of your file system and save it to an external drive.
To begin, use the following command to make a copy of the Linux system file system in the same PATH you are currently in.
$ tar -cvpf /backup/backup.tgz /
The -cvpf flags indicate that tar should create (-c) a verbose copy (-v) with preservation (-p) of ownership, permissions and all directories, files, and link (-f) from the root directory / . The output file (/backup/backup.tgz) is where the tar archive containing the backup will be stored.
2. Use the rsync Command
Another option to back up your file system is to use the rsync command. rsync is a great utility for quickly backing up files and directories locally or remotely.
To back up a complete system file system, you can use the rsync command as indicated below:
$ rsync -azvh --delete / /backup/rsync_backup
The switches and flags used with rsync are: archive (-a), compresses file data (-z), is verbose (-v), and provides information on a transfer’s progress (-h). The additional --delete flag helps ensure that all files and directories in the source are also included in the backup without needing to manually list each one.
3. Create a Clone of Your Linux File System
Another option for backing up your entire Linux file system is to create a clone of the file system using a command-line based disk cloning utility such as partclone. Partclone is a utility used for creating disk images or cloning partitions for backup purposes.
The partclone command used for cloning a filesystem is as follows.
$ partclone.ext4 -c -s /dev/sda1 -o /backup/filesystem_clone.img
The flags used in this command are used to clone (-c) a source partition (-s) located at /dev/sda1. The clone output (-o) is stored in /backup/filesystem_clone.img.
Once the cloning process completes, the cloned image can be mounted and used to restore the original file system.
Backing up your Linux file system is an important part of system administration. Thankfully, with a few simple commands, you can easily make a complete backup of your Linux file system just in case it ever gets corrupted or you need to restore a file or two.