Archive for April, 2007

ShellLearning Linux Commands149As (Web design templates) each screen pauses, I press

Tuesday, April 24th, 2007

ShellLearning Linux Commands149As each screen pauses, I press the spacebar to go to the next page. Many more Linux commands work on files mostly on text files, but somecommands also work on any file. I describe a few of the file-processingtoolsnext. Counting words and lines in a text fileI am always curious about the size of files. For text files, the number of charac- ters is basically the size of the file in bytes (because each character takes up abyte of storage space). What about words and the number of lines, though? The Linux wccommand comes to the rescue. The wccommand displays thetotal number of characters, words, and lines in a text file. For example, trythe following command: wc /etc/inittab53 229 1666 /etc/inittab The second line shows the output. In this case, wcreports that 53 lines, 229words, and 1666 characters are in the /etc/inittabfile. If you simply wantto see the number of lines in a file, use the -loption, such as this: wc l /etc/inittab53 /etc/inittabAs you can see, in this case, wcsimply displays the line count. If you don t specify a filename, the wccommand expects input from the stan- dard input. You can use the pipe feature of the shell to feed the output ofanother command to wc,which can be handy sometimes. Suppose you want a rough count of the processes running on your system. You can get a list of all processes with the ps axcommand, but instead ofcounting lines manually, just pipe the output of psto wcand you get a roughcount automatically: ps ax | wc -l76Here the pscommand produced 76 lines of output. Because the first linesimply shows the headings for the tabular columns, you can estimate thatabout 75 processes are running on your system. (Of course, this count prob- ably includes the processes used to run the psand wccommands as well, but who s reallycounting?)
Note: If you are looking for cheap and reliable webhost to host and run your web application check Vision coldfusion web hosting services

Learning Linux Commands148As you can see, the datecommand (Web hosting solutions)

Monday, April 23rd, 2007

Learning Linux Commands148As you can see, the datecommand alone displays the current date and time. To set the date, log in as rootand then type datefollowed by the date andtime in the MMDDhhmmYYYYformat, where each character is a digit. For exam- ple, to set the date and time to December 31, 2004 and 9:30 p.m., you typedate 123121302004The MMDDhhmmYYYYdate and time format is similar to the 24-hour militaryclock, and has the following meaning: .MMis a two-digit number for the month (01 through 12). .DDis a two-digit number for the day of the month (01 through 31). .hhis a two-digit hour in 24-hour format (00 is midnight and 23 is 11:00 PM). .mmis a two-digit number for the minutes (00 through 59). .YYYYis the 4-digit year (such as 2004). The other interesting date-related command is cal. If you type calwithoutany options, it prints a calendar for the current month. If you type calfol- lowed by a number, caltreats the number as the year and prints the calen- dar for that year. To view the calendar for a specific month in a specific year, provide the month number (1 = January, 2 = February, and so on) followedby the year. Thus, to view the calendar for January 2005, type the followingand you get the calendar for that month: cal 1 2005January 2005Su Mo Tu We Th Fr Sa12 3 4 5 6 7 89 10 11 12 13 14 1516 17 18 19 20 21 2223 24 25 26 27 28 2930 31Processing filesYou can search through a text file with grepand view a text file, a screen at atime, with more. For example, to search for my username in the /etc/passwdfile, I usegrep naba /etc/passwdTo view the /etc/inittabfile a screenful at a time, I typemore /etc/inittab
Note: If you are looking for high quality webhost to host and run your jsp application check Vision christian web host services

ShellLearning Linux Commands147Managing processesEvery time (Web hosting india) the shell executes

Monday, April 23rd, 2007

