1. Which command adjusts the priority of a process at start?
The nice command launches a process with a specific priority value. Lower nice values mean higher priority; positive values reduce CPU priority.
nice -n 10 ./backup.sh
Get the Preplance app for a seamless learning experience. Practice offline, get daily streaks, and stay ahead with real-time interview updates.
Get it on
Google Play
4.9/5 Rating on Store
Tech Mahindra · Linux & Shell Scripting
Practice Linux & Shell Scripting questions specifically asked in Tech Mahindra interviews – ideal for online test preparation, technical rounds and final HR discussions.
Questions
16
Tagged for this company + subject
Company
Tech Mahindra
View company-wise questions
Subject
Linux & Shell Scripting
Explore topic-wise practice
Go through each question and its explanation. Use this page for targeted revision just before your Tech Mahindra Linux & Shell Scripting round.
The nice command launches a process with a specific priority value. Lower nice values mean higher priority; positive values reduce CPU priority.
nice -n 10 ./backup.sh
For complete preparation, combine this company + subject page with full company-wise practice and subject-wise practice. You can also explore other companies and topics from the links below.
The -r (recursive) flag allows rm to delete directories and their contents. To bypass confirmation prompts, -rf is commonly used but should be applied carefully.
rm -r myfolder
The ps command (process status) lists active processes along with their IDs, owners, and CPU usage. The -ef option shows all processes in full format, often used with grep to locate specific tasks.
ps -ef | grep nginx
If-else statements help control execution flow based on conditions. For example, checking if a service is running before restarting it. This prevents unnecessary downtime or duplicate operations in automation scripts.
if systemctl is-active --quiet nginx; then echo 'Nginx is running' else systemctl start nginx fi
The >> operator appends command output to a file without overwriting its contents. This is often used in logging to maintain persistent records.
echo 'Backup complete' >> backup.log
You can redirect both standard output and error to a log file using > and 2> operators. For example, script.sh > output.log 2>&1 saves all messages, making debugging easier later.
./deploy.sh > deploy.log 2>&1
netstat shows open ports, listening services, and active connections. Options like -tuln display TCP/UDP sockets numerically without DNS lookups, helping identify which ports are in use.
netstat -tuln
Start by checking link status with ip a or ifconfig, then test reachability using ping. Next, check DNS with dig or nslookup, and use traceroute to find where packets drop. If still unresolved, verify firewall rules with ufw or iptables.
ping 8.8.8.8 traceroute google.com
systemctl enable creates a symbolic link in the system startup directories. It ensures the service automatically starts during system boot without manual execution.
sudo systemctl enable docker
Use systemctl list-unit-files --type=service to see which units are enabled or disabled. You can also run systemctl is-enabled servicename to check the startup behavior of a specific service.
systemctl list-unit-files --type=service | grep enabled
The command ufw allow ssh opens port 22 for inbound SSH connections. You can also specify the protocol and IP range for more precise access control.
sudo ufw allow ssh
du (disk usage) displays the size of directories and files recursively. It’s helpful to locate which directories consume the most disk space.
du -sh * | sort -rh | head
First, identify the drive using lsblk or blkid and note its UUID. Then add an entry in /etc/fstab specifying the UUID, mount point, and filesystem type. Run mount -a to verify before rebooting.
UUID=abcd-1234 /mnt/data ext4 defaults 0 2
The at command runs a command once at a specific future time. It’s useful for delayed tasks like log rotation or temporary file cleanup.
echo 'rm /tmp/tempfile' | at 3:00 AM
Disable root login by setting PermitRootLogin no in sshd_config. Use SSH keys instead of passwords. Change the default port, restrict users with AllowUsers, and enable firewall rules to allow only trusted IPs.
sudo vi /etc/ssh/sshd_config PermitRootLogin no PasswordAuthentication no
You can automate database backups daily using cron. For instance, schedule a cron job to run a MySQL dump script at midnight and store it with a timestamp for versioned backups.
0 0 * * * /scripts/mysql_backup.sh