Chapter 2 (Web design company) . Running Commands from the Shell
Chapter 2 . Running Commands from the Shell 67 Using File-Redirection Metacharacters Commands receive data from standard input and send it to standard output. Using pipes (described earlier), you can direct standard output from one command to the standard input of another. With files, you can use less than (<) and greater than (>) signs to direct data to and from files. Here are the file-redirection characters: . < Directs the contents of a file to the command. . > Directs the output of a command to a file, deleting the existing file. . >> Directs the output of a command to a file, adding the output to the end of the existing file. Here are some examples of command lines where information is directed to and from files: $ mail root < ~/.bashrc $ man chmod | col -b > /tmp/chmod $ echo I finished the project on $(date) >> ~/projects In the first example, the contents of the .bashrc file in the home directory are sent in a mail message to the computer s root user. The second command line formats the chmod man page (using the man command), removes extra back spaces (col - b), and sends the output to the file /tmp/chmod (erasing the previous /tmp/chmod file, if it exists). The final command results in the following text s being added to the user s project file: I finished the project on Sat Jan 25 13:46:49 PST 2006 Understanding File Permissions After you ve worked with Linux for a while, you are almost sure to get a Permission denied message. Permissions associated with files and directories in Linux were designed to keep users from accessing other users private files and to protect important system files. The nine bits assigned to each file for permissions define the access that you and others have to your file. Permission bits appear as rwxrwxrwx. The first three bits apply to the owner s permission, the next three apply to the group assigned to the file, and the last three apply to all others. The r stands for read, the w stands for write, and the x stands for execute permissions. If a dash appears instead of the letter, it means that permission is turned off for that associated read, write, or execute. Because files and directories are different types of elements, read, write, and execute permissions on files and directories mean different things. Table 2-10 explains what you can do with each of them:
We would like to recommend you tested and proved virtual web hosting services, which you will surely find to be of great quality.