Skip to content

This notebook belongs to

Sadat Jubayer

Senior Software Engineer at Premio

If found, please return to hello@jubayer.dev

Vol. 7Seven years of building

Started
January 2020
Everyday tools
TypeScript, Vue, React, Next.js, NestJS, React Native
Education
B.Sc. CSSE, AIUB, 2020
1 min readDev Tool

Basic command-line commands

Use a terminal to list files, change directories, and create, rename or remove files and folders.

You can do these exercises in your terminal on Linux or macOS. On Windows, use WSL or Git Bash from Git for Windows.

Print, list and move around

echo hello world
whoami
pwd
ls
ls -la

echo prints the words, whoami prints your username, and pwd prints your current directory. ls lists its visible entries. Add -l for details and -a to include entries whose names start with a dot.

Directory listing in a terminal

diagram

Anatomy of a command

The program is ls, the options are -la, and the directory argument is ~/Projects.

Create a folder and a file

Start in a directory where you can create a new folder called cli-practice.

mkdir -p cli-practice/react
cd cli-practice
touch secret.txt
mv secret.txt open.txt
ls

mkdir -p creates the parent directory as needed. cd enters it, touch creates an empty file if the name is new, and mv renames it. The list should now include open.txt and react.

pwd prints where you are, ls lists the directory, and cd .. goes to the parent.

Clean up

rm -i open.txt
rmdir react
cd ..
rmdir cli-practice

Confirm when rm -i asks to remove the practice file. rmdir removes an empty directory. If you skipped the confirmation or created extra files, rmdir cli-practice will report that it is still full. See the GNU Coreutils manual for command options.