You are on page 1of 5

BASIC LINUX COMMANDS

JOHN WALLIN

1. Some Commands ls dir cd lists the contents of a directory with color codes for dierent le and directory types does the same thing as ls, without any color coding change directory - goes up or down in a directory tree structure - a name or path must be specied mkdir make directory - creates a new directory - a name must be specied gedit gnu edit - a basic editor for creating les more displaces a le with page breaks after the screen lls up cat dumps les to the screen with no page breaks gfortran gnu fortran - fortran compiler rm remove - delete a le rmdir remove directory - delete a directory * a wild card character - represents any string. For example, more * will display all the les in a directory up and down arrows goes to previous or next command - a short cut to avoid typing long strings pwd print working directory - lets you know where you are in the directory structure cp copy - copies a le from one name to another or one place to another mv move - moves a le from one place to another or one name to another ! {partial} executes the last command with the name that started with the string {partial} 2. An example session with annotations 2.1. Find out whats in the directory. jwallin@bomb20:~$ ls Desktop Downloads host Documents examples.desktop mount_mac

Music Pictures

Public Templates

Videos

2.2. Change directories into Documents then into helloworld. jwallin@bomb20:~$ cd Documents/ jwallin@bomb20:~/Documents$ ls helloworld helloworld.back project1 jwallin@bomb20:~/Documents$ cd helloworld jwallin@bomb20:~/Documents/helloworld$ ls
1

JOHN WALLIN

array_test.f90 character_test.f90 complex_test.f90

helloworld.f90 integer_test.f90 logical_test.f90

loop_test.f90 newfile.f90 noimplicit.f90

real_test2.f90 real_test.f90

2.3. Edit, then compile a le. Note: the new le created after the compilation is called a.out by default. We will do an ls, then execute it. jwallin@bomb20:~/Documents/helloworld$ gedit helloworld.f90 jwallin@bomb20:~/Documents/helloworld$ gfortran helloworld.f90 jwallin@bomb20:~/Documents/helloworld$ ls a.out complex_test.f90 logical_test.f90 noimplicit.f90 array_test.f90 helloworld.f90 loop_test.f90 real_test2.f90 character_test.f90 integer_test.f90 newfile.f90 real_test.f90 jwallin@bomb20:~/Documents/helloworld$ ./a.out Hello World!

2.4. Examine the contents of the source le helloworld.f90 using more and cat. jwallin@bomb20:~/Documents/helloworld$ more helloworld.f90 program helloworld

! a comment - hello world program print*, Hello World! end program helloworld jwallin@bomb20:~/Documents/helloworld$ cat helloworld.f90 program helloworld

! a comment - hello world program print*, Hello World! end program helloworld jwallin@bomb20:~/Documents/helloworld$

