1
<?xml version="1.0" encoding="UTF-8"?>
2
<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
3
"http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
4
<!ENTITY % globalent SYSTEM "../../../libs/global.ent">
6
<!ENTITY % kde-menus-C SYSTEM "../../../libs/kde-menus-C.ent">
8
<!ENTITY language "en">
13
>Introduction To The Command Line</title>
17
>This document provides a brief description of the Linux command line. It is not a complete guide to the command line, but rather an introduction to complement &kubuntu;'s graphical tools. </para>
21
<sect1 id="introduction">
27
>"Under Linux there are GUIs (graphical user interfaces), where you can point and click and drag, and hopefully get work done without first reading lots of documentation. The traditional Unix environment is a CLI (command line interface), where you type commands to tell the computer what to do. That is faster and more powerful, but requires finding out what the commands are." -- from <emphasis role="strong"
28
>man intro(1)</emphasis
32
>This guide describes some basic GNU/Linux shell commands. It is not intended to be a complete guide to the command line, just an introduction to complement &kubuntu;'s graphical tools. </para>
37
>Všechny názvy příkazů, souborů nebo cesty k adresářům jsou zobrazeny použitím <command
38
>neproporcionálního písma</command
43
>The commands should be issued from a command prompt within a <application
44
>Terminal</application
45
> and will be shown as: <screen
46
>command to type</screen>
51
><emphasis role="strong"
52
>Command Line Linux is case sensitive.</emphasis
53
> User, user, and USER are each different and distinct in Linux. </para>
61
>Starting A Terminal</title>
63
>&kubuntu;'s Terminal application is called <application
65
>, and is opened by going to &menukonsole;. </para>
69
>&kubuntu;'s terminal - Konsole</title>
72
<imagedata fileref="help:/images/C/C/konsole.png" format="PNG"/>
79
<!-- FILES AND DIRECTORIES COMMANDS -->
80
<sect1 id="files-directories">
82
>File and Directory Commands</title>
85
>pwd - print working directory</title>
89
> command displays the directory where the user is currently located. (<acronym
92
>print working directory</quote
93
>). For example, typing <screen
95
> while in the <filename class="directory"
97
> will show <computeroutput
98
>/home/[username]/Desktop</computeroutput
102
>Konsole</application
103
> also displays this information in both the tab and title bar of its window. </para>
109
>cd - change directory</title>
113
> command changes directories. (<acronym
116
>change directory</quote
117
>). When a terminal window is opened, it will be in the user's home directory. Moving around the file system requires the use of the <command
123
>To navigate into the root directory, type: <screen
129
>To navigate to the current user's home directory, type: <screen
138
> character represents the current user's home directory. As shown above, <command
140
> is equivalent to <command
141
>cd /home/username/</command
142
>. However, when running a command as root (using <command
144
>, for example), <command
146
> points to <filename class="directory"
148
>. When running a <command
150
> command with <command
152
>, the full path to the home directory must be given. </para>
157
>To navigate up one directory level, type: <screen
163
>To navigate up two directory levels, type: <screen
169
>To navigate to the previous directory (go back), type: <screen
175
>To navigate through multiple levels of directories at once, specify the full directory path. For example, type: <screen
177
> to go directly to the <filename class="directory"
179
> subdirectory of <filename class="directory"
181
>. For another example, typing: <screen
182
>cd ~/Desktop</screen
183
> moves to the <filename class="directory"
185
> subdirectory inside the current user's home directory. </para>
191
>ls - list files</title>
195
> command outputs a list of the files in the current directory. (<acronym
197
> is short for <quote
199
>). For example, typing <screen
201
> will display the files that are in the current user's home directory. </para>
203
>Used with the <command
207
> outputs other information along with the filename, such as the permissions on the file, the file's owner, and more. </para>
209
>Used with the <command
213
> outputs the information associated with the <command
215
> option in addition to showing hidden files (<command
221
>touch - create empty file</title>
225
> command is used either to change a file's access and modification timestamps or to create a new empty file. For example, <screen
227
> will create a new empty file named <filename
231
> is already a file, then using <command
233
> will update the timestamps on the file which will show the last time a file was <emphasis
239
>mkdir - make directory</title>
243
> command is used to create a new directory. (<acronym
246
>make directory</quote
247
>). To create a new directory named <filename class="directory"
250
>mkdir foobar</screen>
255
>cp - copy files or directories</title>
259
> command makes a copy of a file or directory. (<acronym
261
> is short for <quote
263
>). To make an exact copy of <filename
265
> and name it <filename
269
> To make an exact copy of the <filename class="directory"
271
> directory and name it <filename class="directory"
274
>cp -r foo_dir bar_dir</screen>
279
>mv - move files or directories</title>
283
> command moves a file or directory to a different location or will rename a file or directory. (<acronym
285
> is short for <quote
287
>). To rename the file <filename
293
> To move the file <filename
295
> into the current user's <filename class="directory"
297
> directory, type: <screen
298
>mv foo ~/Desktop</screen
299
> This will not rename <filename
305
> is a file and <filename class="directory"
307
> is a directory. </para>
311
>rm - remove files or directories</title>
315
> command is used to delete files and directories. (<acronym
317
> is short for <quote
319
>). To delete the file <filename
321
> for the current directory, type: <screen
325
>By default, <command
327
> will not remove directories. To remove a directory, you must use the <command
329
> option (also can be entered as either <command
332
>--recursive</command
333
>). For example, <screen
334
>rm -r foobar</screen
336
>rm -R foobar</screen
338
>rm --recursive foobar</screen
339
> will remove the directory <filename class="directory"
341
>, <emphasis role="strong"
342
> and all of its contents!</emphasis
348
<!-- SYSTEM INFORMATION COMMANDS -->
351
>System Information Commands</title>
354
>df - display amount of disk space</title>
358
> command displays filesystem disk space usage for all partitions. (<acronym
364
> will give information using megabytes (<abbrev
366
>) and gigabytes (<abbrev
368
>) instead of blocks (<command
371
>human readable</quote
376
>free - display amount of free and used memory</title>
380
> command displays the amount of free and used memory in the system. <screen
382
> will give the information using megabytes, which is probably the most useful for current computers. </para>
386
>top - display top consuming processes</title>
390
> command displays information on the Linux system - processes that are running, system resources including <acronym
394
> & swap usage, and the total number of tasks being run. To exit <command
402
>uname - print details about the current machine</title>
406
> command with the <command
408
> options displays all system information, including machine name, kernel name & version, and other details. This command is useful for checking which kernel is in use. (<abbrev
410
> is short for <quote
414
<sect2 id="lsb_release">
416
>lsb_release - print details about current Linux release</title>
419
>lsb_release</command
422
> option prints version information for the Linux release in use. For example, typing: <screen
423
>lsb_release -a</screen
424
> will display: <screen
425
>No LSB modules are available.
426
Distributor ID: Ubuntu
427
Description: Ubuntu &distro-rev;
428
Release: &distro-rev;
429
Codename: &distro-short-codename;
435
<!-- ELEVATED PRIVS -->
436
<sect1 id="elevated-privileges">
438
>Executing Commands with Elevated Privileges</title>
440
>The following commands must be prefaced with the <command
442
> command. Please see <ulink url="https://help.ubuntu.com/community/RootSudo"
444
> for information on using <command
448
> is short for <quote
451
<sect2 id="add-group">
453
>Adding a New Group</title>
457
> command is used to create a new group in the system. To create a new group, type: <screen
458
>sudo addgroup foobar</screen
459
> The above command will create a new group called <emphasis role="strong"
463
<sect2 id="add-user">
465
>Adding a New User</title>
469
> command is used to create a new user on the system. To create a new user, type: <screen
470
>adduser foobar</screen
471
> which will create a new user called <emphasis role="strong"
477
>Add or Change a User Password</title>
481
> command is used to assign a new password to a new user or to change the current password for an existing user. To add a password or change the password for the user <emphasis role="strong"
484
>passwd foobar</screen
485
> For new users, this will generate a prompt to enter the new password. For an existing user, there will be a prompt for the existing password before the prompt for a new password. </para>
487
<sect2 id="assign-user-group">
489
>Assign User to Group</title>
491
>To assign the user <emphasis role="strong"
493
> to the group <emphasis role="strong"
496
>adduser foobar barfoo</screen>
506
>The default behavior for a command may usually be modified by adding <command
508
> to the command. For example, the <link linkend="ls"
512
> command has an <command
514
> option. The <command
516
> will include file sizes in the listing. There is also a <command
518
> option to display file sizes in a <quote
519
>human readable</quote
522
>Options can be grouped in clusters, so <screen
524
> is the same command as <screen
526
> Most options have a long version, prefixed with two dashes instead of one, so <screen
527
>ls --size --human-readable</screen
528
> is also the same command as <screen
533
<!-- MANPAGES AND GETTING HELP -->
534
<sect1 id="man-help">
538
> and Getting Help</title>
540
><emphasis role="strong"
546
> <emphasis role="strong"
550
> are the two most important tools at the command line. </para>
552
>Virtually all commands understand the <command
556
>) option which will produce a short usage description of the command and its options, then exit back to the command prompt. Type: <screen
560
> to see this in action. </para>
562
>Every command and nearly every application in Linux has a <abbrev
564
> (manual) file. It is as simple as typing <command
565
>man command</command
566
> to bring up a longer manual entry for the specified command. For example: <screen
568
> brings up the <command
572
>Move up and down the man file with the arrow keys, and quit back to the command prompt with <keycap
578
brings up the manual entry for the <command
580
> command, which is a good place to start. </para>
584
is especially useful. It displays the <quote
585
>introduction to user commands</quote
586
> which is a well-written, brief introduction to the Linux command line. </para>
588
>There are also <command
590
> pages, which generally go into more detail than <command
592
> pages. Try: <screen
594
> for the introduction to info pages. </para>
595
<sect2 id="searching-for-man-files">
597
>Searching for man files</title>
599
>If you aren't sure which command or application you need to use, you can search the <command
603
>To search the <command
608
>man -k konsole</screen>
612
>This is the same as the <command
617
>To search only the titles of your system's <command
619
> files, try: <screen
624
>This is the same as the <command
631
<!-- CUTTING AND PASTING -->
632
<sect1 id="cut-and-paste">
634
>Cutting and Pasting</title>
636
>There are often situations that require text to be pasted into the terminal. </para>
638
>Text copied from a web page using <keycombo
644
> won't paste with <keycombo
650
> as it does in other applications because the terminal uses a different combination for paste, <keycombo
656
>. Pasting can also be done using the mouse by <mousebutton
657
>right-clicking</mousebutton
658
> in the terminal and selecting <guimenuitem
660
> from the menu. </para>
662
>Text can also be copied by selecting (highlighting) the text to be copied. Clicking the <mousebutton
664
> button on the mouse (or both buttons simultaneously on a two-button mouse) in the terminal pastes the selected text. </para>
667
>These actions may work differently in other terminal emulators than <application
668
>Konsole</application
669
>. Consult your terminal emulator's documentation for details. </para>
679
>Save on Typing</title>
693
>Scrolls backwards through the commands entered previously </para>
709
>Scrolls forward through previous commands </para>
719
>Executes the command selected </para>
729
>Tab is a useful feature. It autocompletes any commands or filenames if there is one option, otherwise it displays a list of options that fit the information entered. Using tab in this way reduces typing errors. </para>
736
>Change the Text</title>
739
>The mouse won't work to position the cursor in a command line entry. Use the <keycap
743
> keys to move within the line. </para>
747
>Typing at the cursor <emphasis
749
> text there. It doesn't overwrite what is already there. </para>
764
>Moves the cursor to the <emphasis
766
> of the line </para>
782
>Moves the cursor to the <emphasis
784
> of the line </para>
798
>Deletes from the current cursor position to the end of the line </para>
812
>Deletes the entire current line </para>
826
>Deletes the word before the cursor </para>
832
<!-- MORE INFORMATION -->
833
<sect1 id="more-information">
835
>More Information</title>
837
>The following online guides are available: </para>
841
><ulink url="https://help.ubuntu.com/community/AptGetHowto"
845
> to install packages from the command line. </para>
849
><ulink url="https://help.ubuntu.com/community/Repositories/CommandLine"
850
>Commandline Repository Editing</ulink
851
> - managing software repositories through the command line. </para>
855
><ulink url="https://help.ubuntu.com/community/grep"
861
> is a powerful command line search tool. </para>
865
><ulink url="https://help.ubuntu.com/community/find"
869
> - locate files from the command line. </para>
873
><ulink url="https://help.ubuntu.com/community/CommandlineHowto"
874
>Commandline Howto</ulink
875
> - longer and more complete than this basic guide; still not finished however. </para>
879
><ulink url="https://help.ubuntu.com/community/HowToReadline"
880
>Howto Readline</ulink
881
> - information on more advanced customization for the command line. </para>
885
>For more detailed tutorials on the Linux command line, please see: </para>
889
><ulink url="http://ss64.com/bash/"
891
> - an A-Z index of the Bash command line for Linux. </para>
895
><ulink url="http://linuxcommand.org/"
899
> tutorials, including <acronym
905
><ulink url="http://linuxsurvival.com/index.php"
907
> - Java-based tutorials. </para>
911
><ulink url="http://rute.2038bug.com/index.html.gz"
913
> - a massive online book about system administration, almost all from the command line. </para>
917
><ulink url="http://www.commandlinefu.com/"
919
> - a place to record command-line favorites and view other's gems as well. </para>
928
sgml-minimize-attributes:nil
929
sgml-general-insert-case:lower
934
vim: tabstop=2:shiftwidth=2:expandtab:indentexpr=:tw=80:
935
kate: space-indent on; indent-width 2; tab-width 2; indent-mode none;