Home page
Articles for Windows, Linux, OS X
Mac tips and articles
Mac tips
Windows 8 tips and articles
Windows 7 tips and articles
Vista Tips
XP Tips
Linux tips and articles
Read the blog
Online store
Windows, Linux, OS X programs

Linux tips and tweaks

Essential Terminal commands

Linux's love afair with the command line is legendary and the solution to many problems is to open a Terminal window and type in some obscure commands. When you want to run some utility or program you type in some more commands, and when you need to perform some task, you type in - you guessed it - commands. Windows and OS X both have command prompts, but they aren't used anywhere near as much and many Windows PC and Mac owners have never used the command prompt at all. Not even once.

It's a bit of a shock when switching to Linux and you need to know a few basic commands for listing the disk contents, moving around the disk directories and so on. Here are some useful commands to get you started in the Terminal window.

To see a list of the files and directories (folders) you type ls at the command prompt in a Terminal window. This produces a basic listing that runs across the screen and you may prefer this command instead: ls -l (lowercase L not number 1) which outputs a vertical list of items. You may find that directories are in colour to distinguish them from files, depending on your Linux distro. Files and directories can be hidden in Linux by starting the filename with a . and if you need to see everything, including hidden items, the type ls -l -a. The -a means all files and it can be used with or without the -l long listing switch. Try it and see all the hidden . files.

The ls command assumes that you want to list the contents of the current location and you can display some other location on the disk by including the path like this: ls /home. If you see a . or .. in the output then these are special characters that mean the current directory and the parent directory. They are the first items in the listing with the -a switch.

If you need to change directories, and you often do, then type cd /home, which means change directory and it's followed with the directory to change to. You can use cd .. to change to the parent directory (but cd . does nothing because it means change to the current directory, which you're already in). Supppose that you're in /home/bob, you can change to the /home/bob/downloads directory with cd downloads and entering cd .. goes back up to /home/bob.

If you need to delete a file at the Terminal then use rm filename. You can remove a directory, its contents and any subdirectories with rm -f -r filename where -f means force (gets rid of awkward items) and -r means recursive (everything the directory contains).

You can type a path with the rm command to delete any file or directory anywhere on the disk, but it's a bad idea. Get it wrong and it could do a lot of damage. Always change to the folder containing the item to delete and then type the rm command followed by the file or folder to remove.