Tuesday, June 29, 2021

How to replace a string in file in Linux

https://www.cyberciti.biz/faq/how-to-use-sed-to-find-and-replace-text-in-files-in-linux-unix-shell/

sudo sed   's/efs/fileshare/g' /etc/fstab   //Replace content and its temporary

sudo sed   's+/efs+/fileshare+g' /etc/fstab  // Change Delimiter

sudo sed  -i 's+/efs+/fileshare+g' /etc/fstab //-i save changes to file/stream

sudo sed  -e '/fs-face524e/s/fileshare/helloooo/' /etc/fstab //Replace only if lines contain specific string "fs-face524e"

Friday, June 25, 2021

Sort PS output

https://serverfault.com/questions/27887/how-to-sort-ps-output-by-process-start-time/27900


ps -ef --sort=start_time

Azure Agent - Configure As a Service Linux or Standalone or Nohup &

https://docs.microsoft.com/en-us/azure/devops/pipelines/agents/v2-linux?view=azure-devops


#Configure it as a linux process and using nohup &

./run.sh 

ps -ef --sort=start_time |grep -E 'Agent|run.sh'

--------------------------------------------------------------------------------------------------------

#Configure Listener as a service in Linux, It actually, starts 3 Services 

sudo ./svc.sh install    #Creates a symlink under /etc/systemctl/system

sudo ./svc.sh start

sudo ./svc.sh status

sudo ./svc.sh uninstall  #Uninstall Service(SystemD) ,You should stop before you uninstall.

ps -ef --sort=start_time |grep -E 'Agent|runsvc'


ps -ef --sort=start_time |grep -E 'vsts|Agent|run.sh'

sudo systemctl is-active 'vsts.agent.GenpactDigitalEngineering.eks\x2ddev.dev.service'

sudo systemctl is-enabled 'vsts.agent.GenpactDigitalEngineering.eks\x2ddev.dev.service'

sudo systemctl status 'vsts.agent.GenpactDigitalEngineering.eks\x2ddev.dev.service'


#Configure Listener as a service in Linux, It actually, starts 3 Services 

Loaded: loaded (/etc/systemd/system/vsts.agent.GenpactDigitalEngineering.eks\x2ddev.dev.service; enabled; vendor preset: enabled)

   Active: active (running) since Sat 2021-06-26 04:12:27 UTC; 17min ago

 Main PID: 27333 (runsvc.sh)

    Tasks: 21 (limit: 4915)

   CGroup: /system.slice/vsts.agent.GenpactDigitalEngineering.eks\x2ddev.dev.service

           ├─27333 /bin/bash /home/eks/agent/runsvc.sh

           ├─27336 ./externals/node/bin/node ./bin/AgentService.js

           └─27356 /home/eks/agent/bin/Agent.Listener run --startuptype service


Remove and re-configure an agent (Not Service) The Whole Agent

To remove the agent:

1) Stop and uninstall the service as explained above.

2) Remove the agent.            [As it appears in Agent Pool]

./config.sh remove  [Enter your credentials.]


After you've removed the agent, you can configure it again.

Thursday, June 24, 2021

AWS : S3API vs S3

aws s3api create-bucket --bucket my-bucket --region us-east-1

aws s3 mb s3://myeucentral1bucket --region eu-central-1

aws s3 sync s3://DOC-EXAMPLE-BUCKET-SOURCE s3://DOC-EXAMPLE-BUCKET-TARGET

--------------------------------------------------

aws s3api create-bucket --bucket cca-product-dev-s3bucket --region us-east-1 --acl public-read

aws s3 sync s3://cca-product-s3-bucket s3://cca-product-dev-s3bucket --dryrun

--------------------------------------------------

https://docs.aws.amazon.com/cli/latest/reference/s3api/create-bucket.html

https://aws.amazon.com/blogs/developer/leveraging-the-s3-and-s3api-commands/

https://aws.amazon.com/premiumsupport/knowledge-center/move-objects-s3-bucket/

https://stackoverflow.com/questions/27932345/downloading-folders-from-aws-s3-cp-or-sync

difference b/w Linux Operators : | || && & > >> ;

https://unix.stackexchange.com/questions/159489/is-there-a-difference-between-and-and

https://unix.stackexchange.com/questions/89386/what-is-symbol-and-in-unix-linux




  • > redirects output to a file, overwriting the file.

  • >> redirects output to a file appending the redirected output at the end

  • ;: commands separated by a ; are executed sequentially. The shell waits for each command to terminate in turn.

  • &&: command after && is executed if, and only if, command before && returns an exit status of zero. You can think of it as AND operator.

  • |: a pipe. In expression command1 | command2 The standard output of command1 is connected via a pipe to the standard input of command2.

There are more similar control operators, worth to mention:

  • ||: command after || is executed if, and only if, command before || returns a non-zero exit status. You can think of it as OR operator. Please note, that | and || are completely different animals.

  • &: the shell executes the command terminated by & in the background, does not wait for the command to finish and immediately returns exit code 0. Once again, & has nothing to do with &&.

  • |&: a shorthand for 2>&1 | i.e. both standard output and standard error of command1 are connected to command2's standard input through the pipe.

Additionally if you use zsh then you can also start command with &| or &!. In this case job is immediately disowned, after startup it does not have a place in the job table.

Linux : Difference between >> and >

 > redirects output to a file, overwriting the file.

>> redirects output to a file appending the redirected output at the end


https://unix.stackexchange.com/questions/89386/what-is-symbol-and-in-unix-linux

FSTAB Format

https://www.thegeekdiary.com/understanding-the-configuration-file-for-mounting-file-systems-etc-fstab/

https://askubuntu.com/questions/9939/what-do-the-last-two-fields-in-fstab-mean

Azure - Pipeline - Add Approver for Stage

https://learn.microsoft.com/en-us/azure/devops/pipelines/process/approvals?view=azure-devops&tabs=check-pass