Unix / Linux Shell: Get Third Field Separated by Forward Slash (/) Delimiter

To extract the third field separated by forward slash (/) delimiter in Unix/Linux shell, you can use the following command: echo “field1/field2/field3/field4” | awk -F’/’ ‘{print $3}’ This uses the awk command to split the input string on forward slashes (/) and then prints the third field ($3). The -F option is used to specify … Read more

HowTo: Nginx Block User Agent

You can block specific user agents in Nginx by using the if directive in the server block. Here’s an example: server { … if ($http_user_agent ~* (bad-agent1|bad-agent2)) { return 403; } … } This example blocks requests from user agents that contain the string “bad-agent1” or “bad-agent2”. The return statement returns a HTTP status code … Read more

Linux Reboot Command Example

To reboot a Linux system, you can use the following command: sudo reboot This will immediately restart the system. Note that you need to have root privileges to execute this command. If you are logged in as a regular user, you can use sudo to temporarily elevate your privileges.

Unix HowTo: Start / Stop / Restart Network Service Command

To start, stop, or restart network services in Unix, you can use the following commands: Start network service: sudo service network-manager start Stop network service: sudo service network-manager stop Restart network service: sudo service network-manager restart Note that the exact command may vary depending on the specific distribution and version of Unix you are using.

Linux Check User Password Expiration Date and Time

You can use the following command to check a user’s password expiration date and time in Linux: chage -l username Replace “username” with the actual username you want to check. The output will include information about the account, including the password expiration date and time. (https://lsu79.org)