ShellLearning Linux Commands147Managing processesEvery time the shell executes a command that you type, it starts a process. The shell itself is a process. So are any scripts or programs that the shell runs. Use the ps axcommand to see a list of processes. When you type ps ax, Bash shows you the current set of processes. Here are a few lines of outputfrom the ps axcommand (I also included the –cols 132option to ensurethat you can see each command in its entirety): ps ax –cols 132PID TTY STAT TIME COMMAND1 ? S 0:06 init [5] 2 ? SWN 0:01 [ksoftirqd/0] 3 ? SW< 0:00 [events/0] 4 ? SW< 0:04 [kblockd/0] 8 ? SW< 0:00 [aio/0] 5 ? SW 0:00 [pdflush] 6 ? SW 0:01 [pdflush] 7 ? SW 0:20 [kswapd0] 9 ? SW 0:00 [kseriod] 13 ? SW 0:20 [kjournald] ... lines deleted ... 8973 pts/2 R 0:00 ps ax --cols 132In this listing, the first column has the heading PIDand shows a number foreach process. PID stands for process ID(identification), which is a sequentialnumber assigned by the Linux kernel. If you look through the output of theps axcommand, you see that the initcommand is the first process andthat it has a PID or process number of 1. That s why initis referred to asthe mother of all processes. The COMMANDcolumn shows the command that created each process. The process ID or process number is useful when you have to forcibly stop anerrant process. Look at the output of the ps axcommand and note the PIDofthe offending process. Then, use the killcommand with that process number. To stop process number 8550, for example, type the following command: kill -9 8550Working with date and timeYou can use the datecommand to display the current date and time or set anew date and time. Type the datecommand at the shell prompt and you geta result similar to the following: dateMon Apr 19 21:51:33 EST 2004
Note: If you are looking for cheap webhost to host and run your apache application check Vision apache web hosting services

Learning Linux Commands146Table 2-1 (continued) Command (Web hosting ecommerce) NameActionduDisplays disk

Monday, April 23rd, 2007

Learning Linux Commands146Table 2-1 (continued) Command NameActionduDisplays disk usage information. fdformatFormats a diskette. fdiskPartitions a hard disk. fsckChecks and repairs a file system. mkfsCreates a new file system. mknodCreates a device file. mkswapCreates a swap space for Linux in a file or a disk partition. mountMounts a device (for example, the CD-ROM) on a directory inthe file system. swapoffDeactivates a swap space. swaponActivates a swap space. syncWrites buffered (saved in memory) data to files. ttyDisplays the device name for the current terminal. umountUnmounts a device from the file system. Working with Date and TimecalDisplays a calendar for a specified month or year. dateShows the current date and time or sets a new date and time. Becoming root (superuser) When you want to do anything that requires a high privilege level (for exam- ple, administering your system), you have to become root. Normally you login as a regular user with your normal username. When you need the privi- leges of the superuser, though, use the following command to become root: su - That s sufollowed by the minus sign (or hyphen). The shell then promptsyou for the rootpassword. Type the password and press Enter. After you re done with whatever you wanted to do asroot(and you havethe privilege to do anything as root), type exitto return to your normal self. Instead of becoming rootby using the sucommand, you can also type sudo, followed by the command that you want to run as root. If you are listed asan authorized user in the /etc/sudoersfile, sudoexecutes the command as if you were logged in as root. Type man sudoersto read more about the/etc/sudoersfile.
Note: If you are looking for reliable webhost to maintain and run your java application check Vision java hosting services

ShellLearning Linux Commands145Command NameActionArchiving and (Web server on xp) Compressing FilescompressCompresses files.

Monday, April 23rd, 2007

ShellLearning Linux Commands145Command NameActionArchiving and Compressing FilescompressCompresses files. cpioCopies files to and from an archive. gunzipDecompresses files compressed with GNU ZIP (gzip). gzipCompresses files using GNU ZIP. tarCreates an archive of files in one or more directories (originallymeant for archiving on tape). uncompressDecompresses files compressed with compress. Managing ProcessesbgRuns an interrupted process in the background. fgRuns a process in the foreground. freeDisplays the amount of free and used memory in the system. haltShuts down Linux and halts the computer. killSends a signal to a process (usually used to terminate aprocess). lddDisplays the shared libraries needed to run a program. niceRuns a process with lower priority (referred to as nicemode). psDisplays a list of currently running processes. printenvDisplays the current environment variables. pstreeSimilar to ps, but shows parent-child relationships clearly. rebootStops Linux and then restarts the computer. shutdownShuts down Linux. topDisplays a list of most processor- and memory-intensiveprocesses. unameDisplays information about the system and the Linux kernel. Managing UserschshChanges the shell (command interpreter). groupsPrints the list of groups that includes a specified user. idDisplays the user and group ID for a specified username. passwdChanges the password. suStarts a new shell as another user or root(when invokedwithout any argument). Managing the File SystemdfSummarizes free and available space in all mounted storagedevices. (continued)
Note: In case you are looking for affordable webhost to host and run your servlet application check Vision make web site services

