Unix Cheat Sheet
To see what files you have in your directory you type "ls", which stands for list, but this won't show you all the files in the directory, to do so you should type "ls -a" where the "a" stands for all. To get a full list with a summary about each file and directory you type "ls -al", and typing "ls -alFt" will list all the files with last time of access for the file and a summary about each file. For example you may see something like :
drwxr--r-- 5 abdoawas abdoawas 1024 Jan 7 13:20 Desktop/
drwxr-xr-x 2 abdoawas abdoawas 1024 Jan 28 10:53 fortran/
drwxrwxr-x 2 abdoawas abdoawas 1024 Feb 3 17:41 html/
drwx------ 2 abdoawas abdoawas 1024 Jan 27 20:28 mail/
drwx------ 2 abdoawas abdoawas 1024 Jan 16 12:08 nsmail/
Her The first item -rwxr--r-- represents the access permissions on this file. The following items represent the number of links to it; the username of the person owning it; its size and the time and date it was last changed, and finally, its name. But how to understand the access permissions, well its easy :
r read the file or directory
w write to the file or directory
x execute the file or search the directory
u the user who owns the file (usually you)
g members of the group to which the owner belongs
o all other users
user - group - others
r w x-r w x-r w x
chmod mode filename
chmod mode directory_name
Setting access permissions numerically
There is a shorthand way of setting permissions by using octal numbers. Read permission is given the value 4, write permission the value 2 and execute permission 1.
r w x
4 2 1
1 = execute only
2 = write only
3 = write and execute (1+2)
4 = read only
5 = read and execute (4+1)
6 = read and write (4+2)
7 = read and write and execute (4+2+1)
user group others
chmod 640 file1 rw- r-- ---
chmod 754 file1 rwx r-x r--
chmod 664 file1 rw- rw- r--
cp [file name] destination
cp lineq.f lineq2
cp path_to_source file destination
vi [file name]
creats the file test.txt which is a text file. This will put you in the command mode in the Vi text editor to switch to the Insert mode press "i", now you can write whatever you like, then when you finish press Esc this will take to the command mode again to write the file and quit you should type wqvi test.txt
rm filename
To remove a directory use the command:
rmdir directory_name
find pathname -name filename -print
mv [file name] destination file
lpr filename
To compile a Fortran file in unix you should first know what version of Fortran available on your workstation. Gauss supports both, Fortran 77 & Fortran 90.
For example
g77 file.f -o file.out
./file.out