Sponsored Content
Operating Systems Linux SuSE How to obtain the Linux Distribution Details ? Post 302210128 by Sivaswami on Monday 30th of June 2008 06:34:35 AM
Old 06-30-2008
with uname command I can get only
Linux <kernel version> <time>
not the distribution details.

How ever referring to some manuals i received that /proc/version
gives the distribution details.

But not sure about the system call which helps to obtain these details
( details obtained from /proc ) into the C program. any help on this ?
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

IP details for Unix/Linux login clients?

Hi there, I am wondering if by logging in to a unix system, if it is possible to get the IP address of the machine I am connecting FROM. I know how I can do this using the name server, but is this possible without a host lookup?:confused: Thanks, -ghoti (15 Replies)
Discussion started by: ghoti
15 Replies

2. UNIX for Dummies Questions & Answers

How to know which Linux Distribution i am using

Hi, I m working on many Linux servers in my project. But i am unable to know which Linux Distribution i am using Like whether i am using SUSE or REDHAT or MONDRAKE. I tried with "uname" command. But it does not help me. Please provide me the command if u know. Regards, Basavaraja KC (3 Replies)
Discussion started by: BasavarajaKC
3 Replies

3. Shell Programming and Scripting

How to obtain system open file table value in Linux

Hello , I want to get current system open file table value. Can any one help. Thanking you, mahesh (0 Replies)
Discussion started by: mahesh.
0 Replies

4. UNIX for Dummies Questions & Answers

What Linux distribution should I use?

Hey I am right now working on an old Compaq computer, and because I have a newer one I thought of installing Linux on this one. The thing is that I don't know which Linux distribution that would work with a minimum of lag. My computer specifications is: Compaq Presario 7000 Intel Pentium... (7 Replies)
Discussion started by: Sixmax
7 Replies

5. UNIX for Advanced & Expert Users

Script to access multiple linux servers to get system details such as CPU usage

Hi Is there any shell script that accesses multiple linux servers to get details such as CPU usage, RAM used etc. The access of the servers must be parallel not serial in the sense it must ping all the servers at a time to get information.The script has to be triggered from a host system and get... (7 Replies)
Discussion started by: mssrivatsa
7 Replies

6. UNIX for Advanced & Expert Users

UNIX / LINUX OS CPU configuration details

Hi, How to find the cpu configuration details of Cores, Speed MHz, virtual processors for the following servers: LINUX OS Servers: Linux 2.6.9-89.0.3.ELsmp #1 SMP Sat Jun 13 07:05:54 EDT 2009 i686 i686 i386 GNU/Linux. (Cores, Speed, Processor) Linux 2.6.18-164.el5 #1 SMP Tue Aug 18... (5 Replies)
Discussion started by: jagtheesh
5 Replies

7. UNIX for Dummies Questions & Answers

at -l doesnt give details of the scheduled job. How to get the details?

I have scheduled couple of shell scripts to run using 'at' command. The o/p of at -l is: $ at -l 1320904800.a Thu Nov 10 01:00:00 2011 1320894000.a Wed Nov 9 22:00:00 2011 1320876000.a Wed Nov 9 17:00:00 2011 $ uname -a SunOS dc2prcrptetl2 5.9 Generic_122300-54 sun4u sparc... (2 Replies)
Discussion started by: superparticle
2 Replies

8. Red Hat

Need to mount LUN on two linux boxs (one rw the other ro) caveat details inside

Calling all Linux GURU's. The purpose of this thread is to try an recreate what we already have stood up in my environment, however the steps i am having to produce my own. I have got multiple applications that dump the data to various LUNs, the LUNs are managed by an Enterprise SAN... (11 Replies)
Discussion started by: jcejka
11 Replies

9. UNIX for Advanced & Expert Users

NTP server name and ip details on Linux/Solaris

Hi All, Where can I find all the NTP server names/ip addresses on Linux/Solaris systems. How can I grep these names/IP address from specific files from a specific OS (Linux/Solaris). I know on linux /etc/ntp.conf and /etc/ntp/ntp.conf on solaris contains these details. Whether I am right about... (4 Replies)
Discussion started by: sanzee007
4 Replies
SETNS(2)						     Linux Programmer's Manual							  SETNS(2)

NAME
setns - reassociate thread with a namespace SYNOPSIS
#define _GNU_SOURCE /* See feature_test_macros(7) */ #include <sched.h> int setns(int fd, int nstype); DESCRIPTION
Given a file descriptor referring to a namespace, reassociate the calling thread with that namespace. The fd argument is a file descriptor referring to one of the namespace entries in a /proc/[pid]/ns/ directory; see namespaces(7) for fur- ther information on /proc/[pid]/ns/. The calling thread will be reassociated with the corresponding namespace, subject to any constraints imposed by the nstype argument. The nstype argument specifies which type of namespace the calling thread may be reassociated with. This argument can have one of the fol- lowing values: 0 Allow any type of namespace to be joined. CLONE_NEWIPC (since Linux 3.0) fd must refer to an IPC namespace. CLONE_NEWNET (since Linux 3.0) fd must refer to a network namespace. CLONE_NEWNS (since Linux 3.8) fd must refer to a mount namespace. CLONE_NEWPID (since Linux 3.8) fd must refer to a descendant PID namespace. CLONE_NEWUSER (since Linux 3.8) fd must refer to a user namespace. CLONE_NEWUTS (since Linux 3.0) fd must refer to a UTS namespace. Specifying nstype as 0 suffices if the caller knows (or does not care) what type of namespace is referred to by fd. Specifying a nonzero value for nstype is useful if the caller does not know what type of namespace is referred to by fd and wants to ensure that the namespace is of a particular type. (The caller might not know the type of the namespace referred to by fd if the file descriptor was opened by another process and, for example, passed to the caller via a UNIX domain socket.) CLONE_NEWPID behaves somewhat differently from the other nstype values: reassociating the calling thread with a PID namespace changes only the PID namespace that child processes of the caller will be created in; it does not change the PID namespace of the caller itself. Reas- sociating with a PID namespace is allowed only if the PID namespace specified by fd is a descendant (child, grandchild, etc.) of the PID namespace of the caller. For further details on PID namespaces, see pid_namespaces(7). A process reassociating itself with a user namespace must have the CAP_SYS_ADMIN capability in the target user namespace. Upon success- fully joining a user namespace, a process is granted all capabilities in that namespace, regardless of its user and group IDs. A multi- threaded process may not change user namespace with setns(). It is not permitted to use setns() to reenter the caller's current user namespace. This prevents a caller that has dropped capabilities from regaining those capabilities via a call to setns(). For security reasons, a process can't join a new user namespace if it is sharing filesystem-related attributes (the attributes whose sharing is con- trolled by the clone(2) CLONE_FS flag) with another process. For further details on user namespaces, see user_namespaces(7). A process may not be reassociated with a new mount namespace if it is multithreaded. Changing the mount namespace requires that the caller possess both CAP_SYS_CHROOT and CAP_SYS_ADMIN capabilities in its own user namespace and CAP_SYS_ADMIN in the target mount namespace. See user_namespaces(7) for details on the interaction of user namespaces and mount namespaces. RETURN VALUE
On success, setns() returns 0. On failure, -1 is returned and errno is set to indicate the error. ERRORS
EBADF fd is not a valid file descriptor. EINVAL fd refers to a namespace whose type does not match that specified in nstype. EINVAL There is problem with reassociating the thread with the specified namespace. EINVAL The caller tried to join an ancestor (parent, grandparent, and so on) PID namespace. EINVAL The caller attempted to join the user namespace in which it is already a member. EINVAL The caller shares filesystem (CLONE_FS) state (in particular, the root directory) with other processes and tried to join a new user namespace. EINVAL The caller is multithreaded and tried to join a new user namespace. ENOMEM Cannot allocate sufficient memory to change the specified namespace. EPERM The calling thread did not have the required capability for this operation. VERSIONS
The setns() system call first appeared in Linux in kernel 3.0; library support was added to glibc in version 2.14. CONFORMING TO
The setns() system call is Linux-specific. NOTES
Not all of the attributes that can be shared when a new thread is created using clone(2) can be changed using setns(). EXAMPLE
The program below takes two or more arguments. The first argument specifies the pathname of a namespace file in an existing /proc/[pid]/ns/ directory. The remaining arguments specify a command and its arguments. The program opens the namespace file, joins that namespace using setns(), and executes the specified command inside that namespace. The following shell session demonstrates the use of this program (compiled as a binary named ns_exec) in conjunction with the CLONE_NEWUTS example program in the clone(2) man page (complied as a binary named newuts). We begin by executing the example program in clone(2) in the background. That program creates a child in a separate UTS namespace. The child changes the hostname in its namespace, and then both processes display the hostnames in their UTS namespaces, so that we can see that they are different. $ su # Need privilege for namespace operations Password: # ./newuts bizarro & [1] 3549 clone() returned 3550 uts.nodename in child: bizarro uts.nodename in parent: antero # uname -n # Verify hostname in the shell antero We then run the program shown below, using it to execute a shell. Inside that shell, we verify that the hostname is the one set by the child created by the first program: # ./ns_exec /proc/3550/ns/uts /bin/bash # uname -n # Executed in shell started by ns_exec bizarro Program source #define _GNU_SOURCE #include <fcntl.h> #include <sched.h> #include <unistd.h> #include <stdlib.h> #include <stdio.h> #define errExit(msg) do { perror(msg); exit(EXIT_FAILURE); } while (0) int main(int argc, char *argv[]) { int fd; if (argc < 3) { fprintf(stderr, "%s /proc/PID/ns/FILE cmd args... ", argv[0]); exit(EXIT_FAILURE); } fd = open(argv[1], O_RDONLY); /* Get descriptor for namespace */ if (fd == -1) errExit("open"); if (setns(fd, 0) == -1) /* Join that namespace */ errExit("setns"); execvp(argv[2], &argv[2]); /* Execute a command in namespace */ errExit("execvp"); } SEE ALSO
clone(2), fork(2), unshare(2), vfork(2), namespaces(7), unix(7) Linux 2015-01-10 SETNS(2)
All times are GMT -4. The time now is 03:06 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy