emacs - popular
Linux/Unix editor pico - has some useful features, but
not very powerful vim - powerful editor for Linux/Unix
systems, takes time to get acquainted with
System Monitoring
tail - keep
tabs on a file as it grows top - monitor the status of memory and
CPU w - find out who's logged on
Working with Directories
cd is a command that's used to switch between
directories. If you're familiar with MS-DOS, you'll have an idea how this
works.
For example, if you want to switch one directory upwards, you can type
at your command prompt:
cd ..
Note the space between 'cd' and '..'. When you're providing an extension
to the cd command in Linux, you need to put a space between the command
and the extension.
ls gives you a listing of the files and directories
in your current directory. This command can be used together with optional
flags:
ls -a returns a listing that includes hidden files
ls -l is what you'd use to see extra information about your files.
It shows file sizes and file permissions.
ls -R will traverse the current directory's subdirectories recursively
- the listing will show up the contents of subdirectories too.
By combining flags, you can modify the results to your requirement.
Typing ls -laR would return the contents of the current directory,
its subdirectories, and include hidden files. The file sizes and permissions
would also be listed.
pwd stands for 'Print Working Directory', and
shows you the current directory. It can be useful when you're scripting.
Managing Files
cp copies files.
cp file1 file2 creates a new copy of file1 with the name of file2.
To move a directory with all its contents, type cp -rpf olddir /dir1/dir2/newdir.
r here indicates the command should run recursively through the directory's
contents, p causes the file permissions to be retained, and f forces the
command.
mv can be used to move or rename a file, as in
mv file1 file2.
rm is used to remove, or delete files. For example,
rm file1 will delete file1. Files you've deleted can't be restored,
so use this command with cauton.
To delete an entire directory with its contents, type rm -rf /dir.
Filesystem Concepts
UID - In Unix, every user is a member of a
group. Most are members of the 'users' group. Exceptions are members of
'wheel' or 'admin', the administrative groups. The computer refers to
users by their numerical user ID(UID) , rather than their username.
GID - Each group has a group ID (GID), similar
to the user ID.
Ownership - Each file in the directory
structure is owned by a user. Each user is owned by a group. To keep things
flexible, each file is also owned by a group - by default its owned by
the group that owns the user.
File Permissions
chmod - You can set file permissions with
chmod. There are three kinds of permissions - read the file, write
to it and execute the file.
The chmod command is typed chmod xyz file1. x, y, and z are each
a number between 0 and 7. Each number represents the permissions of a
group - x is for the user that owns the file, y is for the group that
owns the file (normally the users group), and z is for everybody else.
To determine the actual values for each number, you use the following
method: start with x = 0. If you want to be able to read from the file,
add four. x can be 0 or 4 at this point in time. If you want to be able
to write to the file, add two. x can now be 0, 2 (a write-only file??),
4 (read-only file), or 6 (read/write file). If you want to be able to
execute the program, add one.
You now have a full range of possible numbers:
Number
Permissions
0
None - cannot read or write or execute
1
Can execute, but cannot read or write
2
Write-only, cannot read or execute (??)
3
Write-able/executable
4
Read-only, cannot write to or execute
5
Read-only executable, cannot write to
6
Readable Writeable file, but not executable (ie: text
file)
7
Readable Writeable Executable file - most programs are
this
Its typically a bad idea to chmod 777 any file, as it allows the world to replace
the program with whatever they'd like.
When root uses chmod on a file, the ownerships do not change, but the
permissions are changed. If you want to keep a user from accessing a file
that they own, you must change the ownership to root (or anyone else,
for that matter). You can change ownership using chown.
Setting execute permissions for a directory allows that directory to
be read. That is, you can see whats in it. If the user does not have execute
permissions for dir/, when user type ls dir/, ls will return an
error and not list the files in that directory.
chown is a lot simpler than chmod. You simply
type chown new-owner. file1 while logged in as root. Now 'new-owner'
owns the file and the files group is set to new-owner's group. If youd
rather keep the group ownership the same, drop off the '.'after 'new-owner'.
To change both owner and group, type chown new-owner.new-group file1.
To change the group ownership and not the user ownership, type chown
.new-group file1.
Editors
emacs is one of the most popular editors.
To get started with emacs, you need to know a couple of commands:
While youre editing a certain file with emacs, you can save it with the
[Ctrl]-x [Ctrl]-s keystrokes. To exit, type [Ctrl]-x [Ctrl]-c.
pico is another useful editor, though it isn't
as powerful as emacs or vim. You save files in pico by using the [Ctrl]-o
keystroke (for write-out) and exit with [Ctrl]-x. Other commands are displayed
on the screen when you're using pico.
vim - vim is the successor to the vi editor
('vim' stands for 'vi Improved'). Using vim is different in that there
are several modes in which you use it. To do actual editing of the files,
press [ESC] i (both separately). Then to save it, press [ESC] : w. Escape,
the colon, and "w" should be keyed in one after the other. Finally,
to quit, type [ESC] : q. The same rules apply as in previous vim commands.
You can use "w" and "q" at the same time to enable
yourself to write to the file and then quit right afterwards. Just press
[ESC] : w q.
System Monitoring
tail is a program that you can use to follow
your files as they grow. tail is useful when you want to keep track of
your log files.
top shows you the memory usage, uptime, load
average, CPU states, and processes.
w tells you who's currently logged on.
Check
out Ongoing and Completed Sites @ Webmaintainer