2.5. List all les (including the hidden les with long output. jwallin@bomb20:~/Documents/helloworld$ ls -al total 60 drwxr-xr-x 2 jwallin jwallin 4096 2010-09-02 13:53 .

BASIC LINUX COMMANDS

drwxr-xr-x 5 jwallin jwallin 4096 2010-09-02 -rwxr-xr-x 1 jwallin jwallin 7506 2010-09-02 -rw-r--r-- 1 jwallin jwallin 867 2010-09-01 -rw-r--r-- 1 jwallin jwallin 258 2010-09-01 -rw-r--r-- 1 jwallin jwallin 291 2010-09-01 -rw-r--r-- 1 jwallin jwallin 102 2010-09-01 -rw-r--r-- 1 jwallin jwallin 322 2010-09-02 -rw-r--r-- 1 jwallin jwallin 127 2010-09-01 -rw-r--r-- 1 jwallin jwallin 268 2010-09-01 -rw-r--r-- 1 jwallin jwallin 152 2010-09-02 -rw-r--r-- 1 jwallin jwallin 94 2010-09-02 -rw-r--r-- 1 jwallin jwallin 885 2010-09-01 -rw-r--r-- 1 jwallin jwallin 350 2010-09-01 jwallin@bomb20:~/Documents/helloworld$

10:15 13:53 23:50 23:17 22:30 21:34 10:42 23:19 23:36 09:55 10:23 22:30 22:31

.. a.out array_test.f90 character_test.f90 complex_test.f90 helloworld.f90 integer_test.f90 logical_test.f90 loop_test.f90 newfile.f90 noimplicit.f90 real_test2.f90 real_test.f90

2.6. Change Directories upward one level. jwallin@bomb20:~/Documents/helloworld$ cd .. jwallin@bomb20:~/Documents$ ls helloworld helloworld.back project1

2.7. Change directories to . - the same directory where you started. jwallin@bomb20:~/Documents$ cd . jwallin@bomb20:~/Documents$ ls helloworld helloworld.back project1

2.8. Go back to helloworld, and compile to a specied name. jwallin@bomb20:~/Documents$ cd helloworld jwallin@bomb20:~/Documents/helloworld$ gfortran helloworld.f90 -o helloworld jwallin@bomb20:~/Documents/helloworld$ ls a.out helloworld loop_test.f90 real_test.f90 array_test.f90 helloworld.f90 newfile.f90 character_test.f90 integer_test.f90 noimplicit.f90 complex_test.f90 logical_test.f90 real_test2.f90 jwallin@bomb20:~/Documents/helloworld$ ./helloworld Hello World! jwallin@bomb20:~/Documents/helloworld$

2.9. Jump up two levels - then go to where we started.

JOHN WALLIN

jjwallin@bomb20:~/Documents/helloworld$ cd ../../ jwallin@bomb20:~$ ls Desktop Downloads host Music Public Documents examples.desktop mount_mac Pictures Templates jwallin@bomb20:~$ cd Documents/helloworld jwallin@bomb20:~/Documents/helloworld$

Videos

2.10. Figure out where I am usingprint working directory pwd. jwallin@bomb20:~/Documents/helloworld$ pwd /home/jwallin/Documents/helloworld jwallin@bomb20:~/Documents/helloworld$ jwallin@bomb20:~/Documents/helloworld$ ls a.out helloworld loop_test.f90 array_test.f90 helloworld.f90 newfile.f90 character_test.f90 integer_test.f90 noimplicit.f90 complex_test.f90 logical_test.f90 real_test2.f90

real_test.f90

2.11. Make a new directory, copy a le, then execute the program. jwallin@bomb20:~/Documents/helloworld$ mkdir newdir jwallin@bomb20:~/Documents/helloworld$ ls a.out helloworld loop_test.f90 real_test2.f90 array_test.f90 helloworld.f90 newdir real_test.f90 character_test.f90 integer_test.f90 newfile.f90 complex_test.f90 logical_test.f90 noimplicit.f90 jwallin@bomb20:~/Documents/helloworld$ cd newdir jwallin@bomb20:~/Documents/helloworld/newdir$ ls jwallin@bomb20:~/Documents/helloworld/newdir$ cp ../helloworld . jwallin@bomb20:~/Documents/helloworld/newdir$ ls helloworld jwallin@bomb20:~/Documents/helloworld/newdir$ ./helloworld Hello World! jwallin@bomb20:~/Documents/helloworld/newdir$

2.12. Remove the le, go up a level, the remove the directory. jwallin@bomb20:~/Documents/helloworld/newdir$ ls helloworld jwallin@bomb20:~/Documents/helloworld/newdir$ rm helloworld jwallin@bomb20:~/Documents/helloworld/newdir$ cd ../ jwallin@bomb20:~/Documents/helloworld$ rmdir newdir/

BASIC LINUX COMMANDS

jwallin@bomb20:~/Documents/helloworld$ 2.13. Using ls with a wildcard for ALL characters. Note: all les are listed jwallin@bomb20:~/Documents/helloworld$ ls * a.out helloworld loop_test.f90 real_test.f90 array_test.f90 helloworld.f90 newfile.f90 character_test.f90 integer_test.f90 noimplicit.f90 complex_test.f90 logical_test.f90 real_test2.f90 2.14. Using a wildcard to list les that end in 0. jwallin@bomb20:~/Documents/helloworld$ ls *0 array_test.f90 helloworld.f90 loop_test.f90 character_test.f90 integer_test.f90 newfile.f90 complex_test.f90 logical_test.f90 noimplicit.f90

real_test2.f90 real_test.f90

2.15. Using a wildcard to list all les that end in t.f90. jwallin@bomb20:~/Documents/helloworld$ ls *t.f90 array_test.f90 complex_test.f90 logical_test.f90 noimplicit.f90 character_test.f90 integer_test.f90 loop_test.f90 real_test.f90 2.16. Using a wildcard to list all les that end in test.f90. jwallin@bomb20:~/Documents/helloworld$ ls *test.f90 array_test.f90 complex_test.f90 logical_test.f90 real_test.f90 character_test.f90 integer_test.f90 loop_test.f90 2.17. Using a wildcard for les that begin with the letter a. jwallin@bomb20:~/Documents/helloworld$ ls a* a.out array_test.df90 2.18. Using a wildcard for les that have the string cal somewhere in their name. jwallin@bomb20:~/Documents/helloworld$ ls *cal* logical_test.f90 jwallin@bomb20:~/Documents/helloworld$

You might also like