text:
Movie Making Manual/Budget/Funding

If you are raising any kind of a large budget, you are unlikely to get it all from one source. A funding plan is a strategy for how to get the money. Here is one funding plan:

 * 1) Total Budget: $25 million.
 * 2) Convince Charlize Theron and Brad Pitt to be in your film.
 * 3) Take to studio.

Admittedly, this is a longshot. More realistically, you will have thought about what money you can get from where, and how to go about obtaining it. Your funding plan will have headers like "UK tax break financing 15% of budget" and "Advance from US DVD distributor". You will then outline in the plan exactly how certain this money is as well as what you need to do to receive it.

A completed funding plan with half of the money confirmed is a powerful way to leverage additional funding. There is no surer way of making investors feel comfortable than showing them that other investors feel comfortable.

For some specific ideas on raising funds via film grants, private investors, hedge funds, and other film financing sources visit the Film Funding Blog here: Film Funding

/Funding and budgetting

title: Movie Making Manual/Budget/Funding


text:
Movie Making Manual/Recipes

Chili Con Soya
This is a soya version of Chili con Carne. It is cheaper than the meat version and won't upset your vegetarians on set. This provides a lot of energy and is very warming - great for winter shoots!

The amounts below will feed a small crew of 15. This is really easy to cook but takes about 1/2 a day on the stove so you need to be prepare it in advance - you can however freeze it and it always tastes better the second day!

Ingredients

 * 10 tins kidney beans
 * 1kg Soya mince (you can use any dried soya mince or Quorn)
 * 5 large onions chopped
 * 5 cloves of garlic
 * 300 grams tomato paste
 * 30 tomatoes chopped (can use 10 tins of tomatoes but fresh is better)
 * 5 chillies (use assorted chillies as the flavours blend well) - don't worry this is a mild version
 * salt & pepper & assorted herbs to season

Directions

 * Put a bit of oil in a large pot and fry onions until brown.
 * Add soya mince and fry it a little
 * Add garlic, chilies, tomatoes, tomato paste. Turn down heat to 1 and leave to simmer without a lid (you want to reduce the tomato)
 * Leave it simmering for about 6 hours, checking on it about every 20 minutes or so.
 * Taste it! Add salt, pepper, garlic and chilli till it tastes good (keep it mild even if you prefer it hotter).  Remember all the flavours will get stronger after it sits for the next couple of days
 * Have a bowl with a good bread and butter!
 * If your shoot is 2-3 days away refrigerate after it has cooled otherwise freeze it.

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/

title: Movie Making Manual/Recipes


text:
Movie Making Manual/Equipment Timeshares

Abstract
Fairly early in many independent production company's lives a dilemma arises with regards to film equipment - should the company rent or buy?

Indy film and documentary makers need to be busier than their mainstream counterparts. Producing films at lower cost with lower margins means one needs to stay active in order to turnover enough "product" to be a viable business. This should make us more inclined toward the purchase of equipment but we are often deterred by hefty upfront costs and gear often sitting idle due to long development, pre- and post-production periods.

Some producers square the circle by purchasing equipment and renting it to other producers. This can work but the cost of marketing the service, attendant management overheads, threat of damage and distraction from the core business make this a sub-optimal solution.

This paper proposes an alternate model - collective ownership alongside an innovative financing model. Herein is a framework for a group of filmmakers or production companies to collectively purchase and share equipment. The high cost of film equipment, the cyclic nature of film production, and the collaborative nature of the industry make it well suited to such a collective.

 * Equipment Timeshare Agreement
 * Sample Shooting Kit

Ebay Alternative
Find an equipment that:
 * Has been on the market for over a year
 * Is being sold on eBay
 * Has at least 10 bidders on it

Then put in the bid to buy it used. Most likely when you are done with it you can sell it back for roughly the same price you bought it for (used is used).

The longer it has been on the market and the higher the number of bidders for the item, the higher the likelihood that you will be able to sell it at the same price. Save the text and the images from the auction so you can save effort when you decide to resell the item. Also, be sure to follow the typical best practices for eBay: check the seller rating, check shipping rate, etc.

/Tools and equipment


text:
Movie Making Manual/Equipment Timeshare Agreement

This is the Draft Agreement fot the FilmEquipmentTimeshare

Outline

 * The Film Equipment Timeshare is a "for mutual profit" partnership the purpose of which is to enable members to pool resources and buy film-making equipment which the members then share.
 * Each member will contribute an initial £X.00 to the partnership and pay an 1/5th X renewal fee each year.
 * There will be a minimum of 3 and a maximum of 12 members.
 * Members can be individuals, companies, partnerships, etcetera.
 * Members may choose to manage the partnership in-house or appoint an external management member.
 * If Members choose to manage the partnership themselves they should elect a treasurer, a diary keeper, and an equipment maintainer. Members may hold more than one of these positions.

Purchase of Equipment

 * Members should agree their aims and then assemble a list of equipment to meet those aims.
 * Members can then purchase this equipment in any manner the partnership agrees.

Use of Equipment

 * Each member is assigned 350/[number of members] days use per year.
 * Members shall pay Y per day for actual usage of the kit
 * Each Member therefore guarantees to pay each year £Y times 350/[number of members] per year.
 * 15 days each year are set aside for servicing of equipment or emergencies.
 * Members should reserve equipment with the diary controller. The diary should be available to all members at all times (preferably online) so they members can plan their projects.
 * Equipment cannot be booked more than 1 year in advance.
 * Members not using all their assigned days may allocate them to a "pool"/bulletin board where they may be purchased by another member.
 * Members will sign equipment over to themselves when collecting it from the previous user. It is the accepting member's responsibility to cover any insurance excess for loss of or damage to the equipment while it is in his care.

General

 * The equipment shall be insured at all times
 * Equipment cannot be lent or hired to 3rd parties

Governance

 * New members need approval from a majority of existing members
 * Members may sell on at any time: existing members have pre-emption rights but if not taken up any new member to be approved by a majority.
 * General Meetings at least once per year immediately following the anniversary date of the partnership's formation, any two members can requisition an extraordinary general meeting.
 * At General Meeting members will vote on rental levels, how much of the capital to disburse, how much to reinvest in new equipment and how much to leave in the partnership.


text:
Movie Making Manual/Sample Shooting Kit

Kit for Shorts and ultra low-budget Independant feature films
This a the Sample Shooting Kit fot the Film Equipment Timeshare

Purpose: shorts and ultra low-budget independent feature films

Feedback: Re sound recorder. For digital video, this would seem to be redundant. Direct input to the camera would do the trick. The £10 000 total cost would be before discounts. For this particular kit 5 production companies could get it for the following prices: £5000/year)
 * Buy in £500 apiece (produces £2500)
 * Annual renewal £100 apiece (will produces £500/year)
 * Daily rental fee £25 (should produce a minimum of

Assuming financing at around 10% and annual insurance costs of about 10% of equipment value the equipment should be paid off in less than 2 years.

Each company would have guaranteed use of the equipment for 50 days per year more than enough to make at least 1 feature...

This is just an example, these partnership are flexible. A partnership with HD cameras and HBB portadrive sound equipment will have generally higher buy-in and fees whilst entry to a partnership aimed at documentaries could be the price of a good night out.

title: Movie Making Manual/Sample Shooting Kit


text:
Talk:Embedded Systems/Atmel AVR

Keep up the good work guys!

Possible Merge?
Several other similar pages, such as 8051, The 8051 Microcontroller, and PIC were all merged into the Embedded Systems book. Of course, all those other pages were very small stubs, or half-books, and were easy to say goodbye to. This book is a little more substantial, but suffers from the fact that it is only a single monolithic page, and isn't broken up into any kind of book format. I would like to suggest we merge this book into the Embedded Systems book as well, although I would like to hear from some contributers here before I put up the mergeto template, and get the ball rolling. If people here would like to merge this book, I would personally take care of most of the work, and I would divide this information up into a more managable page hierarchy. --Whiteknight T C E 23:53, 17 November 2005 (UTC)

External Memory Interface?
Could it be a good idea to add a topic on how to use the AVR's external memory interface (hardware and software wise)? If I knew how it worked I would be eager to help, but I can't find any information on what kind of SRAM and latch chip to use.

 * I've taken notice of this article, and will be adding material, replacing ASCII art with images, and attempting to (justifiably) get rid of the rewrite tag at the top of the article. Pfagerburg 15:34, 25 July 2007 (UTC)

Rather than draw my own picture, I'll refer to you the "External Memory Interface" section of the datasheets for devices that can use external SRAM, e.g. the Mega162. The requirements for the latch are clearly described (a '573 or equivalent) as well as the connections of the various signals from the AVR to the SRAM. Pfagerburg (talk) 20:51, 6 February 2008 (UTC)

Working on the article
Here are my plans to improve the article so that the "needs improvement" tag can be legitimately removed.
 * Remove (!!!) where it shows up, after considering the text and possibly changing it
 * Rewrite description of interrupts.
 * Minor editing to GPIO section Not so minor after all.
 * Replace ASCII art with a proper drawing in RS-232 section
 * Add explanation of "true" SPI and hardware-assisted like the USI (Universial Serial Interface) found on some of the AVR's, e.g. Tiny26.
 * Protocol issues section might need to be removed entirely.
 * JTAG section needs some parenthetical comments removed.
 * JTAGICE mkII section contains links to several development boards; these need to go into a separate section.
 * JTAGICE references in section 10 (AVR selection) may need to move up to section 8 (debugging interfaces).
 * "AVR Selection" section needs some reorganization.
 * "Firmware Programming" section needs an introduction, possibly some reorganization. Might also want to look for dead links.
 * "Programmer Tools" is a link farm and FAQ, needs cleanup. Some of it (AVRDude) might move up to the in-system programming section.
 * Make "References" its own section.
 * Add a quick overview before section 1 ("Memory"), probably just borrow heavily from the Wikipedia article.
 * Add circuit diagram for using external memory, per request on the talk page.
 * Add drawing/SPI block diagram to SPI section. Datasheets have much better diagrams; point there.
 * "References" is a link farm, needs a lot of cleanup. Some should move up to other sections where particular tools are mentioned.
 * The Timer/Counter section needs clean-up
 * There are several variants of timers on the AVR, 8-bit, 16-bit, PWM, high-speed, and these are not adequately explained. Could use more explanations, but at least there's something there now.
 * Timer1 is not always a 16-bit timer.
 * There was an image that was removed for being unlicensed, needs to be replaced, but what was the image so I know what to replace it with? The image didn't add much, and is in all the datasheets anyway
 * Fix the in the JTAG section one way or the other.
 * Final scan for ?!?, TBD/TODO, etc.'s, ...'s and other signs of needed clean-up.
 * Remove clean-up tag.

I'll be working through the article from start to finish. I'm sure there's more than just this list. I appreciate the efforts of the folks who created this section, and hope that my edits will add to the quality and make it even more useful to other readers. Pfagerburg 17:22, 2 August 2007 (UTC)

 * It's done. Sort of.  The article can always use improvement (and I will continue working on it), but I feel that I have it to a place where it doesn't need the clean-up tag any longer. Pfagerburg (talk) 23:28, 13 March 2008 (UTC)

