Command line basics

From Mandrivausers Wiki

Jump to: navigation, search

[edit] What is Command Line Interface (CLI)

A command line interface or CLI is a method of interacting with a computer. Commands are entered as lines of text (that is, sequences of typed characters) from a keyboard, and output is also received as text. CLIs originated when teletype machines were connected to computers in the 1950s. In terms of immediate interaction and feedback, they represented an advance over the use of punch cards.

With the use of CRTs as interface devices, CLIs began evolving toward graphical user interfaces (GUIs) like Microsoft Windows, Mac OS, and the X Window System, and were largely supplanted by GUIs when Microsoft introduced Windows (prompted by the success of Apple). A significant minority of computer users prefer to use CLIs, some due to visual disability, and others because they feel that CLIs provide an environment with significantly enhanced productivity. They are most often used in scientific, engineering, and technical environments, by programmers, especially in UNIX-based operating systems.

In its simplest form, a CLI displays a prompt, the user types a command on the keyboard and terminates the command (usually with the Enter key), and the computer executes the command, providing textual output.

A program that implements such interface is often called a command line interpreter or shell. Examples include the various Unix shells (sh, ksh, csh, tcsh, bash, etc.), the historical CP/M, and DOS's command.com ("Command Prompt"), the latter two based heavily on DEC's RSX and RSTS CLIs.

[edit] Basic commands

When we talk about going "into" a directory, like opening a folder in a graphical user interface (GUI) with your mouse, we will be able to view the contents of it. "ls" (for list) will list the files and directories within your current working directory (CWD), that is, the directory you are currently sitting in. When you first log onto the computer, or when you first open a "terminal" in X windows (X windows is a GUI incredibly similar to microsoft's GUI called windows), you are at the command line, and your working directory is usually /home/joe to start (if your name is joe - and for now IT IS)


Let's look at the command line.


[joe@joes.computer joe]$ 


What this is telling you is joe is logged into (joe@) the computer, which happens to have been cleverly named "joes.computer". joe@joes.computer makes sense, doesn't it. The last joe is telling you the current working directory, /home/joe (it always only shows the last directory name of your CWD.) The command "pwd" will print your working directory to the screen. It will look like this:


[joe@joes.computer joe]$ pwd 
/home/joe 
[joe@joes.computer joe]$ _ 


Every directory has two special directories in them; "." and ".." ; "." means "this directory" and ".." means "the directory above me" or "my parent directory". The only exception is / has no parent directory there is no /.. to "cd" to.


~ is the same as /home/joe. "cd ~" from anywhere will take you straight to /home/joe. Also, "cd /" will take you straight to the top, /. From /, you could type "cd home".

Personal tools