command line fun – the basics

I was meeting with a younger friend to fix his virus laden laptop, it turned out to be quite a mess so we decided it would be more efficient to restore it from the recovery partition. I was a bit surprised to discover that his understanding of the command line was essentially a mystery.

This column will be examining various Linux commands that can be used in scripting or while working on the command line. Wherever possible I will also demonstrate similar functionality for windows batch files.   It is actually possible to do some basic scripting on windows but on a limited scale unless you install some additional product to help out.

Eventually, I am hoping to go beyond a “random” collection of commands and turn them into scripts to actually do useful work.

Basic commands

Linux Windows Description
ls dir This command lists the files in the current working directory
cd cd change directory to either a fully qualified directory name or to a subdirectory within the current directory
rm del delete the filename in the current directory
rmdir rmdir remove either a fully qualified directory name or to a subdirectory within the current directory
clear cls erases the screen and puts the cursor in the upper left hand corner

Linux command options

Command option meaning
ls -l directory listing in long format
ls -lt directory listing in date/time descending order
ls -ltr directory listing in date/time ascending order
ls -lSr directory listing in long format sorted by filesize ascending.
ls -1 directory listing only filenames
ls -1 directory listing only filenames
rm -r removes subdirectories and their containing files
rm -f ignore nonexistent files, never prompt
rmdir removes empty directories

Windows command options

Command option meaning
dir /od directory listing order by date ascending
dir /os directory listing order increasing by size
dir /b directory listing displaying filenames only
dir /oe directory listing sorted by file extension
del /f Force deleting of read-only files
del /s recursively remove directories and their files
This entry was posted in Command line and tagged , , . Bookmark the permalink.