Learning Linux Commands144Table (Web hosting bandwidth) 2-1 (continued) Command NameActionwhereisFinds files

Sunday, April 22nd, 2007

Learning Linux Commands144Table 2-1 (continued) Command NameActionwhereisFinds files based in the typical directories where executable(also known as binary) files are located. whichFinds files in the directories listed in the PATH environment variable. Processing FilescatDisplays a file on standard output (can be used to concatenateseveral files into one big file). cutExtracts specified sections from each line of text in a file. ddCopies blocks of data from one file to another (used to copydata from devices). diffCompares two text files and finds any differences. expandConverts all tabs into spaces. fileDisplays the type of data in a file. foldWraps each line of text to fit a specified width. grepSearches for regular expressions within a text file. lessDisplays a text file, one page at a time (can go backward also). lprPrints files. moreDisplays a text file, one page at a time (goes forward only). nlNumbers all nonblank lines in a text file and prints the lines tostandard output. pasteConcatenates corresponding lines from several files. patchUpdates a text file using the differences between the originaland revised copy of the file. sedCopies a file to standard output while applying specified editingcommands. sortSorts lines in a text file. splitBreaks up a file into several smaller files with specified size. tacReverses a file (last line first and so on). tailDisplays the last few lines of a file. trSubstitutes one group of characters for another throughout afile. uniqEliminates duplicate lines from a text file. wcCounts the number of lines, words, and characters in a text file. zcatDisplays a compressed file (after decompressing). zlessDisplays a compressed file one page at a time (can go back- ward also). zmoreDisplays a compressed file one page at a time.
Note: If you are looking for high quality webhost to host and run your jsp application check Vision jsp web hosting services

ShellLearning Linux Commands143command-line (Yahoo web hosting) utilities that come with Linux.

Sunday, April 22nd, 2007

ShellLearning Linux Commands143command-line utilities that come with Linux. In this section, I introduce youto a few major categories of Linux commands. I can t possibly cover all the Linux commands in this chapter, but I want togive you a feel for the breadth of the commands by showing you a list ofcommon Linux commands in Table 2-1. It lists common Linux commands bycategory. Before you start learning any Linux commands, browse this table. Table 2-1Overview of Common Linux CommandsCommand NameActionGetting Online HelpaproposFinds online manual pages for a specified keyword. infoDisplays online help information about a specified command. manDisplays online help information. whatisSimilar to apropos, but searches for complete words only. Making Commands EasieraliasDefines an abbreviation for a long command. typeShows the type and location of a command. unaliasDeletes an abbreviation defined using alias. Managing Files and DirectoriescdChanges the current directory. chmodChanges file permissions. chownChanges file owner and group. cpCopies files. lnCreates symbolic links to files and directories. lsDisplays the contents of a directory. mkdirCreates a directory. mvRenames a file as well as moves a file from one directory toanother. rmDeletes files. rmdirDeletes directories. pwdDisplays the current directory. touchUpdates a file s time stamp. Finding FilesfindFinds files based on specified criteria such as name, size, andso on. locateFinds files using a periodically updated database. (continued)
Note: If you are looking for best quality webspace to host and run your tomcat application check Vision personal web hosting services

Learning Linux Commands142Repeating previously typed commandsTo make repeating (Web page design)

Sunday, April 22nd, 2007

Learning Linux Commands142Repeating previously typed commandsTo make repeating long commands easy for you, Bash stores up to 500 oldcommands. Bash keeps a command history(a list of old commands). To seethe command history, type history. Bash displays a numbered list of the oldcommands, including those that you entered during previous logins. If the command list is too long, you can limit the number of old commands youwant to see. To see only the most recent 10 commands, type this command: history 10To repeat a command from the list that the historycommand shows, simplytype an exclamation point (!), followed by that command s number. To repeatcommand number 3, type !3. You can repeat an old command without knowing its command number. Suppose you typed more /usr/lib/X11/xdm/xdm-configa few minutesago, and now you want to look at that file again. To repeat the previous morecommand, type the following: !moreOften, you may want to repeat the last command that you just typed, perhapswith a slight change. For example, you may have displayed the contents ofthe directory by using the ls -lcommand. To repeat that command, typetwo exclamation points as follows: !! Sometimes, you may want to repeat the previous command but add extraarguments to it. Suppose that ls -lshows too many files. Simply repeatthat command, but pipe the output through the morecommand as follows: !! | moreBash replaces the two exclamation points with the previous command andthen appends | moreto that command. Here s the easiest way to recall previous commands. Just press the up-arrowkey and Bash keeps going backward through the history of commands youpreviously typed. To move forward in the command history, press the down- arrow key. Learning Linux CommandsYou type Linux commands at the shell prompt. By Linux commands,I meansome of the commands that the Bash shell understands as well as the
Note: If you are looking for cheap and reliable webhost to host and run your mysql application check Vision mysql hosting services

