Fullstack Software Engineer: Command Cheat Sheet
A list of frequently used commands to manage OpenSSL, Docker, Kubernetes, Linux, Git, Helm, and .NET
OpenSSL
CSR: Generate a CSR used to issue a certificate
openssl req -newkey rsa:2048 -keyout private-key-file.key -out csr-file.csr
Self-Signed Cert: Generate a cert along with a new private key
openssl req -newkey rsa:2048 -nodes -keyout key-file.pem -x509 -days 365 -out certificate-file.pem
Cert: Review existing certificate information
openssl x509 -text -noout -in certificate-file.pem
PEM: See content in plain text
openssl x509 -in pem-file.pem -text
PKCS#12 (P12) Bundle: Combine your key and certificate in a P12bundle — an alternative to pfx
openssl pkcs12 -inkey key-file.pem -in certificate-file.pem -export -out certificate-file.p12
P12: Review existing P12 information
openssl pkcs12 -in p12-bundle-file.p12 -noout -info
PFX: Generate PFX
openssl pkcs12 -export -out certificate-file.pfx -inkey privateKey-file.key -in certificate-file.crt -certfile more.crt
PFX: Extract private key
openssl pkcs12 -in PFX-file.pfx -nocerts -out key-file.pem
PEM: Generate PEM file from a PFX file
openssl pkcs12 -in pfx-file.pfx -out cert-file.pem -nodes
PEM: Convert PEM file to CRT
openssl x509 -outform der -in pem-file.pem -out cert-file.crt
PEM: Export certificate from a PFX with no key
openssl pkcs12 -in file-name.pfx -clcerts -nokeys -out cert.pem
Key: Decrypt an encrypted private key file
openssl rsa -in encrypted-private-key.key -out unencrypted-private-key.key
Key: Removing the password from the private key
openssl rsa -in pem-file.pem -out private-key-with-no-pass-file.key
Thumbprint: Get thumbprint of a SHA-256 cert
openssl x509 -noout -fingerprint -sha256 -inform pem -in cert-file.pem
Thumbprint: Get thumbprint of a SHA-1 cert
openssl x509 -noout -fingerprint -sha1 -inform pem -in cert-file.pem
Thumbprint: Get thumbprint of a MD5 cert
openssl x509 -noout -fingerprint -md5 -inform pem -in cert-file.pem
Docker
Image: Build a new image with a tag
docker build -t hello-docker .
Image: Lists all the images on this machine
docker image ls
Image: Remove redundant images
docker image prune
Container: Remove redundant containers
docker container prune
Image: Tag an existing image
docker image tag <image-id>:<image-tag> <new-image-id>:<new-image-tag>
Image: Saves the image as tar file on disk
docker image save -o <filename like image.tar> <image-name>:<image-tag>
Container: Lists all the running containers on this machine
docker ps
Container: Run a container in interactive mode
docker run -it image-name
Container: Tail the logs
docker logs <container-id> -f
Container: tail the last two lines of logs
docker logs -n 2 -t <container-id>
Network: Lists all the networks
docker network ls
Volumes: Create a new one
docker volume create <volume-name>
Volumes: Inspect a volume
docker volume inspect <volume-name>
Container: Run a container with a volume attached
docker run -d -p 4000:4000 -v <volume-name>:/app/data <image-name></image-name>
Command: Execute a command and run the bash window in interactive mode with root user
docker exec -it 146 -u root bash
Command: execute a command and run the bash window in interactive mode and login as Mahdi
docker exec -it -u Mahdi 146 bash
Docker-Compose: Build with no cache
docker-compose build --no-cache
Docker-Compose: Run an already built compose file
docker-compose up
Docker-Compose: Stop an already running compose application
docker-compose down
Docker-Compose: List of running docker-compose applications
docker-compose ps
Docker-Compose: Logs of all running applications
docker-compose logs
Minikube
Cluster: install a new one
minikube install
Cluster: Start an installed cluster
minikube start
Cluster: Stop a running cluster
minikube stop
Cluster: Get the status of a running cluster
minikube status
Ingress: Enable Ingress
minikube addons enable ingress
Service: assigns a load balancer service an IP address
minikube service <service-name>
Helm
Charts: Run a deployment
helm upgrade --install ecosystem-location-api-release <location-of-the-charts> --values <path-to-values-files-in-the-desired-environment> --set image.tag='v1.0.0' --set global.env.ASPNETCORE_ENVIRONMENT='Production' --set-string timestamp=a_random_values
Kubernetes
Secret: Create a new secret
kubectl create secret tls technologyleads-sample-cert --key unencrypted-key-file.key --cert cert-file.crt
Config: Applies the configuration yaml file to the cluster
kubectl apply -f <config-file-name.yaml>
Cluster: Get information
kubectl cluster-info
Linux
Security: Current logged in user
whoami
Commands: a list of past commands
history
Packages: list of all the packages in the database available to the os, some of installed, some of them not.
apt list
Package: Install a package on OS
apt install app-name
Package: Update the list of available packages to be run before install command
apt update
Package: Uninstall a package from OS
apt remove app-name
Directory: Print Working Directory
pwd
Directory: Goes to the home directory of current user
cd ~
Directory: Create one
mkdir
Directory: Remove one or folder
rm -r
Direct/File: Rename or move files and folders
mv test docker: renames the text folder to docker
File: Create one
touch filename
File: Remove one or more files
rm filename
File: View the content of a file
cat filename
File: View the content of larger files
more filename
File: View the content of larger files with scroll up/down
less fiiename
File: View the first five lines
head 5 file.txt
File: View the last five lines
tail 5 file.txt
Redirection: Copies the content of one file to the other
cat file.txt > file2.txtecho hello > hello.txt
Grep: looks for hello in file.txt in a case-insenstive manner
grep -i hello file.txt
Grep: looks for hello in file.txt in a case-insenstive manner
grep -i hello file.txt
Grep: looks for hello in all files with names begin with file
grep -i hello file*
Grep: looks for hellp in the passwd file
grep hellp /etc/passwrd
Grep: looks for hello in all files and directories in etc
grep -i -r hello /etc/
Search: Find all files and directories in the current directory recursively
find
Search: Find all files and directories in the current directory recursively starting with /etc
find /etc
Search: show all directories in the current directory
find -type d
Search: show all files in the current directory
find -type f
Search: all the files whose names start with f
find -type f -name 'f*'
Search: all the files (case insentivive) whose names start with f
find -type f -iname 'f*'
List: a list of all files in bin, scrolling up and down
ls /bin | less
List: the top 5 files in the bin
ls /bin | head -n 5
List: prints all environment variables
printenv
Environment Variable: Print environment variable PATH
printenv PATH
Environment Variable: Environment Variable: Print environment variable PATH
echo $PATH
Variable: Define a variable in the current session
export DB_USER=test
Variable: Show the variable
echo $DB_USER
Bashrc: Append the current user local settings with a permanent variable
echo DB_USER=5 >> .bashrc
Bashrc: Reload bashrc for the current terminal
source .bashrc
Process: List of all current running processes
ps
Process: Sleep the current prompt for three seconds
sleep 3
Process: Kills the process with a process id
kill PID
Users: Add a new user with home directory
useradd -m Jack
Users: the new script that uses useradd behind the scene, and is more interactive
adduser
Users: Creates a system user named app, and add it to the group app
adduser -S -G app app
Users: list of all users
cat /etc/passwrd
Users: modified the shell used by this user to bash
usermod -s /bin/bash Mahdi
.NET
EF Migration: Add a new migration after making code-first model changes
dotnet-ef migrations --startup-project ..\Api\Start-up-project.csproj add migration-name --verbose
EF Migration: Run migrations and apply them to the database
dotnet-ef database --startup-project ..\Api\Start-up-project.csproj update --verbose
EF Migration: Roll back database to a specific migration
dotnet-ef database --startup-project ..\Api\Start-up-project.csproj update migration-name --verbose
Local Host Cert: Generate a certificate for HomeApi localhost endpoint
dotnet dev-certs https -ep C:\Users\mahdi\.aspnet\https\HomeApi.pfx -p LOCAL-CERTIFICATE-PASSWORD --trust
User Secret: Add a local user secret to a.NET project
dotnet user-secrets set 'Movies:ServiceApiKey' '12345' --project 'C:\apps\WebApp1\src\WebApp1
Groups: Add a new group
groupadd
Groups: Remove a grou
groupdel
Groups: Lists the groups for this user
groups <username>
Groups: lists of the groups for this user
groups <username>
Groups: lists all the groups
cat /etc/group
Groups: adds Mahdi to developers group
usermod -G developers Mahdi
Groups: lists of the groups of this user
groups Mahdi
Permissions: change the permission for the user, add the execute permission
chmod u+x filename/pattern
Permissions: change the permission for the user, removes the execute permission
chmod u-x filename/pattern
Permissions: change the permission for the group owning the file, and add read permission
chmod g+r filename/pattern
Permissions: change the permission for others, and remove write permission
chmod o-w filename/pattern
Permissions: change the permission for others, and remove write permission, add read and execute permissions
chmod ogu-w+r+x filename/pattern
Sql Server
Login: to a SQL instance
sqlcmd -s SQL5080.site4now.net -U user-id -P password
Azure
Deploy: Disable run from a package
az webapp config appsettings set --resource-group resource-group-name --name app-or-api-name --settings WEBSITE_RUN_FROM_PACKAGE='0'
Deploy: Enable App/API access app certificates
az webapp config appsettings set -n app-name -g resource-group-name --settings WEBSITE_LOAD_CERTIFICATES=*
Deploy: Enable App/API load user profile
az webapp config appsettings set -n app-name -g resource-group-name --settings WEBSITE_LOAD_USER_PROFILE=1
Deploy: Set an app setting
az webapp config appsettings set -n app-name -g resource-group-name --settings ASPNETCORE_ENVIRONMENT='Production'
Git
Commit: Take back the last commit, but keep the changes
git reset --soft HEAD~1
LFS: Enable LFS Tracking for an extension (like zip)
git lfs track *.zip
LFS: Clean up Git commit history from large files
java -jar 'path-to-bfg-jar-file\bfg-1.14.0.jar' --convert-to-git-lfs '*.{zip,onnx,tsv,csv}' --no-blob-protection .
Pellerex: Foundation for Your Next Enterprise Software
How are you building your current software today? Build everything from scratch or use a foundation to save on development time, budget and resources? For an enterprise software MVP, which might take 8–12 months with a small team, you might indeed spend 6 months on your foundation. Things like Identity, Payment, Infrastructure, DevOps, etc. they all take time, while contributing not much to your actual product. These features are needed, but they are not your differentiators.
Pellerex does just that. It provides a foundation that save you a lot development time and effort at a fraction of the cost. It gives you source-included Identity, Payment, Infrastructure, and DevOps to build Web, Api and Mobile apps all-integrated and ready-to-go on day 1.
Check out Pellerex and talk to our team today to start building your next enterprise software fast.