Skip to content

Latest commit

 

History

History
137 lines (91 loc) · 4.7 KB

File metadata and controls

137 lines (91 loc) · 4.7 KB

Basic Command Line Tutorial for Beginners

Welcome to this beginner-friendly tutorial on using the command line. This guide aims to introduce you to the basics of command line operations. Learning the command line is crucial in data science for enhancing efficiency and handling complex tasks. Key reasons include:

  1. Speed: Command line operations often execute tasks faster than graphical interfaces.
  2. Automation: Scripts in the command line allow for automating repetitive tasks.
  3. Handling Big Data: The command line is effective for processing large datasets.
  4. Access to Tools: Many specialized data science tools are optimized for command line usage.
  5. Advanced Features: Certain advanced functions are more accessible or exclusively available through the command line.
  6. Version Control: Command line proficiency is essential for using version control systems like Git, which are vital in collaborative data science projects.
  7. Understanding Systems: Using the command line offers deeper insights into the workings of computers and software, beneficial for troubleshooting and optimization.

Overall, command line skills significantly contribute to the efficiency, power, and versatility of data science workflows.

VSCode setup

Introduction to the Command Line

The command line, also known as the terminal or shell, is a text-based interface to the system. You can perform almost all the tasks that you do with a GUI, but using text commands can often be more efficient.

Opening the Terminal

Before navigating the file system, you need to know how to open the terminal on your operating system:

Windows

  • Press Windows + R, type cmd, and press Enter. This opens the Command Prompt.
  • Alternatively, you can search for "Command Prompt" in the Start menu.

MacOS

  • Open Finder, go to Applications > Utilities, and double-click on Terminal.
  • Alternatively, you can use Spotlight by pressing Command + Space, typing Terminal, and pressing Enter.

Linux

  • Usually, you can open the terminal with a shortcut, typically Ctrl + Alt + T.
  • Alternatively, you can find it in your applications menu, the location of which varies by distribution.

Navigating the File System

Displaying the Current Directory

  • Command: pwd (Linux/Mac) or cd (Windows, without arguments)
  • Purpose: To display the path of the current directory.
  • Usage:
pwd

Listing Files and Directories

  • Command: ls (Linux/Mac) or dir (Windows)
  • Purpose: Lists all files and directories in the current directory.
  • Usage:
ls

A full list of ls command options is available here.

Changing Directories

  • Command: cd
  • Purpose: To change your current directory.
  • Usage:
cd Documents

File Operations

Managing files is a frequent task in the command line.

Creating a New File

  • Command: touch (Linux/Mac) or type nul > (Windows)
  • Purpose: To create a new, empty file.
  • Usage:
touch newfile.txt

Creating a New Directory

  • Command: mkdir

  • Purpose: To create a new directory.

  • Usage:

    mkdir NewFolder

Deleting Files and Directories

  • Command: rm (file) or rm -r (directory, Linux/Mac) and del (file) or rmdir /s (directory, Windows)
  • Purpose: To delete files or directories.
  • Usage:
rm unwantedfile.txt
rm -r OldFolder

Viewing and Editing Files

  • Command: cat (Linux/Mac) or type (Windows)
  • Purpose: To display the content of a file.
  • Usage:
cat example.txt

This tutorial has covered the basics of using the command line, providing you with the foundational skills necessary for many tasks in software development, data science, and system management. As you gain more comfort with these commands, you'll find the command line to be a powerful tool in your toolkit.

Resources