DEV Community

Cover image for 40+ Bash commands for cloud architects & engineers.
Phaustin Karani
Phaustin Karani

Posted on • Edited on

40+ Bash commands for cloud architects & engineers.

Linux is one of the most widely used open-source OS because of its safety, security features, and ease of use. In the cloud, you will find it in IoT, big data, DevOps, networking, data management, compute, and much more.

Major cloud providers like AWS, GCP, AZURE, Oracle & IBM Cloud have virtual machines running a variation of the Linux operating system like Ubuntu, Redhat, open SUSE, KALI Linux, CentOS, Fedora, etc. You will need to understand the bash commands to SSH Into such virtual machines or even use the command line.

for a beginner working with bash the terminal can look intimidating and you might think it's only meant for people with programming knowledge, which isn't true.in my experience bash has a small learning curve as compared to some programming languages.

in my case when I got into the cloud computing space I used to avoid using the CLI as much as possible but with practice, I got better at it and I now prefer using the CLI to the console. interacting with IAAS like Terraform or Ansible without knowing basic CLI commands is impossible so it's better to get used to it in the first place if you desire to build a career on the cloud.

Bash commands for AWS, Azure, GCP, Oracle, IBM Cloud & other clouds

all the major cloud providers have a cloud shell CLI to enable developers to build or destroy from the command line. you should note, to begin with, that the CLI is case sensitive ls and LS and 2 different commands so use lowercase letters unless stated otherwise.

the below commands are for bash which is native to Linux distros and not PowerShell.if you are interacting with PowerShell like on Azure cloud shell make sure to use their commands as they are not all the same as bash commands.

head -display just the beginning of a file, by default 10 lines

tail -displays the end of a file and does the opposite of the head command.

less - returns the content of a file one page at a time.
Enter fullscreen mode Exit fullscreen mode

Once you’ve accessed your content with the less command, you can use several keyboard controls to move through the file

Space bar -Move forward one page

b -Move back one page

Down arrow -Move forward one line

Up arrow -Move back one line

q -Quit and return to the previous terminal window
Enter fullscreen mode Exit fullscreen mode
ls -an argument used to list the contents of a directory.
Enter fullscreen mode Exit fullscreen mode
ls-l command gives a detailed list such as file type, permissions, and timestamp.
Enter fullscreen mode Exit fullscreen mode
ls -lt command sorts the files by timestamp.
Enter fullscreen mode Exit fullscreen mode
ls -l -t command sorts the file by size.
Enter fullscreen mode Exit fullscreen mode
pwd- print working directory used to discover where you currently are in the file system.
Enter fullscreen mode Exit fullscreen mode
cd-change directory can be used to change from the current directory to another.
Enter fullscreen mode Exit fullscreen mode
su- allows you to create a new cloud shell environment temporarily and act as a different user. to exit use the exit command to return the the admin account.
Enter fullscreen mode Exit fullscreen mode
sudo-allows a user to execute a command as another user without creating a new shell. sudo gives a user administrative privileges.
Enter fullscreen mode Exit fullscreen mode

sudo stands for superuser do.

chmod-used to change the permissions of a file or directory. Only the root user or file owner can be able to change permissions.
Enter fullscreen mode Exit fullscreen mode
chown-used to change the ownership of a file and directory.
Enter fullscreen mode Exit fullscreen mode
cp- used to copy files, you however need to have access/read permissions to execute. 
Enter fullscreen mode Exit fullscreen mode
cat-used to quickly view the entire contents of a file.
Enter fullscreen mode Exit fullscreen mode
mv- Similar to the copy command it is used to move files from one location in the file system to another. It also requires both a source and destination file path and necessary execution permissions.

Enter fullscreen mode Exit fullscreen mode
find -searches for directories and files that meet specified criteria
Enter fullscreen mode Exit fullscreen mode
grep - searches a specified file and returns all lines in the file containing a specified string
Enter fullscreen mode Exit fullscreen mode
piping -accessed using the pipe character (|). Piping sends the standard output of one command as standard input to another command for further processing
Enter fullscreen mode Exit fullscreen mode

aws cloud shell
Image description

rm-command is used to permanently delete files and directories.
Enter fullscreen mode Exit fullscreen mode
whoami-to find out your username
Enter fullscreen mode Exit fullscreen mode

gprep-command is used to search, filter and interpret text patterns presenting a matched result.
Enter fullscreen mode Exit fullscreen mode
shutdown-used to shut down the terminal in a safe way by the root account. the command needs a time argument specifying when the shutdown should begin.
Enter fullscreen mode Exit fullscreen mode
ps-lists processes running on the cloud shell terminal by default
Enter fullscreen mode Exit fullscreen mode
ps-e will display every process running in the system
Enter fullscreen mode Exit fullscreen mode
sudo apt-get update-administrative command to install package files from repositories.
Enter fullscreen mode Exit fullscreen mode
apt-get update shows the current list of available packages ready for download.
Enter fullscreen mode Exit fullscreen mode
APT (advanced packaging tool) is a command used to install new software packaging and upgrade existing ones.
Enter fullscreen mode Exit fullscreen mode

azure bash CLI
Image description

apt-get install- command to install/update a package by name

apt-get update-get package list from the package repository and update the local package database

apt-get upgrade-update all currently installed packages to their latest versions.

apt-get remove-command to delete all the files of a package except the configuration files.

apt-get purge-command to delete all package files from the system together with the configuration files.
Enter fullscreen mode Exit fullscreen mode
passwd-used to update a user's password. Users can only change their passwords but admins can change any password.
Enter fullscreen mode Exit fullscreen mode

echo-command prints the output to the terminal if used to add a comment or note to a file. Echo can also replace original content in a text through redirection.

CTRL +C breaks a continuous running process on the cloud shell.

mkdir -make directory command.
Enter fullscreen mode Exit fullscreen mode
ssh-keygen command to create a key pair for your VM.
Enter fullscreen mode Exit fullscreen mode
cat ..ssh/id_rsa.pub command to view your public key and use it with a VM.


Enter fullscreen mode Exit fullscreen mode

Ready to level up your Linux skills? Dive into expert-led courses and tutorials that will boost your expertise. Start learning today with this special link!

Top comments (0)