Showing posts from 2023

AWS CLI Script to list all the EC2 Servers in all AWS Accounts in all Regions

  To list all EC2 servers across all AWS accounts and regions using AWS CLI, you can use the aws command with the ec2 describe-instances option and specify the --profile and --region options for each account and region. Here's an example command that you can use as a starting point: #!/bin/bash # List of AWS accounts and regions accounts=("account1" "account2") regions=("us-east-1" "us-west-2" "eu-west-1") # Loop through the accounts and regions for account in "${accounts[@]}" do for region in "${regions[@]}" do # Set the profile and region export AWS_PROFILE=$account export AWS_DEFAULT_REGION=$region # Get the EC2 instances in the region instances=$(aws ec2 describe-instances --query 'Reservations[].Instances[].InstanceId' --output text) # Print the instances echo "Instances in $account - $region:" echo "$instances" done done In this scrip

Linux : Special permissions to users for file & directories using "setfacl"

  To set special permissions to users for files and directories using the "setfacl" command in Linux, you can follow these steps: Install the "acl" package if it is not already installed on your system. You can do this using your distribution's package manager, such as apt, yum, or pacman. For example, on Ubuntu or Debian, you can run the following command: sudo apt-get install acl Check the current ACL settings of the file or directory you want to modify by using the "getfacl" command. For example, to check the ACL settings of a file called "example.txt", you can run the following command: getfacl example.txt This will show you the current permissions and access control entries (ACEs) for the file. Use the "setfacl" command to add or modify the ACEs for the file or directory. The basic syntax of the "setfacl" command is as follows: ruby setfacl -m user: <username> :<permissions> <file/directory> In this

Linux : Port Numbers for common services

 Below are some of the default port numbers in Linux SSH (Secure Shell) - port 22 FTP (File Transfer Protocol) - port 20 (data) and port 21 (control) HTTP (Hypertext Transfer Protocol) - port 80 HTTPS (HTTP over SSL/TLS) - port 443 DNS (Domain Name System) - port 53 SMTP (Simple Mail Transfer Protocol) - port 25 POP3 (Post Office Protocol version 3) - port 110 IMAP (Internet Message Access Protocol) - port 143 NFS (Network File System) - port 2049 Samba (Windows file sharing) - port 137-139 and 445 Note that these are the default port numbers for these services, but they can be configured to use different ports if needed. Also, some services may use multiple ports depending on their configuration.