5 Fun & Useful Terminal Commands You Can Use More Than Once [Mac & Linux]
There 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, 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.
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…”
That’s what you have to type into the terminal to log in to that account on that computer. To login using SSH, simply type:
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.
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
, 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"
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.
To navigate to a location on your Terminal, just type:
You can also drag the folder to the Terminal window after typing cd and then press Enter.
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:
Use ls to see the contents of a directory. First you must cd into the location. Then just type:
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.
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!