Linux / Unix: Add Line Numbers To Files

To add line numbers to a file in Linux/Unix, you can use the nl command. Here is an example: nl file.txt > numbered_file.txt This will create a new file numbered_file.txt with line numbers added to the contents of file.txt. The nl command can also be used with other options and arguments to customize the line … Read more

Debian Linux Squeeze 6.0: Install Python v2.6/2.5 Argparse Module

To install the Python Argparse module on Debian Squeeze 6.0, you can use the following steps: Open a terminal window Update the apt-get package manager index by running the following command: sudo apt-get update Install the python-argparse package by running the following command: sudo apt-get install python-argparse This will install the Python Argparse module on … Read more

FreeBSD: Delete User Account Command

You can delete a user account in FreeBSD using the pw command. The following command will delete a user account named “user1”: # pw userdel user1 By default, the user’s home directory and related files will also be deleted. If you want to preserve the user’s home directory, use the -d option with pw userdel: … Read more

Linux / Unix Shell Script: Get The Current Directory

You can get the current directory in a shell script using the pwd command. However, it’s recommended to use the $PWD shell variable, which is automatically set to the current working directory. Here’s an example shell script that prints the current directory: #!/bin/bash echo “Current directory: $PWD” You can also use the $(pwd) command substitution … Read more

Linux: Start / Stop / Restart Apparmor

To start, stop, or restart AppArmor on a Linux system, you can use the following commands: Start AppArmor: $ sudo service apparmor start Stop AppArmor: $ sudo service apparmor stop Restart AppArmor: $ sudo service apparmor restart Note: The exact commands may vary depending on the distribution you are using. On some systems, you may … Read more