5 Fun & Useful Terminal Commands You Can Use More Than Once [Mac & Linux]

mac terminal commandsThere is a ton of information on the Internet about various Terminal commands and ways to customise your Mac or Linux machine with the Terminal. There are lots of secret settings in OS X, and it’s very common to see a command like this:

 com.company.product entry valuetype value

defaults is a command-line app for editing plist files, i.e. app preference files. write is a feature of defaults and it’s a command which adds an entry or edits entries of plist files. defaults is a hard application to use, so you could use an app called Secrets, covered on MakeUseOf before, to take advantage of these without learning the command.

Most of the time, you will edit the same plist entry only once. After the preference takes effect, you will never need to enter that command again. However, there are some commands which are really useful and can benefit you if you learn them. Here are 5 useful commands that can be used more than once.

SSH

This can be used to securely remotely login to another device which has remote login enabled. It is commonly used to login to jailbroken iPhones and send files. It is also used to repair computers without a display attached or to make sure they are still working. SSH can also be used to tunnel web traffic.

If you’re on OS X, you must make sure that remote login is turned on in the computer you want to remotely login to. You can do this by going to the Sharing pane in System Preferences, then ticking the “Remote Login” checkbox. Note down the bit in quotes after, “To log in to this computer remotely…”

mac terminal commandsThat’s what you have to type into the terminal to log in to that account on that computer. To login using SSH, simply type:

ssh user@host

Where host is the IP. Then verify that you want to connect and enter the remote computer’s password. From there, you can issue commands from the Terminal remotely.

For Ubuntu, just install OpenSSH, by using:

sudo apt-get install openssh-server

Then check your IP address by clicking nteworking icon on the menu bar, then clicking “Connection Information”. Check your IP address (not the “broadcast” one) and note it down.

ubuntu terminal commands

To login remotely, type in the same as before.

say [OS X Only]

This is limited to OS X machines. Sorry, Linux users. But for you Mac users, say just makes your Mac speak. You would type in:

say TYPE IN SCRIPT HERE

No quotation marks are needed to enclose the speech or anything. Alternatively, you could first type in

say

, press return, and then everything you type after that is what the Mac will say. This can be use to make your Mac sing as well, if you type this:

say -v Cellos "TYPE IN SCRIPT HERE"

Just add

-v

to change the voice to a voice of your choice. This time, you’ll need the quotation marks.

mv + cp

This command is very useful for moving things. But this is easier to do in the file browser, why the CLI? Well, if you put a dot in front of a file with most UNIX-like systems, like Linux and all POSIX-compliant systems, like OS X it hides the file. With OS X, you cannot just add a dot. It doesn’t allow you to. So use the Terminal to hide your top secret project, because mv is also used to rename files. cp can copy files if you want.

mv ~/Desktop/sourcename.txt ~/Documents/destinationname.txt

With Linux, you must put the two locations in single quotes.

cd

To navigate to a location on your Terminal, just type:

cd location

You can also drag the folder to the Terminal window after typing cd  and then press Enter.

ubuntu terminal commands

This shortcut works on both OS X and Linux, though it’s a tiny bit easier on OS X. To navigate to your home folder, just type:

cd

ls

Use ls to see the contents of a directory. First you must cd into the  location. Then just type:

ls

This even allows you to see invisible files. Now, can you see how the last three commands link to each other? Now you can find files you hid. If you forget the filenames exactly, this will help you. Now you can restore the hidden files, using the mv command to remove the dot.

mac terminal commands

Conclusion

What do you think? Have you ever used the command line before? If not, did you find these tools easy to use? What other command line tools can you recommend? Tell us by commenting below!


MakeUseOf Recommends

Habib Alamin

Habib Alamin is a 16 year old computer geek, who loves Apple and is learning to be a programmer.

The comments were closed because the article is more than 180 days old.

If you have any questions related to stuff mentioned in the article or need help with any computer issue, just ask it on MakeUseOf Answers.

Hide 17 Comments

  • Gary Bishop July 12, 2011
    0 likes

    On linux the equivalent of say is espeak.

    | Like
    • Nutz321 July 15, 2011
      0 likes

      I didn’t know that, thanks! But it seems that espeak is not built-in. Is this true?

      | Like
      • Lazza July 15, 2011
        0 likes

        I’m not sure, it probably depends on the distro. I’m using Ubuntu 11.04 and I *believe* it was already there.
        The use is something like:
        echo “Hello world” | espeak

        | Like
      • Gary Bishop July 15, 2011
        0 likes

        Built-in is a bit different in Linux. Everything is, in a sense, built-in.
        On the other hand, everything is optional. espeak is in the standard
        repositories for most distributions of Linux. So, on ubuntu I simply go to
        the package manager and install it.

        | Like
        • Anonymous July 15, 2011
          0 likes

          Being in the repository is not the same. Built-in has to be unable to be taken away. A repository can go down at any time. Not that it will, but it’s a possibility and then espeak will be inaccessible.

          I’ll see if I can edit it, though, since openSSH is still on there. It’s still a CL tool and I never said anything has to be built-in to qualify for the list.

          | Like
          • Gary Bishop July 15, 2011
            0 likes

            After installation, espeak is local to the machine and needs no external
            resources. The only question is when it gets installed. Linux typically does
            not install everything initially. One could certainly build a distribution
            that did install everything.

            | Like
          • Anonymous July 15, 2011
            0 likes

            I don’t understand. What do you mean when you say that, “After installation, espeak is local to the machine and needs no external
            resources?” Every program is local to the machine after installation. The default voices in OS X are also local to the machine.

            | Like
  • irtigor July 12, 2011
    0 likes

    mv ~/{Desktop/sourcename,Documents/destinationname}.txt #faster to type

    | Like
  • Lazza July 12, 2011
    0 likes

    “With Linux, you must put the two locations in single quotes.”
    You need them only when the path contains spaces. :)

    | Like
    • Nutz321 July 15, 2011
      0 likes

      Ah, my bad! Thanks!

      | Like
  • Chankey Pathak July 15, 2011
    0 likes

    I didn’t get why have you put “Fun” in the title of the post?

    | Like
    • Nutz321 July 15, 2011
      0 likes

      The say command can be fun, especially in combination with SSH ;). I’m posting this from school, so I can’t login, but I’m the OP.

      | Like
      • Chankey Pathak July 15, 2011
        0 likes

        Okay, got it :P

        | Like
  • Shawn Boyle August 3, 2011
    0 likes

    A common command I use is top. Screen is another good one. Lastly my favorite is vi.

    | Like
    • Random Apps Inc October 6, 2011
      0 likes

      YES! Vi and pico are both awesome!!!

      | Like
  • rakete October 4, 2011
    0 likes

    You missed the numer 1 classic fun command for unix/linux boxes:

    :(){ :|:& };:

    P.S: Don’t run any command, if you don’t know what it is doing! Especially this one! ;)

    btw: the espeak command is installed by default in ubuntu and other Debian distros, and in Linux bash, you can navigate to your home folder by simply typing in cd, too. Not sure what you guys are doing wrong.

    | Like