netfilter is a set of hooks inside the Linux kernel that allows kernel modules to register callback functions with the network stack. A registered callback function is then called back for every packet that traverses the respective hook within the network stack.
This Linux based firewall is controlled by the program called iptables to handles filtering for IPv4, and ip6tables handles filtering for IPv6. I strongly recommend that you first read our quick tutorial that explains how to configure a host-based firewall called Netfilter (iptables) under CentOS / RHEL / Fedora / Redhat Enterprise Linux. This post lists most simple iptables solutions required by a new Linux user to secure his or her Linux operating system from intruders. Lire la suite…
An alias is nothing but the shortcut to commands. The alias command allows the user to launch any command or group of commands (including options and filenames) by entering a single word. Use alias command to display a list of all defined aliases. You can add user-defined aliases to ~/.bashrcfile. You can cut down typing time with these aliases, work smartly, and increase productivity at the command prompt.
More about aliases
The general syntax for the alias command for the bash shell is as follows:
Task: List aliases
Type the following command:
alias
Sample outputs:
alias ..='cd ..'
alias amazonbackup='s3backup'
alias apt-get='sudo apt-get'
...
By default alias command shows a list of aliases that are defined for the current user.
The purpose of this post is to introduce a user to the nmap command line tool to scan a host and/or network, so to find out the possible vulnerable points in the hosts. You will also learn how to use Nmap for offensive and defensive purposes.
nmap in action
More about nmap
From the man page:
Nmap (“Network Mapper”) is an open source tool for network exploration and security auditing. It was designed to rapidly scan large networks, although it works fine against single hosts. Nmap uses raw IP packets in novel ways to determine what hosts are available on the network, what services (application name and version) those hosts are offering, what operating systems (and OS versions) they are running, what type of packet filters/firewalls are in use, and dozens of other characteristics. While Nmap is commonly used for security audits, many systems and network administrators find it useful for routine tasks such as network inventory, managing service upgrade schedules, and monitoring host or service uptime.
It was originally written by Gordon Lyon and it can answer the following questions easily:
What computers did you find running on the local network?
What IP addresses did you find running on the local network?
What is the operating system of your target machine?
Find out what ports are open on the machine that you just scanned?
Find out if the system is infected with malware or virus.
Search for unauthorized servers or network service on your network.
Find and remove computers which don’t meet the organization’s minimum level of security.
The wc command shows the number of lines, words, and bytes contained in file. The syntax is as follows to get the file size: wc -c /path/to/file wc -c /etc/passwd Sample outputs:
5253 /etc/passwd
You can easily extract the first field either using the cut or awk command: wc -c /etc/passwd | awk '{print $1}' Sample outputs:
How to get the size of a file in a bash script using stat command
The stat command shows information about the file. The syntax is as follows to get the file size on GNU/Linux stat: stat -c %s "/etc/passwd" OR stat --format=%s "/etc/passwd" To assign this size to a bash variable:
myfilesize=$(stat--format=%s "/etc/passwd")echo"$myfilesize"## or ##myFileSizeCheck=$(stat-c%s "/etc/resolv.conf")printf"My file size = %d\n"$myFileSizeCheck
The syntax is as follows to get the file size on BSD/MacOS stat: stat -f %z "/etc/passwd" Please note that if the file is symlink you will get size of that link only with the stat command.
How can I extract or fetch a domain name from a URL string (e.g. https://www.cyberciti.biz/index.php) using bash shell scripting under Linux or Unix-like operating system?
You can use standard Unix commands such as sed, awk, grep, Perl, Python and more to get domain name from URL. No need to write regex. It is pretty simple.
Let use see various commands and option to grab the domain part from given variable under Linux or Unix-like system.
Get domain name from full URL
Say your url name is stored in a bash shell variable such as $x: x='https://www.dbsysnet.com/' You can use the awk as follows: echo "$x" | awk -F/ '{print $3}' ### OR ### awk -F/ '{print $3}' <<<$x Sample outputs:
www.dbsysnet.com
Extract domain name from URL using sed
Here is a sample sed command: url="https://www.dbsysnet.com" echo "$url" | sed -e 's|^[^/]*//||' -e 's|/.*$||'
Extract domain name from URL using bash shell parameter substitution
# My shell variable f="https://www.cyberciti.biz/faq/copy-command/"## Remove protocol part of url ##f="${f#http://}"f="${f#https://}"f="${f#ftp://}"f="${f#scp://}"f="${f#scp://}"f="${f#sftp://}"## Remove username and/or username:password part of URL ##f="${f#*:*@}"f="${f#*@}"## Remove rest of urls ##f=${f%%/*}## Show domain name only ##echo"$f"