Tuesday, June 30, 2015

Command Line

Introduction to the Command Line
Linux system administrators spend a significant amount of their time at a command line prompt. They often automate and troubleshoot tasks in this text environment. The command line interface provides the following advantages:
  • No GUI overhead.
  • Virtually every task can be accomplished using the command line.
  • You can script tasks and series of procedures.
  • You can log on remotely to networked machines anywhere on the Internet.
  • You can initiate graphical apps directly from the command line.
The Command Line
Most input lines entered at the shell prompt have three basic elements:
  • Command
  • Options
  • Arguments
The command is the name of the program you are executing. It may be followed by one or more options (or switches) that modify what the command may do. Options usually start with one or two dashes, for example,-p or--print, in order to differentiate them from arguments, which represent what the command operates on.
However, plenty of commands have no options, no arguments, or neither. You can also type other things at the command line besides issuing commands, such as setting environment variables.

Understanding Absolute and Relative Paths
There are two ways to identify paths:
  1. Absolute pathname: An absolute pathname begins with the root directory and follows the tree, branch by branch, until it reaches the desired directory or file. Absolute paths always start with /.
  2. Relative pathname: A relative pathname starts from the present working directory. Relative paths never start with /.
Multiple slashes (/) between directories and files are allowed, but all but one slash between elements in the pathname is ignored by the system. ////usr//bin is valid, but seen as /usr/bin by the system.
Most of the time it is most convenient to use relative paths, which require less typing. Usually you take advantage of the shortcuts provided by: . (present directory), .. (parent directory) and ~ (your home directory).
For example, suppose you are currently working in your home directory and wish to move to the /usr/bin directory. The following two ways will bring you to the same directory from your home directory:
  1. Absolute pathname method: $ cd /usr/bin
  2. Relative pathname method:   $ cd ../../usr/bin
In this case, the absolute pathname method is less typing.

    No comments:

    Post a Comment