dir - lists the files and folders in your current working directory in PowerShell.
ssh-keygen - generates a pair of keys used for encrypted connections between your local Windows computer and your virtual linux computer. Note: leave things in their default settings. By default the pair of keys will be found in your C:/users/{your login}/.ssh folder. Their names will be id_ed25519 for the private key and id_ed25519.pub for the public key. The public key is the file that will need to be uploaded to AWS in order for a secure connection to be establishd.
For Mac/OSX Users
ls - lists the files and folders in your current working directory in your terminal.
ssh-keygen - generates a pair of keys used for enrypted connections between your local OSX computer and your virtual linux computer. Note: leave things in their default settings. By default the pair of keys will be found on your /users/{your login}/.ssh folder. Their names will be id_rsa for the private key and id_rsa.pub for the public key. The public key is the file that will need to be uploaded to AWS in order for a secure connection to be established.
cd {directory} - moves your current working directory to the new directory.
cd .. - moves your current working directory back one step.
cp {file name} ../. - copies a file one directory back from the current working directory.
This is what we learned in Engagement 3.
Note: Some things were different from the live engagement. I forgot to cover some things and added a few other things.
pwd - to print your working directory.
ls - to list the contents of a directory. Files and Directories.
ls -a - to list the contents of a directory including any hidden files or directories.
ls / - to list the contents of your root directory.
cd {directory name} - to move the working directory to a new directory.
cd .. - to move the working directory back one step in the tree.
clear - to clear off what has been printed on your screen.
clear -x - to clear off what has been printed on your screen but still be able to scroll up to see your histoy.
[TAB] - to auto-fill based on what is in your workind directory.
cat - to print the contents of a file to your screen.
cat {file 1} {file 2} etc. - to print the contents of multiple files to your screen.
more {file 1} {file 2} etc. - to print the contents of files or multiple files to your screen in readable chunks.
> {file name} - divert standard out into a file.
>> {file name} - divert standard out into a file but appending it instead of writing over it.
less {file name} - to print the contents of files or multiple files to your screen where you can scroll up and down with arrow keys and search with "/".
rm {file name} - remove a file.
fold -s -w80 {file name} - print the contents of a file with the arguments of -s to wrap text only when there is a space, and -w80 to limit the width of the text to 80 columns (80 characters) wide. (You will probably never use this.)
touch {file name} - create an empty file with a specific name.
vi {file name} - this opens a file in vim. vim is a text editor. (users of linux always call it "vim". Only old time boomers still call it "vi.")
i - switches the user into "insert" mode where you can type, paste, navigate with your keyboard arrows etc.
[Esc] - switches the user out of the mode and back into the default mode.
:wq - ":" brings up the command input. "w" saves the file, "q" quits vi.
mv {file} {directory} - moves a file into a specific directory. It is also how you can re-name files. (I always find this weird but. . . it works.)
cp {file} {directory} - copies a file into a specific directory.
rm {file} - removes a file.
rm -r {directory} - removes a folder with the -r (recursive) argument.
man {program name} - brings up the manual in "less" that lets you search it with "/".
Pro tip. Install tldr! note: these instructions ONLY work on your AWS Ec2 cloud instance that you ssh into. It will not work on your RedHat e-book. Also, if you create a new Ec2 instance and remove the one that you have installed a program on, you will need to re-install the programs you want to use on the new Ec2 instance.
wget {url to file} - downloads a specified file into the current working directory.
chmod +x {file} - changes a file to make it executable.
tar -xvf {compressedfilename}.gz - extracts a compressed archive file into the current working directory.
./{script.sh} - launches the script if it has the correct permissions.
[ctrl]+[c] - kills the process that is in the foreground.
./{script.sh} & - launches the script in the background.
fg - brings the most recent job to the foreground.
fg {job#} - brings a specific job to the foreground.
[ctrl]+[z] - stops the foreground job and puts it into the background.
bg {job#} - starts a background job that has been stopped.
jobs - prints a list of the currently running jobs.
top - program that lists system resources allowing you to find the PID of a process.
kill {process-id#} - kills a running program with that specific process id.
./{script.sh} & ./{script.sh} & - launches both scripts. & puts the jobs into the background with as many jobs in the line as you need all running at the same time.
./{script.sh} && ./{script.sh} & - launches both scripts in order. && puts the jobs into the background with as many jobs in the line as you need all run one after the other.
exit - this will terminate your SSH session and return you to your local shell.
This is what we learned in Engagement 5.
whoami - prints the username that you are using currently.
sudo - runs the command as "root" for when you need to do something that requires root permissions to execute.
sudo !! - runs last command you (tried) to exicute as "root".
ls -l - lists the files and folders in a set directory in a "long" form where it gives you a lot of information.
ls -a - lists all of the the files and folders, including the hidden "dot" files.
ls -t - lists all of the the files and folders, in order based on the time they were created.
ls -r - lists all of the the files and folders, in the reverse order.
ls -h - lists all of the the files and folders, in a format that is more human readable.
ls -latrh - lists all of the files and folders in long form l, including hidden files a, based on time of creation t, but reversed r, and in a human readable format.h (phew) note: you can play with the order to get your desired output. Look in man or tldr for more arguments!
mkdir - creates a new director.
mkdir -p {directory1/directory2/directory3/etc.} - uses the parent argument to create folders nested within themselves.
tree {directory name} - draws a tree of the files and folders in your pwd. for example, if your directories were: limb/branch/nest/egg/bird/wing/feather/bug/germ it would draw this.
tree -a {directory name} - draws a tree of the files and folders in your the specified directory including all of the hidden files and folders.
mkdir {1..10} - will create ten folders named 1 through 10.
mkdir {a,b,c,d,e,f,g,h} - will create ten folders named a, b, c, d, e, f, g and h.
This explains vi or vim.
navigation? - arrow keys will move you around the document. j,k,h,l will work as well.
[/what] - searches for the term "what" within the document.
[n] - brings you to the next word in your document that is currently being searched for. In this case the next time "what" is found in the document.
[N] - brings you to the previous word in your document that is currently being searched for. In this case the previous time "what" is found in the document.
[yy] - copies the current line into memory. "yank yank"
[p] - pastes the line that is in memory below the current line the curser is at.
[dd] - deletes the current line the curser is at.
[u] - undoes the last thing you did.
[:help] - brings up help file within vim.
[:q] - quits the tab you are in. (Probably the help documentation.)
[:%s/this/that/gn] - number the times the search for "this" could be replace it with "that" in the whole document....
[:%s/this/that/g] - replace "this" with "that" in the whole document....
[:w] - write your changes to the document to the file you are editing.
[:q!] - quits vim without saving.
[:wq] - writes out your changes (save) and quits vim.
This is what we learned in Engagement 6.
useradd {username} - generates a new user.
/etc/shadow - file that lets you see the users on your system and their encrypted passwords.
passwd {username} - sets the password for the user.
pwgen - tool in linux that lets you play with generating new more secure passwords.
cowsay {what you want the cow to say} - generates a cow saying something.
scp {file} {userid}@{remoteIP#}:{location on server} - how you move files to a server.
scp {userid}@{remoteIP#}:{location on server/file} . - how you move files from a server to your current working directory.
rsync - more advanced way of moving files to a server that can handle larger files and even resume the up-load if your internet connection breaks.
This is what we learned in Engagement 7.
ls -l - lists fils and folders with extra information. (long)
chmod -{options} {files or folders} - program to change the premissions of files and folders.
chown -{user} {files or folders} - program to change the owner of files and folders.
chown -{user}:{group} {files or folders} - program to change the owner and group of files and folders.
chgrp -{options} {files or folders} - program to change the group permissions of files and folders.
sudo - - switches your user to root. (DANGEiR!)
groupadd {groupname} - - creates a new user group.
groupdel {groupname} - - deletes a user group.
tail {file} - - prints to your screen the last 7 lines of a file.
sueradd -g {group} {username} - - creates a new user in a specific group.
sueradd -g {group} {username} - - creates a new user in a specific group.
umask - prints to the screen your current umask setting.
umask -P - prints to the screen your current umask setting in a human readable format.
umask u=rwx,g=rwx,o=rwx - sets your usmask for your user, group and other.
chmod +t {file or folder} - puts a "sticky bit" on the file or folder.
chmod -t {file or folder} - removes a "sticky bit" on the file or folder.
chattr +i {file or folder} - sets a file or folder to immutable.
chattr -i {file or folder} - removes a file or folder's immutable setting.
This is what we learned in Engagement 8
Sym Links
ln -s {file/folder to link} {link of file/folder} - generates simulated link between two files or folders.
pwd -P - lists the actual project working directory resolving all sym links.
ls -l - lists the long format of the files and directories in a folder including sym links.
ls -l - lists the long format of the files and directories in a folder including sym links.
Links
ln {file to link} {linked file} - generates a linked file that shares the same space on the system's hard drive.
ls -li - lists the files and folders in a directory with the -i argument telling us the unique ID of the files on the hard drive of the system. Note: this will ONLY work on one partition or drive. This will not work across different partitions or drives.
scp and tar
ls *.tar - lists the files and folders in your working directory with a wild card that will show everything that has the .tar extension.
scp {file} {user}@{ip_address}:{folder_name}/. - uploads a file to your server in a specified folder. eg: scp site.tar ec2-user@{ip_address}:sites/. This will put the site.tar file on the server into the sites folder.
tar -xzvf {file}.tar - uncompresses the .tar file with the arguments. -x indicates that you want to extract. -z lets tar know that the file is compressed with gzip. -v tells tar that we want to see the process happening. -f tells tar what the file will be after the argument.
lynx {website}.html - tells lynx (a terminal web browser) to open up a website.
This is what we learned in Engagement 9
Grep, Regex
egrep {search term} {file} - searches through the file with the parameters set up in the search term. For example: egrep Jesus kjv.txt will search for the times that Jesus is found in the kjv.txt file and print out the lines that match. note: syntax is important! use the training in Regexoneto be sure you are using the correct syntax.
Locate
locate {file} - searches for a file with a specific name.
updatedb - updates the database that locate uses to find files. note: it needs root permissions to run. so: sudo updatedb would be how you would update your system's file database prior to using locate.
locate -r {file} - enables the ability to use some expressions to narrow your search. For example: locate -r conf$ would locate files with the name conf but cut off anything after conf in the file name.
Find
find {path to search} -name "{name of file}" - finds a file with a specific name in a specified path.
find {path to search} -name "{name of file}" -size +2k - finds a file with a specific name in a specified path that is larger that 2k.
find {path to search} -name "{name of file}" -exec ls -ltrah {} \; - finds a file with a specific name in a specified path and outputs the result through ls with the -ltrah arguments.
This is what we learned in Engagement 10
cut, paste, sort
echo -e "{textA}\n{textB}" - prints to the screen textA and then in a new line, textB.
column -s ',' -t {file} - arranges the contents of the file deliniated with "," into culmns with a tab separating them.
cut -d ',' -f1 {file} - cuts away everything that isn't in field 1 away.
paste -d ',' {fileA} {fileB} - pastes the columns found in {fileB} to the end or the right of {fileA}.
sort - n {file} - numerically sort the rows found in the file.
last - prints the users who have logged into the system.
uniq - removes duplicates.
This is what we learned in Engagement 11
Split Diff
split -l 10 file.txt file.txt - splits the file.txt into separate files with 10 lines per file. The output adds aa, ab, ac, ad etc.
cat file.txt* > file.txt - merges all of the file.txtaa, file.txtab, file.txtac into the file named file.txt. Essentually piecing everything back together that was split appart with split.
split -b 500k file.txt - splits the file.txt into separate files that are each 500k in size.
diff fileA.txt fileB.txt - compares fileA.txt to fileB.txt and prints out the lines that are different.
This is what we learned in Engagement 12
EFS
sudo mount -t efs {fs-##############} myefsmount/ - mounts an efs to the myefsmount directory assuming you have correctly set up an efs and your firewall permissions are correctly set up.
sudo umount {path to mounted efs} - unmounts the mounted efs.
S3 Buckets
aws s3 sync {local directory} S3://{S3BucketName} - performs a sync on the local directory and the bucket that is on AWS.
aws s3 cp {local file} S3://{S3BucketName} . - copies a local file onto the base directory of the S3 bucket.