I worked with:
I needed to create an alias that gives me the ability to back up whatever path I provide it.
First, I had to create an alias that uses the tar to back up the second parameter provided into the first parameter. Here's the command line example:
Usage example: backup "fileToSaveTo.tar.gz" "pathToBackUp"
To validate that I was in the home folder in the terminal, I entered the following command:
pwdExpected output:
[ec2-user@ ~]$ pwdTo create an alias called backup, I entered the following command:
alias backup='tar -cvzf 'I remembered that tar is a command that I use to create or extract an archive that contains files and folders.
tar -cf would work perfectly but would not display what is inside the archive and would not compress it.
To use the backup alias to back up the CompanyA folder, I entered the following command:
backup backup_companyA.tar.gz CompanyAExpected output:
*The command backup backup_companyA.targz CompanyA shows the entire directory of Company A. The contents include folders such as Management, Employees, Finance, HR, IA, SharedFolders, and bin. Files include the following: Sections.csv, Promotions.csv, Schdules.csv, Salary.csv, Managers.csv, Assessments.csv, and hello.sh.*
[ec2-user@ ~]$backup backup_companyA.tar.gz CompanyATo verify that the archive was created, I entered the ls command:
[ec2-user@ ~]$ lsIn this task, I displayed the PATH environment variable. I then updated the variable and added a new directory, in which I can place executables.
To navigate to the bin folder in the home CompanyA directory, I entered the following command:
cd /home/ec2-user/CompanyA/binTo run the hello.sh script, I entered the following command:
./hello.shExpected Output:
[ec2-user@ bin]$ hello.shTo navigate to the parent folder, I entered the following command:
cd ..Expected Output:
[ec2-user@ bin]$ cd ..To run the hello.sh script again, I entered the following command:
./bin/hello.shExpected Output:
[ec2-user@ CompanyA]$ ./bin/hello.shTo run the hello.sh script again, I entered the following command:
hello.shExpected Output:
[ec2-user@ CompanyA]$ hello.shTo display the value of the PATH variable, I entered the following command:
echo $PATHExpected Output:
[ec2-user@ CompanyA]$ echo $PATHTo add the /home/ec2-user/CompanyA/bin folder to the PATH variable, I entered the following command:
PATH=$PATH:/home/ec2-user/CompanyA/binExpected Output:
[ec2-user@ CompanyA]$ PATH=$PATH:/home/ec2-user/CompanyA/binTo try to run the hello.sh script again, I entered hello.sh:
[ec2-user@ CompanyA]$ hello.sh