Welcome, Guest
You have to register before you can post on our site.

Username/Email:
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 5,207
» Latest member: Meup
» Forum threads: 4,029
» Forum posts: 16,404

Full Statistics

Online Users
There are currently 168 online users.
» 0 Member(s) | 165 Guest(s)
Applebot, Bing, Google

Latest Threads
How to install Archboot i...
Forum: Network Problems
Last Post: Meup
2025-05-13, 01:41 PM
» Replies: 0
» Views: 50
clear logs in smoothwall
Forum: Security and Firewalls
Last Post: amanda63
2024-03-10, 03:27 PM
» Replies: 8
» Views: 73,377
I cannot install RedHat 8...
Forum: Redhat
Last Post: hybrid
2023-11-11, 01:01 PM
» Replies: 1
» Views: 30,089
How things are done, usin...
Forum: Xorg Problems
Last Post: ross
2023-09-04, 09:03 AM
» Replies: 0
» Views: 1,635
Im back.....
Forum: Hello
Last Post: anyweb
2021-01-17, 11:36 AM
» Replies: 1
» Views: 5,038
add mp3 plugin to xmms in...
Forum: Fedora
Last Post: anyweb
2021-01-17, 11:30 AM
» Replies: 11
» Views: 40,602
Configuring VSFTPd Server
Forum: FTP Server
Last Post: Johnbaca
2020-10-14, 10:25 AM
» Replies: 32
» Views: 103,030
Wolf won't play sound!
Forum: Game Problems
Last Post: Guest
2020-10-03, 05:51 PM
» Replies: 1
» Views: 43,851
Using git + python
Forum: How Do I?
Last Post: Clueless puppy
2020-08-21, 04:37 PM
» Replies: 0
» Views: 34,344
what does your nick mean ...
Forum: Hello
Last Post: volt
2020-08-06, 03:25 PM
» Replies: 28
» Views: 40,093

 
  Wildcards, Quotes, Back Quotes and Apostrophes
Posted by: Digerati - 2003-12-16, 05:52 PM - Forum: Tips and Tricks - No Replies


In Linux whenever you are not sure about the name of a file and you want to do something with files such as either search for them or copy them or delete some files based on some knowledge you have about the filenames then you can use Wildcards. Wildcards are basically an indicator to the shell that some particular part of the filename is not known to you and the shell can insert a combination of characters in those places and then work on all the newly formed filenames. This concept would be clear by the end of this article

 

There are 3 types of wildcards that can be used Linux. They are the * ? and [] . All the 3 shall be explained in detail.

 

* (Asterisk) Wildcard

 

This represents any sequence of characters. This means that if you include a * in your filename then that part of the filename can be formed using any sequence of characters. The example below explains this concept

 

$ cat article* > combinedarticle

Would find all the files that begin with the letter sequence ' article ' and can have anything following those letters. I mean article01 or article10 or articlenew.. and any such file would be considered. All these files would be merged and would be written to a file named combinedarticle

 

$ ls *gif

Would list all the files having the letters ' gif ' in them. So a file named somegifs.txt as well as a file named 123.gif would be listed in the output.

 

$ ls *.gif

Would list all the files having ' gif ' as the extension of their filename. Thus in this case a file named somegifs.txt file would NOT be listed since its extension is not ' gif '. Whereas a file named 123.gif would be listed.

 

$ ls *day*

Would list all the files that have the letters ' day ' anywhere in their filenames. Thus files such as today.txt , dayone.txt and lastday.gif would all be listed in the output.

 

$ ls .*gif*

Would list all the hidden files in the current directory that have the letters ' gif ' in their filenames. Hidden files in Linux begin with a . (period) in their filenames.

 

$ pl * a.txt

Notice that there is a space between the * and ' a.txt ' . It is this space that causes the command to act as if 2 parameters have been passed to ' pl ' rather than one. The above command would print all the files that are present in the current directory. Once that is done it would proceed to the next file named a.txt and would print that also if it exists.

 

Note : The * would not work with the ' . ' (period) that exists in filenames. Thus in case you use ' *a ' and there is a file whose name begins with ' .a ' , it would not be listed. When a . (period) is the first character in a filename then the file becomes a hidden file in Linux.

 

