Saturday, March 23, 2013

Where do I find source code of linux commands?

Q. Linux commands like cp, dir, ls, shred, man (etc...) are nothing but programs (hopefully all written in C). I would really like to know exactly how they work (and make a few modifications to some) so I need their source code...
Can you tell me where to find source code of linux commands?
Thank you in advance!

A. In general there are several places you can go to get the source for these commands. This is mostly because there can be several different implementations of the commands.

1) The company who distributed your version of Linux. Most versions of these types of commands are under the GPL and as such the person or company who gave you the executable has to make a copy of the source code available to you. Usually these are released as source rpms, and some times come on one of the CDs or DVDs that you used to install Linux with. You can often find them on the web too.

For example the RHEL5 Server source rpm (SRPM) is
ftp://ftp.redhat.com/pub/redhat/linux/enterprise/5Server/en/os/SRPMS/coreutils-5.97-12.1.el5.src.rpm

Most of the time your distribution will have a tool like yum to install these and other rpms for you.

2) www.gnu.org
GNU probably wrote the commands that are on your distribution of Linux, although a few very specialized distros use different implementations of the commands (Usually busybox http://www.busybox.net/ but this is really rare).

http://www.gnu.org/software/coreutils/
has instructions on how to download a very recent copy of the code, which may be much much newer then the version currently installed on your computer.

NOTE:

Some shells, like tcsh and csh have their own implementations of these commands built into them. This is because it is faster to run the command as part of your shell then to fork and exec a new command. So if you do change them be sure to check that you are actually running your updated version. BASH usually does not play these games but you can always check by running which followed by the name of your command.

What would it take to make you change from Windows to Linux?
Q. Personally I would switch tomorrow if all of the software I used was compatible with Linux.

I hope that with the average person coming out of school being more computer savy these days we will see more and more software developers releasing Linux versions.
I have tried Linux in the past and wasn't very fond of it, at that time I was not aware of all the different types available such as Red Hat and Ubuntu. There are versions out there easy to get to grips with and similar to Windows.

A. A direct port of Microsoft Office not a watered down version like they made for Mac. I have tried open office I don't like it.

More automation, I would like to be abe to double click an install file and have it install - I hate hate HATE using the Linux command terminal it is like pulling teeth.

A better IM client I think kMess and GAIM are crap - and a better music player I don't like amarok and WinAmp style media players I just don't like them and I won't 'get used to them over time'.

Did I mention how much I hate using the terminal?

Better games, Linux supports OpenGL and has tonnes of C++ compilers etc, there really is no excuse for not having better games.

Faster boot times, every version of Linux I have tried took ages to boot and my PC isn't exactly low spec, its got a Core 2 Duo @ 1.83ghz with 2 gigs of RAM it shouldn't take so long to boot.

And finally I really like to nosey around and change things when I muck up Windows its easy to restore, Linux isn't I want better recovery options for when theings do go wong because the always do.

I don't ask for much really.

On a unix-like system, how can I set the file permissions of a file to the current default permissions?
Q. Let us suppose I have a file set to the permissions -rwxr----- but the default on the system is -rwx-r-xr-x and insead of using the typical chmod command typing chmod 755 fileName, could I just type a command that sets it to the current default? I am using Ubuntu 12.04 but it would be much appreciated if it worked on mac and other linux versions as well.

A. There is no system default. However, there may will be a default set when you login. It is possible to derive the chmod value from the umask, but be aware that the umask is inverted:

$ umask
0022
$ touch ttt ; ls -l ttt
-rw-r--r-- 1 chris chris 0 Sep 14 23:37 ttt

Here's a tip. If you want to set permissions to rwx-r-xr-x, then don't bother trying to convert that to octal, just use the symbolic setting: chmod u=rwx,g=rx,o=rx fileName. Similar bits on the LHS can be merged, thus giving u=rwx,go=rx.

Don't use the x (execute) bit for files unless they really are supposed to be executable. u=rw,go=r is quite sufficient.



Nec Projector Review

Plastic Shed Reviews

Ati Graphic Reviews

Nurse Uniforms Reviews

Cabochons Reviews

Inflatable Water Slides Reviews

Barcode Scanner Reviews

No comments:

Post a Comment