Beginner's Command Line

From LQWiki
Jump to: navigation, search

This is an introduction to the Linux command line for users migrating to Linux from Windows.

The objective is to help migrating windows users learn to navigate the basic Linux command line and assumes you have installed Linux on a computer. When experimenting with the command line do so logged in as a user and not as root until you get familiar with it. Most Linux distributions do not protect themselves against root logins and you can do most anything good or bad.

Drive Scheme

To start, lets learn the basic drive scheme in Linux.

  • sda - refers to the first hard drive
  • sda1 - refers to the first hard drive and the first partition on that drive.
  • sda2 - first hard drive second partition
  • sdb - second hard drive
  • sdb1 - first partition on the second hard drive
  • sdc - and so on...

Dated: For distributions that haven't changed to the new system IDE drives follow the IDE Tree Mapping.

Drive Mounting Scheme

Drives in Linux are mounted to folders. Ex:

  • 'C:\' in windows would be approximated by '/' "Root Folder" in Linux.
  • 'C:\Documents and Settings\(User-name)' also 'My Documents' would be '/home/(user-name)' in Linux.

Other drives in Linux are mounted to folders and are accessed as such.

Getting Around the Command Line

The most common commands used for navigating and looking around on the Linux command line would be ls and cd.

General comparison to windows commands would be:

  • 'ls' = 'dir' lists the contents of a directory or folder
  • 'cd' = 'cd' changes your current folder

Getting Help in the Command Line

In Linux, the most common way to learn a command is man. man gives you advanced help on commands and you can type 'man man' (without quotes) for more information on using man.

More Commonly Used Commands

  • mkdir - creates a directory
  • rm - deletes a file or directory
  • cp - copies files and directories
  • mv - moves and/or renames files