BasicCommands

Differences between revisions 12 and 13
Revision 12 as of 2005-08-15 03:12:36
Size: 4988
Editor: S0106000d88b9f3db
Comment: formatting
Revision 13 as of 2005-08-15 23:19:34
Size: 5649
Editor: S0106000d88b9f3db
Comment: added "man intro" info
Deletions are marked like this. Additions are marked like this.
Line 2: Line 2:
''"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 '''man intro''' ''
Line 53: Line 54:
'''"man intro"''' is especially useful - it displays the "Introduction to user commands" which is a well-written, fairly brief introduction to the Linux command line.
Line 59: Line 62:
 * http://linuxcommand.org/
 * http://linuxsurvival.com/index.php
 * http://linuxcommand.org/  - basic BASH tutorials, including BASH scripting
 * http://linuxsurvival.com/index.php  - Java-based tutorials

attachment:BasicCommandsSample.png

"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 man intro

Using this page

  • This page will make you familiar with basic GNU/Linux shell commands.
  • It is not intended to be a complete guide to the command line, just an introduction to complement Ubuntu's graphical tools.
  • All command names will be in bold.

  • Commands needing to be typed will be in "bold with quotes".

  • All of the commands on this page are to be issued from a command prompt in a terminal.
  • To get a terminal window in Ubuntu Hoary: Applications - System Tools - Terminal
  • Note that Linux is case senstive. User is different from user, and USER is different again.

Commands

File & Directory Commands

  • cd: The cd command will allow you to change directories. When you open a terminal you will be in your home directory. To move around the file system you will use cd. Example: "cd ~/Desktop" will move you to your desktop directory.

    • To navigate into the root directory, use "cd /"

    • To navigate back to your home directory, use "cd ~"

    • You can move through multiple levels of directory at once. For exampe, "cd /var/www" will take you directly to the /www subdirectory off /var.

  • ls: The ls command will show you the files in your current directory. Used with certain triggers, you can see sizes of files, when files where made, and permissions of files. Example: "ls ~" will show you the files that are in your home directory.

  • mkdir: The mkdir command will allow you to create directories. Example: "mkdir music" will create a music directory.

  • pwd: The pwd command will allow you to know in which directory you're located. Example: "pwd" in the Desktop directory will show "~/Desktop".

  • man: The man command is used to show you the manual of other commands. To get a good understanding, use the example: "man man" this will give you the man page for man

  • mv: The mv command will move a file to a different location or will rename a file. Examples are as follows: "mv file foo" will rename the file "file" to "foo". "mv foo ~/Desktop" will move the file "foo" to your Desktop directory but will not rename it. You must specify a new file name to rename a file.

  • cp: The cp command will make a copy of a file for you. Example: "cp file foo" will make a exact copy of "file" and name it "foo", but the file "file" will still be there. When you use mv that file would no longer exist, as when you use cp the file stays but a new copy is made.

System Information Commands

  • top: The top command displays information on your Linux system, running processes and system resources, including CPU, RAM & swap usage and total number of tasks being run. To exit top, press "q".

  • df: The df command displays filesystem disk space usage for all partitions. "df -h" is probably the most useful - it uses megabytes (M) and gigabytes (G) instead of blocks to report. (-h means "human-readable")

  • uname -a: The uname command with the -a option prints all system information, including machine name, kernel name & version, and a few other details. Most useful for checking which kernel you're using.

Options

When commands have optional behaviour it usually triggerd by adding a --option to the command. The ls command for example has an -s option so that "ls -s" will include file sizes in the listing. There is also a -h option to get those sizes in a "human readable" format.

Options can be grouped in clusters so "ls -sh" is exactly the same command as "ls -s -h". Most options has a long version, prefixed with two dashes instead of one, so even "ls --size --human-readable" is the same command.

Warning /!\ command --help and man command are the two most important tools at the command line.

Virtually all commands understands the -h (or --help) option which will produce a short usage description of the command and it's options, then exit back to the command prompt.

"man "command"" brings up a longer manual entry for the specified command. Move up and down this entry with the arrow keys, and quit back to the command prompt with "q". "man man" will bring up the manaual entry for the man command, which is a good place to start!

"man intro" is especially useful - it displays the "Introduction to user commands" which is a well-written, fairly brief introduction to the Linux command line.

sudo is a special option added in front of other commands, sudo mkdir for example. Please see RootSudo for more details.

More Information

For more detailed tutorials on the Linux command line, please see:

Head back to UserDocumentation

CategoryDocumentation

BasicCommands (last edited 2008-08-06 16:37:47 by localhost)