Web site development - ShellUsing the Bash Shell141Wildcards are handy when you

Sunday, April 22nd, 2007

ShellUsing the Bash Shell141Wildcards are handy when you want to do something to a whole lot of files. For example, to copy all the files from the /mnt/cdromdirectory to the cur- rent directory, type the following: cp /mnt/cdrom/* . Bash replaces the wildcard character *with the names of all the files in the/mnt/cdromdirectory. The period at the end of the command represents thecurrent directory. You can use the asterisk with other parts of a filename to select a more spe- cific group of files. Suppose you want to use the grepcommand to searchfor the text typedef structin all files of the /usr/includedirectory thatmeet the following criteria: .The filename starts with s. .The filename ends with .h. The wildcard specification s*.hdenotes all filenames that meet these crite- ria. Thus you can perform the search with the following command: grep typedef struct /usr/include/s*.hThe string contains a space that you want the grepcommand to find, so youhave to enclose that string in quotation marks. That way, Bash does not tryto interpret each word in that text as a separate command-line argument. The question mark (?) matches a single character. Suppose that you havefour files image1.pcx, image2.pcx, image3.pcx, and image4.pcx in thecurrent directory. To copy these files to the /mnt/floppydirectory, use thefollowing command: cp image?.pcx /mnt/floppyBash replaces the single question mark with any single character, and copiesthe four files to /mnt. The third wildcard format […] matches a single character from aspecific set of characters enclosed in square brackets. You may want to com- bine this format with other wildcards to narrow down the matching file- names to a smaller set. To see a list of all filenames in the /etc/X11/xdmdirectory that start with xor X, type the following command: ls /etc/X11/xdm/[xX]*
Note: If you are looking for cheap webhost to host and run your apache application check Vision apache web hosting services

Free web hosting music - Using the Bash Shell140Typing less with automatic command

Saturday, April 21st, 2007

Using the Bash Shell140Typing less with automatic command completionMany commands take a filename as an argument. To view the contents of the/etc/modprobe.conftext file, for example, type the following command: cat /etc/modprobe.confThe catcommand displays the /etc/modprobe.conffile. For any com- mand that takes a filename as an argument, you can use a Bash feature toavoid having to type the whole filename. All you have to type is the bareminimum just the first few characters to uniquely identify the file in itsdirectory. To see an example, type cat /etc/modbut don t press Enter; press Tabinstead. Bash automatically completes the filename, so the commandbecomes cat /etc/modprobe.conf. Now press Enter to run the command. Whenever you type a filename, press Tab after the first few characters of thefilename. Bash probably can complete the filename so that you don t have totype the entire name. If you don t enter enough characters to uniquely iden- tify the file, Bash beeps. Just type a few more characters and press Tab again. Going wild with asterisks and question marksYou can avoid typing long filenames another way. (After all, making less workfor users is the idea of computers, isn t it?) This particular trick involves using the asterisk (*) and question mark (?) and a few more tricks. These special characters are called wildcardsbecausethey match zero or more characters in a line of text. If you know MS-DOS, you may have used commands such as COPY *.* A:tocopy all files from the current directory to the A drive. Bash accepts similarwildcards in filenames. As you d expect, Bash provides many more wildcardoptions than the MS-DOS command interpreter does. You can use three types of wildcards in Bash: .The asterisk (*)character matches zero or more characters in a file- name. That means * denotes all files in a directory. .The question mark (?)matches any single character. If you type test?, that matches any five-character text that begins with test. .A set of characters in bracketsmatches any single character from thatset. The string [aB]*, for example, matches any filename that startswith aor B.
Note: In case you are looking for affordable webhost to host and run your web application check Vision http web server services