Monday, July 11, 2011

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

mac terminal commands
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, 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!

No comments:

Post a Comment

[Please do not advertise, or post irrelevant links. Thank you for your cooperation.]