💻 Welcome to the Command Line Interface (CLI) Section! Whether you’re new to the terminal or looking to sharpen your shell skills, this section will guide you through foundational commands used in real-world workflows. Through hands-on scenarios, you’ll learn how to navigate directories, manipulate files, search and filter text, and automate tasks—essential tools for data scientists.
Summary Table
Summary of the Command Line Interface (CLI) section.
Scenario: Create a Project
mkdir |
mkdir scripts |
Creates a new directory |
cd |
cd my_project |
Changes the current working directory |
touch |
touch analyze.py |
Creates an empty file |
ls |
ls -R |
Lists files and folders, -R lists recursively |
pwd |
pwd |
Prints the full path of the current directory |
New-Item |
New-Item file.txt |
(PowerShell) Creates a new file |
Get-ChildItem |
Get-ChildItem -Recurse |
(PowerShell) Lists files and folders recursively |
Get-Location |
Get-Location |
(PowerShell) Shows current directory path |
Scenario: Files
echo |
echo "hello" > file.txt |
Writes a string into a file |
cat |
cat README.txt |
Displays the contents of a file |
nano |
nano README.txt |
Opens a text file in the terminal editor |
cp |
cp file.txt backup.txt |
Copies a file |
mv |
mv file.txt archive/ |
Moves or renames a file |
rm |
rm backup.txt |
Deletes a file |
Get-Content |
Get-Content README.txt |
(PowerShell) Displays file contents |
notepad |
notepad README.txt |
(PowerShell) Opens file in Notepad |
Copy-Item |
Copy-Item file.txt archive\ |
(PowerShell) Copies a file |
Move-Item |
Move-Item file.txt archive\ |
(PowerShell) Moves a file |
Remove-Item |
Remove-Item file.txt |
(PowerShell) Deletes a file |
Scenario: Troubleshooting
tree |
tree |
Shows full directory tree (requires tree installed) |
grep |
grep "ERROR" *.log |
Searches text files for a pattern |
chmod |
chmod +x script.sh |
Changes file permissions |
history |
history |
Displays previously run shell commands |
clear |
clear |
Clears the terminal screen |
Select-String |
Select-String "ERROR" -Path *.log |
(PowerShell) Finds matching text in files |
Get-History |
Get-History |
(PowerShell) Shows command history |
Clear-Host |
Clear-Host |
(PowerShell) Clears terminal window |
Set-ExecutionPolicy |
Set-ExecutionPolicy RemoteSigned |
(PowerShell) Adjusts permission to run scripts |