Skip to main content
Advertisement

Basic Terminal Commands

Linux is more powerful in a CLI (command input) environment than in a GUI (mouse click) environment.

1. File and Directory Management

  • pwd: Print current directory path (Print Working Directory)
  • ls: List files and folders in the current directory (-al option recommended)
  • cd [path]: Change directory (cd .. to move to the parent directory)
  • mkdir [name]: Create a new directory (folder)
  • rm [name]: Delete file (rm -rf forcefully deletes a folder, so be careful)
  • cp [source] [target]: Copy file/folder
  • mv [source] [target]: Move file/folder or rename

2. Checking and Editing File Content

  • cat [file]: Print the entire contents of a file
  • head/tail [file]: Print the beginning/end of a file (tail -f is useful for checking logs in real-time)
  • grep [string] [file]: Search for a specific string within a file
  • vi or vim: Standard Linux text editor (Exit: :q, Save and exit: :wq)
  • nano: A text editor that is easy for beginners to use

3. Network and System Information

  • top / htop: Check real-time system resource (CPU, memory) usage
  • df -h: Check disk free space
  • free -m: Check memory usage
  • ip addr: Check network interface information such as IP address
  • ping [address]: Check network connection status

4. Package Management (Ubuntu based)

  • sudo apt update: Update package lists
  • sudo apt install [package]: Install a program
  • sudo apt upgrade: Update all package versions

In the next section, we'll learn about the file permission system, which is the security model of Linux.

Advertisement