AVR Butterfly Demo Board
I re-worded the Butterfly Demo Board section, specifically mentioning the company that designed the board. I removed the link to smileymicros.com, since they sell the board, but did not design it. I realize that this promotes Ecros over Smiley (since both sell the board), but I think this is unavoidable. If, for every protoboard and development tool listed, we have to have a link to every vendor that sells it, things get messy very fast.

For example, Olimex makes a lot of great protoboards and tools for the AVR, and they are specifically mentioned in the article as making a JTAG clone. Since SparkFun Electronics stocks many Olimex products, should we put in a link to SparkFun's website? BTW, SparkFun is in Boulder, CO, about 2 miles from where I used to work, and I've bought several things from them. They're great folks, and if not for some serious self-control, I could spend a fortune on all the nifty stuff they carry. Should they have a link in this article every time a product that someone else designed happens to be stocked at SparkFun? I say no.

So, nothing against SmileyMicros, but the wiki is not a place to advertise that you sell someone else's product. Pfagerburg (talk) 19:42, 1 February 2008 (UTC)

 * OK, I admit it: I'm a living organ donor. I donated my brain, since I seem to have so little use for it.

 * It turns out I was the one that put that link to Smiley Micros in the first place, and now I remember why. I was looking for a particular part, found it at Smiley, and in the process, noted that they stocked the Butterfly carrier board, and so added the information to the wiki.  A little more careful research at the time would have led me to the designer of the board (Ecros).  Someone (an IP addr) added the link to Ecros, and the diff brought that to my attention.

 * I apologize for any confusion or offense I may have caused. Pfagerburg (talk) 19:54, 1 February 2008 (UTC)

serial communication
I agree that this Embedded Systems book needs to talk about all kinds of serial protocols -- RS-232, RS-485, SPI, etc. However, lots of different CPUs use these protocols. Is there some more appropriate chapter of the Embedded Systems book to discuss serial communication in general? That way we can avoid explaining these things over and over again, in the chapter for each specific CPU. Or should we move most of that information to another book entirely, one on the serial communications bookshelf ? --DavidCary (talk) 18:09, 19 April 2008 (UTC)

I removed the circuit diagram for using a few resistors to talk to an RS-232 port. As I had noted in the text when I first replaced the ASCII art with a proper picture, it is a poor choice for anything but a "one-off" system. One thing I failed to note is that you can't use the hardware UART with this circuit; the polarity is reversed compared to what the RS-232 port expects to see. Aside from that, it's not specific to the AVR, so if this particular circuit belongs in Wikibooks at all, a more appropriate place would be the general article on serial communication. Pfagerburg (talk) 19:14, 18 August 2008 (UTC)

Submitting your AVR project to this page
A few edits in the past month have been obvious self-promotion. I'm not completely sure what to do about that in cases where there aren't many resources in the category already, or the project is in some way notable. e.g. if someone from Kanda edited this page to mention some new debugger that they were making, I don't think I would have an issue with that. However, I also don't want to see this page cluttered with 20 different BASIC compilers or interpreters, etc. For right now, I'm just going to clean up the ad copy that a few people have posted, and later I will come back and see if I can tone some of this down.

You do realize that AVRFreaks has a complete list of every tool? So you can get your stuff listed there, for free as far as I know? It's pure supposition on my part, but I believe that when people are looking for AVR tools, they are going to look at AVRFreaks before they look at wikibooks. But that's just my guess. Pfagerburg (talk) 04:38, 11 September 2008 (UTC)

title: Talk:Embedded Systems/Atmel AVR


text:
Wikijunior:Big Cats/Jaguar

The Jaguar is sometimes called Onça by South Americans and El Tigre (the tiger) by Central Americans. Long ago, they called it Yaguara, the "cat that kills with a single spring." Both names convey the awe and reverence this largest New World cat inspires. Their gold coat spangled with black rosettes was said to be the stars of night. In the Mayan religion, the sun took the form of a jaguar when travelling through the underworld at night. Jaguars are closely related to lions, tigers, and leopards. The jaguar and leopard are almost the same but their spots are different. If you look very closely you will see that they have a different pattern.

Where do jaguars live?
Jaguars live in the rain forests and more open countryside in South and Central America, and are the largest members of the cat family there. Jaguars are strong swimmers and climbers, and they often prefer to live by rivers, in swamps, and in dense forest with thick cover for stalking prey.

Jaguars once lived as far north as the southwestern United States. The last wild jaguar in the United States died around 1960. Some of these cats are once again migrating north from Mexico.

What do jaguars look like?
Jaguars look very similar to leopards, but they behave more like tigers. The jaguar has the strongest jaw structure in the cat family. Its powerful cheek muscles and lower jaw gives the Jaguar a much more rounded face than the leopard. Jaguars are also rather short-legged compared to other cats, which increases their strength rather than their speed.

Jaguars usually have background fur that is orange-yellow in color. There are numerous rings of spots on their flanks and spots on their heads and necks. Jaguars and leopards can be distinguished by the fact that jaguars have spots within the centers of their ring markings, while leopards do not. Some scientific evidence suggests these two cats are very closely related but jaguars are native to the New World while leopards are native to the Old World. There are some jaguars that seem to be entirely black in color, but the spots can still be seen if you look closely. Jaguars with the all black coloring are sometimes called black panthers, but they are really jaguars.

What do jaguars eat, and how do they catch their prey?
Jaguars mostly take large prey, such as deer and peccaries, but they are great opportunists and will eat anything from frogs and mice to birds, fish, and domestic livestock. Jaguars can run quite quickly, but do not have much endurance and rarely make long chases. Their strong, muscular jaws let them crush through large, thick bones and they can even crunch through a turtle's shell quickly. This great strength allows these cats to crush the skull of prey animals rather than suffocating them with a neck bite, as most cats do. Jaguars have very good night vision and do most of their hunting on the ground at night. They are nocturnal creatures, meaning that they prefer to be active at night.

Fun facts

 * Jaguars will sometimes wait by the water, hitting it occasionally with their tail. When fish are attracted by this, they swipe out with a paw, spearing the fish in their claws.

Next Topic: Snow leopard

ca:Viquijúnior:Grans felins/Jaguar Wikijunior Großkatzen/ Jaguar Wikichicos/Grandes felinos/Jaguar

title: Wikijunior:Big Cats/Jaguar


text:
Cookbook:Egg Separator

| Kitchen tools

An egg separator is a tool used to separate the yolk of an egg from the egg white.

Those not wishing to purchase a device to separate their eggs for them can simply crack the egg into their hand (fingers a very tiny distance apart) and allow the egg white to slide through their fingers while the yolk remains.

Separating eggs by passing them from one half of the shell to the other is more sanitary, but can cause a risk of the egg yolk from braking and shards of egg shell to end up in food.

title: Cookbook:Egg Separator


text:
User:Jun-Dai/Np/L1

= Lesson 1: Hiragana =

Overview
The Japanese written language, in its modern form, consists of:

 * かんじ (kanji, Chinese characters)
 * Two syllabaries, or alphabets:
 * ひらがな (hiragana) - the main syllabary
 * カタカナ (katakana) - the syllabary used for borrowed words, onomotopaeia, and emphasis.
 * Punctuation
 * Borrowed characters, such as Arabic numberals (e.g., 1, 7, or 0) or roman letters (e.g., a, b, c, etc.).

In order to learn Japanese, it is necessary to know the main Japanese syllabary, ひらがな (hiragana), so well that you never have to think about it. It consists of 46 basic letters, 20 voiced letters, 33 palatal letters, and the little-つ—100 letters in all. Just below is a chart of the 46 basic letters, with romanization. The chart should be read from right to left, in vertical columns (each of which should be read from top to bottom. Thus the first letter is あ and the last one is ん.

This chart is referred to, in Japanese, as 五十音図 (ごじゅうおんず, gojūonzu), which literally means "fifty-sounds chart" (why?). The first five letters are simply vowels, the next forty letters are consonant-vowel pairings, and the final letter, ん, is the one lone consonant in the Japanese language. The remainder of ひらがな can be illustrated in the next two charts of derived letters.

The column on the left are the half-voiced syllables. The remaining characters are the voiced syllables.

The left five columns on the palatal chart are also voiced/half-voiced syllables.

The last letter that should be mentioned is　っ, which is the little-つ. This is also known as 促音 (そくおん). Its effect is to double the length of the following consonant. きって, for example, is romanized as kitte. Without the っ, it would become きて, which is romanized as kite.

Now that we have the tools, let's discuss pronunciation before examining the ひらがな in detail.

Pronunciation (はつおん)
Pronunciation guide.

ひらがな, Column I: あ, い, う, え, お
illustrations, indicating how to draw each letter, and various representations of the letter (i.e., different styles of drawing them).

Vocabulary
Try to memorize all of the vocabulary in this section before continuing on in this book. Every chapter will assume that you know the vocabulary from all the previous chapters. Starting with chapter three, the vocabulary will be presented at the beginning of the chapter. As the first two chapters present the Japanese syllabaries, it is necessary to know the material in the chapter before being able to learn the vocabulary)

Beyond this chapter the following terms will be used without explanation. Additionally, you will be expected to use them in writing exercises.

 * 1) ひらがな - hiragana; the main Japanese syllabary
 * 2) はつおん - pronunciation
 * 3) etc.
 * 4) あじ - taste; flavor
 * 5) いろ - color
 * 6) and the rest of the words, which in combination must use all the hiragana letters.

title: User:Jun-Dai/Np/L1


text:
Cookbook:Grater

| Kitchen tools

A grater is a kitchen utensil that is usually made from metal (and sometimes ceramic or even wood), with sharp perforations or protrusions used to shred food. Graters come in various sizes: from those with larger perforations which are often used to shred cheese and vegetables, to the very fine graters and micro planes that can be used to zest citrus fruit. Micro planes are preferred by many for their efficiency in producing finely grated food. Fresh ginger or wasabi graters are usually made from porcelain or bamboo, and use spikes or ridges to tear those fibrous rhizomes (they are not clogged with fibres like conventional graters).

title: Cookbook:Grater


text:
Cookbook:Salad Spinner

| Kitchen tools

A salad spinner is a tool used for removing excess water from salad greens.

The greens are placed in a large strainer, which fits inside a slightly larger bowl. A lid, which contains a spinning mechanism, is placed on top. The spinning mechanism causes the inside strainer to spin rapidly and usually works by repeatedly pulling a cord or pushing a button on the lid. Centrifugal force removes the excess water from the greens in the central strainer, sending it into the outer bowl.

title: Cookbook:Salad Spinner


text:
Cookbook:Melon Baller

| Kitchen tools

A spoon-like tool with a small, deep bowl used to shape melons in balls.

title: Cookbook:Melon Baller


text:
User:Jun-Dai/Np/L2

= Lesseon 2: Katakana =

Overview
In addition to ひらがな, Japanese has a second syllabary, カタカナ (katakana), which is used for most がいらいご (borrowed words) and onomatopoeic or mimetic words, as well as for certain かんじ readings and as a form of emphasis (esp. in advertising and signage).

Every ひらがな letter has a カタカナ equivalent, and beyond that there are a number of additional カタカナ letters used to represent certain sounds that are not possible in traditional Japanese words. The three charts from the first lesson (ごじゅうおんず, だくおん+はんだくおん, and ようおん) are represented just below.

As you can see, some of the letters resemble their ひらがな counterparts. Most notably: カ, キ, ヘ, and リ.

