Mar 29 2007

LCoTD: About Commands and Users

Published by georgegumpert at 4:15 pm under Linux Command of the Day, Linux Resources ()

If you're new here, you may want to subscribe to my RSS feed. Thanks for visiting!

Since I’m using Linux more and more on a daily basis, I decided to start this series: Linux Command of the Day (LCoTD for short). The goal is to both help myself learn more about the Linux operating environment, and help others learn as well.

Today I’ll cover the basics of commands in the Linux environment. For reference, I am using Ubuntu, though they work in most distros.

What is a Command?

A Linux command typically consists of a program name followed by options and arguments, typed within a shell (command prompt). The program name refers to a program somewhere on disk (which the shell will locate and run). Options, which usually begin with a dash, affect the behavior of the program, and arguments usually represent inputs and outputs. For example, the following command to count the lines in a file:

$ wc -l myfile


consists of a program (wc, the “word count” program), an option (-l) saying to count the lines, and an argument (myfile) indicating the file to read. (The dollar sign is a prompt from the shell, indicating that it is waiting for your command.) Options may be given individually:
$ myprogram -a -b -c myfile


or combined behind a single dash:
$ myprogram -abc myfile


though some programs are quirky and do not recognize options combined in this manner.

Commands can also be much more complex than running a single program:

  • They can run several programs at once, either in sequence (one after the other) or connected into a “pipeline” with the output of one command becoming the input of the next.
  • Options are not standardized. The same option (say, -l) may have different meanings to different programs: in wc -l it means “count lines of text,” but in ls -l it means “produce longer output.” In the other direction, two programs might use different options to mean the same thing, such as -q for “run quietly” versus -s for “run silently.”
  • Likewise, arguments are not standardized. They often represent filenames for input or output, but they can be other things too, like directory names or regular expressions.
  • The Linux command-line user interface- the shell- has a programming language built in. So instead of a command saying “run this program,” it might say “if today is Tuesday, run this program, otherwise run another command six times for each filewhose name ends in .txt.”

Users and Superusers

Linux is a multiuser operating system (OS). On a given computer, each user is identified by a unique username, like “jones” or “w15h1w3r31337,” and owns a (reasonably) private part of the system for doing work. There is also a specially designated user, with username root, who has the priviledges to do anything at all on the system. Ordinary users are restricted: though they can run most programs, in general they can modify only the files they own. The superuser, on the other hand, can create, modify, or delete any file and run any program.

Some commands can be run successfully only by the superuser. In Ubuntu, to run a program as the superuser, prepend the command with sudo for “superuser do.”

And that wraps up today’s Linux Command of The Day…though there really isn’t any command to speak of, more of a simple orientation.

Sphere: Related Content

If you found this article useful and use StumbleUpon, please give it a thumbs up so more people can read it! Thank you!

Please take the time to check out this thread and leave a comment letting me know what you would like to see from this site. It's still relatively young and trying to find its way- you can make design pitstop the resource you always wanted!

Leave a Reply