Command line: Difference between revisions

No edit summary
 
(14 intermediate revisions by 5 users not shown)
Line 1: Line 1:
'''The command line''' is often mentioned as a tool for starting or setting up [[Flightgear]], [[Atlas]], [[Terrasync]], [[FGCOM]] and other programs related to Flightgear. Many users simply don't know, what the command line acutally is or how to make use of it. This article shall help...
'''The command line''' is often mentioned as a tool for starting or setting up [[Flightgear]], [[Atlas]], [[Terrasync]], [[FGCOM]] and other programs related to Flightgear. Many users aren't aware of the command line or how to make use of it. This article may help...


As an advice independent from what operating system you may use:
Operating System independent advice:
'''Try to use copy & paste as much as you can in order to avoid spelling mistakes, whenever you try to execute command line commands!'''
'''Try to use copy & paste as much as possible in order to avoid spelling mistakes, whenever you try to execute command line commands!'''
The command line will do ''exactly'' what you tell her and when you spell it wrong, she'll act the wrong way...
The system will do ''exactly'' what you tell it on the command line and when you get it wrong, the system will do it wrong.


==Windows==
== Windows ==
On Windows, you have access to the command line by clicking the "Start" button and then chosing "Run...". Type "cmd" (without quotation marks) into the field and hit Enter.
On Windows, you can get to the command line by clicking the "Start" button and then choosing "Run...". As a handy shortcut to the "Run..." prompt: Hold down the "Windows" key (the one with the windows flag on it) and tap the "R" key.
 
Type "cmd" (without quotation marks) into the field and hit Enter.


''Note: Both Windows XP and Windows Vista might have no "Run..." command in the start menu, when you attempt to try all of this. You can enable the "Run..." command in the "Configure Start Menu" dialog.''


You should see the so called ''prompt'' now, which says something like that:
You should see the so called ''prompt'' now, which says something like that:
Line 19: Line 20:
That says you're operating on drive C in directory Windows. The blinking cursor awaits your commands.
That says you're operating on drive C in directory Windows. The blinking cursor awaits your commands.


You can simply chance drives by entering <drive-letter>: like that:
You can simply change drives by entering <drive-letter>: as shown below:


  C:\Windows> d:
  C:\Windows> d:
Line 29: Line 30:
  C:\Windows>_
  C:\Windows>_


Now how about changing the directory? Assuming you downloaded Flightgear into the directory "Flightgear", that is located on drive D and its directory "Games". You do the following:
Now how about changing the directory? Assuming you downloaded Flightgear into the directory "Flightgear", that is located on drive D and its directory "Simulators". You do the following:


  C:\Windows> d:
  C:\Windows> d:
  D:\> cd Games
  D:\> cd Simulators
  D:\Games> cd Flightgear
  D:\Simulators> cd Flightgear
  D:\Games\Flightgear>_
  D:\Simulators\Flightgear>_


Easy, isn't it? You can also change directly into subdirectories:
Easy, isn't it? You can also change directly into subdirectories:
Line 48: Line 49:
  D:\>_
  D:\>_


That's most you'll need to know about the command line, when operating under Windows. Any commands that appear in the forums or in a wiki can be executed directly on the command line. after you have changed into the correct directory first.
That's most you'll need to know about the command line, when operating under Windows. Any commands that appear in the forums or in a wiki can be executed directly on the command line, after you have changed into the correct directory first.


==Linux==
== Linux ==
===Basics===
=== Basics ===
On Linux systems, there are several ways to get a command line. As Flightgear does only run in a graphic X-Window system, we'll use a so-called ''terminal''.
On Linux systems, there are several ways to get a command line. As Flightgear does only run in a graphic X-Window system, we'll use a so-called ''terminal''.


The mosty used window managers are Gnome, KDE and Xfce. First way to get yourself a console would be using the window managers menue:
The most often used window managers are Gnome, KDE and Xfce. One way of getting to a console would be using the window managers menu:
'''KDE''' KDE-Menue > System > Konsole
* '''KDE''' KDE-Menue > System > Konsole
'''Gnome''' Applications > Accessories > Terminal
* '''Gnome''' Applications > Accessories > Terminal
'''Xfce''' Applications > Terminal
* '''Xfce''' Applications > Terminal


