How to Use Terminal on macOS & Linux - Adcod.com

How to Use Terminal on macOS & Linux for Everyday Tasks

Anúncios

If you have ever felt intimidated by the black window of the terminal, you are not alone. Yet the command-line interface (CLI) on Terminal (macOS) or on any typical Linux distribution is one of the most powerful tools in a technologist’s toolbox. With more than 20 years writing copy for tech audiences, I can tell you: mastering a handful of common commands and workflows will save you hours and elevate your productivity. In this post for AdCod (adcod.com) I will guide you through using the terminal for everyday tasks—navigating the filesystem, managing files and directories, monitoring processes, and automating simple workflows. Follow along, copy the commands into your own terminal, and begin working smarter, not harder.

Why use the terminal?

The terminal may look intimidating at first, but it is one of the most efficient and versatile tools in any operating system. Whether you’re using macOS or Linux, the command line gives you direct access to your system’s core functions, allowing you to perform tasks faster, automate repetitive processes, and troubleshoot issues with precision.

Anúncios

Terminal window showing simple commands on macOS
Basic macOS Terminal

While graphical interfaces are great for everyday users, developers, IT professionals, and power users know that mastering the terminal unlocks a deeper level of control and productivity that simply isn’t possible with clicks alone.

While graphical interfaces are familiar and user-friendly, the terminal offers advantages:

Anúncios

  • Speed – one command can replace multiple clicks.

  • Precision – you control exactly what happens.

  • Automation – you can script repetitive tasks.

  • Portability – the same commands apply on macOS and Linux (often with minimal changes).
    By embracing the CLI you become more efficient. So let’s dive in.

Also read: Best SSH Client Software Tools for Windows, Mac, and Linux

Opening the terminal and getting oriented

Before you can start mastering commands, you first need to know how to open the terminal and understand its basic layout. The terminal acts as your direct gateway to the operating system, allowing you to communicate with it through text-based commands instead of graphical menus.

User customizing terminal theme and preferences
Terminal Settings

Once opened, you’ll see a command prompt, the place where you’ll type instructions that the system will immediately execute. Getting familiar with this environment is the first step toward becoming confident in navigating, managing files, and running processes efficiently on macOS or Linux.

On macOS you open Terminal via Applications → Utilities → Terminal, or use Spotlight (Cmd + Space then type “Terminal”). On Linux you may press Ctrl + Alt + T or select your “Terminal” application from the menu.
Here are two excellent tutorials:

Once open, you will see a prompt: something like username@computername ~ % or similar. The ~ indicates your “home” directory. The shell (often bash or zsh) awaits your instruction. Let’s start with navigation.

Also read: What command is used to terminate a process?

Navigating the filesystem

One of the first skills to learn in the terminal is how to move through your computer’s filesystem. Understanding how to navigate directories lets you access files, organize data, and execute commands in the right locations, all without touching your mouse. It’s the foundation for nearly every task you’ll perform in the command line.

Print working directory

pwd

This shows your current directory.

Change directory

cd Documents

Moves you into the Documents folder.

cd ..

Moves you up one level.

cd ~

Returns you to your home directory.

List contents

ls

Lists files and directories. Add -l for details (ls -l), or -a to include hidden files (ls -la).

Why this matters

Rapidly moving around your filesystem from the keyboard speeds up tasks like editing files, moving directories, or invoking scripts.

Managing files and directories

Once you know how to navigate the filesystem, the next essential step is learning how to manage files and directories. From creating and renaming to copying, moving, and deleting, these basic operations form the backbone of everyday command-line use. Mastering them allows you to organize your workspace quickly and efficiently.

Create a directory

mkdir new_folder

Create an empty file (macOS/Linux)

touch new_file.txt

Copy, move and remove

cp source.txt destination.txt
mv file.txt target_folder/
rm file.txt

Be careful with rm because it deletes immediately (no trash). To remove a directory and its contents:

rm -r old_folder

View a file’s contents

cat file.txt

For large files, use less file.txt so you can scroll.

Editing files

You can launch a terminal editor like nano or vim:

nano file.txt

Automating simple workflows via chaining

You can combine commands with && so that one runs after another:

mkdir backup && cp important.doc backup/

This creates a “backup” directory and then copies the file into it.

Monitoring processes and system status

Beyond managing files, the terminal also lets you monitor what’s happening inside your system in real time. You can view active processes, check memory and disk usage, or identify which tasks are consuming resources. This knowledge is invaluable for troubleshooting performance issues and keeping your system running smoothly.

View running processes

ps aux

Or install and use top / htop for real-time process monitoring.

Find a process

ps aux | grep process_name

Kill a process

kill PID

Where PID is the Process ID you found earlier. To force kill:

kill -9 PID

Check disk usage

df -h

Shows disk usage in human-readable format.

Check file/directory size

du -sh folder_name

Why these matter

As a technologist you often need to troubleshoot – check for hung processes, heavy disk usage, zombie tasks. Doing this via GUI is slower.

Networking and remote access basics

The terminal is also a powerful tool for managing network connections and accessing remote systems. With just a few commands, you can test connectivity, transfer files, or securely connect to another computer from anywhere. These networking fundamentals are especially useful for developers, system administrators, and anyone working across multiple machines.

Ping a host

ping google.com

(Ctrl +C to stop)

SSH into a remote machine

ssh user@hostname

Copy files from local to remote

scp localfile.txt user@remote:/home/user/

Or from remote to local accordingly.

Why this matters

If you work in DevOps, sysadmin, or just manage remote servers, knowing CLI networking and remote access commands is essential.

Also read: What are the operating system error?

Useful scripting and automation tips

User typing automation commands
Automation with Scripts

Once you’re comfortable with basic commands, scripting and automation take your terminal skills to the next level. By combining commands or writing small scripts, you can automate repetitive tasks, back up data, or manage files with a single execution. This not only saves time but also ensures consistency and efficiency in your daily workflows.

Using wildcard patterns

rm *.log

Deletes all files ending in .log.

mv *.jpg images/

Moves all JPEGs into the “images” folder.

Redirecting output

ls -l > filelist.txt

Saves the output of ls -l into filelist.txt.

grep “ERROR” logfile.txt | tee errors.txt

Shows lines containing “ERROR” and writes them into errors.txt.

A simple Bash script example

Create a file backup.sh:

#!/usr/bin/env bash
tar -czf backup_$(date +%F).tar.gz ~/Documents
echo "Backup created on $(date)"

Then make it executable:

chmod +x backup.sh

Run it:

./backup.sh

Automate this via cron (Linux) or launchd on macOS to run nightly.

Best practices for terminal use

As you become more confident using the terminal, following best practices helps you work smarter and avoid costly mistakes. Simple habits like using aliases, leveraging keyboard shortcuts, and double-checking commands before execution can greatly improve your efficiency and safety. These practices ensure a smoother and more productive command-line experience.

  • Use tab completion to avoid typos.

  • Use arrow keys to recall previous commands.

  • Use aliases for common commands (in ~/.bashrc or ~/.zshrc):

    alias ll='ls -lah'
  • Keep your working directory tidy.

  • Use version control tools like git inside the terminal.

  • Always double-check when using rm –r, sudo, or pipelines that delete files.

Summary

In this post we covered how to open the terminal on macOS and Linux, navigate the filesystem, manage files and directories, monitor processes and system metrics, run simple networking commands, and begin scripting for automation. The terminal is not just for experts—it can become your everyday productivity tool. With consistent practice you will find yourself doing tasks faster and with more accuracy.

You may also like:

MacBook screen showing memory optimization process

How to Reduce Memory Usage on macOS

Anúncios If your Mac seems sluggish, apps freeze, or you keep seeing warnings to force-quit applications, chances are memory (RAM) is under pressure. In this detailed guide, we will explore proven, up-to-date techniques to reduce memory usage on macOS—so your system runs faster, smoother, and more reliably. Modern versions of macOS, from Monterey to Sonoma,…
Secure VPN connection

How to Install & Configure VPN on Any Device

Anúncios A VPN not only protects your personal data from cyber threats but also gives you the freedom to browse the internet without borders. From accessing streaming content restricted to certain regions to safeguarding your connection when using public Wi-Fi, the benefits go far beyond privacy alone. By understanding how to properly install and configure…
Recovering Deleted Files on Windows and macOS

How to Recover Deleted Files on Windows / macOS

Anúncios Accidentally deleting an important file can feel like a nightmare. Whether it’s a work document, cherished photo, or critical project folder, losing data can disrupt your workflow and peace of mind. The good news is that, in most cases, your files are not truly gone — they can often be recovered with the right…
Pourquoi mon Mac est-il lent ? 10 solutions pour l’accélérer

Why Is My Mac Running Slow? 10 Fixes to Speed It Up

Anúncios Why is my Mac running slow? If you’ve ever asked yourself this question, you’re not alone. Even powerful and reliable Macs eventually start showing signs of slowdown: apps take forever to load, your browser crawls, and sometimes the whole system freezes. The good news is—you don’t have to buy a new Mac. With the…
How to Get Rid of a Virus on Mac or PC

How to Get Rid of a Virus on Mac or PC

Anúncios Malware comes in many flavors—viruses, adware, spyware, ransomware—and yes, it targets both Windows and macOS. If the computer is acting weird (pop-ups, slow performance, sketchy browser redirects), this guide explains how to get rid of a virus on Mac or PC safely and thoroughly, without making things worse. What to Do First Why It…
MacBook Screen Showing Lines

How to Fix Horizontal or Vertical Lines on MacBook Screen

Anúncios Seeing horizontal or vertical lines on your MacBook screen is frustrating. One moment everything looks fine, the next your display looks like a glitchy barcode. The good news? Not every striped screen means your MacBook is doomed. In many cases, you can troubleshoot the issue at home without rushing to the Apple Store. And…

How do I find my AnyDesk ID and password?

Anúncios To recover your password, go to my.anydesk.com and click “Forgot your password?”. This will send a password reset email to the one registered to your account. Where can I find my AnyDesk ID? The remote user provides their AnyDesk-ID or Alias found in the “This Desk” (pre-AnyDesk 7) or “Your Address” (AnyDesk 7+) field.…
errordomain=nscocoaerrordomain&errormessage=could not find the specified shortcut.&errorcode=4

Understanding and Fixing the NSCocoaErrorDomain Error: “Could Not Find the Specified Shortcut” (Error Code 4)

Anúncios Encountering the error message “errordomain=nscocoaerrordomain&errormessage=could not find the specified shortcut.&errorcode=4” can be frustrating for macOS and iOS users. This error is part of the NSCocoaErrorDomain, which is used by Apple’s operating systems to handle various file handling and system access issues. Specifically, error code 4 indicates a problem with locating a specified shortcut. In…

Can we use max with * in SQL?

Anúncios You can obviously retrieve multiple columns for each record, and (only if you want to retrieve all the columns) you can replace the list of them with * , which means “all columns”. So, in a SELECT statement, writing * is the same of listing all the columns the entity has. What does a…

Why do we need wildcards?

Anúncios Wildcards are special characters that can stand in for unknown characters in a text value and are handy for locating multiple items with similar, but not identical data. Wildcards can also help with getting data based on a specified pattern match. Why do we need wildcards in Java? In generic code, the question mark…