source code about commands - linux

where can I found source files (in C language) about unix Commands (ls, sleep, cd etc).
I've downloaded the kernel linux-2.6.39-rc3, but there are no source about linux command.
thanks for your help :-)

Most of the generic Linux commands come from coreutils http://www.gnu.org/software/coreutils/ there might be some missing there, but everything you asked specifically about should be found in coreutils source.
the kernel source doesn't contain any userland programs in it.

If you are using debian based os then u can use
dpkg -S command
to find the package it is present in and then
apt-get source package
to download the source. You can find similar commands on other machines.

Pickup the GNU coreutils # http://ftp.gnu.org/pub/gnu/coreutils/ and this includes a lot of these commands.

use
sudo apt-get build-dep core-utils
apt-get source core-utils --compile
to get and compile everything in core-utils from scratch

Related

Build MPICH2 from source

As a follow-up of this question, I started building MPICH2 from source. I found this tutorial: Installing MPICH2 on a Single Machine and so far what I did is this:
./configure --disable-f77 --disable-fc --disable-fortran
[seems to be OK]
make; sudo make install
[long output with one warning]
libtool: warning: relinking 'lib/libmpicxx.la'
root#pythagoras:/home/gsamaras/mpich-3.1.4# mpich2version
bash: mpich2version: command not found
What am I doing wrong? Notice that I had first installed MPICH2 with apt-get and in order to remove it, I did:
apt-get remove --purge mpich2
apt-get autoremove // which might removed something that I need now
Tomorrow, I am going to try this: Getting And Building MPICH (which with first attempt failed to work in the autogen.sh part).
EDIT_1:
I couldn't get it to work, will try a combination of the two tutorials and report back. I did a configure and then the make from the other tutorial, failed too.
EDIT_2
This may shade some light about where it got installed (by following the first tutorial):
root#pythagoras:/home/gsamaras/mpich-3.1.4# which mpiexec
/usr/local/bin/mpiexec
root#pythagoras:/home/gsamaras/mpich-3.1.4# which mpirun
/usr/local/bin/mpirun
You installed into /usr/local, which is an OK way to do things. The README instructions you followed suggests another way which will not require administrative privileges.
I like to install into /home/robl/soft/mpich-whatever , so I can have different compilers, versions, configurations, etc. such flexibility is probably overkill for you, but it's one strategy.
To your question:
root#pythagoras:/home/gsamaras/mpich-3.1.4# mpich2version
bash: mpich2version: command not found
First, the command is now mpichversion, not mpich2version -- it's possible you were following an old tutorial.
Second, your shell might not know about the newly installed binaries. hash -r (at least on bash and tcsh) will tell the shell "forget about what you think you know about my file system and look harder".
I found this mpich-3.0.4-README, who seems to provided the solution.
Long story short, it says (it assumes you want to build 3.0.4 version, I did it with 3.1.4 (available here)):
tar xzf mpich-3.0.4.tar.gz
cd mpich-3.0.4
// you might want to disable fortran compiler (see the README I linked above)
./configure --prefix=/home/<USERNAME>/mpich-install 2>&1 | tee c.txt
make 2>&1 | tee m.txt
make install 2>&1 | tee mi.txt
PATH=/home/<USERNAME>/mpich-install/bin:$PATH ; export PATH
which mpicc
// should return something reasonable (with your directory)
mpiexec -n 2 ./examples/cpi
Now, the option with the machinefile does not work, because ssh needs a password, but that's another question.

I can't find VLC libraries

I am writing application to video streaming. My professor from programming gave us instruction but it is for Windows. I am writing it for Linux so I need libs for it *.so (I suppose so). This is list for Windows. How I can find counterparts:
axvlc.dll libvlc.dll libvlccore.dll npvlc.dll
Firstly I installed vlc from my dist repo but I couldn't find libs I was searching in:
#whereis vlc vlc: /usr/bin/vlc /usr/lib64/vlc /usr/share/vlc
So I downloaded source code and I do ./configure and make but I also couldn't find those libs
If you on some of Ubuntu clone, you could just run:
sudo apt-get install libvlc-dev