A different approach would be pressing ''Alt F2''. That should open a dialog box, where you can enter one single command. Depending on which distribution of Linux you chose and which window manager you use, you can try (all without quotation marks) "xterm", "konsole", "gnome-terminal", "gtkterm", "kterm", "xfce4-terminal"... there's a lot of graphical console emulators!
A different approach would be pressing ''Alt F2''. That should open a dialog box, where you can enter one single command. Depending on which distribution of Linux you chose and which window manager you use, you can try (all without quotation marks) "xterm", "konsole", "gnome-terminal", "gtkterm", "kterm", "xfce4-terminal"... there's a lot of graphical console emulators!
Line 65: Line 66:
  username@computername:~$_
  username@computername:~$_


This (especially the dollar sign) is called the so called "prompt", where ''username'' should be the name of the currently logged on user and ''computername'' is the name of your computer.
This (especially the dollar sign) is the so called "prompt", where ''username'' should be the name of the currently logged on user and ''computername'' is the name of your computer. If your prompt is "#" instead of "$", you are logged in as root (superuser) and probably shouldn't be.


Note the "~" (tilde) sign before the prompt. On Linux systems that sign indicates, that your in your home directory, which normally should be equal to "/home/username".
Note the "~" (tilde) sign before the prompt. On Linux systems that sign indicates, that you're in your home directory, which normally should be equal to "/home/username".


On Linux systems, you can chance directories equally to the above described Windows method:
On Linux systems, you can change directories equally to the above described Windows method:


  username@computername:~$ cd Flightgear
  username@computername:~$ cd Flightgear
Line 87: Line 88:
  username@computername:/$ _
  username@computername:/$ _


Notice, that the "~" sign disappeared, as you went out of your personal home directory from /home/username to /home. The directory "/" is the so called root directory - you can't go downwards from here as all directories are based here.
Notice, that the "~" sign disappeared, as you went out of your personal home directory from "/home/username" to "/home". The directory "/" is the so called root directory - you can't go downwards from here as all directories are based here.


To change directly to a specific directory, you may use:
To change directly to a specific directory, you may use:


  username@computername:~$ cd /any/path/you/like
  username@computername:~$ cd /any/path/you/like
  username@computername:any/path/you/likehome$ cd /home/username
  username@computername:/any/path/you/like$ cd /home/username
  username@computername:~$ cd /some/other/path
  username@computername:~$ cd /some/other/path
  username@computername:/some/other/path$ cd ~
  username@computername:/some/other/path$ cd ~
Line 98: Line 99:


Notice, that cd-ing to /home/username produces the "~" sign, indicating, that you're at your home directory, as well as "cd ~" directly brings you there.
Notice, that cd-ing to /home/username produces the "~" sign, indicating, that you're at your home directory, as well as "cd ~" directly brings you there.
One last note, before we finish this thing:
''Linux systems are case sensitive, so you have use the correct case sensitive spelling of files and directories. Otherwise the command line won't act as expected!''


Now this should be enough, to change to a desired directory, where commands can be executed.
Now this should be enough, to change to a desired directory, where commands can be executed.


===Special commands===
=== Special commands ===
On Linux, the command line is a very essential tool and it provides a lot of means to do special actions.
On Linux, the command line is a very essential tool and it provides a lot of means to do special actions.


Line 116: Line 121:
  OpenSceneGraph                run_fgjs.sh~
  OpenSceneGraph                run_fgjs.sh~


Okay. Imagine, you just want to know about the files and directories containing the sequence "run". In order to achieve this, you can pass the output of the "ls" command to another program. A very common filter program is "grep". You use "grep" by telling the program what to filter. Directing the output of "ls" to "grep" (filtering for "run") is by using the ''pipe'' symbol: "|"
Okay. Imagine, you just want to know about the files and directories containing the sequence "run". In order to achieve this, you can pass the output of the "ls" command to another program. A very common filter program is "grep". You use "grep" by telling the program what to filter. Directing the output of "ls" to "grep" (filtering for "run") is done by using the ''pipe'' symbol: "|"


  username@computername:~/flightgear$ ls | grep run
  username@computername:~/flightgear$ ls | grep run
Line 161: Line 166:
  drwxr-xr-x  3 username usergroupname  4096 2009-01-26 07:20 simgear
  drwxr-xr-x  3 username usergroupname  4096 2009-01-26 07:20 simgear


