As I mentioned in some of my previous articles from the #3MonthsOfCloudDevOps series, I recently started working with Linux and Linux commands.
It has been a continuous learning curve and I wanted to highlight some of the commands (and packages) I have used so far.
Apart from the basic commands, this article will highlight others that have been extremely useful in resolving Linux-related issues. I will most likely keep adding to this article as time goes by, so I can always come back to them as a reference.
Let's go!
Package installers/managers
These managers are probably the ones I made the most mistakes with. I always have to remind myself when to use what.
apt (Advanced Packaging Tool): I used this when working within Ubuntu-based EC2 instances.
yum (Yellowdog Updater, Modified): This was the packager manager I used whenever I was working with amazon/aws-cli Docker image (or the AWS circleCI orb); basically AWS-CLI related installations.
apk (Alpine Package Keeper): Mostly used this with CircleCI config files when working with alpine-related Docker images.
The Others - ssh, wget, tar, gzip, etc
I am not sure how to classify most of these, so I would just list them:
ssh
: start a secure connection to the SSH server on a remote machine. I used the command for connecting to EC2 instances from my machine.nano
: command line text editor. Another option isvim
but so far, I've only tried nano.wget
: retrieve files from the internet. I used this command quite a number of times for installations that required fetching compressed/archived files and extracting them.tar
: extracting and compressing files. Mostly used with files I fetched withwget
, and in conjunction withgzip
.grep
: command line utility for searching for characters in files. This one has helped me a whole lot!chmod
: change access permissions of files and directories. Mostly used on AWS key files whenever I try tossh
into EC2 instances.
System utilities
launchctl
:systemctl
but for MacOS.tee
: I personally used this when I wanted to append the output of a command that read the contents of a file to a file.
Basic syntax is
[command] | tee [options] [filename]
.
Command Chunks
Quick commands for some common issues:
1) Create new files
There are just so many ways to do this, so I'm jotting down my go-tos:
a) echo > [newfile]
b) cat [file] > [newfile]
: when you want to create a copy of a file as another file.
2) List all users accounts
Ubuntu/Linux: cut -d: -f1 /etc/passwd
macOS: dscl . list /Users | grep -v “^_”
3) Fix "port in use" issue
a) find the process id (pid) for the port: lsof -i :[port]
b) free the port: sudo kill -9 <pid>
I'll keep updating but I hope it helps save your time as well!