Command line: Difference between revisions

Jump to navigation Jump to search
1,331 bytes added ,  14 February 2009
no edit summary
No edit summary
No edit summary
Line 115: Line 115:
  install                      run_fgjs.sh
  install                      run_fgjs.sh
  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: "|"
username@computername:~/flightgear$ ls | grep run
fgrun
run_fgcom.sh
run_fgfs.sh
run_fgfs_test.sh
run_fgfs_test.sh~
run_fgjs.sh
run_fgjs.sh~
run_fgrun.sh
run_fgrun.sh~
run_js_demo.sh
run_js_demo.sh~
run_terrasync.sh
Easy, isn't it?


Now on Linux, you can't simply rename a file into "filename.exe" to attempt to execute it, as you might consider in Windows. In Linux, every file has its restrictions, called mode bits. You can show them by using the "ls" command with option "-l":
Now on Linux, you can't simply rename a file into "filename.exe" to attempt to execute it, as you might consider in Windows. In Linux, every file has its restrictions, called mode bits. You can show them by using the "ls" command with option "-l":
Line 147: Line 165:
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 "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.


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. Notice, that "download_and_compile.sh" isn't executable
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
-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@reggae-machine:~/flightgear$ ls -l | grep 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@reggae-machine:~/flightgear$ ls -l | grep 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"


==External links==
==External links==
51

edits

Navigation menu