Renaborges.com

Showing category "Linux" (Show all posts)

Ping from a script

Posted by Renata Shaw on Monday, July 3, 2023, In : Linux 

Method: We can write our own script using the ping command to query list of IP addresses and check whether they are alive or not as follows:

 

#!/bin/bash

#Filename: ping.sh

# Change base address 192.168.0 according to your network.

 

for ip in 192.168.0.{1..255} ;

do
       #Amount of packets transmitted "-c 2"
       #/dev/null is a virtual file. This will discard anything written to it.

ping $ip -c 2 &> /dev/null ;

if [ $? -eq 0 ];

then

echo $ip is alive

fi

done

 

...
Continue reading ...
 

For Machines Without Telnet Installed

Posted by Renata Shaw on Monday, July 3, 2023, In : Linux 

cat < /dev/tcp/IP/PORT

cat < /dev/tcp/192.90.70.200/3306

OR

curl -v telnet://ip:port'

curl -v telnet://192.90.70.200:3306

curl -v telnet://192.90.70.2001:3306



Continue reading ...
 

Helper Script

Posted by Renata Shaw on Monday, July 3, 2023, In : Linux 

#!/bin/bash

 

echo "----------------------------"

echo "Sourcing Functions:"

echo "----------------------------"

echo " - nodes_up: Checks what hosts are up or down using nmap"

echo " - slbs_status: Check if NGINX Process and Status in AZ1 & AZ2"

echo " - slbs: Check if NGINX nodes are up / down using nmap in AZ1 & AZ2"

echo " - service_db_netwk: Checks connectivity between the Service in AZ1 and MySQL in AZ2 and vice-versa"

echo " - tail_service_log: Tail 100 lines of the service.lo...


Continue reading ...
 

IF statements arguments / flags / options / operation

Posted by Renata Shaw on Monday, July 3, 2023, In : Linux 

Test operators

-e file exists

-f file exists and is not a directory

-s file is not empty

-d directory exists

-x file is executable (for the user running the test)

-r file is readable (for the user running the test)

-w file has write permission (for user running the test)

-h / -L file is a symbolic link

! "not"

 

Compound Comparison

-a logical 'and' similar to &&

-o logical 'or' similar to ||

 

Integer Comparison

-eq is equal to

-ne is not equal to

-gt or > is greater t...


Continue reading ...
 

Learning awk

Posted by Renata Shaw on Monday, July 3, 2023, In : Linux 

Print column 1 & 2

ps | awk '{print $1,$2}'


To separate the columns titles you can use "\t" between the numbers:

ps | awk '{print $1"\t"$2}'


By default the field separator for awk is a space, if it's not the case tell awk which one it is by using F for field separator. In the example of /etc/passwd file the separator is semi-colon

awk -F ":" '{print $1}' /etc/passwd

You can also grep:

awk -F ":" '{print $1}' /etc/passwd | grep myservice

 

To search for every last field in the line, but r...


Continue reading ...
 

Learning sed

Posted by Renata Shaw on Monday, July 3, 2023, In : Linux 

sed > Stream editor allow filter and transform texts, find pattern and replace with whatever is that you want to replace with, it's like search and replace.

You can use other separators instead of slashes (/). Example pipe | or hash #

1 - sed substitution -- s for substitution. replaces only the first occurrence in each line of the file and save to a new file

sed 's/word/newword/' < oldfile > newfile

 

2 - replaces every occurrence of 'word'. g for global

sed 's/word/newword/g' < oldfi...


Continue reading ...
 

A Quick Explanation About the Output from the Free Command in Linux

Posted by Rena Borges / Renata Shaw on Saturday, August 22, 2020, In : Linux 
First I would like to quickly explain about Buffer and Cache, so things can make sense up ahead :)
Difference between Buffer and Cache:

Buffer is a temporary location for storing data for a particular application and this data is not used by any other application.

Cache is a memory location to store frequently used data for faster access.

Both are temporary store for your data processing. However memory specified as buffer/cache can be made available when an application needs it, so we count it ...

Continue reading ...
 

Linux Directory Structure Explained

Posted by Reny Borges / Renata Shaw on Friday, April 10, 2020, In : Linux 
 Apart from the home folder, you need administrator privileges to access the other folders. Although you can look.
  
= This is the root directory which should contain only the directories needed at the top level of the file structure.  
  
root folder - home directory for the super user = That's where the root home users directory is if you have a root user account activated on your system. This is different from the / directory, which is the system's root directory.
  
/bin - essential binary c...

Continue reading ...
 

How to install a fully portable desktop on a USB for on-the-go access

Posted by Rena Borges on Sunday, August 18, 2013, In : Linux 

Porteus is a portable Linux operating system which is able to be installed on a portable USB device.
"Porteus manages to offer a full-blown distribution by installing in a compressed state (to keep its footprint small). During the boot process, it uncompresses and boots very quickly. Porteus also offers a package manager so you can easily install more applications. The package manager has a dedicated Porteus repository to select from, but you can install applications from any repository...

Continue reading ...
 
 
blog comments powered by Disqus
blog comments powered by Disqus