/usr/bin/time: No such file or directory

I'm trying to run the time command for a file on a virtual machine running Fedora 19 64-bit and I get the message "/usr/bin/time: No such file or directory". I tried googling, but it appears it's something that I should already have. How do I get this on my computer?
For those on a raspberry pi or similar debian-based distributions, I found that I could install the package time (sudo apt install time) to obtain access to the time command.
Edit: For Fedora-based systems, the package name might be different. Try a dnf search time, followed by a sudo dnf install {package_name}. I don't have a Fedora machine immediately to hand to get the exact package name from.
bash/zsh/modern shells usually implement a basic time command as a builtin. So it won't exist on the filesystem, but time mycommand should work.
If you want the "proper" time command (with more options eg: -l/-v), then you'll need to install it via apt/yum/etc. You'll need to run it as /usr/bin/time mycommand so the shell-builtin doesn't get invoked.
It might be in other locations. I'd start by typing:
which time
This command will give you the path to time, if it's anywhere in your path.
If you need to build it yourself, you can get the source here:
http://directory.fsf.org/wiki/Time

Do you know any tools like smush.it I could on command line?

You may know http://www.smushit.com/ysmush.it/ it is a tool to optimize images (png, jpg, gif)
I'd like to implement a phing task or something, so I'm looking for a similar tool to be used on cli.
I know that smushit is a bundle of several tools, but I don't have time to pack them all together.
Any ideas?
What OS? For Windows, PNGSlim from http://people.bath.ac.uk/ea2aced/tech/png/pngslim.zip is a nice commandline tool. It's a batchfile that runs the same file through a variety of different optimising tools that are out there, and keeps the best of what it gets (or reverts to a backup made at the beginning if it doesn't manage to shave off at least one batch).
Because of commandline limits, it can only do a handful of PNGs at a time, but because it's commandline, it's easy to script something to pass a whole directory through it.
It's pretty slow, but it is being thorough after all; one to leave running overnight.
Check the Image Magick toolkit: http://www.imagemagick.org/Usage/formats/ You can can convert,transform, rotate, up/down scale, overlap , etc. It is available is pretty much all linux distros I know of.
Old question, but you might want to check out littleutils.
To install on Ubuntu / Debian:
Download littleutils
wget -O littleutils.tar.bz2 http://sourceforge.net/projects/littleutils/files/latest/download
Unzip / Untar
tar jxvf littleutils.tar.bz2
Install the dependencies
sudo apt-get install gifsicle pngcrush lzip libpng12-0 libpng12-dev libjpeg-progs p7zip-full
cd into the littleutils directory (check version number)
cd littleutils-1.0.27
Configure and install
./configure --prefix=/usr && make && sudo make install && sudo make install-extra
You'll then be able to use opt-jpg {filename}, opt-png {filename} and opt-gif {filename} direct from the command line.

How to know system is currently installing ISO

I am creating an RPM. This RPM will be packed with the CentOS ISO and will install when CentOs is installed. This can also be installed using normal rpm installation method. But rpm installation need to behave differently if it is installed from ISO and installed by rpm normal installation method. So, the question is how do I know whether the system is currently installing the ISO.
Thanks in advance.
You could check if /dev/cdrom is mounted and if the /mnt/cdrom contains the installation disc in the %pre /%post scripts.
Strictly speaking, RPMs should be agnostic to how they are installed, so the chances are if you need this in the RPM it's probably a flawed design and what you are trying to do can be done in some other way.
I would suggest looking at anaconda / kickstart scripts.
Definitely a flawed design.
There should never be any user interaction with an RPM install which is what I bet you are trying to do.
If you are installing from a live OS, you can check the existence of /dev/live or liveimg in kernel command line,
i.e.
[[ $(grep -c liveimg /proc/cmdline) != 0 ]] || [ -b readlink -f /dev/live ]

Resources