5 Fun & Useful Terminal Commands for Mac & Linux

Leveraging the Terminal for Mac and Linux Customization
A wealth of information exists online regarding Terminal commands and methods for personalizing your Mac or Linux system. OS X incorporates numerous hidden configurations, frequently accessed through commands structured like this:
com.company.product entry valuetype value
Understanding the 'defaults' Command
The defaults command is a command-line utility designed for modifying plist files, which essentially store application preference settings. Within defaults, the write function allows for the addition or alteration of entries within these plist files.
While defaults can be complex to master directly, applications like Secrets offer a user-friendly interface to access these functionalities without requiring extensive command-line knowledge.
Commands for Repeated Use
Typically, a specific plist entry requires modification only once. Once the preference is applied, re-entering the command becomes unnecessary. Nevertheless, certain commands prove consistently valuable and warrant learning for ongoing system management.
Below are five particularly useful commands that can be employed repeatedly to enhance your experience:
- Modifying Dock Behavior: Adjust the automatic hiding of the Dock.
- Customizing Finder Settings: Alter how Finder displays files and folders.
- Changing Terminal Appearance: Personalize the Terminal's color scheme and font.
- Adjusting System Notifications: Control the types and frequency of system alerts.
- Managing Login Items: Configure applications to launch automatically at startup.
These commands provide a foundation for efficient system customization, allowing users to tailor their Mac or Linux environment to their specific needs. Learning these can significantly streamline workflow and improve overall usability.
By understanding the power of the Terminal and the defaults command, users can unlock a deeper level of control over their operating systems.
SSH: Secure Remote Access
SSH, or Secure Shell, provides a method for establishing a secure remote connection to another device that has remote access enabled. It’s frequently employed for accessing jailbroken iPhones and transferring files between systems.
Furthermore, SSH is invaluable for troubleshooting and maintaining computers lacking a direct display, or for verifying operational status. It also facilitates the creation of secure tunnels for web traffic.
Enabling Remote Login on macOS
Users of macOS need to ensure remote login is activated on the target computer. This is achieved through System Preferences, specifically within the Sharing pane. Simply select the "Remote Login" checkbox to enable this functionality.
Pay close attention to the text displayed following "To log in to this computer remotely…", as this string is crucial for establishing the connection.
This string represents the command you'll utilize within the terminal to access the specified account on the remote machine.
Connecting via SSH
To initiate an SSH connection, use the following command in your terminal:
ssh user@host
Replace "host" with the IP address of the remote computer. You will then be prompted to confirm the connection and enter the password associated with the remote account. Upon successful authentication, you can execute commands remotely through the terminal interface.
Installing and Configuring SSH on Ubuntu
On Ubuntu systems, the OpenSSH server can be installed using the following command:
sudo apt-get install openssh-server
After installation, determine your computer’s IP address. This can be found by clicking the networking icon in the menu bar and selecting "Connection Information". Record the IP address, ensuring you note the correct one (not the broadcast address).
Once the IP address is obtained, remote access can be established using the same SSH command as described previously.
Utilizing the 'say' Command [macOS Exclusive]
The say command is a functionality exclusive to macOS operating systems. Regrettably, it is not available for Linux distributions. However, for users on Mac platforms, this command enables text-to-speech conversion.
To initiate speech output, simply enter the following command in the terminal:
say TYPE IN SCRIPT HERE
It's important to note that enclosing the text within quotation marks is unnecessary.
An alternative method involves typing say, pressing the return key, and then inputting the desired text. Everything typed subsequently will be vocalized by the system.
This feature can even be employed to generate synthesized singing, achieved through the following command:
say -v Cellos "TYPE IN SCRIPT HERE"
The -v flag allows for voice customization.
When altering the voice, the inclusion of quotation marks around the text is required.
Voice Selection
The -v option provides access to a range of voices. Experiment with different voice names to find one that suits your preferences.
For example, to use a different voice, you would modify the command as follows:
say -v "Your text here"
Replace with the desired voice identifier.
Practical Applications
- Accessibility: Assists users with visual impairments.
- Notifications: Provides audible alerts.
- Automation: Integrates with scripts for automated voice announcements.
The say command offers a simple yet powerful way to add speech capabilities to your macOS environment.
File Management with mv and cp
The mv and cp commands are essential tools for file management within a command-line interface. While graphical file browsers offer a user-friendly approach, utilizing the CLI provides advantages in specific scenarios.
One such instance involves hidden files. On most UNIX-like operating systems, including Linux and POSIX-compliant systems such as older versions of macOS, prepending a dot (.) to a filename conceals it from standard directory listings.
However, macOS presents a limitation; directly adding a dot to a filename through the Finder is not permitted. Therefore, the Terminal becomes the preferred method for hiding sensitive projects or files.
It's important to note that mv also functions as a renaming tool, offering dual functionality.
The cp command, conversely, is dedicated to file duplication. It allows you to create copies of existing files as needed.
Example Usage of mv
To relocate and potentially rename a file using mv, the following syntax can be employed:
mv ~/Desktop/sourcename.txt ~/Documents/destinationname.txt
This command moves the file "sourcename.txt" from the Desktop to the Documents directory, simultaneously renaming it to "destinationname.txt".
When working with Linux systems, enclosing the file paths within single quotes is often necessary to ensure proper interpretation, especially when dealing with spaces or special characters in filenames.
Navigating with the 'cd' Command
The cd command is utilized within the Terminal to change directories, effectively allowing you to move between locations on your system.
To move to a specific location, simply type cd followed by the desired path.
cd location
An alternative method for directory navigation involves dragging the target folder directly into the Terminal window after initiating the cd command.
Pressing Enter after this action will complete the navigation.
This convenient shortcut functions consistently across both OS X and Linux operating systems, with a slight ease of use advantage on OS X.
Returning to your home directory is simplified by typing just cd with no additional arguments.
cd
This will always bring you back to your user's home folder.
ls
The ls command is utilized to display the files and directories contained within a specific location. Prior to execution, it's necessary to navigate to the desired directory using the cd command.
Once positioned correctly, simply entering the following command will list the contents:
ls
This command is also capable of revealing files that are normally hidden from view. Consider how this functionality connects with the preceding commands discussed.
It provides a means to locate files that were previously concealed, aiding in their recovery. Hidden files can then be restored to visibility by employing the mv command to remove the leading dot from their names.
This allows for easy management and retrieval of all files, regardless of their visibility status.
Reflections and Further Exploration
Consider your own experience. Have you previously engaged with the command line interface? If this was your first time, did you discover these utilities to be straightforward and accessible?
Expanding Your Command Line Toolkit
The world of command line tools is vast. What other utilities would you suggest to fellow users?
We encourage you to share your recommendations and insights in the comments section below. Your contributions can help others discover valuable resources and enhance their command line proficiency.
Your Feedback is Valuable
We are eager to hear your thoughts on the tools discussed. Do you have any questions or suggestions for future explorations of command line utilities?
- Share your experiences with these tools.
- Recommend other helpful command line applications.
- Let us know what you’d like to learn about next.
Please contribute to the discussion by leaving a comment below. Your feedback is instrumental in shaping future content and ensuring we address the needs of our audience.