-

 

? (Question Mark) Wildcard

 

This represents only one character which can be any character. Thus in case you know a part of a filename but not one letter, then you could use this wildcard. If there are many files that are named such as article10, article11 and so on till article19 you could get all these files by using article1? . In this case the ? would be interpreted as any one character and it would find all the files like article10, article11..and so on till article19, since all these files differ in their names by only the last letter.

 

$ ls article1?

Would list all the files that begin with ' article1 ' and have one more character in their names which can be any one valid character.

 

$ ls ??.gif

Would list all the .gif files in the current directory that have only 2 characters before the extension. Thus files such as ab.gif or xy.gif would be listed but 123.gif would not be listed

 

Remember that the ? means any ONE character to be substituted in the place of the ?

 

$ ls *.???

Would list all the files in the current directory that have a file extension of 3 characters in length. Thus files having extensions such as .gif , .jpg , .txt would be listed.

 

-

 

[] (Square Brackets) Wildcard

 

This represents a range of characters. So in case you have files that are named article10, article11, article12..all the way till article19 then you could select all the first 5 of them using the above wildcard as shown below

 

$ ls article1[0-4]

Remember that [] represents a range from which any character can be present. This range can be something like [0-4] or [1-9] or anything like that in case of numbers. Letters could also be selected such as [a-g] or [F-Z] or [A-Z].

 

Note : Remember that in Linux the filenames are case sensitive, Thus a range of [a-z] is different from [A-Z]

 

$ ls beckham[123].jpg

Would list all the files that begin with the letter sequence ' beckham ' and end with either a 1, 2 or 3. Thus the possible filenames that could be listed (if they exists) are beckham1.jpg , beckham2.jpg and beckham3.jpg

 

$ ls [a-d,A-D]*.jpg

This would list all the files that have an extension as .jpg and have as their first letter either a,b,c,d,A,B,C or D . The [ , ] imply that this entire range indicates ONLY ONE letter which can be from any of the two given sub-ranges. A comma is used to merge different range of letters or numbers.

 

Note : I would once again like to mention that [a-d,p-z] does NOT mean that there can be two letters, the first one from a to d and the second one from p to z. It means that there is ONLY ONE letter, and that letter can be from either a to d or from p to z.

 

In case you want to specify the range for 2 characters in the filenames then use the following as follows

$ ls beckham[0-9][0-9]

 

Now I shall discuss the use of special characters such as " ' and ` in various commands that you type at the shell prompt. The information given here is general and has to be followed when typing any command.

 

 

" " (Double Quotes) : Suppress Expansion

 

Whenever you use double quotes (" ") the shell suppress the filename expansion. Thus even if you use a wildcard such as * but enclose it within double quotes you would not get the standard feature of matching for all characters. I mean a command such as

 

$ ls c*

would list all the files with the names beginning with the letter ' c ' . But a command such as

 

$ ls "c*"

would search for a file named ' c* '. There would be no expansion of the * to match other letter sequences. The shell would expect the filename to have the actual character * in its name. Thus you would mostly get a 'No File Found error' message.

 

-

 

` (Back Quotes) : Command Substitution

 

The ` character (found on the key with the ~) is very important when used in shell commands. This ` indicates that command substitution is required wherever it is used. Hence whenever ` is used, whatever part of the command is enclosed by these Backquotes marks would be executed (as if it was the only command) and then the result of that command would be substituted in the original shell command that you typed. The following explains this clearly

 

$ echo "The contents of this directory are " `ls -l` > dir.txt

 

Note : Remember to use the ` (found on the key with the ~ and NOT the one found next to the Enter button)

 

The above command would basically execute the ' ls -l 'part first and then substitute the result after the string "The contents of this directory are " and both of these together (directory listing + the string) would be written to a file named dir.txt

 

Basically after command substitution the new substituted value would act as additional parameter to the main command that was present in your initial statement.

 

-

 

' (Apostrophe Marks) : No Change

 

The ' character (found on the button next to the Enter button) is a very powerful character whenever used in any shell command. Basically the ' (apostrophe marks) disables all kinds of transformations or modifications. It would consider whatever is enclosed with the ' marks as a single entity i.e. a single parameter. Absolutely no sort of substitution or expansion would take place.

 

$ echo '$HOME'

would produce at the output the string $HOME itself and would not print the path to your home directory. Since the single quotes prevents any sort of expansion, substitution and simple considers whatever to be present as a simple parameter in itself.

 

Just so that you remember in case you had typed the following

 

$ echo `$HOME`

(with the backquotes) you would get an error stating that the command not found. Since in this case the $HOME would be substituted with the path to your home directory (suppose /home/david) and the shell would try to execute the path as such. It would search for a program named (such as) /home/david. Remember that backquotes cause it to consider the part within the quotes to be considered as separate command and the output of that command would be substituted here. Hence in this case there is no command / program named as /home/david. Thus you would get an error when bash tries to execute that command

 

On the other hand when you type

 

$ echo "$HOME" or $ echo $HOME

You would get the expected output. i.e the path to your home directory would be printed at the output.

 

Thus you are now familiar with forming various filenames using wildcards. You would generally end up using the special characters such as quotes when trying to make complex shell commands. With this knowledge I hope you can get the shell to do some real good stuff for you.

Print this item

  Pipes - Get the most out of your shell
Posted by: Digerati - 2003-12-16, 05:46 PM - Forum: Tips and Tricks - No Replies


Pipes is probably one of the most important features that is available in the linux shell. This feature is simply astonishing, specially to people who are not familiar to the concept of pipes are totally surprised when they see it work. Without further delay, lets get to the core issue.

 

Explanation :

 

Pipes as the name suggests is a sort of hollow tube (a pipe) where you can put data into one end and get it out of the other end. Whats the use? You will see soon.. Using pipes you can connect two programs. Using pipes you can make the output of a particular command to act as the input for another command.

 

This is best explained using an example

 

$ ls | grep 'mp3'

This command basically consists of 2 commands joined by a pipe. The first command gets the listing of the current directory and then pipes it to (sends it to) the second command which is a grep command. The grep command selects those lines from the directory listing (which it received from the ls command) having the string 'mp3' in them. So basically as a result of this command you would get a list of files / directories that have the letters 'mp3' in their names.

You might think this is not really useful, when you could have used some form of ls command itself (probably shorter) to get the some work done. The use of pipes becomes evident as you design more complex commands.

 

 

Take the following command. This one too is simple, but you would get the idea behind pipes.

 

$ ls | grep 'mp3' | sort -r

This command would do the same as the above one, but this time instead of displaying all the files/directories having the string 'mp3' in their names, this result is passed on to the sort command through a pipe. The sort command with the -r option sorts this result in the reverse order. And then finally displays the result.

 

 

Thus as you can see, pipes let you pass the output of one command to the input of another command. You can carry on this chain as long as you want (you can use pipes between 5,6,7..commands..how many ever you want) ..and you can get extremely customized outputs. The capabilities of linux shell when pipes are used effectively is left to your imagination.

 

In A Nutshell :

Basically pipes can be used with most of the linix commands. But the basic concept remains the same - the output of the first command acts as the input to the second command. You should take care to check that the output of the first command is acceptable input to the second command. It should not be that the first command has its output in some format other than text format and the second command works with only text input. If at all this sort of thing happens, you would mostly get an error message or you would have to type <Ctrl>-C to quit the execution of the command and come back to the prompt.

Print this item

  Text scrolling off the screen?
Posted by: Digerati - 2003-12-16, 05:44 PM - Forum: Tips and Tricks - No Replies


This is actually no tutorial in a real sense. It is a simple tip which many newcomers would appreciate. Most of the Linux commands that you type create a lot of text at the output, and generally this text scrolls off the screen. Pressing the <Up Arrow> key simply gets the last command executed and doesn't let you see the text that scrolled up the screen. So how do you do it??

 

Solution :

 

You have to press <Shift> + <Up Arrow> keys to scroll the screen in the upward direction. Similarly once you have scrolled up you can use the <Shift> + <Down Arrow> key to scroll downwards. Alternatively you can press <Shift> + <Page Up> to scroll one page at a time and <Shift> + <Page Down> would scroll down a page at a time.

 

Once you have scrolled many pages upwards if you want to come back to the prompt you can simply leave the <Shift> button and press any other key such as <Page Down> or <Page Up> or the <Right Arrow> or <Left Arrow> key.

 

That's it for this .. I though this tip would be worth adding to this website. Once you know this trick you would be using this almost every time you do some serious stuff in the shell.

Print this item

  How to find files in Linux using 'locate'
Posted by: Digerati - 2003-12-16, 05:42 PM - Forum: Tips and Tricks - No Replies


The simplest way to find files under Linux is to use the locate program. This article explains how to use locate tool to find your files easily. When you run locate for the first time, you might get an error message. To get it working refer to the Note at the bottom of the page.

 

Procedure :

 

Here are various ways to use locate tool

 

 

-

 

$ locate index.html

 

It would produce a list of the locations where you could find files that are named as index.html. This might produce results as follows

 

 

/home/pamela/index.html

/usr/local/games/pam/index.html

 

-

 

You could use the -q option to suppress error messages. Error messages would typically be messages stating that permission to access files were not allowed since you are only a user (not superuser). The -q option would suppress any other error messages as well

 

$ locate "*.dat" -q

 

-

 

You could use the -n option to limit the number of returned results to a specific number. E.g. you could ask for only 10 search results by the following command

 

$ locate "*.c" -n 10

 

This would return the first 10 files that end in .c that Linux finds.

 

-

 

You could use the -i option in case you wanted to perform a case insensitive search. The case of the filenames would not be considered

 

$ locate INDEX.HTML -i

 

-

 

You could make your search faster by typing the following

 

$ locate index.html -l 0

 

Typing -l 1 takes longer time for the search to complete but is more secure. This is the default action that takes place when the -l option is not mentioned.

 

-

 

There are few more parameters that can be used with locate, but they are generally not used. You can find them in the man pages.

 

Note : When you run 'locate' for the first time, you will get a message stating that the db is not available. Linux requires a database of all the files, which locate uses to find the files. The message would also state that you can log in as root and run a particular command. Simply doing so would get locate to work perfectly. To change to the superuser mode type 'su' at the prompt. Then type the command you were asked to run (as indicated in the message). Type <Ctrl>+D to exit the superuser mode. Now you can continue with locate commands as normal.

Print this item

  Scheduling tasks using Cron
Posted by: Digerati - 2003-12-16, 05:39 PM - Forum: Tips and Tricks - No Replies


This article explains task scheduling using a program called cron which is used for complex task scheduling. Scheduling of tasks under Linux is an extremely powerful procedure which is used by almost everyone. The basic advantage of cron over at is that if you want a task to occur at regular intervals or basically more than once, then you don't have to repeatedly enter 'at' commands multiple times. You can use cron and feed in the number of times that you want the task to occur and cron handles the details of executing that task again and again.

 

Cron basically uses a particular table which has all the information about the task you want to execute and when you want to execute it. The user has to make this table and ask cron to use that table for its scheduling. You can make this table using any text editor such as vi or emacs and store it in any text file. This file is called the crontab file and I shall name mine as 'myjobs'.

 

 

Procedure :

 

Simply make a new text file, and enter this line in that text file. I have named my text file (crontab file) as 'myjobs'

 

30 04 * 3-5 * backup

 

Save the file and then run this command at the prompt

 

$ crontab myjobs

 

Thats it !! Now you will have your program called backup (in case you really have one) running at the times you have set it to run.To run whichever program you want, you have to make similar entries in the crontab file that you make and simply tell cron which file you have made using the command 'crontab [filename]'

 

Remember that all the output that your executing program generates, will be sent to you as a local mail. Not your ISP mail but your local Linux mail. So next time you check your local mail, you would find a mail whose contents would be the output of your task that cron executed. I mean suppose you used cron to execute the 'ls' commmand at regular intervals, then you would receive mails whose content would be the directory listing of your linux filesystem.

 

Few Tips On Cron :

 

To know what tasks cron shall be executing you can use the following command

$ crontab -l

This command shall provide a detailed list of all the jobs that cron shall execute. It would basically be showing you your crontab file. So you need to know the meaning of the 6 fields to make sense of the output

 

_

 

To remove the current crontab you can use the following command

$ crontab -r

This shall remove whatever entries you added to cron using your own crontab file.

 

_

 

To edit the crontab to enter or remove tasks type the following command

$ crontab -e

But note that typing this command would mostly open ' vi ' in order to edit the crontab file. And in case you are not familiar with vi then you would not like this behaviour. In that case open your crontab file (the one in which you entered all the tasks) using whichever text-editor you want, then add/remove the lines you want to, and then after saving the file run the following command

$ crontab [filename]

This will update the crontab with your new tasks. You can also check whether the update has taken place by typing the following command

$ crontab -l

 

_

 

If in a crontab file entry, the 'Day of Week' and 'Day of Month' fields are both restricted (i.e. Both are NOT * ) then the task would be executed when either condition gets satisfied.

E.g. Day of month is 1-10 and Day of week is 3, then the task would be executed on the the first 10 days of the month and thereafter on every Wednesday that occurs in the month.

 

_

 

To run a task every 5 hours

If you want to do the above then in the crontab file entry, in the hour field you can enter a Step Value as follows '*/5' (without the inverted commas). This would cause the task to be executed every 5 hours.

 

_

 

To run a task in the first 10 days of a month and then last 10 days of the month you can use Ranges as follows

Enter '1-10,21-30' (without the inverted commas) in the 'Days' field.

 

_

 

To run a task every alternate day for the first 15 days of the month you can enter '1-15/2' in the 'Days' field. This would run the task on the following days of the month (1,3,5,7,9,11,13,15)

 

_

 

If you want to enter Comments, all you have to do is to add a # at the beginning of the line. Remember comments are not allowed on the same line with a cron command. So comments need to be entered on a separate line starting with a # (first character should be #)

 

_

 

This tip is important for all those countries that use daylight saving techniques. If a particular instant of time (when a task was to be executed) is lost because of changing the time for daylight saving then cron will simply skip that task and wait for the next occurrence of that particular time. Similarly if a particular instant of time occurs twice because of change in timing, then cron would once again execute that task a second time.

 

_

 

Besides comments and cron commands you can also make environment setting in the crontab file. In case the program that you would be executing requires any environment variables to be set, than those too can be set in the file that cron would use. An environment setting can be simply made using a name=value pair.

E.g. typing HOME=/home/david/myprograms on a separate line in the crontab file would make that particular directory your HOME directory.

 

_

 

More cron tips in the future articles in this series. Till then hope you have a good time with the information presented here. Do mail me in case you have any problems with cron.

Print this item

  Execute a task 'at' the time you want..
Posted by: Digerati - 2003-12-16, 05:31 PM - Forum: Tips and Tricks - No Replies


Scheduling of tasks under Linux is an extremely powerful procedure which is used by almost everyone. Scheduling of tasks basically means running whichever program you want at a particular time without having to manually be present at the machine at that time. Linux will run that program for you at that time. In this article I shall explain the simplest way to schedule tasks using the simple command called 'at'.

 

 

Advanced task scheduling is possible using 'cron'. Please use 'cron' if you want to repeatedly execute any task.

 

 

Procedure :

 

At the prompt type this command followed by <Enter>

 

$ at 2359

 

The moment you press Enter the prompt changes into an arrow indicating that more information is required by Linux. Type the following command assuming you have installed XMMS player which plays mp3 files and that you actually have a mp3 file in the directory shown below

 

> xmms /home/david/mp3s/rock_my_world.mp3

 

Once you have typed the above press <Enter> and then finally press <Ctrl>-D

 

Thats it. Now Linux will make the XMMS player to play the particular mp3 file at the time 23:59. Thats just a minute before midnight. Linux surely rocks your world !! ;-)

 

Basically if you are using the 24 hour clock then you enter the time you want with the hours and the minutes together one after another. Hours = 0-23 & Minutes = 0-59. Then type the exact command that you would have typed had you wanted to execute the task manually. If you want you can issue more commands after the first one. Once you finish entering all the tasks press <Ctrl>-D to indicate that you have finished. Then wait and enjoy.. Linux will do the rest.

 

 

 

Remember :

 

At any time you can see the list of pending jobs by typing the following at the prompt

$ at -l (that a lowercase 'L')

 

If you want to remove any particular job in case you suddenly decided that you don't want that program to execute then first get the list of pending jobs as shown above. You will see that every job has a corresponding ID associated with it. Use the command below (In this case to remove job with ID=10)

$ atrm 10

Print this item

  How to find files in Linux using 'find'
Posted by: Digerati - 2003-12-16, 05:27 PM - Forum: Tips and Tricks - No Replies


Files can be found under Linux in many different ways. Using the find tool is one of the best ways to find files. The find tool has a huge number of parameters which can be set so that Linux finds exactly those files that you were searching for. Many users use the find tool with just the basic parameters. They get the results that they were looking for. Unfortunately most of the users don't spend time to learn all about find. If they do, they can make excellent use of this tool and I am sure you would be surprised at the possibilities.

 

 

In case you just want to know where a particular file exists on your system, and nothing else is required, then use locate tool.

 

 

Here are a few ways to use find

 

-

 

$ find / -name 'program.c' 2>/dev/null

$ find / -name 'program.c' 2>errors.txt

 

 

/ Start searching from the root directory (i.e / directory)

-name Given search text is the filename rather than any other attribute of a file

'program.c' Search text that we have entered. Always enclose the filename in single quotes.. why to do this is complex.. so simply do so.

 

Note : 2>/dev/null is not related to find tool as such. 2 indicates the error stream in Linux, and /dev/null is the device where anything you send simply disappears. So 2>/dev/null in this case means that while finding for the files, in case any error messages pop up simply send them to /dev/null i.e. simply discard all error messages.

 

Alternatively you could use 2>error.txt where after the search is completed you would have a file named error.txt in the current directory with all the error messages in it.

 

-

 

 

$ find /home/david -name 'index*'

$ find /home/david -iname 'index*'

The 1st command would find files having the letters index as the beginning of the file name. The search would be started in the directory /home/david and carry on within that directory and its subdirectories only.

The 2nd command would search for the same, but the case of the filename wouldn't be considered. So all files starting with any combination of letters in upper and lower case such as INDEX or indEX or index would be returned.

 

-

 

$ find -name met*

The above command would start searching for the files that begin with the letters 'met' within the current directory and the directories that are present within the current directory. Since the directory is not specified as the the second parameter, Linux defaults to using the current directory as the one to start the search in.

 

-

 

$ find /mp3collection -name '*.mp3' -size -5000k

$ find / -size +10000k

The 1st command would find within a directory called /mp3collection, only those mp3 files that have a size less than 5000 Kilobytes ( < 5MB)

The 2nd command would search from the / directory for any file that is larger than 10000k (> 10MB)

 

-

 

$ find /home/david -amin -10 -name '*.c'

$ find /home/david -atime -2 -name '*.c'

$ find /home/david -mmin -10 -name '*.c'

$ find /home/david -mtime -2 -name '*.c'

 

The 1st commmand searches for those files that are present in the directory /home/david and its subdirectoires which end in .c and which have been accessed in the last 10 minutes.

The 2nd command does the same but searches for those files that have been accessed in the last 10 hours.

The 3rd and the 4th commands do the same as the 1st and 2nd commands but they search for modified files rather than accessed files. Only if the contents of the files have been modified, would their names be returned in the search results.

 

-

 

$ find / -mount -name 'win*'

This command searches for files starting with the letters 'win' in their filenames. The only difference is that the mounted filesystems would not be searched for this time. This is useful when you have your Windows partitions mounted by default. And a search for 'win' might return many files on those partitions, which you may not be really interested in. This is only one use of -mount parameter.

 

-

 

$ find /mp3-collection -name 'Metallica*' -and -size +10000k

$ find /mp3-collection -size +10000k ! -name "Metallica*"

$ find /mp3-collection -name 'Metallica*' -or -size +10000k

Boolean operators such as AND, OR and NOT make find an extremely useful tool.

The 1st command searches within the directory /mp3-collection for files that have their names beginning with 'Metallica' and whose size is greater than 10000 kilobytes (> 10 MB).

The 2nd command searches in the same directory as above case but only for files that are greater than 10MB, but they should not have 'Metallica' as the starting of their filenames.

The 3rd command searches in the same directory for files that begin with 'Metallica' in their names or all the files that are greater than 10 MB in size.

 

-

 

The exec option is probably the most important feature of the find tool. The exec command allows you to execute a particular command on the results of the find command. A simple demonstration of this feature is shown below. Its upto your imagination to make maximum use of this feature. Suppose you wanted to see the details of the files (read, write, execute permission, file size, owner etc..) that have been returned as a search result you could do the following

 

$ find / - name 'Metallica*' -exec ls -l {\}\ \;

 

This command would find all the files on your system that begin with the letters 'Metallica' and would then execute the 'ls -l' command on these files. So basically you would be able to see the details of the files that were returned according to your search criteria.

 

The words following the -exec option is the command that you want to execute i.e. ls -l in this case.

{\}\ is basically an indicator that the filenames returned by the search should be substituted here.

\; is the terminating string, and is required at the end of the command

Print this item

  Digerati
Posted by: Digerati - 2003-12-16, 05:21 PM - Forum: Hello - Replies (1)


Yo world wasup!

 

My name is Mitch and I am a network admin at a small company.

I have recently obtained my MCSA and I think I will try for a linux cert now :)

 

The network I support is soley a windows network with a few exceptions, we use apache for www and xmail for smtp.

 

I hope to migrate them into using linux one day soon as M$ keeps pissing me off with their lameness. I am tired of getting used to one os and then bam no more service packs for you, you must upgrade now or die. Plus I am sick of the TCO as well. truck some licenses!

 

Anyways this is not a vent section its a hello section so let me calm down a bit.

ahhh

Ok,.

I am liking this site. I have dabbled in linux for over a year now and loving it.

I hope this site really takes off. I promise to post often as I can with as much useful info as I can.

 

holla.

 

[/url][url=http://www.thebatchfile.com]http://www.thebatchfile.com

Print this item

  Setting the path
Posted by: Digerati - 2003-12-16, 05:16 PM - Forum: Tips and Tricks - Replies (1)


This article explains how set your PATH variable under Linux. This has the same use as that of setting the PATH variable under DOS. Under Linux too, modifying the PATH would add these new directories to your default search path.

So in case you have a particular executable in a particular directory, then if you add that directory to your PATH, then you would only have to type the name of the executable at the prompt rather than then absolute path for that executable. Got it?? Read the example below to figure out what exactly I am speaking about..

 

 

Assumption

 

 

Suppose you have a program by the name 'tetris' in a folder called /usr/local/games . So in order to run this program you would have to type the following at the prompt

$/usr/local/games/tetris

 

The above command would execute your program. But typing this every time you want to play this wonderful game makes it slightly cumbersome. It would be much better if you could only type 'tetris'.

 

 

Solution

 

A solution would be to add the /usr/local/games directory to your PATH, so that next time onwards you would only have to type 'tetris' at the prompt rather than the absolute path.

 

To add this directory to your PATH you have to edit a file called 'bash_profile' that would be present in your Home directory (in Redhat Linux 6.2). So if there is a user by the name David then this file would mostly be found at /home/David/.bash_profile

 

Note : The period (.) before the name of the file. This period make this file a hidden file. So remember to view hidden files also while seeing a directory listing (This option would be in some menu in X , at the prompt simply use 'ls -a' to see hidden files).

 

This file would be having a particular line starting with the string PATH. For e.g. the file that I have on my machine has a line such as

PATH=/optional/bin:$PATH:$HOME/bin

 

To add the directory /usr/local/games to this I would have to modify this line as follows

PATH=/usr/local/games:optional/bin:$PATH:$HOME/bin

 

Once you have modified this file, save it and then execute it as follows

. $HOME/.bash_profile

 

Note : To execute this script basically at the $ prompt type a period ' . ' leave a space and then type $HOME/ Once this is done press <Tab> key. Doing so would replace what ever you have typed with the path to your home directory. Once this happens all you have to do is append a .bash_profile to what is already present at the prompt and finally press <Enter>

 

On executing the script you wouldn't see any messages at the output, but then onwards you could simply type 'tetris' at the prompt to execute the program /usr/local/games/tetris

 

So now you are on the right PATH ;-)

Print this item

  What to do if Linux refuses to boot after a power
Posted by: Digerati - 2003-12-16, 05:13 PM - Forum: Tips and Tricks - No Replies


This article deals with what action is to be taken (during a reboot) after a power failure or an incomplete shutdown of a Linux system due to any reason. This problem seems to be very common since many newcomers install Linux and get all the various softwares/hardwares working under Linux and suddenly one day the power fails. And there after they are totally clueless as to what to do ..since they cant even access HOW TO's without booting into Linux.

 

This tutorial will most probably help you get out of that problem. So please read this even if you haven't faced this problem..since you never know when you may get unlucky.

 

Solution

 

There are a few things that you can try to get Linux back on track..

 

 

 

1. While rebooting, Linux may print a message saying that there is a problem with the filesystem and it might force a check. It would do this for all Linux partitions. If the checks (they generally take around 30-60 seconds..also displays a rotating indicator) are successful then you are lucky. Linux should mostly continue booting and you should be back in business soon. If this is what happens then you may be under an impression that a direct switch off of a Linux machine leads to no problems. Please note that you were just lucky that you got away without any major problems.

 

 

 

2. While rebooting, Linux may not be successful in any of the filesystem checks. In this case the booting stops abruptly with a message stating that you should run fsck manually without a few parameters. Once you reach the bash prompt (#) then run the fsck command as mentioned (fsck -a -p /dev/hdaX). The fsck command requires the partition which it has to check. So if you have installed linux on /dev/hda1 then you have to run fsck as follows : fsck -a -p /dev/hda1

 

When you run fsck it would mostly find some inode problems and ask you whether you want to fix them, Select the default option (yes). It would do so for all the problems found. Once this is over you can restart the machine using either "Ctlr+Alt+Del" or "shutdown -r 0", whichever works. Now this time your Linux machine should boot properly.

 

 

 

3. It has so happened that once when the power failed, Linux simple failed to boot on my machine. It gave no errors at all, but the init process would just not get initiated. It would find my partitions, mount the ext2 filesystem as read only and then would simply display a prompt. Even with this prompt I wasn't able to do a lot. Also I noticed that a few of the default directories were missing on the native partition. The only solution that I found to this was to Reinstall Linux.

 

Note : While reinstalling, the best and safest way for the above problem would be to insert the installation media (Redhat Linux 6.1 CD). And instead of selecting to install the OS once again, select to upgrade the existing installation. This would effectively replace all the damages areas of the OS and would also retain all your personal data and configurations in Linux (This should work in almost all cases).

Hence I would always advice an upgrade to the same version (If you originally had Redhat Linux 6.1 , insert the CD and once again select to upgrade to Redhat Linux 6.1 itself). If the upgrade option doesn't fix the problem, then you would have to do a reinstall after a reformat of the Linux partitions.

 

 

 

4. In one case when Linux refused to boot I noticed that a few of the main files / directories were missing. I found that the /sbin directory (which is a very important directory) wasn't there in the root directory. I performed a search for this directory and found it to be within another directory. After some discussion I realised that my friend has accidently moved this directory within his GUI when he was working in superuser mode. As long as he was working a few commands didn't work but he did not bother about finding out why they didn't work. Once he rebooted his machine the abscence of this directory hung the booting process. So I suggest that you never work in superuser mode unless absolutely necessary. Even within the superuser mode prefer the shell, since you can hardly ever do anything accidently in the shell. In my friend's case I simply moved that directory back within the root directory and Linux booted without any problems.

 

So when you have a properly working Linux machine, do take the time to have a look at the filesystem and make a mental note of the directory structure which appears to be pretty complex to newcomers.

 

 

 

Finally after all this if your Linux machine still doesn't boot, do mail me the exact messages that you see on the screen, I shall try to help you out. And also invest in an UPS if affordable. You wouldn't be reading this page if you had one initially.

Print this item