Command Line Basics
The command line interface (also known as terminal, shell, or CLI) is a text-based interface for interacting with your computer. This guide provides basic instructions for using the CLI, intended for users who occasionally need to execute programs or interact with files through the terminal.
Basic Commands
Navigation
pwd
- Shows your current directory (Print Working Directory)ls
- Lists files and folders in the current directorycd [directory]
- Changes to the specified directorycd ..
- Moves up one directory levelcd ~
- Returns to your home directory
File Operations
cp [source] [destination]
- Copies a filemv [source] [destination]
- Moves or renames a filerm [file]
- Removes a file (use with caution!)mkdir [name]
- Creates a new directory
Running Programs
./program_name
- Runs an executable in the current directorypython script.py
- Runs a Python script (this assumes you have python installed on the machine)
Tips for Beginners
- Use Tab Completion: Press the Tab key to auto-complete file and directory names
- Check Your Current Directory: Always know where you are using
pwd
before running commands - Be Careful with
rm
: The shell will not ask twice. Deleted files cannot be recovered from the trash - Use
ls
Often: Check what files are in your directory before making changes
Common Issues and Solutions
- “Command not found”: The program you’re trying to run isn’t in your PATH or isn’t installed
- “Permission denied”: You don’t have the right permissions to execute the file. You may need to ask the program creator to run
chmod
, or contact the system adminstrators for access to certain files. - “No such file or directory”: Check your spelling and current directory