Bash basics
TIP
If you're working on Windows, this guide assumes you're working in WSL. There's a quickstart guide to setting up WSL in the installation steps.
Running a command
Open a terminal and run
bash
echo "Hello, Bash!"to print a cheery message in the console.
Create a directory
Create a Repos directory with
bash
mkdir ReposChange directory
Enter your new directory with
bash
cd ReposChain commands
You can chain commands with &&
bash
mkdir notes && cd notesMake a new file
Make a new file with
bash
touch note1.txtMake multiple files with
bash
touch note2.txt note3.txtList a directory
List the contents of the current directory with
bash
lsor some other directory by passing its path
bash
ls todosMove a file
Move a file with
bash
mv todo2.txt todosRename a file
Rename a file with the mv command
bash
mv note2.txt todo2.txtDelete a file
Delete a file with
bash
rm note3.txtDelete a folder
Delete a whole directory with rm and some options
bash
rm -rf todosDANGER
The todos folder and everything it contains will be deleted without going into the recycle bin. Once it's gone, you can never get it back.
Corndel