Skip to main content

Introduction

Bash is a shell scripting language. It is used to run programs on a Unix-like system (Linux, Mac). This is a collection of useful commands and shortcuts for Bash.

Commands

Listing files

ls

Changing directories

cd

Listing mounted volumes

mount

Changing to a mounted drive

cd /mnt/drive

If the volume name has spaces in it, you will need to put it in quotes. For example, if the volume name is "My Drive", you would type:

cd "/mnt/My Drive"

Moving Files and Directories

mv [source] [destination]

Copying Files and Directories

cp [source] [destination]

Using SSH

SSH is a secure shell. It is used to connect to remote servers. The following commands are used to connect to a remote server.

Connecting to a remote server

ssh [username]@[server]

Note: The username and server are case sensitive. Also, you can use the IP address instead of the hostname.

You might need to add the public key of the server to your known hosts file. This is done by typing the following command.

ssh-keygen -R [server]

You might need a .pem file to connect to a remote server. This is done by typing the following command.

ssh-keygen -t rsa

After generating the key, the ssh command to connect to the server will look like the following.

ssh -i [path to .pem file] [username]@[server]