Developer Forums | About Us | Site Map


Useful Lists

Web Host
site hosted by netplex

Online Manuals

Windows-to-Linux roadmap: Part 2. Console crash course
By Chris Walden - 2004-05-17 Page:  1 2 3 4 5


There are many potential commands available from the console. Some of these tools are only truly useful when writing scripts. Here are some of the first ones that you'll probably need. Remember that all commands and options are case sensitive.

-R is different from -r, and will probably do different things. Console commands are almost always lowercase.


Moving around in directories uses the familiar cd command. The main trick is to remember that in Linux the forward-slash (/) is used where you are accustomed to using the back-slash (\). The back-slash is still used, but it specifies that a command should be continued on the next line. This is sometimes done for readability when typing in a particularly long command.


Listing files in a directory can be done with the ls command. There are several switches you can use to alter the look of the listing:

Listing files

ls -lShows a long listing, including files size, date and time, and attributes
ls -tSorts files by time
ls -SSorts files by size
ls -rCombined with one of the sorting switches, reverses the order. ls -lt shows the files with the newest one at the top of the list. ls -lrt shows the files with the newest ones at the bottom.
ls -hHuman readable. Uses friendly k, M, and G indicators to show file size rather than listing them in bytes.
ls -aShows all the files in a directory, even the hidden ones


Copy files with the cp command. The command works essentially the same as the DOS copy command. Essential switches:

Copying files

cp -RCopies files recursively; required if you are copying an entire directory
cp -fForces the copy and overwrites existing files without asking
cp -lLinks files instead of copying; see below

Creating links with the copy command
The cp command can be used to create a quick set of hard links to a file, or to an entire file structure. Use the -l switch to indicate link copying. All directories will be created as directories, but all files will be set up as hard links.

cp -lR /data/accounting/payroll /data/management/hr

The above command will copy the entire directory structure from /data/accounting/payroll and below to /data/management/hr/payroll. All files in the directory structure will be set up as links. This can be used to provide different views of the same files within a file system. This is also a helpful security technique, allowing access to files from a different directory with different access controls.


Move files and rename files with the mv command. It works essentially the same as the DOS move command, except that it will move entire directory structures as well as files.


View files with the cat command. This is the equivalent of the DOS type command. It will dump the contents of a file to another file, to the screen, or to another command. cat is short for concatenate, and can be used to sequence several files together into a larger file.


View information one page at a time with the more command. It works essentially the same as the DOS more command.


Use less to view a text file with the ability to scroll up and down through the document and search for text patterns.


Some might say that vi stands for "virtually impossible." It is a text editor that has a long tradition in the Unix world. vi is not really intuitive, but it is available in almost any Unix-like environment. There is a built-in tutorial for the version installed in Linux, and once you get used to it, you can do some truly incredible things in a few keystrokes. Truly, no editor has managed to replace vi for editing password and configuration files.


View documentation for a command with the man command. Man is short for manual. Documentation tends to be thorough. To learn more about man, type:

man man


info is like man except it provides hyperlinked text to make browsing documentation easier.

View Windows-to-Linux roadmap: Part 2. Console crash course Discussion

Page:  1 2 3 4 5 Next Page: Which shell

First published by IBM developerWorks

Copyright 2004-2017 All rights reserved.
Article copyright and all rights retained by the author.