• Skip to main content

Uly.me

cloud engineer

  • Home
  • About
  • Archives

copy

Copy Directory Structure

August 25, 2022

Here’s how to copy a directory structure from one directory to another without the files.

Copy directory structure of DIR1 to DIR2.

find /DIR1 -type d > /tmp/dirs.txt
sed -i 's/DIR1/DIR2/' /tmp/dirs.txt 
xargs mkdir -p < /tmp/dirs.txt
chown -R USER:GROUP /DIR2

find /DIR1 -type d > /tmp/dirs.txt sed -i 's/DIR1/DIR2/' /tmp/dirs.txt xargs mkdir -p < /tmp/dirs.txt chown -R USER:GROUP /DIR2

Filed Under: Linux Tagged With: copy, directory, files, structure, without

AWS Copy Security Group

December 28, 2021

You can copy rules from a security group to a new security group created within the same Region.

Open the Amazon Elastic Compute Cloud (Amazon EC2) console.

  1. In the navigation pane, choose Security Groups.
  2. Select the security group you’d like to copy.
  3. For Actions, choose Copy to new.
  4. The Create Security Group dialog opens, and is populated with the rules from your existing security group.
  5. Specify a Security group name and Description for your new security group.
  6. For VPC, choose the ID of the VPC.
  7. Choose Create.

Filed Under: Cloud Tagged With: aws, clone, copy, firewall, security groups, vpc

Copy S3 To Another Region

June 22, 2021

Buckets are regional. Your source and destination buckets should be in different regions.

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

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

Use the sync command. It will copy new or modified files.

Filed Under: Cloud Tagged With: another, copy, region, s3

AWS Copy AMI to another Region

March 2, 2021

Here’s how to copy an AMI to another region.

aws ec2 copy-image \
  --source-image-id ami-xxxxxxxxxxx \
  --source-region us-east-1 \
  --region us-east-2 \
  --name "My DR server"

aws ec2 copy-image \ --source-image-id ami-xxxxxxxxxxx \ --source-region us-east-1 \ --region us-east-2 \ --name "My DR server"

Output:

{
    "ImageId": "ami-xxxxxxxxxxx"
}

{ "ImageId": "ami-xxxxxxxxxxx" }

Filed Under: Cloud Tagged With: ami, copy, ec2, region

AWS Copy Snapshot to another Region

March 2, 2021

If you need to copy a snapshot from one region to another, here’s the AWS CLI command.

aws ec2 copy-snapshot \
    --region us-east-1 \
    --source-region us-east-2 \
    --source-snapshot-id snap-xxxxxxxxxxxxxxxxx \
    --description "This is the DR snapshot copy"

aws ec2 copy-snapshot \ --region us-east-1 \ --source-region us-east-2 \ --source-snapshot-id snap-xxxxxxxxxxxxxxxxx \ --description "This is the DR snapshot copy"

Output:

{
    "SnapshotId": "snap-xxxxxxxxxxxxxxxxx"
}

{ "SnapshotId": "snap-xxxxxxxxxxxxxxxxx" }

Filed Under: Cloud Tagged With: aws, copy, disk, region, snapshot

Copy A Symbolic Link

November 27, 2020

Here’s how to copy a symbolic link which is also known as a soft link from one directory to another. A regular copy command will not work. You will need to use the -P option to copy the symbolic link from one directory to another. If omitted, the symbolic links will not be copied.

cp -P /directory1/* /directory2/

cp -P /directory1/* /directory2/

How to create a symbolic link.

ln -s sourcefile myfile
ln -s /path/to/file myfile

ln -s sourcefile myfile ln -s /path/to/file myfile

Here are the man pages for ln and for cp.

Filed Under: Linux Tagged With: copy, cp, create, link, ln, symbolic

SCP with a Key

October 22, 2020

SCP is a secure copy utility in Linux. You’ll need access to your system. In this example, a pem key is used to authenticate to a host. SCP copies filename.ext to the home directory of ec2-user. It’s important to add the target directory, otherwise it will not work.

Here’s how to use SCP with a key from local to server.

scp -i key.pem filename.ext user@server:/home/user

scp -i key.pem filename.ext user@server:/home/user

From server to local. Run the command from local machine.

scp user@server:/home/user/file.txt /local/directory

scp user@server:/home/user/file.txt /local/directory

Filed Under: Linux Tagged With: copy, ec2-user, key, pem, scp

Audacity Copy

August 8, 2020

I was getting an error when launching Audacity.

The error was:

“The system has detected that another copy of Audacity is running.”

However, Audacity wasn’t running at all. Not one process. It turned out to be just a locked file located in /var/tmp/audacity-[your-username].

All you have to do is delete the entire directory and rerun Audacity.

rm -rf /var/tmp/audacity=[your-username]/

rm -rf /var/tmp/audacity=[your-username]/

Once deleted, Audacity starts right up with no issues.

Filed Under: Linux Tagged With: another, audacity, copy, file, locked, running

  • Go to page 1
  • Go to page 2
  • Go to Next Page »
  • Home
  • About
  • Archives

Copyright © 2023