HowTo: grep All Sub-directory For Files

To search all subdirectories for files using grep you can use the following command: grep -r pattern directory where pattern is the search string and directory is the top-level directory to search. The -r or –recursive option tells grep to search recursively through subdirectories. For example: grep -r “error” /var/log This will search for all … Read more

Debian Linux: Configure Network Interfaces As A Bridge / Network Switch

In Debian Linux, you can configure network interfaces as a bridge, also known as a network switch, using the brctl utility and the /etc/network/interfaces file. Here’s an example of how to configure two network interfaces, eth0 and eth1, as a bridge: Install the bridge-utils package: sudo apt-get install bridge-utils Create a bridge device: sudo brctl … Read more

How to change directory in Linux terminal

In the Linux terminal, you can change the current working directory using the cd command. Here’s how you can use the cd command to change to a different directory: cd path/to/directory where path/to/directory is the path of the directory you want to change to. For example, to change to the /home directory, you would use … Read more

Linux Rename Eth0 Network Interface Card Name [ Udev ]

In Linux, you can change the name of a network interface card using the udev subsystem. Here’s how you can change the name of the eth0 interface to new_name: Create a new udev rule file: sudo nano /etc/udev/rules.d/10-network.rules Add the following lines to the file: SUBSYSTEM==”net”, ACTION==”add”, DRIVERS==”?*”, ATTR{address}==”xx:xx:xx:xx:xx:xx”, NAME=”new_name” where xx:xx:xx:xx:xx:xx is the MAC … Read more

less Command Display Line Numbers

To display line numbers while using the less command, you can add the -N option when running the less command: less -N file.txt In this example, the -N option causes less to display line numbers in front of each line of the file. This can be useful when you need to refer to specific lines … Read more

Python Delete/Remove a File If Exists On Disk

In Python, you can remove/delete a file from disk using the os module’s remove function. Here’s an example: import os file_path = “path/to/file.txt” if os.path.exists(file_path): os.remove(file_path) print(“File removed successfully.”) else: print(“File not found.”) In this example, we first check if the file exists using the os.path.exists function. If the file exists, we remove it using … Read more