Linuxdoc Linux Questions
Click here to ask our community of linux experts!
Custom Search

8. Advanced Topics

Here the game gets tough. Learn these features, then you'll be ready to say that you `know something about Linux' ;-)

8.1. Permissions and Ownership

Files and directories have permissions (`protections') and ownership, just like under VMS. If you can't run a program, or can't modify a file, or can't access a directory, it's because you don't have the permission to do so, and/or because the file doesn't belong to you. Let's have a look at the following example:

$ ls -l /bin/ls
-rwxr-xr-x   1 root     bin         27281 Aug 15  1995 /bin/ls*

The first field shows the permissions of the file ls (owner root, group bin). There are three types of ownership: owner, group, and others (similar to VMS owner, group, world), and three types of permissions: read, write (and delete), and execute.

From left to right, - is the file type (- = ordinary file, d = directory, l = link, etc); rwx are the permissions for the file owner (read, write, execute); r-x are the permissions for the group of the file owner (read, execute); r-x are the permissions for all other users (read, execute).

To change a file's permissions:

$ chmod <whoXperm> <file>

where who is u (user, that is owner), g (group), o (other), X is either + or -, perm is r (read), w (write), or x (execute). Examples:

$ chmod u+x file

this sets the execute permission for the file owner. Shortcut: chmod +x file.

$ chmod go-wx file

this removes write and execute permission for everyone except the owner.

$ chmod ugo+rwx file

this gives everyone read, write, and execute permission.

A shorter way to refer to permissions is with numbers: rwxr-xr-x can be expressed as 755 (every letter corresponds to a bit: --- is 0, --x is 1, -w- is 2...).

For a directory, rx means that you can cd to that directory, and w means that you can delete a file in the directory (according to the file's permissions, of course), or the directory itself. All this is only part of the matter---RMP.

To change a file's owner:

$ chown username file

To sum up, a table:

VMS                            Linux                   Notes
------------------------------------------------------------------------------

SET PROT=(O:RW) file.txt        $ chmod u+rw file.txt
                                $ chmod 600 file.txt
SET PROT=(O:RWED,W) file        $ chmod u+rwx file
                                $ chmod 700 file
SET PROT=(O:RWED,W:RE) file     $ chmod 755 file
SET PROT=(O:RW,G:RW,W) file     $ chmod 660 file
SET FILE/OWNER_UIC=JOE file     $ chown joe file
SET DIR/OWNER_UIC=JOE [.dir]    $ chown joe dir/

8.2. Multitasking: Processes and Jobs

More about running programs. There are no `batch queues' under Linux as you're used to; multitasking is handled very differently. Again, this is what the typical command line looks like:

$ command -s1 -s2 ... -sn par1 par2 ... parn < input > output &

where -s1, ..., -sn are the program switches, par1, ..., parn are the program parameters.

Now let's see how multitasking works. Programs, running in foreground or background, are called `processes'.

In addition to this, the shell allows you to stop or temporarily suspend a process, send a process to background, and bring a process from background to foreground. In this context, processes are called `jobs'.

8.3. Files, Revisited

More information about files.

8.4. Print Queues

Your prints are queued, like under VMS. When you issue a print command, you may specify a printer name. Example:

$ lpr file.txt          # this goes to the standard printer
$ lpr -Plaser file.ps   # this goes to the printer named 'laser'

To handle the print queues, you use the following commands:


VMS                                       Linux
------------------------------------------------------------------------------

$ PRINT file.ps                         $ lpr file.ps
$ PRINT/QUEUE=laser file.ps             $ lpr -Plaser file.ps
$ SHOW QUEUE                            $ lpq
$ SHOW QUEUE/QUEUE=laser                $ lpq -Plaser
$ STOP/QUEUE                            $ lprm <item>