Save Time With the Linux Command Line
The Linux command line is a useful and time-saving tool, even for the new user. It can be a little confusing in the beginning, especially if you're used to strictly a graphical interface. Speaking of the beginning, the command line was all you had before the advent of laptops, desktops, and tablets. Now, we've kind of come full circle, because there is quite a selection of Linux-based devices available today that don't have any video chips built-in. Tasks are accomplished just using the command line. A great example is the Plug Computer. Another situation might be logging into a remote Linux machine. Chances are you'll interact with it using the command line over the network. A good way to learn about the command line is to just jump right in, code a few commands and build from there. Go to your main desktop toolbar and open a terminal. You should see a prompt that looks like this in the window. rob:~$ From here you can type in your commands and get results (output). The basic layout of a Linux command is: [the command] -options filename Take the ls command for example. If you simply type ls, you'll get a list of the files in your current directory. A directory is the same thing as a folder in other operating systems. Command: rob:~$ ls Result: kst0001.pdf kst0002.pdf kst0003.pdf kst0004.pdf kst0005.pdf Here's one using the -l option. Command: rob:~$ ls -l rob.txt Result: -rw-r--r-- 1 rob rob 313130 2012-07-09 11:58 rob.txt In this case, ls is the name of the command, -l is an option and means to give a long listing, followed by rob.txt, which is the file name. You can always find out about the command using the --help option. The –help option usually gives a condensed version of command usage, although you sometimes get several pages of options. For a more detailed description of the command you can always use another command, man. man is short for manual and is available on virtually every version of Linux ever made. The man command is also sometimes referred to as the man pages. So if somebody says to check the man pages, that just means to type man [command], to find out about the command. You can also type help to get a partial list of Linux commands. The Web has extensive lists of Linux commands. Use “linux commands” in Google. Here are several important commands I use all the time, in the terminal. cd cd is for changing the directory. A directory is the same as a folder, on other operating systems. If you type cd by itself, it will put you back in your home directory. An example of your home directory might look like /home/rob. To change to another directory type cd and the directory name. For example, if I'm in my home directory (/home/rob) and want to move down to my Download directory, I'd just use the following. Command: rob:~$ cd Downloads Result: rob:~/Downloads$ pwd pwd tells you your present working directory. Command: rob:~$ pwd Result: /home/rob cp cp is for copying files. The normal layout of this command is: cp [original file name] [target file name] Command: rob:~$ cp rob.txt rob.htm Result: The rob.txt file is copied to the rob.htm file, in the same directory. cat cat is used to display the contents of a file. I use it to show me what's in a text file. Command: rob:~$ cat rob.txt Result: c0001|77.34 c0001|77.45 c0001|77.45 c0001|77.34 c0001|77.45 c0001|77.45 c0001|77.45 c0001|77.45 c0001|77.45 As you can see, the command line isn't that scary. Try some of the commands and remember to use the --help option. A lot of jobs can be done with the command line and I think you'll find it very useful. You'll find a few common command line lists under the related links.