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
Related
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 days ago.
Improve this question
I have an assignment in my OS design course and my instructor has asked us to open and view the source code of any of the functions (like the source code of copy or paste, something like that) of the kernel of our choosen linux distro.
I have searched a lot but I coudent find a way to do that from the terminal. Is there a way to do this via the terminal?
Searching on google keeps leading to websites that have the kernel source code
Here is the source code of GNU's core utilities. The source code won't be available from your own machine, there is no need to have uncompiled code. But you could use a C decompiler to watch it. These programs are usually located under /usr/bin
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.
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().
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.
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 8 years ago.
The community reviewed whether to reopen this question 8 months ago and left it closed:
Original close reason(s) were not resolved
Improve this question
I want to create "my own" sudo command (for my file manager/commander written in C++/OpenGL). Please help provide necessary steps and things to consider. I know it has something to do with suid bit, but that's all I know so far.
It's all about filesystem flags, and you only to ensure that:
The executable file does belongs to root
It has the suid flag in the file system (you can set it with chattr u+s).
After you'll do that, it will be executed with root permissions even when running from a regular user.
Please also note that you can get an UID which had actually ran the program by calling getuid(), while geteuid() will always evaluate to 0.
I suggest to you to download sudo command code and modify it based on your requirement