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:
|Shows a long listing, including files size, date and time, and attributes|
|Sorts files by time|
|Sorts files by size|
|Combined with one of the sorting switches, reverses the
|Human readable. Uses friendly k, M, and G indicators to show file size rather than listing them in bytes.|
|Shows 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
command. Essential switches:
|Copies files recursively; required if you are copying an entire directory|
|Forces the copy and overwrites existing files without asking|
|Links files instead of copying; see below|
Creating links with the copy command
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
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
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
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
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
for editing password and configuration files.
View documentation for a command with the
command. Man is short for manual. Documentation tends to be thorough. To
learn more about
info is like
man except it provides
hyperlinked text to make browsing documentation easier.