Some additional letters that are used to represent sounds not included in the basic Japanese phonetic framework:

title: User:Jun-Dai/Np/L2


text:
User:Arky~enwikibooks

Currently working on Guide_to_UNIX_commands

Other interest include
 * Guide to UNIX

title: User:Arky~enwikibooks


text:
Guide to Unix/Commands/Getting Help

man
Displays the manual page for the specified command

A useful option is: $ man -k TEXT

This searches manual page titles and synopsis lines for TEXT

Examples:

To display the manual page for the chown command:

$ man chown

man has different sections.
 * section 1 is user commands
 * section 2 is system calls (used by programs to communicate with the kernel)
 * section 3 is library reference (for programming in C)
 * section 4 is device drivers
 * section 5 is configuration files and other file formats
 * section 6 is games
 * section 7 is miscellaneous (for example, "ascii" map and C "operator" precedence)
 * section 8 is system commands (like user commands, but mostly for root)

A section number can be specified before the page name. For example, man chmod normally shows the user command "chmod". To see the system call "chmod": $ man 2 chmod

To search the man pages for "newsgroups",

$ man -k newsgroups actsync             (8)  - synchronize newsgroupsoups newsgroups          (1)  - a program to list unsubscribed newsgroups

 * If this does not work you may have to run the makewhatis command.

Links:
 * man, opengroup.org
 * man man page, man.cat-v.org

info
An advanced man command that is sometimes available. It displays the improved manual pages in Info format for specified command. Seems absent from POSIX.

Examples:

To display the manual page for the grep command:

$ info grep

To find occurrence of 'grep' in all info manual pages:

$ info --apropos grep "(autoconf-2.13)Examining Declarations" -- EGREP_CPP "(autoconf-2.13)Examining Declarations" -- EGREP_HEADER "(autoconf-2.13)Old Macro Names" -- HEADER_EGREP ...

To see the physical location of 'grep' info manual page:

$ info -w grep /usr/share/info/grep.info.gz To view a file a info page:

$ info -f ./some_cmd.info.gz

Links:
 * info man pag, freebsd.org
 * info man page, manpages.ubuntu.com
 * Stand-alone GNU Info 6.2 - GNU manual, gnu.org

apropos
Searches the manual page short descriptions for a specified keyword. Seems absent from POSIX.

On many systems this is exactly the same as the -k option of the man command.

Examples:

$ apropos newsgroups active              (5)  - list of active Usenet newsgroups newsgroups          (1)  - a program to list unsubscribed newsgroups

Links:
 * apropos man page, freebsd.org

whatis
Displays short man page descriptions. Seems absent from POSIX.

Examples:

$ whatis info info (1)            - read Info documents info (5)            - readable online documentation

$ whatis chmod chmod (1) - change file modes chmod, fchmod (2) - change mode of file

Links:
 * whatis man page, freebsd.org

makewhatis
Creates the database for the whatis, apropos, and man -k commands. This is commonly run automatically by your system however sometimes you need to run this manually. Seems absent from POSIX.

Examples:

 * 1) makewhatis

$ sudo makewhatis

Links:
 * makewhatis man page, freebsd.org

title: Guide to Unix/Commands/Getting Help


text:
Guide to Unix/Commands/File System Utilities

ls
ls is a utility for listing the files in a directory.

Most used options are:
 * -a : all files (include files with . prefix)
 * -l : long detail (provide file statistics)
 * -t : order by creation time
 * -u : sort by access time (or show when last accessed together with -l)
 * -S : order by size
 * -r : reverse order
 * -F : mark directories with /, executables with *, symbolic links with @, local sockets with =, named pipes (FIFOs) with |

Other options include:
 * -Fx --color : color-coded listing
 * -s : show filesizes
 * -Z : show the file/directory with there SELinux context  ( only on SELinux enable tree)
 * -h : "human readble"; show filesizes in kilobytes and megabytes (-h can be used together with -l or -s)

ls *st* : list files that contain st in name ls > list : output list to file named "list" ls | more : fit listing to screen

Examples $ ls fish hello.txt

$ ls -l -rw-r--r--   1 username    groupname        0 Apr 11 00:09 fish -rw-r--r--   1 username    groupname       11 Apr 11 00:10 hello.txt

Several systems have an alias ll which does the same as ls -l: $ ll -rw-r--r--   1 username    groupname        0 Apr 11 00:09 fish -rw-r--r--   1 username    groupname       11 Apr 11 00:10 hello.txt

Be careful with the -F option. Here is one example: $ ls -F /usr/X11R6/bin/X* /usr/X11R6/bin/X@         /usr/X11R6/bin/Xnest*      /usr/X11R6/bin/Xprt* /usr/X11R6/bin/Xmark*     /usr/X11R6/bin/Xorg*       /usr/X11R6/bin/Xvfb*

We do not know yet if there is a symbolic link "X" and an executable "Xmark" or if "X@" and "Xmark*" are just the names of normal files. (Though "@" and "*" are not much found in filenames, they are possible.) So we check by dropping the -F: $ ls /usr/X11R6/bin/X* /usr/X11R6/bin/X          /usr/X11R6/bin/Xnest       /usr/X11R6/bin/Xprt /usr/X11R6/bin/Xmark      /usr/X11R6/bin/Xorg        /usr/X11R6/bin/Xvfb

Links:
 * ls, opengroup.org

mkdir
mkdir is a utility for creating a directory.

Examples $ mkdir newdirectoryname

The -p option also makes parent-directories as needed. Instead of: $ mkdir foo $ cd foo $ mkdir bar

you can just do: $ mkdir -p foo/bar

Links:
 * mkdir, opengroup.org
 * mkdir man page, man.cat-v.org
 * 12.3 mkdir in GNU Coreutils manual, gnu.org

cd
cd changes the current directory of the shell. This current directory will be used by other programs launched from the shell.

Because "cd" changes the state of the shell, it is a shell built-in command. In contrast, most commands are separate programs which the shell starts.

Examples

Change to 'foobar' directory: $ cd foobar

Change to your home directory, cd command used without an option will drop you back into your home directory.

$ cd

~ (tilde) stores the path to your home directory, this command has same effect as the previous one. $ cd ~

When suffixed with a username, the command will change into that particular user's home directory.

$ pwd / $ cd ~user $ pwd /home/user

Change to parent directory: $ cd ..

Change to the previous directory: $ cd -

Tips:

By setting "CDPATH" environment variable in your shell you can take advantage of shell command completion facility.

$ echo $CDPATH .:/usr/local:/usr/share/doc

If you have the $CDPATH set, then you press 'TAB' key and get possible path completions

$ cd bas [TAB] base-config/ base-files/   base-passwd/  bash/         bastille/

pwd
pwd (for Print Working Directory) shows the current directory that you are in.

Though "pwd" is often available as an external program (like /bin/pwd), many shells offer an equivalent version as a shell builtin command. Like any external command, "pwd" would inherit the current directory from the shell or other program that starts it.

Examples $ pwd /home/username

You can change the directory, you can also $ cd /usr $ pwd /usr

You can also use "pwd" in scripts. If you have enough experience with scripting, then you would know that the next line complains if the current directory is /home/username. $ test "x$(pwd)" = x/home/username || echo wrong directory

chroot
chroot changes the root filesystem. The "chroot" page at the Linux questions wiki explains why you might want to do this.

Examples

To change the root filesystem so /mnt/usbdrive/ becomes / and files outside of it cannot be seen:
 * 1) chroot /mnt/usbdrive/

You must be root user to "chroot". Other users would be able to use "chroot" to gain root (superuser) privileges, so their use of "chroot" is disallowed. $ chroot /mnt/usbdrive/ chroot: /mnt/usbdrive/: Operation not permitted

cp
cp copies a file

Most used options are:
 * -r : copies directories (recursively)
 * -p : preserves permissions, ownership, and timestamps
 * -i : prompt before overwrite
 * -v : verbose, show filenames as they are being copied

Examples Makes a copy of file 'debian' and call it 'Debian' (assuming 'Debian' is not already a directory) $ cp -i debian Debian

Makes a copy of file 'debian' and put it at /tmp/debian $ cp -i debian /tmp/debian

Same as the previous command (the filename defaults to be the same). $ cp -i debian /tmp

Makes a copy of directory 'mydir' (and all its contents) and put it at /tmp/mydir $ cp -ir mydir/ /tmp

Copy multiple files to directory /tmp $ cp -i foo bar baz /tmp

Links:
 * cp, opengroup.org
 * cp man page, man.cat-v.org
 * 11.1 cp in GNU Coreutils manual, gnu.org

mv
mv move and/or rename files

Examples Rename file 'unix' to 'Unix' (assuming "Unix" is not a directory) $ mv -i unix Unix

Move file Unix from your home directory to /tmp. $ mv -i ~/Unix /tmp/Unix

Same as the previous command (the filename defaults to be the same). $ mv -i ~/Unix /tmp

Move file Unix from your home directory to /tmp, and rename it to 'unix'. $ mv -i ~/Unix /tmp/unix

Move multiple files to directory /tmp $ mv -i foo bar baz /tmp

Links:
 * mv, opengroup.org
 * mv man page, man.cat-v.org
 * mv in GNU Coreutils manual, gnu.org

rm
rm deletes a file from the filesystem, like the "del" command in DOS.

The GNU long options (like --directory) are available on Linux, but not most other systems.

Some useful options are:
 * -d, --directory : unlink FILE, even if it is an empty directory (some systems let superuser unlink non-empty directories too)
 * -f, --force : ignore nonexistent files, never prompt
 * -i, --interactive : prompt before any removal
 * <tt>-P</tt> : (*BSD only) overwrite file before deletion
 * <tt>-r, -R, --recursive</tt> : remove the contents of directories recursively (the force option must often be used to successfully run rm recursively)
 * <tt>-v, --verbose</tt> : (GNU only) explain what is being done
 * <tt>--help</tt> : (GNU only) display help and exit
 * <tt>--version</tt> : (GNU only) output version information and exit

Examples:

The usage of "rm" is considered potentially more dangerous than equivalents in other operating systems because of the way the shell parses wildcards and names of special directories and in its non-verbose actions.

Here is a classic example. Instead of deleting files that end with <tt>.o</tt> ("*.o") it deletes all files in the directory ("*") and also a file called <tt>.o</tt>. There is an unwanted space between the asterisk and the period.

$ rm * .o rm: cannot remove `.o': No such file or directory

To remove a file whose name starts with a `-', for example `-foo', use one of these commands:

$ rm -- -foo

$ rm ./-foo

It might be useful to create an alias such as "remove" which moves the files to a local "trash" file so you can go there and recover files you accidentally "remove"d.

Secure deletion of files:

Note that  if  you  use rm to remove a file, it is usually possible to recover the contents of that file since <tt>rm</tt> does not remove it from the hard disk. It simply removes the file systems link to it.

On *BSD systems, the -P option overwrites the data with the file before removing it.

$ rm -P secretfile

However, as the NetBSD manual page explains it:

 * Recent research indicates that as many as 35 overwrite passes with carefully chosen data patterns may be necessary to actually prevent recovery of data from a magnetic disk. Thus the -P option is likely both insufficient for its design purpose and far too costly for default operation.