Firts, every item has its mode bit, shown on the very left in a scheme of "drwxrwxrwx", followed by a number, the username of the owner (should be the same as of the current user!), the name of the group of the current user, the file size, its last change date and its name. If there is a "-", the specifiy mode bit isn't set.
First, every item has its mode bit, shown on the very left in a scheme of ''drwxrwxrwx'', followed by a number, the username of the owner (should be the same as of the current user!), the name of the group of the owner, file size, its last change date and its name. If there is a "-" (minus) sinstead of a character in the ''drwxrwxrwx'' sequence, the specific mode bit isn't set.
 
The first ''d'' in some of the items indicates a directory. Then, three groups of ''rwx'' follow. Each ''r'' means "file/directory may be read", each ''w'' means "file/directory may be written", each ''x'' means "file may be executed".  


The first "d" in some of the items indicates a directory. Then, three groups of "rwx" follow. Each "r" means "file/directory may be read", each "w" means "file/directory may be written", each "x" means "file may be executed". The first group of "rwx" shows the rights of the owner of the file, the next group of "rwx" shows the rights of the group of the owner and the last group gives information about what everybody may do with the file.
The first group of ''rwx'' shows the rights of the owner of the file, the next group of ''rwx'' shows the rights of the group of the owner and the last group of ''rwx'' gives information about what everybody else may do with the file.


As there are some scripts out there, that can be downloaded, you have to make them executable in most of the cases (because downloading only sets "-rw-r--r--" per default). Making a file executable can be achieved by the "chmod" command. We use the "ls" command with its "-l" option and the ''pipe'' to filter the output of "ls" by "grep":
As there are some scripts out there, that can be downloaded, you have to make them executable in most of the cases (because downloading only sets ''-rw-r--r--'' per default). Making a file executable can be achieved by the "chmod" command. We use the "ls" command with its "-l" option and the ''pipe'' to filter the output of "ls" by "grep":


  username@computername:~/flightgear$ ls -l | grep download_and_compile.sh  
  username@computername:~/flightgear$ ls -l | grep download_and_compile.sh  
  -rwxr-xr-x  1 username usergroupname  15263 2009-02-05 21:23 download_and_compile.sh
  -rwxr-xr-x  1 username usergroupname  15263 2009-02-05 21:23 download_and_compile.sh
  username@reggae-machine:~/flightgear$ chmod -x download_and_compile.sh  
  username@computername:~/flightgear$ chmod -x download_and_compile.sh  
  username@reggae-machine:~/flightgear$ ls -l | grep download_and_compile.sh  
  username@computername:~/flightgear$ ls -l | grep download_and_compile.sh  
  -rw-r--r--  1 username usergroupname  15263 2009-02-05 21:23 download_and_compile.sh
  -rw-r--r--  1 username usergroupname  15263 2009-02-05 21:23 download_and_compile.sh
  username@reggae-machine:~/flightgear$ chmod +x download_and_compile.sh  
  username@computername:~/flightgear$ chmod +x download_and_compile.sh  
  username@reggae-machine:~/flightgear$ ls -l | grep download_and_compile.sh  
  username@computername:~/flightgear$ ls -l | grep download_and_compile.sh  
  -rwxr-xr-x  1 username usergroupname  15263 2009-02-05 21:23 download_and_compile.sh
  -rwxr-xr-x  1 username usergroupname  15263 2009-02-05 21:23 download_and_compile.sh


Notice, that "download_and_compile.sh" at first had the executable bits all set, then we take them away by "chmod -x" and give them back by "chmod +x". You can do the same with read and write rights.
Notice, that "download_and_compile.sh" at first had the executable bits all set, then we take them away by "chmod -x" and give them back by "chmod +x". You can do the same with read and write rights.


==External links==
That should be enough of command line knowledge, to perform several command line actions related to Flightgear and its Addons so far.
 
== Related content ==
=== Wiki articles ===
* [[Command line options]]
 
== External links ==
* [https://help.ubuntu.com/community/UsingTheTerminal?action=show&redirect=BasicCommands Ubuntu wiki page on the command line]
* [https://help.ubuntu.com/community/UsingTheTerminal?action=show&redirect=BasicCommands Ubuntu wiki page on the command line]
==Development==
Windows Vista?


[[Category:Howto]]
[[Category:Howto]]