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.

Related links

Comments

  1. BY John Q. Public says:

    You’ve got to be kidding. I don’t think there’s anybody on the planet using Linux who doesn’t know these simple commands. Maybe it new to you, but for the rest of us, this is so basic as to not warrant writing about. I see now why you wrote the other articles about the job market for Linux shrinking when the opposite is happening.

  2. BY Rob Reilly says:

    John Q. Public,

    Thank you for your comment. I always appreciate feedback from Dice readers.

    Yes, the story was basic. And, while it’s not new to myself, or you, it might be to readers just discovering the joys of Linux. In your opinion, the Linux market is expanding. Wouldn’t we want to encourage absolute newbies to Linux, by providing basic information? In my opinion, you don’t just pick up Linux. There’s always been a moderately steep learning curve. As the Linux community guide, I work hard to encourage and motivate all readers to be the best they can be, regardless of their level of expertise.

    With all that in mind, what stories do you think would be the most useful to Dice Linux community readers?

    Would you like to see deep technical articles about building Web sites using Open Source tools or configuring an email server?
    How about applying Linux applications to small business operations?
    What about an advanced command line series?
    Do you want to see more small-Linux device stories or product reviews?
    Do you want to see interviews with Linux experts? Covering what topics?
    Could you use more statistics and analysis of Linux jobs and opportunities?

    We certainly want to build the Dice readership and be the most trusted source of information available on the Web.

    Now, we can look at page view numbers, all day long, to judge what everyone would like to see. Passionate feedback from readers is definitely a more direct route for us to follow.

    The Dice community is a two-way street.

    Maybe you’d be up for an interview? Send me your contact information at robreilly@earthlink.net and we’ll set it up. I’m game if you are. Our conversation might benefit the whole Dice Linux community.

    So fire away and let me know what you want to see.

    Again, thanks for your feedback.

    Rob Reilly
    Dice Linux community guide

    • BY John Q. Public says:

      If you wanted to do something useful command-line wise, why not do an article on using chmod to set the suid bit and/or the sticky bit on files and diectories and what that accomplishes?

  3. BY John says:

    How about something from recent conferences or user group meetings?

    Don’t you hail from Orlando? There was the SUSECon & openSUSE Summit 2012 with lots of more Linux-related events to come the rest of the year. You could give a rehash of one of the many presentations.

    Or better yet, lurk thru Stackoverflow or Hacker News where I spend most of my time.

    Of course I’d like to see a strong focus on the “unemployable”, those old (40+), long-term unemployed IT folks who are struggling just to survive!!!

  4. BY Mike says:

    “Code a command”? A command is a command, usually one line.

    You might suggested “coding” a batch (command) file/script.

    I disagree “ix” is a moderately steep learning curve unless your tech experience is limited to GUI.

Post a Comment

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>