Softpanorama

May the source be with you, but remember the KISS principle ;-)
Home Switchboard Unix Administration Red Hat TCP/IP Networks Neoliberalism Toxic Managers
(slightly skeptical) Educational society promoting "Back to basics" movement against IT overcomplexity and  bastardization of classic Unix

uname

News Recommended Books Recommended Links Reference uname hack

Examples

 
uptime     Admin Horror Stories Unix History Humor Etc

The  uname command displays the name, node, version, release, and hardware type of the current UNIX operating system. By default only the system's name is displayed. The most common use of uname is to find out which system you are using. Many users set their shell prompt (PS1) to the name of their system. This is especially useful if you have access to multiple systems.

General format

     uname [ option ]

In Linux the following options are supported:

-a, --all
print all information, in the following order, except omit -p and -i if unknown:
-s, --kernel-name
print the kernel name
-n, --nodename
print the network node hostname
-r, --kernel-release
print the kernel release
-v, --kernel-version
print the kernel version
-m, --machine
print the machine hardware name
-p, --processor
print the processor type or "unknown"
-i, --hardware-platform
print the hardware platform or "unknown"
-o, --operating-system
print the operating system
--help
display this help and exit
--version
output version information and exit

The uname command writes to the standard output.

Examples

In this activity you use the uname command to display all of the information about your system. Begin at the shell prompt.

1.  Type uname -a and press Return to display the information about your system.
  cj> uname -a
  cj   cj  4.0  1  80386

The first cj is the system name, the second is the nodename, 4.0 is the UNIX release, 1 is the version, and 80386 is the hardware type.
2.  Type PS1="$" and press Return. This resets your shell prompt to the system default.
3.  Type PS1="`uname`>" and press Return. This sets your shell prompt to the name of your system.
  $ PS="`uname`>"
  cj> _
4.  Turn to Module 85 to continue the learning sequence.

uname hack

The simplest "uname hack" is renaming the original and creation of the wrapper that produces the requred version.

Here is an example:

#!/bin/bash
uname-wrapped $@ | sed 's/2.6.7/2.6.9/'

In case of Red Hat and Oracle linux much depends on how tha application chacks for version. It it check via /proc/version that hack does not help.

If it checks uname plus /etc/ * release files you need in additon to replace /etc/*version files. For example in order to emulate Oracle 5.6 on Oracle 6 which is nessesary for ther installation of Oracle LDAP server you can try:

EOL 5:

uname

Linux lusand04.andipc.basf-corp.com 2.6.18-238.5.1.0.1.el5 #1 SMP Tue Mar 1 21:21:14 EST 2011 x86_64 x86_64 x86_64 GNU/Linux
Files in /etc
-rw-r--r-- 1 root root 64 Jan 18 12:58 enterprise-release
-rw-r--r-- 1 root root 32 Jan 14 18:28 oracle-release
-rw-r--r-- 1 root root 54 Jan 18 12:58 redhat-release
# cat enterprise-release
Enterprise Linux Enterprise Linux Server release 5.6 (Carthage)
# cat oracle-release
Oracle Linux Server release 5.6
cat redhat-release
Red Hat Enterprise Linux Server release 5.6 (Tikanga)

EOL 6:

uname

Linux lusand05.andipc.basf-corp.com 2.6.32-100.28.11.el6.x86_64 #1 SMP Wed Apr 13 12:42:21 EDT 2011 x86_64 x86_64 x86_64 GNU/Linux
Files in /etc:
-rw-r--r--.  1 root root   32 Jan 29 12:20 oracle-release
-rw-r--r--.  1 root root   55 May  2 16:16 redhat-release
# cat oracle-release
Oracle Linux Server release 6.0
---: /root/etc
# cat redhat-release
Red Hat Enterprise Linux Server release 6.0 (Santiago)
---: /root/etc

Top Visited
Switchboard
Latest
Past week
Past month

NEWS CONTENTS

Old News ;-)

changing uname -r output by 7.e.Q

Yes there is. rename your original uname to something like uname-wrapped and create a script in the same location called uname, that runs this uname-wrapped binary with the parameters and output alterations you need. For example, if you want to change the kernel version inside the output of uname from "2.6.7" to "2.6.9" put the following into your uname script: Code:
#!/bin/bash
uname-wrapped $@ | sed 's/2.6.7/2.6.9/'
this is called "uname hack"... you may google for it.

The uname hack revisited by Kevin Krumwiede

Jul 19, 2001 | Linux From Scratch!

I always wondered why, instead of hacking uname itself, it can't be
temporarily renamed or moved and replaced with a script that fakes the -m
option and calls the original for everything else?

raw (hmm, where's my bash book?):

#!/bin/sh
if [ "$1" = '-m' ]; then
echo 'i386'
else
/usr/bin/uname-orig $@
fi

-----Original Message-----
From: lfs-discuss-owner at linuxfromscratch.org
[mailto:lfs-discuss-owner at linuxfromscratch.org]On Behalf Of Jeroen
Coumans
Sent: Thursday, July 19, 2001 7:03 PM
To: lfs-discuss at linuxfromscratch.org
Subject: Re: BASH static compilation using termcap library

> Also I am installing LFS into a second hard-drive which I
> would like to moe into an old i386 I have lying around
> (Just for fun really). I noticed that Bash seemed to find
> the i586 equivalent processor in the computer it is
> currently resident in. Is this going to completely screw
> me up? i.e. has it compiled for pentium PC?

This could get you into trouble. I remember there was a uname-hack exactly
for this kind of cross-compiling. Search the mail-archives for
cross-compiling and uname, it should come up. Cross-compiling has gotten a
lot of people into trouble, but there are also lots of hints in the
archives.
Good luck!

uname lies ... - Jon Haslam's Weblog

Well, it's been a while to say the least but I think it's about time to put fingers to keys again and see what comes forth ...

I've mentioned before some of the great things that can be achieved with destructive actions. Indeed many good examples are popping up - check out this cool example from Chris Gerhards blog. Today we'll just take a quick look at another one (I actually have a bunch which I'll try and write-up over the next few weeks).

In the UK we have run a series of events called Make-It-Fly which I've been involved with. Last week I did a session on DTrace which I hope everyone who was present enjoyed (I did anyway!). At the events I usually do quite a bit of hands on demo with most of it being hand cranked. However, one of the scripts I use that always gets a laugh is the following one which I don't hand crank as I can never remember the offsets ... If you've ever wanted to get uname(1) to return something different to normal then this is what you need:

#!/usr/sbin/dtrace -s

#pragma D option destructive

syscall::uname:entry
{
        self->addr = arg0;
}

syscall::uname:return
{
        copyoutstr("SunOS", self->addr, 257);
        copyoutstr("PowerPC", self->addr+257, 257);
        copyoutstr("5.5.1", self->addr+(257*2), 257);
        copyoutstr("gate:1996-12-01", self->addr+(257*3), 257);
        copyoutstr("PPC", self->addr+(257*4), 257);
}
Before we have:
# uname -a
SunOS homer 5.10 SunOS_Development sun4u sparc SUNW,Ultra-5_10
and like magic we morph into something else when the above script is ran:
# uname -a
SunOS PowerPC 5.5.1 gate:1996-12-01 PPC sparc SUNW,Ultra-5_10
Here at Sun we often test pieces of software on versions of Solaris that return something different to that which the software is expecting. Previously I would LD_PRELOAD a library in with my own uname hack. Now I can not only do this without bothering the application but I can present different uname information to different applications/users/whatever as I can predicate accordingly!

Note, that the above script isn't quite complete as it returns the incorrect ISA information. This is me being idle and a bit of twiddling with sysinfo() is all that's needed. Maybe another day.


Recommended Links

Google matched content

Softpanorama Recommended

Top articles

Sites

uname - Wikipedia, the free encyclopedia

How to change the output of the uname command in the Solaris OS ...



Etc

Society

Groupthink : Two Party System as Polyarchy : Corruption of Regulators : Bureaucracies : Understanding Micromanagers and Control Freaks : Toxic Managers :   Harvard Mafia : Diplomatic Communication : Surviving a Bad Performance Review : Insufficient Retirement Funds as Immanent Problem of Neoliberal Regime : PseudoScience : Who Rules America : Neoliberalism  : The Iron Law of Oligarchy : Libertarian Philosophy

Quotes

War and Peace : Skeptical Finance : John Kenneth Galbraith :Talleyrand : Oscar Wilde : Otto Von Bismarck : Keynes : George Carlin : Skeptics : Propaganda  : SE quotes : Language Design and Programming Quotes : Random IT-related quotesSomerset Maugham : Marcus Aurelius : Kurt Vonnegut : Eric Hoffer : Winston Churchill : Napoleon Bonaparte : Ambrose BierceBernard Shaw : Mark Twain Quotes

Bulletin:

Vol 25, No.12 (December, 2013) Rational Fools vs. Efficient Crooks The efficient markets hypothesis : Political Skeptic Bulletin, 2013 : Unemployment Bulletin, 2010 :  Vol 23, No.10 (October, 2011) An observation about corporate security departments : Slightly Skeptical Euromaydan Chronicles, June 2014 : Greenspan legacy bulletin, 2008 : Vol 25, No.10 (October, 2013) Cryptolocker Trojan (Win32/Crilock.A) : Vol 25, No.08 (August, 2013) Cloud providers as intelligence collection hubs : Financial Humor Bulletin, 2010 : Inequality Bulletin, 2009 : Financial Humor Bulletin, 2008 : Copyleft Problems Bulletin, 2004 : Financial Humor Bulletin, 2011 : Energy Bulletin, 2010 : Malware Protection Bulletin, 2010 : Vol 26, No.1 (January, 2013) Object-Oriented Cult : Political Skeptic Bulletin, 2011 : Vol 23, No.11 (November, 2011) Softpanorama classification of sysadmin horror stories : Vol 25, No.05 (May, 2013) Corporate bullshit as a communication method  : Vol 25, No.06 (June, 2013) A Note on the Relationship of Brooks Law and Conway Law

History:

Fifty glorious years (1950-2000): the triumph of the US computer engineering : Donald Knuth : TAoCP and its Influence of Computer Science : Richard Stallman : Linus Torvalds  : Larry Wall  : John K. Ousterhout : CTSS : Multix OS Unix History : Unix shell history : VI editor : History of pipes concept : Solaris : MS DOSProgramming Languages History : PL/1 : Simula 67 : C : History of GCC developmentScripting Languages : Perl history   : OS History : Mail : DNS : SSH : CPU Instruction Sets : SPARC systems 1987-2006 : Norton Commander : Norton Utilities : Norton Ghost : Frontpage history : Malware Defense History : GNU Screen : OSS early history

Classic books:

The Peter Principle : Parkinson Law : 1984 : The Mythical Man-MonthHow to Solve It by George Polya : The Art of Computer Programming : The Elements of Programming Style : The Unix Hater’s Handbook : The Jargon file : The True Believer : Programming Pearls : The Good Soldier Svejk : The Power Elite

Most popular humor pages:

Manifest of the Softpanorama IT Slacker Society : Ten Commandments of the IT Slackers Society : Computer Humor Collection : BSD Logo Story : The Cuckoo's Egg : IT Slang : C++ Humor : ARE YOU A BBS ADDICT? : The Perl Purity Test : Object oriented programmers of all nations : Financial Humor : Financial Humor Bulletin, 2008 : Financial Humor Bulletin, 2010 : The Most Comprehensive Collection of Editor-related Humor : Programming Language Humor : Goldman Sachs related humor : Greenspan humor : C Humor : Scripting Humor : Real Programmers Humor : Web Humor : GPL-related Humor : OFM Humor : Politically Incorrect Humor : IDS Humor : "Linux Sucks" Humor : Russian Musical Humor : Best Russian Programmer Humor : Microsoft plans to buy Catholic Church : Richard Stallman Related Humor : Admin Humor : Perl-related Humor : Linus Torvalds Related humor : PseudoScience Related Humor : Networking Humor : Shell Humor : Financial Humor Bulletin, 2011 : Financial Humor Bulletin, 2012 : Financial Humor Bulletin, 2013 : Java Humor : Software Engineering Humor : Sun Solaris Related Humor : Education Humor : IBM Humor : Assembler-related Humor : VIM Humor : Computer Viruses Humor : Bright tomorrow is rescheduled to a day after tomorrow : Classic Computer Humor

The Last but not Least Technology is dominated by two types of people: those who understand what they do not manage and those who manage what they do not understand ~Archibald Putt. Ph.D


Copyright © 1996-2021 by Softpanorama Society. www.softpanorama.org was initially created as a service to the (now defunct) UN Sustainable Development Networking Programme (SDNP) without any remuneration. This document is an industrial compilation designed and created exclusively for educational use and is distributed under the Softpanorama Content License. Original materials copyright belong to respective owners. Quotes are made for educational purposes only in compliance with the fair use doctrine.

FAIR USE NOTICE This site contains copyrighted material the use of which has not always been specifically authorized by the copyright owner. We are making such material available to advance understanding of computer science, IT technology, economic, scientific, and social issues. We believe this constitutes a 'fair use' of any such copyrighted material as provided by section 107 of the US Copyright Law according to which such material can be distributed without profit exclusively for research and educational purposes.

This is a Spartan WHYFF (We Help You For Free) site written by people for whom English is not a native language. Grammar and spelling errors should be expected. The site contain some broken links as it develops like a living tree...

You can use PayPal to to buy a cup of coffee for authors of this site

Disclaimer:

The statements, views and opinions presented on this web page are those of the author (or referenced source) and are not endorsed by, nor do they necessarily reflect, the opinions of the Softpanorama society. We do not warrant the correctness of the information provided or its fitness for any purpose. The site uses AdSense so you need to be aware of Google privacy policy. You you do not want to be tracked by Google please disable Javascript for this site. This site is perfectly usable without Javascript.

Last modified: March 12, 2019