So while examining the data (using fsdb or making a disk image) will not reveal the secret data, other methods (such as laboratory examination of the disk) will reveal the data. In short, rm -P does not delete data securely. A program that attempts to delete data securely is GNU shred, available on Linux. But "shred" is not always successful in secure deletion; read its entry below.

rmdir
rmdir is a utility for deleting empty directories.

Examples $ rmdir directoryname

If the directory is not empty, the correct way to remove the directory and all its contents recursively is to use $ rm -r directoryname

Links:
 * rmdir, opengroup.org
 * rmdir man page, freebsd.org
 * 12.7 rmdir in GNU Coreutils manual, gnu.org

shred
shred overwrites a file multiple times with special data patterns to make the old contents of the file unrecoverable from a disk, especially a hard disk. This command is part of GNU coreutils, so it is often only available on Linux systems.

Note that this actually is ineffective on most filesystems because they can keep old copies of data. Most popular Linux filesystems (including ext3) keep such copies through journaling. However, "shred" is very useful for destroying the data on entire partitions or disks.

Some useful options are:
 * -u, --remove : unlink the file after removing it
 * -NUMBER, -n NUMBER, --iterations=NUMBER : the number of iterations of overwriting the file; default is 25 iterations

Examples: Remove and completely destroy <tt>secretfile</tt> from a filesystem that overwrites data in place and does not use journaling (for example, the UFS filesystem of *BSD). For the last step, after the data is destroyed, the "-u" option unlinks the file from the filesystem. $ shred -u secretfile

Note that if <tt>secretfile</tt> has multiple hard links (with ln for example), it will continue to exist with those other names, but will contain only random data.

touch
touch lets you change the date on a file. Can also be used to create a blank file.

Examples

This will change the access date and time of filename to the current time. If filename doesn't exist it will create a blank file. $ touch filename

Links:
 * touch, opengroup.org
 * touch man page, man.cat-v.org
 * 13.4 touch in GNU Coreutils manual, gnu.org

df
df reports the amount of free disk space available on each partition.

$ df Filesystem          1K-blocks      Used Available Use% Mounted on /dev/md0               5763508    207380   5263352   4% / /dev/md1             78819376  13722288  61093296  19% /home /dev/md4             23070564   4309572  17589056  20% /usr /dev/md2              5763508   1757404   3713328  33% /var /dev/md3              2877756    334740   2396832  13% /tmp

Reports disk usage in human readable format with block-sizes in Kilo,Mega,Gigabytes. $ df -h Filesystem           Size  Used Avail Use% Mounted on /dev/hda1             2.3G  2.1G  133M  95% / tmpfs                 61M  8.0K   61M   1% /dev/shm /dev/hda2            2.0G  1.8G  113M  94% /usr

Links:
 * df, opengroup.org
 * df man page, man.cat-v.org
 * 14.1 df in GNU Coreutils manual, gnu.org

du
Shows disk usage.

Links:
 * du, opengroup.org
 * du man page, man.cat-v.org
 * 14.2 du in GNU Coreutils manual, gnu.org

ln
ln creates links between files.

Symbolic links are special files that contain the absolute or relative path to a separate file. References to the symbolic link are "forwarded" to the file it (the symbolic link) points to. The file to which the reference is forwarded is not "aware" of the link; if the file pointed to is moved or deleted, the link will just point to nothing (no warnings are given, nor are any attempts made to "refresh" the link to the file's new location).

In Unix all information about files - owner, group, permissions, size, number of links, location on disk - are stored in the inode (with the notable exception of the filename). The filename is stored in directories, where inode-numbers (the way the OS refers to files) are paired with filenames (text-strings; the way the user refers to files). The "number of links" entry in the inode, keeps track of how many times the inode-number has thus been paired with a name in some directory.

When creating a (hard) link with <tt>ln</tt>, the "source" file is only used to determine the inode-number. A new inode-number-to-filename entry is then made in some directory using that inode-number, and the "number of links" counter is incremented. It's important that this (unlike a symbolic link) is the same file in every way... it's just that the file can be accessed by different names and/or from different locations. Moving or deleting the "original" source-file has no effect on the other links. Deleting one of the file's links only removes its entry from that directory... it's first when the last link in any directory is removed, that the file is actually deleted from the disk.

Hard links can not (unlike symbolic links) be used to refer to a file on another filesystem, nor can hard links usually be used to link to a directory.

Examples:

To make a soft (symbolic) link "hello" to the file "/home/alice/code/bin/world": $ ln -s /home/alice/code/bin/world hello

To make a (hard) link from the file "foo" to the file "bar":

$ ls -l total 1 -rw-r--r-- 1  rtm  users  50  Aug 15   foo $ ln foo bar $ ls -l total 2 -rw-r--r-- 2  rtm  users  50  Aug 15   foo -rw-r--r-- 2  rtm  users  50  Aug 15   bar

The 1st number of <tt>ls -l</tt>'s listing, shows the number of (hard) links a file has - in other words, the number of times it's been entered into some directory.

Links:
 * ln, opengroup.org
 * ln man page, man.cat-v.org
 * 12.2 ln in GNU Coreutils manual, gnu.org

chown
chown changes the owner and group of files. Normally, only root is allowed to do this, but if a user owns a file, then that user can change the group, but only to groups containing that user. On old systems, the ability of users to give files to other users caused abuses, so most systems prohibit non-root users from changing the owner of files.

Some useful options are:
 * -R : recursively change owner/group on an entire directory tree
 * -h : do not follow symbolic links i.e. changes owner of the link, not the target file
 * -f : indicate no errors if change failed

Examples:

Root changes the ownership of "/etc/passwd" and "/etc/shadow" to user root, group wheel:
 * 1) chown root:wheel /etc/passwd /etc/shadow

The same, but only changing the owner:
 * 1) chown root: /etc/{passwd,shadow}

The same, but only changing the group:
 * 1) chown :wheel /etc/{passwd,shadow}

Root gives every file in "/etc/ssh", including files in subdirectories, to user root, group wheel:
 * 1) chown -R root:wheel /etc/ssh

The same, but excluding files in directories (and the invisible files "/etc/ssh/.*" will also be missed):
 * 1) chown root:wheel /etc/ssh/*

User "tux" changes the directory "/usr/local/src/xc" from group "tux" to group "wheel". Tux is a member of both groups. $ ls -ld /usr/local/src/xc drwxr-xr-x 11 tux  tux  512 Sep 30 16:19 /usr/local/src/xc $ chown tux:wheel /usr/local/src/xc $ ls -ld /usr/local/src/xc drwxr-xr-x 11 tux  wheel  512 Sep 30 16:19 /usr/local/src/xc

chmod
chmod changes permissions of files. One must be familiar with Unix file permissions to understand this command. There are three permissions: read ("r"), write ("w"), and execute ("x"). There are three sets of permissions: for the owning user of the file ("u"), for the group of the file ("g"), and for other users ("o").

For a file, "execute" means to run it as a program. For a directory, "execute" permission is required to use anything in that directory tree, so doing anything with "/usr/share/doc/README" requires execute permissions on all of "/", "/usr", "/usr/share", and "/usr/share/doc".

If you are interested in more advanced topics like the set-uid, set-gid, sticky bits and octal numbers, try reading the FreeBSD manual page at http://www.FreeBSD.org/cgi/man.cgi (type "chmod" in the form and submit).

A useful option is:
 * -R : recursively change or set permissions on an entire directory tree

Examples:

We wrote a shell script called "configure". We make it executable ("+x") and then execute it as a command. Usually, "+x" is the same as "u+x" or "ug+x", depending on the status of the file mode creation mask. $ chmod +x configure $ ./configure

Allow the owning user to run "configure": $ chmod u+x configure

Deny the group and other users from running "configure": $ chmod go-x configure

For all users except the owner ("go"), disable all access to "~/mail" and "~/private" ("-rwx"). This way, the contents are private and only their owner (or root) can access them. $ chmod go-rwx ~/mail ~/private

Note that in the previous example, "-R" was not specified. By disabling the execute bit ("-x"), all files inside <tt>~/{mail,private}</tt> are protected even if their group and other read bits are enabled. Thus, simply moving some file from inside <tt>~/{mail,private}</tt> to some public place like <tt>/tmp</tt> can make the files available to other users again.

The "root" user wants to set up <tt>/usr/local/src</tt> so that all users in group "wsrc" (including "tux") can create files there. Root will continue to own the directory. This is done by changing the group of <tt>/usr/local/src</tt> to "wsrc" and then by granting to the group ("g") the read, write, and execute permissions ("+rwx").
 * 1) chown :wsrc /usr/local/src
 * 2) chmod g+rwx /usr/local/src

All Unix-like systems should allow all users to create temporary files in "/tmp" and "/var/tmp". Thus root gives everyone ("a", short for "ugo") all permissions ("+rwx") on the files.
 * 1) chmod a+rwx /tmp /var/tmp

The problem with the above is that because all users have write access to /tmp and /var/tmp, every user can delete and rename files, even ones not created by them. For example, "tux" could create "/tmp/socket.3908" and another user could delete it or rename it to "/tmp/garbage", thus annoying Tux. To keep temporary files safe, we use the sticky bit called "t". This limits the deletion and renaming of files in /tmp to root, the owner of /tmp (also root), and the owner of the file (Tux for "/tmp/socket.3908"). It does the same for /var/tmp. So what we should do is:
 * 1) chmod a+rwxt /tmp /var/tmp

chgrp
Changes the group ownership of files.

Links:
 * chgrp in The Open Group Base Specifications Issue 7, pubs.opengroup.org
 * 13.2 chgrp: Change group ownership in GNU Coreutils at gnu.org
 * Chgrp

link
Makes a hardlink. See also ln.

Links:
 * link, opengroup.org
 * link man page, man.cat-v.org
 * link, freebsd.org
 * link in GNU Coreutils, gnu.org

unlink
Deletes a file.

Links:
 * unlink, opengroup.org
 * unlink, freebsd.org
 * unlink in GNU Coreutils, gnu.org


text:
Guide to Unix/Commands/Finding Files

find
Searches a given path for a file or folder. The syntax is: find [path...] [expression...]

Examples: On some of the latest Unix-like OS's, the -print option is a default and can be omitted. The following command searches for the file 'grub.conf' starting at the root ('/') directory. $ find / -name grub.conf /etc/grub.conf

If you are not the administrator of the computer, you get error messages for all the directories you are not allowed to read. In this case do it like this for a bash shell:

$ find / -name grub.conf 2>/dev/null /etc/grub.conf

Or like this for a csh/tcsh:

$ find / -name grub.conf >& /dev/null /etc/grub.conf

If you want to ignore the case of the characters, you can use -iname. The following will find files with extensions txt, TXT, Txt, and so on:

$ find / -iname '*.txt'  /home/rtm/hacking.txt /home/bok/Documents/MyLetter.TXT /home/bok/tmp/found.tXt

The following command will search for all directories named 'local'.

$ find / -name local -type d /usr/X11R6/lib/X11/fonts/local /usr/local /var/cache/man/local /var/local

The above example combined two tests - filename (-name) and filetype (-type) - and returned files satisfying both (logical AND).

It's also possible to specify two or more tests, and return files satisfying any of them, with the -o (logical OR) directive. The tests to be ORed must be grouped together between (...) (which must be escaped with \ as parentheses are special to the shell). The following return files with the extensions txt or doc, as well as any file larger than 5MB (megabyte) in size.

$ find / \( -name '*.txt' -o -name '*.doc' -o -size +5M \) /home/rtm/hacking.txt /home/bok/report.doc /home/bok/backup/may.tar.bz2 /home/koppe/BiggerThan5Megs.doc

Where the last file satisfied two tests.

Note: Each directive must be complete, tests cannot be omitted. E.g. -name '*.txt' -o '*.doc'  (omitting the 2nd -name) is not valid.

Tips: Using 'exec' option executes certain commands for each file found by find:

$ '''find. -name '*bak' -exec rm -i {} \;''' rm: remove regular empty file `./file1.bak'? y rm: remove regular empty file `./file2.bak'? y rm: remove regular empty file `./file3.bak'? y

Using 'ok' has same effect but it will prompt for every file: $ '''find. -name '*~' -ok rm {} \;''' < rm ... ./RMAIL~ > ? y

Warning : When using "-exec" or "-ok", a semicolon must be used to indicate the end of the arguments (to "rm" in the example). Because semicolon is special to the shell, it must be quoted. The above examples quote the semicolon with a backslash.

Links:
 * find, opengroup.org
 * find man page, man.cat-v.org
 * Finding Files, gnu.org

whereis
Searches the normal executable and man page locations for a specified file. Does not seem covered by POSIX.

Examples:

$ whereis ls ls: /bin/ls /usr/bin/ls /usr/man/man1/ls.1.gz /usr/share/man/man1/ls.1.gz

Links:
 * whereis man page, man7.org
 * whereis man page, freebsd.org

which
Searches the locations in your PATH variable for a specified file. If you know a program is in your path (i.e. you can run it) this is faster than whereis. $ which pine /usr/bin/pine

Links:
 * GNU which project, savannah.gnu.org
 * which man page, freebsd.org

locate
Finds all filenames that match the specified query. Absent from traditional UNIX, is GNU software and comes standard with Linux.

Examples: $ locate make.conf /etc/make.conf /etc/make.conf.orig /etc/make.conf.example /usr/qt/3/mkspecs/linux-g++/qmake.conf /usr/share/man/man5/make.conf.5.gz

Note that locate uses a database of already collected filenames, that is typically updated once every 24 hours. As such, using locate will not correctly show newly created or deleted files/directories.

Links:
 * 8.2 Invoking locate in GNU Findutils manual, gnu.org
 * locate man page, freebsd.org

xargs
Turns items in its input stream into arguments of another command to invoke. One common use is in conjunction with find.

Examples:
 * echo a b c | xargs -n1 echo
 * Outputs a, b, and c, each one on a separate line; -n1 specifies that at most 1 input item should be passed to the command at a time.
 * echo a,b,c | xargs -d, -n1 echo
 * In certain versions of GNU xargs, outputs a, b, and c, each one on a separate line. -d specifies the item delimiter.

Links:
 * xargs, opengroup.org
 * xargs, freebsd.org
 * 8.4 Invoking xargs in GNU Findutils manual, gnu.org
 * xargs source code, git.savannah.gnu.org
 * xargs

title: Guide to Unix/Commands/Finding Files


text:
Guide to Unix/Commands/Devices

fuser
fuser tells you what process is using an indicated filesystem object (ordinary file, device, etc.) $ fuser /dev/dsp /dev/dsp:            8369

Links:
 * fuser, opengroup.org
 * fuser, freebsd.org
 * fuser, manpages.ubuntu.com

lsof
lsof lists all open files,is more detailed than fuser.

Example:

$ lsof /dev/dsp COMMAND PID USER   FD   TYPE DEVICE SIZE NODE NAME mplayer 8406 alex   7w   CHR   14,3       389 /dev/sound/dsp

Tips:

Using -i 4 option will report all programs currently using IPv4 network, it is useful for watching the programs accessing the network and Internet resources.

$ lsof -i 4 COMMAND   PID   USER   FD   TYPE DEVICE SIZE NODE NAME btdownloa 2618 arky   3u  IPv4   9524       TCP *:6886 (LISTEN) btdownloa 2618 arky   6u  IPv4   9544       TCP  dsl-KK-229.53.101.203.ttel.net:1539->cpc1-leed3-3-0-cust10.ldst.cable.ntl.com:59074 (ESTABLISHED)

Links:
 * lsof, freebsd.org
 * lsof, manpages.ubuntu.com

fstat
fstat lists all open files.

The previous two commands (fuser and lsof) do not exist on all systems. The 4.3BSD-Tahoe system introduced the "fstat" command that is found on many *BSD systems. Unlike the previous two commands, it seems not to know the exact path of each file, but only what filesystem it is on?

Some options are: -p PROCESSID show open files of this process -u USERNAME  show open files of this user

Examples: Lists every open file by every user, including root! Pipe it into a pager. $ fstat | less

Get the process ID of the running Bourne shell and then list the files it opened. $ echo $$ 5283 $ fstat -p 5283 USER    CMD          PID   FD MOUNT      INUM MODE       R/W    DV|SZ ...

The init process always has ID of 1. List its open files. In this example it only opened one file somewhere on the / filesystem. $ fstat -v -p 1 USER    CMD          PID   FD MOUNT      INUM MODE       R/W    DV|SZ root    init           1   wd /             2 drwxr-xr-x   r      512

Links:
 * fstat, freebsd.org

title: Guide to Unix/Commands/Devices


text:
Guide to Unix/Commands/File Viewing

cat
cat displays the contents of a file to screen. It can also display multiple files concatenated together, and using the shell, its standard output can be redirected from the screen to the file.

Some useful options are: -n line numbering -s squeeze sequences of blank lines into one -v show non-printing characters

Examples $ cat example.txt The contents of the file example.txt are now displayed.

$ cat -n example.txt 1 The contents of the file 2 example.txt are now 3 displayed.

Concatenating multiple files (in this example, the same file twice): $ cat example.txt example.txt The contents of the file example.txt are now displayed. The contents of the file example.txt are now displayed.

Concatenate the files, but use the shell to redirect the result to a new file. $ cat example.txt example.txt > double.txt

We can concatenate binary files, too. Some programs limit downloads to 2 GB; this is bad for larger files like some DVD images. Suppose a web site helpfully divides the file "sodalinux.dvd" into three parts, 2 GB or less, for downloading and later concatentation. We combine the files, and use the > shell redirection output to put the DVD image in a file: $ cat sodalinux.dvd1 sodalinux.dvd2 sodalinux.dvd3 > sodalinux.dvd

If we want to type less, then most shells also allow this: $ cat sodalinux.dvd{1,2,3} > sodalinux.dvd

The -v option is useful for viewing control characters embedded mostly in text. In this example, the file "/usr/share/man/cat1/pax.0" is mostly text but contains control characters which the pagers "less" and "more" use to make text bold. Using cat -v we can see the control characters. Here are the first four lines: $ cat -v /usr/share/man/cat1/pax.0 | head -4 PAX(1)                    OpenBSD Reference Manual                     PAX(1) N^HNA^HAM^HME^HE p^Hpa^Hax^Hx - read and write file archives and copy directory hierarchies

Using "cat" with no arguments makes it copy standard input to standard output. Combined with shell redirection, this makes it easy to write a very short text file. All one needs to know is to press Control-D (^D) to indicate end of input, finish the file, and return to the shell. Here is how to write "example.txt": $ cat > example.txt The contents of the file example.txt are now displayed. ^D $

If you put "cat" with no arguments in a pipe, it only copies standard input to standard output. This might seem useless. For example, the following two pipes have the same function: $ dmesg | less $ dmesg | cat | less

However, "cat" can be used as insulation to make programs think that they are not running on terminals. In the next example, GNU bc does not print its copyright message on startup. We enter one calculation ("3 + 9") and then quit (^D): $ bc | cat 3 + 9 12 ^D

Links:
 * cat, opengroup.org
 * cat man page, man.cat-v.org
 * 3.1 cat in GNU Coreutils manual, gnu.org

tac
tac (cat spelled backwards) works like cat, but reverse the order of the lines (last line is written out first). It does not seem to be part of traditional Unix. When multiple files are given, they are printed out in the order they appear.

$ tac foo Third Line Second Line First Line

Links:
 * 3.2 tac: Concatenate and write files in reverse in GNU Coreutils manual, gnu.org

more
more paginates output. The problem with "cat" is that if a file is too long, then it falls beyond the top of the screen. The job of "more" is to stop and wait when it fills the screen. Most users find it easier to use "less", but on some systems "more" has all of the features of "less".

Keys:
 * return read next line
 * space bar read next screen
 * q quit

Examples: The pager will act like "cat" if the file is short enough. $ more hello.txt Hello World

Links:
 * more, opengroup.org

less
less paginates output. The program is called "less" because of the joke that "less is more", "less" actually has several features which "more" lacks.

Keys:
 * h read help. You might forget the other commands, but remember this one!
 * j go down one line. The down-arrow key might also work.
 * k go up one line. The up-arrow key might also work.
 * d go down one-half screen.
 * u go up one-half screen.
 * f go forward one screen.
 * b go back one screen.
 * p return to the top of the file.
 * q quit the pager.

Number arguments:
 * 0 through 9: type a number. The number will be used as the argument N to the next command.
 * j go down N lines.
 * k go up N lines.
 * p jump to the N% position, where 0% is the first line and 100% the last line of the file.

Examples:

Read some file: $ less example.txt

Pipe "dmesg" into "less" so that the dmesg does not scroll off the screen: $ dmesg | less

Links:
 * less home page, greenwoodsoftware.com
 * less(1) OS X Manual Page at developer.apple.com
 * less man page, freebsd.org
 * GNU less pages at gnu.org; no user manual apparent
 * less (Unix)

od
Lets you view binary files by outputting octal representation, hexadecimal representation and more. See also Od.

Examples:

View a file in octal format:

$ od wordlist.dat 0000000 064506 071562 006564 051412 061545 067157 006544 040412 0000020 070160 062554 005015 072522 061155 062554 005015 061501

View a file in hex format:

$ od -x wordlist.dat 0000000 6946 7372 0d74 530a 6365 6e6f 0d64 410a 0000020 7070 656c 0a0d 7552 626d 656c 0a0d 6341

View a file in character format:

$ od -c wordlist.dat 0000000  F   i   r   s   t  \r  \n   S   e   c   o   n   d  \r  \n   A 0000020   p   p   l   e  \r  \n   R   u   m   b   l   e  \r  \n

Links:
 * od, opengroup.org
 * od man page, man.cat-v.org
 * 3.4 od in GNU Coreutils manual, gnu.org

head
Outputs 10 lines or other count of lines from the head (top) of a file, files or standard input. See also tail, outputting last lines.

Examples:
 * head wordlist.dat
 * Outputs first 10 lines of the file.
 * head -n 2 wordlist.dat
 * Outputs first 2 lines of the file.
 * head -2 wordlist.dat
 * Outputs first 2 lines of the file. A legacy option no longer supported by POSIX, still supported by GNU head.
 * seq 10 | head -n -2
 * In GNU head, outputs all but the last 2 lines of the input stream, in this case of 1 ... 10. A GNU extension not supported by POSIX.
 * seq 10 | sed 2q
 * A sed alternative that avoids head, outputting the first two lines.

Links:
 * head, opengroup.org
 * 5.1 head in GNU Coreutils manual, gnu.org
 * head, freebsd.org
 * , wikipedia.org

hexdump
Hexdump is a command-line tool used to show the raw bytes of a file in various ways including hexadecimal, available on Linux, FreeBDS, OS X, and other platforms. Hexdump is not part of traditional Unix systems or GNU commands, and does not seem to be covered by POSIX. A similar tool is (POSIX covered) and.

Examples of hexdump use:
 * hexdump myfile
 * Outputs hexadecimal of the file content, with no ASCII. Seems to default to outputting 16-bit chunks separated by space, 16 bytes per line.
 * hexdump -C myfile
 * Outputs bytes in hexadecimal, each byte separated by a space, together with ASCII at a right column.
 * hexdump -v -e '"" 1/1 "%02X" " "' myfile
 * Outputs the bytes in hexadecimal using capitalized letters, each byte separated by a space. The first "" specifies and empty prefix, while the last " " specifies a single-space suffix.

Links:
 * hexdump, man7.org - from util-linux
 * hexdump at freebsd.org
 * hexdump, opensource.apple.com
 * , wikipedia.org

xxd
Outputs hexadecimal content of a file or standard input, or creates a file based on a hex dump. Not covered by POSIX and not part of GNU tools; seems to be part of Vim project, distributed with it.

Examples:
 * xxd myfile
 * Outputs hexadecimal output together with ASCII at a right column; the default seems to be to output 16-bit space-separated chunks. Does not seem to respect the endianness of the platform in these 16-bit chunks.
 * xxd -g 1 myfile
 * As above but separating each byte by a space.
 * xxd -b myfile.
 * Outputs binary output.

Links:
 * xxd, linux.die.net
 * xxd at freebsd.org
 * , wikipedia.org
 * xxd.c in vim, github.com

tail
Outputs last 10 lines or other specified number of lines or bytes of the file, files or standard input. Its counterpart is. Whether POSIX allows multiple input files is unclear.

Examples:
 * tail wordlist.dat
 * Outputs last 10 lines.
 * tail -n 2 wordlist.dat
 * Outputs last 2 lines.
 * tail -2 wordlist.dat
 * Outputs last 2 lines. A legacy option no longer supported by POSIX, still supported by GNU tail.
 * printf hello | tail -c 2
 * Outputs two last bytes/characters of the input, and thus, "lo".
 * tail file1.txt file2.txt
 * In GNU tail, processes multiple files, introducing the output for each file with a header.

The -f option displays the tail, then waits for and displays any new options to the file. This is normally used to watch log files. (The next example has only three lines from tail, but the 80-column terminal was too narrow, so the lines were broken into five lines.) $ tail -f /var/log/messages Apr 14 00:05:33 redserver sshd[1575]: Accepted password for rumbear from 24.52.1 45.23 port 33372 ssh2 Apr 14 00:05:34 redserver sshd[1594]: subsystem request for sftp Apr 14 00:06:35 redserver sshd[1594]: Received disconnect from 242.122.35.47: 11 : Disconnect requested by Windows SSH Client.

Links:
 * tail, opengroup.org
 * tail man page, man.cat-v.org
 * 5.2 tail in GNU Coreutils manual, gnu.org
 * tail, freebsd.org
 * , wikipedia.org

title: Guide to Unix/Commands/File Viewing


text:
Use the Source/I have to give you what

Many people in this day and age still don't know much about the way that copyright works, so I will attempt to sum it up in as plain and concise a manner as possible. When a work is made it is under the control of whoever made it, this work is exclusive to the creator and they are the only person with the right to copy it and unless permission is explicitly given no one has the right to copy or show the work at all for any reason.

If a person says that their work is licensed under the terms of the BSD license this is not enough to actually give permission to a person to use that work as though it were licensed BSD - the person licensing it must have the license accompanying the work, be it in another file or on another page at the same website. Unless the work directly points to a copy of the license, there is no license, and the work is therefore not permitted to be copied.

Here is a list of several open source licenses approved by the Open Source Initiative, I have listed them from least to most open (most to least restrictive):

 * The Bell Labs LPL (Lucent Public License) which is used for the release of Plan 9 restricts redistribution to countries which the United States holds sanctions against; this is viewed in a very negative light by many around the world because these people feel that politics and coding should not mix.
 * The Sun CDDL (Common Development and Distribution License), which will cover the open source release of Solaris, restricts one's ability to hold and maintain their own patents; this clause set is a matter of debate in online communities as on one hand it helps to prevent a company maliciously adding patented technology into software and suing users and distributors that make use of said software, on the other hand it is another restriction for what some view as no reason - it is implied by submitting code that you release your claim over any technologies involved. If any entity that uses works licensed under the CDDL does sue entity that contributes to any project licensed under the CDDL, that license is automatically revoked as well.   These patent and revocation clauses are basically the only differences between the CDDL and the MPL.
 * The Mozilla MPL (Mozilla Public License)
 * The GNU GPL (General Public License) in a nutshell says that anything you distribute with GPL code must come with the code available as well and that you cannot make the code you release harder to read. This is the basic "viral license"; once applied to code it cannot be relicensed without the permission of all contributors, thus it is viewed with great distaste by companies which are looking to make an easy profit.
 * The GNU LGPL (Lesser General Public License)
 * The Original BSD (Berkeley Software Distribution) license allows for complete usage of any code for any purpose under the conditions that proper credit is given, the license remains intact in any binary derivatives, any advertisements for derived works must list that the work contains code from the University of California, Berkeley and its contributors and that the names of contributors and the University can not be used to promote the derived work without written permission. Pretty straight forward, no?
 * The Modern BSD license dropped the condition of listing the university in advertisements; this was in part due to the number of various BSD-like licenses that were beginning to be used, they were beginning to fill up a fair amount of space in any advertisements which used multiple sources of code.
 * The ISC (Internet Systems Consortium) license is basically a two-part BSD-styled license which removes the fourth term where the names of contributors and copyright holders cannot have their name used in promotions without prior written consent. This is because in 1971 the Berne convention set down this term as standard for all copyrighted works.

There is another option beyond licensing a work, the creator may state that the work in question is released to the public domain, which is the property of anyone that wants to use it and there are no restrictions what so ever on the work; there is no further need for permissions, no credit need be given, it is no longer the property of the creator alone. This does not, however, function globally, though this anti-licence is accepted within some nations, others do not allow for the release of property in this manner, and thus a content creator must create a licence that recreates the terms of the public domain and release their source code under it.

title: Use the Source/I have to give you what


text:
Guide to Unix/Commands/File Analysing

file
file displays the file type. To get the mimetype, use the -i option.

Examples

$ file Unix.txt Unix.txt: ASCII text

$ file -i Unix.txt Unix.txt: text/plain; charset=us-ascii

Links:
 * file, opengroup.org
 * file man page, man.cat-v.org

wc
wc tells you the number of lines, words and characters in a file.

Examples: $ wc hello.txt 2      6      29 hello.txt

$ wc -l hello.txt 2 hello.txt

$ wc -w hello.txt 6 hello.txt

$ wc -c hello.txt 29 hello.txt

Links:
 * wc, opengroup.org
 * wc man page, man.cat-v.org
 * 6.1 wc in GNU Coreutils manual, gnu.org

cksum
Outputs a particular variant of 32-bit cyclic redundancy check (CRC) checksum of a file, files or standard input, together with sizes; in latest GNU Coreutils and some other implementations, it can output other checksums via -a option. This variant of 32-bit CRC is different from the CRC-32 used by zip, PNG and zlib; for one thing, cksum calculates the CRC not only from the octet stream of the file or input but rather from the stream to which the stream length has been appended.

The CRC output by cksum can be used to protect against accidental modifications to files: if the checksum has not changed, the file is very likely undamaged. The default CRC checksum is not cryptographic: it protects only against modifications that are not malicious (intentional).

Latest GNU Coreutils cksum allows a choice from multiple different kinds of checksums, including cryptographic ones, via -a option. These include sysv, bsd, crc, md5, sha1, sha224, sha256, sha384, sha512, blake2b, and sm3. None of the checksums is the CRC-32 of zip, PNG and zlib. OpenBSD cksum provides -a option as well, while the list of algorithms differs slightly. FreeBSD cksum allows a choice of one of three checksum algorithms in addition to the default one via -o1, -o2 and -o3 options; -o3 is the CRC-32 of zip, PNG and zlib; this applies to macOS as well.

Examples: $ cksum /etc/passwd 3052342160 2119 /etc/passwd

Some "cksum" implementations provide other algorithms, such as "md5" and "sha1": $ cksum -a sha1 /etc/passwd SHA1 (/etc/passwd) = 816d937ca4cdb4dee92d5002610fae63b639d224

You can test "cksum" by feeding it a string via standard input: $ printf 'Guide to UNIX'|cksum 2195826759 13

Links:
 * cksum, opengroup.org
 * sum man page, man.cat-v.org
 * cksum, freebsd.org
 * 6.3 cksum in GNU Coreutils manual, gnu.org
 * cksum, openbsd.org
 * , wikipedia.org
 * Catalogue of parametrised CRC algorithms, reveng.sourceforge.io
 * cksum.c in coreutils, github.com
 * cksum folder in file_cmds-188, opensource.apple.com

sum
A legacy tool, outputs a certain kind of checksum of a file, files or standard input, together with sizes. Is not covered by POSIX; POSIX codified as a replacement tool instead, using a kind of checksum different from those used by legacy sum. Different variants of legacy sum used different algorithms. The legacy algorithms used by variants of sum are provided by the FreeBSD cksum via -o1 and -o2 options, and by latests GNU Coreutils cksum via -a option.

GNU Coreutils sum allows choice of legacy algorithm via -r and -s options.

The two commonly used legacy algorithms are as follows.

The BSD sum, -r in GNU sum:
 * Initialize checksum to 0
 * For each byte of the input stream
 * Perform 16-bit bitwise right rotation by 1 bit on the checksum
 * Add the byte to the checksum, and apply modulo 2 ^ 16 to the result, thereby keeping it within 16 bits
 * The result is a 16-bit checksum

The System V sum, -s in GNU sum:
 * checksum0 = sum of all bytes of the input stream modulo 2 ^ 32
 * checksum1 = checksum0 modulo 2 ^ 16 + checksum0 / 2 ^ 16;
 * checksum = checksum1 modulo 2 ^16 + checksum1 / 2 ^ 16;
 * The result is a 16-bit checksum calculated from the initial 32-bit plain byte sum

Links:
 * cksum, opengroup.org
 * sum man page, man.cat-v.org
 * cksum, freebsd.org
 * 6.2 sum in GNU Coreutils manual, gnu.org
 * , wikipedia.org
 * sum.c in coreutils, github.com
 * sum1.c in freebsd-src, github.com
 * sum2.c in freebsd-src, github.com
 * sum.c in Seventh Edition Unix, tuhs.org

stat
Outputs file or file system status, including size, access rights, creation and modification times and more. The command seems absent from POSIX; POSIX only specifies system call stat.

Links:
 * stat, man7.org
 * stat, freebsd.org
 * stat in GNU Coreutils manual, gnu.org

grep
Outputs lines matching a regular expression, not matching it, and similar, depending on options and the regular expression used. See Grep Wikibook.

Links:
 * grep, opengroup.org
 * grep man page, man.cat-v.org
 * grep, freebsd.org
 * GNU Grep 3.0, gnu.org

diff
Compares file content of two files line by line and outputs differences. See also diff3.

Links:
 * diff, opengroup.org
 * diff man page, man.cat-v.org
 * diff, freebsd.org
 * Comparing and Merging Files, gnu.org

diff3
Compares file content of three files line by line and outputs differences. See also diff.

Links:
 * diff3 man page, man.cat-v.org
 * diff3, freebsd.org
 * Comparing and Merging Files, gnu.org

cmp
Compares files byte by byte, outputting the byte number and the line number where a first difference is found, if any. Outputs nothing if the files are binary identical. No indication is made of the further differences beyond the first one unless option -l is used.

Links:
 * cmp, opengroup.org
 * cmp man page, man.cat-v.org
 * cmp, freebsd.org
 * Invoking cmp in Comparing and Merging Files, gnu.org

strings
Outputs printable strings found in files, useful when these files are binary.

Links:
 * strings, opengroup.org
 * strings, freebsd.org
 * strings in GNU Binary Utilities, sourceware.org
 * strings (Unix)

title: Guide to Unix/Commands/File Analysing


text:
Guide to Unix/Commands/Multiuser Commands

who
who gives information about the users logged into the machine. The information includes the user's terminal, login date ,login time and the location they are connecting from.

Examples:

$ who alice   pts/0        Mar 23 08:05 (213.23.423.24) bob     pts/2        Apr 10 22:06 (domain.aol.com) carol   pts/3        Apr 10 18:34 (space.com)

The option "-w" shows wheter or not a user's tty is accessible with commands like write or talk. + indicates that the tty is accessible, and - that it's not:

$ who -w root    - tty3         Jan 19 02:26 koppe   - tty4         Jan 19 17:10 bok     + pts/1        Jan 19 23:03

Using "who" with two non-option words gives your username. On some systems, this gives your actual username, and using "su" or "sudo" to switch user does not change this name. $ who am i puffy

On other systems, this gives more information: $ who am i puffy   ttyp2    Oct 27 10:08

Links:
 * who, opengroup.org
 * who man page, man.cat-v.org
 * 20.6 who in GNU Coreutils manual, gnu.org

finger
finger finds out information about a user. If the user has created a .plan (several lines) and/or a .project (one line) file in their home directory this will also be displayed.

Examples:

$ finger alice Login: alice                   Name: Alice Makemerry Directory: /home/alice         Shell: /bin/bash On since Sat Apr 10 18:34 (BST) on pts/3 from ip.fakedomain.com 1 hour 25 minutes idle Mail last read Sat Apr 10 23:57 2004 (BST) No Plan.

Links:
 * finger, freebsd.org
 * GNU Finger, a manual, gnu.org

su
su switch user

Examples:

Become another user: user> su bob Password: bob>

Become root... then become another user:

user> su Password: root# root# su bob bob> (Note: root is not asked for password to become bob!)

Switching user and using the new user's environment (shell, shell-variables, home-directory) as if after a normal log-in:

user> su - bob Password: bob$

Run a program as another user (as root unless otherwise specified):

user> su -c 'apt-get update'  Password:

Note: The permission and owner/group of su - as well as other config-files (typically /etc/su and /etc/login.defs) - may prevent users not belonging to certain groups from switching user even with the correct password, or even being able to execute su at all (E.g. in BSD it's traditionally been restricted to members of the wheel-group only).

Links:
 * C.4 Utilities, opengroup.org
 * su man page, man.cat-v.org
 * su, freebsd.org
 * 22.5 su, a manual for old coreutils, ftp.gnu.org


text:
Guide to Unix/Commands/Self Information

whoami
whoami tells you your current username.

Examples: $ whoami abicool

Links:
 * whoami, freebsd.org
 * 20.3 whoami in GNU Coreutils manual, gnu.org

groups
groups states the groups the current user is a member of

Examples:

$ groups wheel slocate www

Links:
 * groups, freebsd.org
 * 20.4 groups in GNU Coreutils manual, gnu.org

id
id gives you the same information as the whoami and groups commands, but also includes the user id (uid) and group id (gid) integers associated with the login.

Examples:

$ id uid=3426(alice) gid=10(wheel) groups=10(wheel),21(slocate),401(www)

Links:
 * id, opengroup.org
 * 20.1 id in GNU Coreutils manual, gnu.org

tty
tty tells you the terminal device that is assigned to your interactive login. The tty represents your console device, network connection ("ssh", ...), or terminal emulator process ("xterm", "konsole", ...).

Examples:

$ tty /dev/pts/14

Links:
 * tty, opengroup.org
 * tty man page, man.cat-v.org
 * 19.4 tty in GNU Coreutils manual, gnu.org

title: Guide to Unix/Commands/Self Information


text:
Guide to Unix/Commands/System Information

uptime
uptime tells you how long the computer has been running since its last reboot or power-off.

Example:

$ uptime 22:27:49 up 10:14, 2 users,  load average: 0.03, 0.32, 0.28

Links:
 * uptime, freebsd.org
 * 21.7 uptime in GNU Coreutils manual, gnu.org

uname
uname displays the system information such as hardware platform,system name and processor, Operating System type.

Example: $ uname -a Linux DarkBox 2.4.27-1-k6 #1 Wed Apr 14 19:00:29 UTC 2004 i586 GNU/Linux

Links:
 * uname, opengroup.org
 * uname, freebsd.org
 * 21.4 uname in GNU Coreutils manual, gnu.org

dmesg
dmesg display the messages from the kernel, since boot. Example:

$ dmesg

Tips:

While a UNIX system is booting, usually a lot of messages flash on the console screen in rapid succession; to view those messages after the system is booted, use the following command:

$ dmesg | less

Using a command option, dmesg can filter the kernel messages, based on priority. The '-n 1' arguments will display only the panic messages:

$ dmesg -n 1

Links:
 * dmesg, freebsd.org
 * dmesg, manpages.ubuntu.com

free
free display used and free memory

Example:

$ free total      used       free     shared    buffers     cached Mem:       123260     119540       3720          0       8752      58096 -/+ buffers/cache:     52692      70568 Swap:      369452      63212     306240

Display in human readable form using MegaByte block sizes:

$ free -m total      used       free     shared    buffers     cached Mem:          120        116          3          0          8         56 -/+ buffers/cache:        51         68 Swap:         360         61        299

Tips: Display system memory usage every 5 seconds, use Ctl+c to exit: $ free -m -s 5 total      used       free     shared    buffers     cached Mem:          120        116          3          0          8         56 -/+ buffers/cache:        51         68 Swap:         360         61        299

total      used       free     shared    buffers     cached Mem:          120        116          3          0          8         55 -/+ buffers/cache:        52         68 Swap:         360         61        299

Links:
 * free, manpages.ubuntu.com

vmstat
vmstat displays a compact summary of overall system activity (processes, memory, and cpu information).

Example: $ vmstat procs ---memory-- ---swap-- -io --system-- cpu r b   swpd   free   buff  cache   si   so    bi    bo   in    cs us sy id wa  2  0  63108   4484   7432  56480    8   11    93    45 1110   622 41 11 48  0

Tips: Print out vmstat summaries every two seconds, for five iterations.

$ vmstat -n 2 5 procs ---memory-- ---swap-- -io --system-- cpu r b   swpd   free   buff  cache   si   so    bi    bo   in    cs us sy id wa  1  0  63100   5172   7440  55892    8   10    90    44 1110   622 41 10 49  0 2 0  63100   5168   7440  55892    0    0     0     0 1120   559 32  3 65  0  1  0  63100   5160   7440  55892    0    0     0     0 1111   499  8  6 86  0  1  0  63100   5160   7440  55892    0    0     0     0 1113   505 12  3 85  0  1  0  63100   5168   7440  55892    0    0     0     0 1121   532 20  3 77  0

Links:
 * vmstat, freebsd.org
 * vmstat, manpages.ubuntu.com

top
top displays system process in real time

Example: $ top Tasks: 50 total,   2 running,  45 sleeping,   2 stopped,   1 zombie Cpu(s): 40.9% user,  10.5% system,   0.0% nice,  48.7% idle Mem:   123260k total,   119508k used,     3752k free,     7420k buffers Swap:  369452k total,    63036k used,   306416k free,    57212k cached

PID USER     PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND 5340 arky   15   0   968  968  780 R 13.8  0.8   0:00.22 top 1408 root      6 -10 23712 6692 3252 S  1.5  5.4   3:39.58 [XFree86] 1 root      8   0   500  472  448 S  0.0  0.4   0:00.31 init [2] 2 root      9   0     0    0    0 S  0.0  0.0   0:01.60 [keventd] 3 root     19  19     0    0    0 S  0.0  0.0   0:00.02 [ksoftirqd_CPU0] 4 root      9   0     0    0    0 S  0.0  0.0   0:07.03 [kswapd] 5 root      9   0     0    0    0 S  0.0  0.0   0:00.00 [bdflush] 6 root      9   0     0    0    0 S  0.0  0.0   0:00.44 [kupdated] 154 root      9   0     0    0    0 S  0.0  0.0   0:00.00 [khubd] 562 root      9   0   604  588  508 S  0.0  0.5   0:05.09 /sbin/syslogd 565 root      9   0  1152  492  448 S  0.0  0.4   0:01.24 /sbin/klogd -c 3 .........

Links:
 * top, freebsd.org
 * top, manpages.ubuntu.com

df
df reports the amount of free disk space available on each partition. $ df Filesystem          1K-blocks      Used Available Use% Mounted on /dev/md0               5763508    207380   5263352   4% / /dev/md1             78819376  13722288  61093296  19% /home /dev/md4             23070564   4309572  17589056  20% /usr /dev/md2              5763508   1757404   3713328  33% /var /dev/md3              2877756    334740   2396832  13% /tmp

To report the number of free i-nodes $ df -i Filesystem           Inodes   IUsed   IFree IUse% Mounted on /dev/hda3             321952   32558  289394   11% / /dev/hda2             67320      67   67253    1% /boot /dev/mapper/vg00-home 372352  34227  338125   10% /home /dev/mapper/vg00-tmp 242784   11649  231135    5% /tmp /dev/mapper/vg00-usr 1821568 208669 1612899   12% /usr /dev/mapper/vg00-var 1282560  75704 1206856    6% /var Reports disk usage in human readable format with block-sizes in Kilo,Mega,Gigabytes. This option is specific for GNU version of df. $ df -h Filesystem           Size  Used Avail Use% Mounted on /dev/hda1             2.3G  2.1G  133M  95% / tmpfs                 61M  8.0K   61M   1% /dev/shm /dev/hda2            2.0G  1.8G  113M  94% /usr

In some of Unix systems (SYS V family i.e. HP-UX) df displays the information in a different way: $ df /home               (/dev/vg01/lvol2     ):   262478 blocks   2647709 i-nodes /tmp                (/dev/vg00/lvol5     ):   952696 blocks    125941 i-nodes /usr                (/dev/vg00/lvol6     ):   132842 blocks     17633 i-nodes /var                (/dev/vg00/lvol7     ):   131704 blocks     17288 i-nodes /stand              (/dev/vg00/lvol1     ):    47548 blocks     13390 i-nodes /                   (/dev/vg00/lvol3     ):   160772 blocks     21215 i-nodes

In such cases try to use bdf command.

Links:
 * df, opengroup.org
 * df man page, man.cat-v.org
 * 14.1 df in GNU Coreutils manual, gnu.org

hostname
hostname displays and set system host name

Example:

Display the host name: $ hostname Darkstar

Display the IP address of the system:

$ hostname -i 61.95.196.52

Set the host name of the system to 'DarkHorse': $ hostname DarkHorse DarkHorse

Links:
 * hostname, freebsd.org
 * 21.5 hostname in GNU Coreutils manual, gnu.org


text:
Guide to Unix/Commands/Process Management

nohup
nohup lets you run a program in a way which makes it ignore hangup signals. This can be used to make a program continue running after a user has logged out. The output of the program is redirected from the standard output to the file nohup.out.

Examples:

$ nohup wget http://foo.org/foo_list.gz nohup: appending output to `nohup.out' $

Links:
 * nohup, opengroup.org
 * nohup, freebsd.org
 * 23.4 nohup in GNU Coreutils manual, gnu.org

ps
ps displays a list of current processes and their properties.

Examples:

Processes owned by the current user:

$ ps PID TTY         TIME CMD 17525 pts/0   00:00:00 su 17528 pts/0    00:00:00 bash 17590 pts/0   00:00:00 ps where pid is process id.

All processes:

$ ps -A

Links:
 * ps, opengroup.org
 * ps man page, man.cat-v.org

kill
kill is used to send termination signals to processes.

Examples

To send the kill signal to the processes with process id 17525,

$ kill -9 17525

To send the kill signal to all processes,

$ kill -9 -1

see Guide to Unix/Commands/Process Management/Kill

Links:
 * kill, opengroup.org
 * kill man page, man.cat-v.org
 * 24.1 kill in GNU Coreutils manual, gnu.org

pgrep
pgrep search and kill system processes

Example: Check if apache webserver is running. $ pgrep -f apache 5580 5581  5582  5583  5584  5585 or $ svcs -a | grep -i apache.

Links:
 * pgrep, freebsd.org
 * pgrep, manpages.ubuntu.com

pkill
Stop xterm program with 'pkill' program:

$ pkill -9 xterm

Tips: Display all the process of a user $ pgrep -l -u arky 894 bash 895 bash 897 bash 898 bash 899 bash 1045 links 1396 startx 1407 xinit 1411 openbox 1412 xterm 1413 xfaces 1414 xsetroot 1415 emacs

Links:
 * pkill, freebsd.org
 * pkill, manpages.ubuntu.com

pidof
pidof display Process ID (PID) of a task

Example: Display the PID of emacs process: $ pidof emacs 1415

Links:
 * pidof, manpages.ubuntu.com

killall
killall kill a process by name

Example:

Kill the 'xfaces' program: $ killall xfaces

Links:
 * killall, freebsd.org
 * killall, manpages.ubuntu.com


text:
Guide to Unix/Commands/Kernel Commands

lsmod
lsmod lists the modules loaded by the Linux kernel.

Links:
 * lsmod, manpages.ubuntu.com

modprobe
modprobe loads a Linux kernel module. You can specify only the name of the module, and modprobe will load it from the correct location and also load any dependent modules.

Many modules load automatically. For example, Linux loads a USB keyboard module when a USB keyboard is attached. It also loads the base USB modules as dependencies. Some modules must be loaded manually, and "modprobe" is the easiest way to do this.

Links:
 * modprobe, manpages.ubuntu.com

sysctl
sysctl sets a parameter to change the behavior of the kernel. The available parameters vary by kernel, so check the man page for sysctl in your distribution.

Examples:

Check the setting for the "vm.swapencrypt.enable" parameter:

$ sysctl vm.swapencrypt.enable vm.swapencrypt.enable=0

Root can set the parameter to 1.

$ sysctl vm.swapencrypt.enable=1 vm.swapencrypt.enable: 0 -> 1

Links:
 * sysctl, freebsd.org
 * sysctl, manpages.ubuntu.com

title: Guide to Unix/Commands/Kernel Commands


text:
Cookbook:Camp Cooking

Sometimes you just have to get out and walk around in the solitude and beauty of the country. You may want to hike for just a few hours, or you may want to hike for a few days. One meal and some snacks are all that’s needed for a short hike. Planning meals for a longer hike requires more thought. You have to choose foods that are light enough to carry in a backpack and that can be transported safely.

Hot or Cold?
The first principle is to keep foods either hot or cold. Since it is difficult to keep foods hot without a heat source (although the new insulated casserole dishes will keep things hot for an hour or so), it is best to transport chilled foods. Refrigerate or freeze the food overnight. For a cold source, bring frozen gel-packs or freeze some box drinks. The drinks will thaw as you hike and keep your meal cold at the same time. What foods to bring? For a day hike, just about anything will do as long as you can fit it in your backpack and keep it cold – sandwiches, fried chicken, bread and cheese, and even salads – or choose non-perishable foods.

Clean
The second principle is to keep everything clean, so remember to bring disposable wipes if you are taking a day trip. (Water is too heavy to bring enough for cleaning dishes!)

Safe Drinking Water
It is not a good idea to depend on fresh water from a lake or stream for drinking, no matter how clean it appears. Some pathogens thrive in remote mountain lakes or streams and there is no way to know what might have fallen into the water upstream. Bring bottled or tap water for drinking. Always start out with a full water bottle, and replenish your supply from tested public systems when possible. On long trips you can find water in streams, lakes, and springs, but be sure to purify any water from the wild, no matter how clean it appears.

The surest way to make water safe is to boil it. Boiling will kill microorganisms. First, bring water to a rolling boil, and then continue boiling for 1 minute. Before heating, muddy water should be allowed to stand for a while to allow the silt to settle to the bottom. Dip the clear water off the top and boil. At higher elevations, where the boiling point of water is lower, boil for several minutes.

As an alternative to boiling water, you can also use water purification tablets and water filters. The purification tablets – which contain iodine, halazone, or chlorine – kill most waterborne bacteria, viruses, and some (but not all) parasites. Because some parasites – such as Cryptosporidium parvum, Giardia lamblia, and larger bacteria – are not killed by purification tablets, you must also use a water filter. These water filtering devices must be 1 micron absolute or smaller. Over time purification tablets lose their potency, so keep your supply fresh. Water sanitizing tablets for washing dishes can also be purchased (just don’t confuse the two). Water purification tablets, filters, and sanitizing tablets can be purchased at camping supply stores.

What Foods to Bring?
If you are backpacking for more than a day, the food situation gets a little more complicated. You can still bring cold foods for the first day, but you’ll have to pack shelf-stable items for the next day. Canned goods are safe, but heavy, so plan your menu carefully. Advances in food technology have produced relatively lightweight staples that don’t need refrigeration or careful packaging. For example:

 * peanut butter in plastic jars;
 * concentrated juice boxes;
 * canned tuna, ham, chicken, and beef;
 * dried noodles and soups;
 * beef jerky and other dried meats;
 * dehydrated foods;
 * dried fruits and nuts; and
 * powdered milk and fruit drinks.

Powdered mixes for biscuits or pancakes are easy to carry and prepare, as is dried pasta. There are plenty of powdered sauce mixes that can be used over pasta, but check the required ingredient list. Carry items like dried pasta, rice, and baking mixes in plastic bags and take only the amount you’ll need.

Cooking at Camp
After you have decided on a menu, you will need to plan how you will prepare the food. You’ll want to take as few pots as possible (they’re heavy!). Camping supply stores sell lightweight cooking gear that nest together, but you can also use aluminum foil wrap and pans for cooking.

You’ll need to decide in advance how you will cook. Will you bring along a portable stove, or will you build a campfire? Many camping areas prohibit campfires, so check first or assume you will have to take a stove. Make sure to bring any equipment you will need. If you are bringing a camp stove, practice putting it together and lighting it before you pack. If you build a campfire, carefully extinguish the fire and dispose of the ashes before breaking camp. Likewise, leftover food should be burned, not dumped. Lastly, be sure to pack garbage bags to dispose of any other trash, and carry it out with you.

Use a Food Thermometer
Another important piece of camping equipment is a food thermometer. If you are cooking meat or poultry on a portable stove or over a fire, you’ll need a way to determine when it is done and safe to eat. Color is not a reliable indicator of doneness, and it can be especially tricky to tell the color of a food if you are cooking in a wooded area in the evening.

When cooking hamburger patties on a grill or portable stove, use a digital thermometer to measure the temperature. Digital thermometers register the temperature in the very tip of the probe, so the safety of thin foods -- such as hamburger patties and boneless chicken breasts -- as well as thicker foods can be determined. A dial thermometer determines the temperature of a food by averaging the temperature along the stem and, therefore, should be inserted 2 to 2 ½ inches into the food. If the food is thin, the probe must be inserted sideways into the food.

It is critical to use a food thermometer when cooking hamburgers. Ground beef may be contaminated with E. coli O157:H7, a particularly dangerous strain of bacteria. Illnesses have occurred even when ground beef patties were cooked until there was no visible pink. The only way to insure that ground beef patties are safely cooked is to use a food thermometer, and cook the patty until it reaches 160 °F. For chicken, cook breasts or cutlets to 170 °F; legs and thighs to 180 °F. Pork should be cooked to 160 °F. Heat hot dogs and any leftover food to 165 °F. Be sure to clean the thermometer between uses.

Keeping Cold
If you are "car camping" (driving to your site), you don’t have quite as many restrictions. First, you will have the luxury of bringing a cooler. What kind of cooler? Foam chests are lightweight, low cost, and have good "cold retention" power. But they are fragile and may not last through numerous outings. Plastic, fiberglass, or steel coolers are more durable and can take a lot of outdoor wear. They also have excellent "cold retention" power, but, once filled, larger models may weigh 30 or 40 pounds.

To keep foods cold, you’ll need a cold source. A block of ice keeps longer than ice cubes. Before leaving home, freeze clean, empty milk cartons filled with water to make blocks of ice, or use frozen gel-packs. Fill the cooler with cold or frozen foods. Pack foods in reverse order. First foods packed should be the last foods used. (There is one exception: pack raw meat or poultry below ready-to-eat foods to prevent raw meat or poultry juices from dripping on the other foods.) Take foods in the smallest quantity needed (e.g., a small jar of mayonnaise). At the campsite, insulate the cooler with a blanket, tarp, or poncho. When the camping trip is over, discard all perishable foods if there is no longer ice in the cooler or if the gel-pack is no longer frozen.

Cleanup
Whether taking a hike or camping at an established site, if you will be washing dishes or cookware, there are some rules to follow. Camping supply stores sell biodegradable camping soap in liquid and solid forms. But use it sparingly, and keep it out of rivers, lakes, streams, and springs, as it will pollute. If you use soap to clean your pots, wash the pots at the campsite, not at the water’s edge. Dump dirty water on dry ground, well away from fresh water. Some wilderness campers use baking soda to wash their utensils. Pack disposable wipes for hands and quick cleanups.

Recipes

 * Baked Potatoes in Foil
 * Campfire Banana Boat
 * Campfire S'mores
 * Corn on the Cob with Husks
 * Hobo Burgers
 * Campfire Trout

This module uses text from the public domain U.S. Department of Agriculture article .

title: Cookbook:Camp Cooking