8/14/2023 0 Comments Ubuntu sudo as another user![]() ![]() This includes installing and uninstalling programs, accessing and modifying system files, and customizing the system. The root user is an administrative user with the highest privileges and is not bound by any permission restrictions. One unique user in the Linux system is the root user. If you own a file or a directory, you can pretty much do anything you want with it – you can access it, edit it, rename and even delete it.īut not all users are the same. These permissions determine access rights or privileges that users have on the file. By default, each file in Linux has its own permissions and directories. This oversimplification then leads us to the concept of file permissions and directories. These entities are represented by a file descriptor which is a unique identifier for a file or other resources such as directories, network sockets, or processes – hence the concept “everything is a file”. It implies that in a Linux system, every single entity is considered a file. The oversimplification simply gives a high-level overview of the Linux architecture. We have directories, symbolic links, processes, pipes, and sockets just to mention a few. This sounds somewhat puzzling since the Linux system comprises various entities and not just files. ![]() You have learned running commands as another user with the help of su, sudo and runuser Linux commands.You probably have heard of the concept “In Linux, everything is a file”. In this tutorial, you have learned to run commands as another user in Linux system. runuser - rahul -c 'mkdir -p ~/hello ls -l' Conclusion Just add multiple commands wit semicolon separated. You can also execute booth commands in a single command. rw-r-r- 1 rahul rahul 8980 sktopĭrwxr-xr-x 2 rahul rahul 4096 Dec 21 15:55 hello Then list files under home directory of user ‘rahul’. Use runuser command to execute commands with the effective user ID and group ID of the defined user.Įxample – for example, run a command as user “rahul” and create directory in his home directory. This is lesser known commands by the Linux users. You can also use runuser to run commands as another user in Linux systems. Like: sudo -u root 'systemctl restart apache2' Run Command As Another User with Runuser In that case you can use sudo to run command as root user. After that specificy the command to run as defined user.įor example, you are writing a shell script, which required to run as non-root user. Enter the name of user to which you want to run command. Here you don’t need to use any command line switches. This is generally used to run command as root user, but you can also use it with other users. All commands are separated with semicolon ( ) as we do in general. Again prints the present working directory. In the above command, first prints present working directory with pwd, then create and switches to new directory named “hello”. You can also run multiple commands as another user in Linux, like: su - rahul -c "pwd mkdir hello & cd hello pwd" Output: Now, the below example will run “ls” command as user rahul without switching to the user. You can pass your command with -c parameter. But our aim is to run Linux command as another user without switching to them. The above command which you to another user, where you can run commands with that user. The basic su command looks like below: su - username This command switches to the new user and load their environment. Su (Switch User) command is used to run shell as another user. In this tutorial you will learn how to run command as another user in Linux/Unix systems. ![]() Now a days Zsh (Z Shell) is also getting popularity between the users due to its features. In which the Bash (Born Shell) is the most used shell and available default on most systems. The Linux users uses shell to interact with operating systems. Mainly the Linux server editions comes with command line option only, which create them lighter and faster. But still Linux professionals love the command line to work. You have options to choose desktop for your Linux systems. The Linux users have a large number of options to choose operating system. Linux is the best and most-used open source operating system. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |