Create user inside a syscall [closed] - linux

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
Is it possible to create an user, just like the useradd command does, inside a system call on Linux kernel?
I saw somewhere that syscalls cannot use the exec family, is it true?

Inside the kernel, users are identified by their ID (a number), and this is the only information that the kernel knows about a user.
As far as the kernel is concerned, users do no need to be created: to make a process have a different user, just call setuid() with a different number.
The mapping between user IDs and other information (name, home directory, etc.) is done entirely in user space. And that the user information is stored in files like /etc/passwd is just a convention; there are systems that use users differently (e.g. Android gives each app its own user ID).
If you really want to execute a user-mode program, call call_usermodehelper().

Related

How many standard input files exist on my ubuntu, and how it is related to terminal, shell and command? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed last month.
Improve this question
Does an entire linux system have a single file as standard input file (actual entry in i-node table)? If yes, what is its name (pathname)?
Can you provide a connection diagram (like which is connected to which and how) or a source where I can find about these?
More specifically, I want the relation between stdin-file, terminal, shell, process (command) and piping and redirection.

How to Create Custom Command in Linux? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I'm new to Linux and I'm wondering if I can create custom Linux commands:
For Example
LearningPhase1 cpu getinfo
To show similar output as we get from lscpu command
LearningPhase1 memory getinfo
to get memory information of my Computer
Also, I want to know if I can create new user using my own custom command
LearningPhase1 user create <username>
To create new user
LearningPhase1 user list
To get all the users of my computer
LearningPhase1 user list --sudo-only
To get the users with sudo permissions
This is my question on stackoverflow.
Any Link, Material, or Help regarding this will be much appreciated.
Please Help me in Learning more about these things.
Linux shells looking for programs which are stored in Specific Locations and if there is a program named LearningPhase1, they execute it as command.
you have to write your program and put its binaries or its code (if its interpreted) in those specific location.
you can view those specific locations with this:
echo $PATH

How System Call Works [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I was studying system calls from my operating systems course until this image appeared and I couldn't exactly understand its content.
Can anyone explain to me what is going on in user space and kernel space?
I try to Explain the mechanism of a system call to answer to your question:
When a System call is invoked a software interrupt is raised in user space ( or better in user mode ).
At this point, ever in user mode, the state of the user program is saved into memory.
After that there is the transaction in the kernel mode ( or kernel space ) to handle the interrupt, and return the value to the user space.
Then ,in user mode, the state of the running user program is restored from memory and the execution goes ahead.
I leave you a complete description of system call in this link : Kernel System Call

How to block Particular Commands in Linux for Specific user? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
Suppose i create a new user TEST in ubuntu and i need to block all commands except cp,ssh,exit.Please help me.i am new to linux.
Alternatively, consider using some restricted shell like rbash which you might set up as the user's login & ssh shell (use chsh and/or configure his/her's ~/.ssh/config); of course set up the PATH appropriately, it might contain a single ~/bin/ directory containing symlinks to /bin/cp, /usr/bin/ssh, etc. You might want to make ~/bin/ not owned and not writable by the user.
Be careful: if your user is more experimented than you are, you might leave some holes that he/she would be able to exploit. Make it also a social/contractual issue, by at least explicitly forbidding (in words) things.
You might also want to learn more about chroot and/or setuid; see also the references in this answer.
Notice that if your user gets ssh, he is likely to get scp and be able to hack his account (e.g. by adding executable files into his ~/bin/ ....)
I think you need to create a new group in which you set all the commands you want to use and add your TEST user to this group.

New user creation in linux [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
Can anyone explain what exactly happens when new user is created in linux. I mean how user space is created and everything that happens internally.
what is shell space
From where home space is given etc.
The only really necessary thing is a new entry in the file /etc/passwd. That represents the list of users.
But, typically, however, there will be done some more things.
A home directory for the user is created. This is just a mkdir on a path like /home/bilbo for the user bilbo. It typically matches the user's name but it does not need to. Which belongs to which is specified in the /etc/passwd.
The user's encrypted password is added to /etc/shadow
Some files are copied from templates to that new user's home directory. This depends on the distribution you are using, but often some standard configuration things are done within that new home directory; e. g. creating directories like /home/bilbo/Pictures etc.
Sometimes also a group is created for that user, if so, then typically, that group also is named like the user. Creating a group is done by inserting an entry to the file /etc/group.
On a modern system like Ubuntu the whole user directory might be set up to be mounted from an encrypted path, but this is a special case worth a new question ;-)

Resources