Debian GNU/Linux: Guide to Installation and Usage - John Goerzen and Ossama Othman (top fiction books of all time .txt) 📗
- Author: John Goerzen and Ossama Othman
- Performer: -
Book online «Debian GNU/Linux: Guide to Installation and Usage - John Goerzen and Ossama Othman (top fiction books of all time .txt) 📗». Author John Goerzen and Ossama Othman
Removing a symlink removes only the link. It has no effect on the linked-to file. Removing the only hard link to a file removes the file.
Try this:
cd; ln -s tmpme MyTmp
cd to your home directory. ln with the -s option makes a symbolic link -
in this case, one called MyTmp that points to the filename tmpme.
ls -l MyTmp
Output should look like this:
lrwxrwxrwx 1 havoc havoc 7 Dec 6 12:50 MyTmp -> tmpme The date and user/group names will be different for you, of course. Notice that the file type is l, indicating that this is a symbolic link. Also notice the permissions: Symbolic links always have these permissions. If you attempt to chmod a symlink, you’ll actually change the permissions on the file being pointed to.
chmod 700 MyTmp
You will get a No such file or directory error, because the file tmpme doesn’t exist. Notice that you could create a symlink to it anyway.
mkdir tmpme
Creates the directory tmpme.
chmod 700 MyTmp
Should work now.
touch MyTmp/myfile
Creates a file in MyTmp.
ls tmpme
The file is actually created in tmpme.
rm MyTmp
Removes the symbolic link. Notice that this removes the link, not what it points to. Thus you use rm not rmdir.
rm tmpme/myfile; rmdir tmpme
Lets you clean up after yourself. symlinks!removing Device Files
Device files refer to physical or virtual devices on your system, such as your hard disk, video card, screen, and keyboard. An example of a virtual device is the console, represented by devconsole.
There are two kinds of devices:character and block. Character devices can be accessed one character at a time. Remember the smallest unit of data that can be written to or read from the device is a character (byte).
Block devices must be accessed in larger units called blocks, which contain a number of characters. Your hard disk is a block device.
You can read and write device files just as you can from other kinds of files, though the file may well contain some strange incomprehensible-to-humans gibberish. Writing random data to these files is probably a bad idea. Sometimes it’s useful, though. For example, you can dump a postscript file into the printer device devlp0 or send modem commands to the device file for the appropriate serial port.
devnull
devnull is a special device file that discards anything you write to it.
If you don’t want something, throw it in devnull. It’s essentially a bottomless pit. If you read devnull, you’ll get an end-of-file (EOF) character immediately. devzero is similar, except that you read from it you get the character (not the same as the number zero).
Named Pipes (FIFOs)
A named pipe is a file that acts like a pipe. You put something into the file, and it comes out the other end. Thus it’s called a FIFO, or First-In-First-Out, because the first thing you put in the pipe is the first thing to come out the other end.
If you write to a named pipe, the process that is writing to the pipe doesn’t terminate until the information being written is read from the pipe. If you read from a named pipe, the reading process waits until there’s something to read before terminating. The size of the pipe is always zero: It doesn’t store data, it just links two processes like the shell |. However, because this pipe has a name, the two processes don’t have to be on the same command line or even be run by the same user.
You can try it by doing the following:
cd; mkfifo mypipe
Makes the pipe.
echo “hello” > mypipe &
Puts a process in the background that tries to write “hello” to the pipe. Notice that the process doesn’t return from the background; it is waiting for someone to read from the pipe.
cat mypipe
At this point, the echo process should return, because cat read from the pipe, and the cat process will print hello.
rm mypipe
You can delete pipes just like any other file.
Sockets
Sockets are similar to pipes, only they work over the network. This is how your computer does networking. You may have heard of “WinSock,” which is sockets for Windows.
We won’t go into these further because you probably won’t have occasion to use them unless you’re programming. However, if you see a file marked with type son your computer, you know what it is.
The proc Filesystem
The Linux kernel makes a special filesystem available, which is mounted under /proc on Debian systems. This is a “pseudo-filesystem” because it doesn’t really exist on any of your physical devices.
The proc filesystem contains information about the system and running processes. Some of the “files” in /proc are reasonably understandable to humans (try typing cat procmeminfo or cat proccpuinfo); others are arcane collections of numbers. Often, system utilities use these to gather information and present it to you in a more understandable way.
People frequently panic when they notice one file in particular -
prockcore - which is generally huge. This is (more or less) a copy of the contents of your computer’s memory. It’s used to debug the kernel. It doesn’t actually exist anywhere, so don’t worry about its size.
If you want to know about all the things in /proc, type man 5 proc.
Large-Scale Copying
Sometimes you may want to copy one directory to another location. Maybe you’re adding a new hard disk and you want to copy usrlocal to it. There are several ways you can do this.
The first is to use cp. The command cp -a will tell cp to do a copy preserving all the information it can. So, you might use cp -a usrlocal /destination
However, there are some things that cp -a won’t catch13.1. So, the best way to do a large copy job is to chain two tar commands together, like so: tar -cSpf - usrlocal | tar -xvSpf - -C /destination The first tar command will archive the existing directory and pipe it to the second. The second command will unpack the archive into the location you specify with -C.
Security
Back in section 7.1 on page [*], we discussed file permissions in Linux.
This is a fundamental way to keep your system secure. If you are running a multiuser system or a server, it is important to make sure that permissions are correct. A good rule of thumb is to set files to have the minimum permissions necessary for use.
If you are running a network server, there are some other things to be aware of as well. First, you ought to uninstall or turn off any network services you’re not using. A good place to start is the file etcinetd.conf; you can probably disable some of these. For most network services, it’s also possible to control who has access to them; the etchosts.allow and etchosts.deny files (documented in man 5 hosts_access) can control who has access to which services. You also ought to keep up-to-date with patches or updates to Debian; these can be found on your nearest Debian FTP mirror.
Some other commonsense rules apply:
* Never tell anyone your password.
* Never send your password in cleartext across the Internet by using something like telnet or FTP. Instead, use encrypted protocols or avoid logging in remotely.
* Avoid using root as much as possible.
* Don’t install untrusted software, and don’t install it as root.
* Avoid making things world-writable whenever possible. /tmp is one exception to this rule.
While this is probably not of as much use to somebody not running a server, it is still pays to know a bit about security. Debian’s security mechanism is what protects your system from many viruses.
Software Development with Debian Debian makes a great platform for software development and programming.
Among the languages and near-languages it supports are: C, C++, Objective-C, Perl, Python, m4, Ada, Pascal, Java, awk, Tcl/Tk, SQL, assembler, Bourne shell, csh, and more. Writing programs is beyond the scope of this book, but here are some of the more popular development programs in Debian:
gcc
The GNU C Compiler, a modern optimizing C compiler.
g++
The C++ compiler from the gcc line.
cpp
The C preprocessor from gcc.
perl
The Perl interpreter. Perl is a great “glue” language.
gdb
GNU Debugger, used to debug programs in many different languages.
gprof
Used for profiling, this program helps you to find ways to improve the performance of your programs.
emacs
GNU Emacs is a programmers’ editor and IDE.
as
The GNU Assembler.
Reference
Reading Documentation and Getting Help Kinds of Documentation On Debian systems, you can find documentation in at least the following places:
* man pages, read with the man command.
* info pages, read with the info command.
* The usrdoc/package directories, where package is the name of the Debian package.
Tip:
zless is useful for reading the files in usrdoc; see section 8.1
on page [*] for details.
* usrdoc/HOWTO/contains the Linux Documentation Project’s HOWTO documents, if you’ve installed the Debian packages containing them.
* Many commands have an -h or -help option. Type the command name followed by one of these options to try it.
* The Debian Documentation Project has written some manuals.
* The Debian support page has a FAQ and other resources. You can also try the Linux web site.
The confusing variety of documentation sources exists for many reasons.
For example, info is supposed to replace man, but man hasn’t disappeared yet. However, it’s nice to know that so much documentation exists!
So where to look for help? Here are some suggestions: * Use the man pages and the -help or -h option to get a quick summary of a command’s syntax and options. Also use man if a program doesn’t yet have an info page.
* Use info if a program has info documentation.
* If neither of those works, look in usrdoc/packagename.
* usrdoc/packagename often has Debian-specific information, even if there’s a man page or info page.
* Use the HOWTOs for instructions on how to set up a particular thing or for information on your particular hardware. For example, the Ethernet HOWTO has a wealth of information on Ethernet cards, and the PPP HOWTO
explains in detail how to set up PPP.
* Use the Debian Documentation Project manuals for conceptual explanations and Debian-specific information.
If all else fails, ask someone. See section A.1.3 on page [].
Using man pages is discussed above in section 5.1 on page [*]. It’s very simple: press the space bar to go to the next page, and press q to quit reading. Using info, viewing files in usrdoc, and asking for help from a person are all discussed in the remainder of this chapter.
Using info
info is the GNU documentation viewer. Some programs provide documentationin info format, and you can use info to view that documentation. You can start up the viewer by simply typing info, or by supplying a topic as well:
info emacs
You can also bring up the information
Comments (0)