croc logo

Neon-komputadór

Computer Users Manual, Ministry of Foreign Affairs and Cooperation, Democratic Republic of East Timor
2003


Lingua

Inglês
Portugues

Index

Introduction
Chapter I: Hardware and Software
Chapter II: Networks and Communications

Chapter III: Operating Systems

Basic Concepts
MS-Windows98
Linux and MS-Windows
GNU Network Object Model Environment (GNOME)
Windows NT, Windows 2000 and Windows XP
MS-DOS and NTVDM
Bourne Again Shell (BASH)

Chapter IV: Applications
Chapter V: Basic Coding and Programming
Chapter VI: Basic System Administration
Appendicies: Ministry Policy

Ministry Hompage

GNU Bourne Again Shell (BASH)

As mentioned previously, UNIX and Linux come with different types of shell command line interface, whereas Microsoft has only one, implemented through the MS-DOS CLI. Fortunately, despite the variation, for the average user the basic shell commands are almost identical. This section will concentrate on those commands available through the GNU Bourne Again Shell. It can accessed from the GNOME Linux desktop by going from the Gnome Menu button -> System Tools -> Terminal whereupon the user will be confronted with a command prompt, patiently waiting for the user to enter some text.

The Linux file system has a base root directory '/'. Under the root directory there are several subdirectories, such as '/bin', which holds binary files, '/src', which holds source files, '/dev' for device files, '/usr' for user files and '/home' for home directories - keeping in mind that Linux is designed to be a multiuser system, there is usually several subdirectories under '/home', which have the shortcut of ~username to represent /home/username. Thus 'cd ~' has the same effect as 'cd /home/user'. As a matter of practice, anything that a user installs should go into '/usr/local' with source files into 'usr/local/src' and executables into '/usr/local/bin'.

The basic directory and file manipulation commands are follows; 'chdir' or 'cd' to change directory, 'mkdir' to create a directory,'rmdir' to delete an empty directory, 'cat' to concatenate files and display, 'cp' to copy files according to the directory path noted, 'mv' for moving or renaming files (it's the same thing really) according to the directory path, 'ls' to list files, 'rm' to delete files, 'more' to view a file, 'pico' to edit a file, 'diff' to compare the contents of files, 'gzip' and 'gunzip' for archiving, 'lpr' to print a file, 'lprm' to remove a job from a printer queue, 'grep' to search a file for a phrase and display the output (global search for regular expression and print). Among some very computer inclined people (this author included) the term "grep" also means "to look for something".

Unlike MS-DOS, BASH switches are implemented with -?, where '?' represents the switch to be implemented. Useful switches for the 'mkdir' command include '-m' which sets the permission mode for ownership and the '-p' or parents option, that makes parents directories as necessary. For the 'cp' command the most often used switches are '-b', which makes backups of files that are about to overwritten or removed, '-p' which preserves the original files' owner, group, permissions and timestamps, -r, which recursively copies directories and '-f' which forces the removal of existing files. Useful directory listing switches include '-a', which lists all files including files normally hidden, '-w', which lists files in a column display (this is usually set as a default), '-t', '-r' and '-S', which respectively displays the directory contents according to time, reverse order and size. Useful switches for the 'mv' command are similar with '-b' and '-f' for backups and to force overwriting, Switches that can be used for the 'rm' command include '-r' or '-R' which deletes recursively (which can be very dangerous!), and '-i' for interactive removals (recommended). For the 'grep' command the following particularly useful switches; '-c' to display a count of lines rather than the standard display, '-i' to ignore case changes, '-q' to display just the first match.

Disk manipulation is significantly different in BASH compared to MS-DOS. As mentioned in the section describing the features of GNOME, simply inserting a floppy disk into the drive of a Linux machine will not automatically give you access to the contents. One must first used the 'mount' command, with \ the syntax 'mount /dev/fd0' (floppy drive number 0), and when one is finished with the files on it, unmount the drive ('umount /dev/fd0') - the same applies to cd-roms, ('mount /dev/cdrom and 'umount /dev/cdrom'). When these filesystems are mounted, then file manipulation can occur through the filesystem - thus 'cd /mnt/floppy', rather than the MS-DOS version, 'cd a:'. If this sounds somewhat complex, you're right, it is. But the advantage of the system is that in Linux, everything exists under the '/' directory and an enormous variety of files, filesystem and devices can be accessed from these mountpoints - for example, 'cd /mnt/windows' will - assuming it exists - provide access to the MS-Windows partition of the hard disk drive. Trying accessing a Linux drive from MS-Windows however! (This can be done through Samba)

Other minor file utilities in Linux includes 'df', which provides a summary of free disk space, 'du', a summary of disk usage, and 'eject', which when followed by the device name ejects removable devices (such as cd-roms). Useful system utilities include 'passwd', which changes the users password, 'date' which displays the current date and time, 'cal' which displays a simple calendar, 'at', which sets a tome for the execution of a specific command syntax that understands minutes, hours, days, weeks and time in am or pm. You can even use 'today' or 'tomorrow'. Finally, 'man' which provides a terse manual account of a particular command.

UNIX command shell screenshot

Pipes and Redirection

Pipes and redirections are command operators, rather than commands. They filter and redirection command combinations for a particular effect. The pipes and redirects discussed here work for MS-DOS and the Linux command shell. Usually, for example, the Linux command 'ls' will display a file listing to the screen. But what if they user would rather that the listing be directed to a file instead? This requires that the output of the 'ls' command be redirected from the standard output (the display screen) to a file. This is achieved through the use of the '>' output operator, thus: 'ls > dirlist.txt'. If you want to append, rather than overwrite a redirected output the '>>' operator is used instead, thus 'date >> dirlist.txt' will add the date to the end of the directory listing. A less commonly used refirect is the input redirectors, '<' and '<<'. They are most commonly used to issue preset responses to questions from commands (e.g., 'format another (Y/N)?').

Pipes allow the results of a following command to apply to preceding command. Their syntax is 'command1 | command2'. When a command statement uses pipes it is mentally easier to read the statement from right to left. For example, think of a very long directory listing - the sort that flashes past your eyes after you type in 'ls' or 'dir'. To display this one screen at a time, so you can actually read the results you would use the 'ls' or 'dir' command piped through 'more, e.g., 'ls | more' or 'dir | more'.


Ministry of Foreign Affairs and Cooperation, GPA Building #1, Ground Floor, Dili, East Timor

valid XHTML 1.0! valid CSS Level2! Level Triple-A conformance icon, W3C-WAI Web Content Accessibility Guidelines 1.0 Unicode encoded use any browser!

Website code and design by Lev Lafayette. Last update August 20, 2003

Hosted by www.Geocities.ws

1